abapgit-agent 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +179 -1
- package/CLAUDE.md +202 -0
- package/INSTALL.md +6 -11
- package/README.md +10 -0
- package/RELEASE_NOTES.md +44 -0
- package/abap/CLAUDE.md +130 -0
- package/abap/zcl_abgagt_cmd_factory.clas.abap +1 -0
- package/abap/zcl_abgagt_command_preview.clas.abap +386 -0
- package/abap/zcl_abgagt_command_preview.clas.xml +15 -0
- package/abap/zcl_abgagt_resource_preview.clas.abap +67 -0
- package/abap/zcl_abgagt_resource_preview.clas.xml +15 -0
- package/abap/zcl_abgagt_rest_handler.clas.abap +1 -0
- package/abap/zif_abgagt_command.intf.abap +2 -1
- package/bin/abapgit-agent +237 -0
- package/docs/commands.md +5 -0
- package/docs/preview-command.md +528 -0
- package/package.json +1 -1
- package/src/abap-client.js +18 -0
- package/src/agent.js +19 -0
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
# preview Command Requirements
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Preview data from ABAP tables or CDS views directly from the ABAP system. This command retrieves sample data rows to help developers understand table/view contents without needing to query manually.
|
|
6
|
+
|
|
7
|
+
**This is the PRIMARY way to explore table and CDS view DATA.**
|
|
8
|
+
|
|
9
|
+
## Use Cases
|
|
10
|
+
|
|
11
|
+
- Inspect table data before writing reports
|
|
12
|
+
- Verify data in CDS views
|
|
13
|
+
- Check sample records in staging tables
|
|
14
|
+
- Explore unknown tables/views quickly
|
|
15
|
+
- Validate WHERE clause filters before using in code
|
|
16
|
+
|
|
17
|
+
## Command
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Preview table data (auto-detect type)
|
|
21
|
+
abapgit-agent preview --objects SFLIGHT
|
|
22
|
+
abapgit-agent preview --objects ZMY_TABLE
|
|
23
|
+
|
|
24
|
+
# Preview CDS view data
|
|
25
|
+
abapgit-agent preview --objects ZC_MY_CDS_VIEW --type DDLS
|
|
26
|
+
|
|
27
|
+
# Preview with explicit type
|
|
28
|
+
abapgit-agent preview --objects SFLIGHT --type TABL
|
|
29
|
+
|
|
30
|
+
# Preview with row limit
|
|
31
|
+
abapgit-agent preview --objects SFLIGHT --limit 20
|
|
32
|
+
|
|
33
|
+
# Preview with WHERE clause filter
|
|
34
|
+
abapgit-agent preview --objects SFLIGHT --where "CARRID = 'AA'"
|
|
35
|
+
|
|
36
|
+
# Preview specific columns only
|
|
37
|
+
abapgit-agent preview --objects SFLIGHT --columns CARRID,CONNID,FLDATE,PRICE
|
|
38
|
+
|
|
39
|
+
# Preview multiple tables/views
|
|
40
|
+
abapgit-agent preview --objects SFLIGHT,ZSCUSTOMER
|
|
41
|
+
|
|
42
|
+
# Vertical format (for wide tables)
|
|
43
|
+
abapgit-agent preview --objects SFLIGHT --vertical
|
|
44
|
+
|
|
45
|
+
# JSON output (for scripting/AI processing)
|
|
46
|
+
abapgit-agent preview --objects SFLIGHT --json
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Prerequisite
|
|
50
|
+
|
|
51
|
+
- `.abapGitAgent` exists with valid credentials
|
|
52
|
+
- Table or CDS view must exist in the ABAP system
|
|
53
|
+
|
|
54
|
+
## Parameters
|
|
55
|
+
|
|
56
|
+
| Parameter | Required | Description |
|
|
57
|
+
|-----------|----------|-------------|
|
|
58
|
+
| `--objects` | Yes | Comma-separated list of table/view names |
|
|
59
|
+
| `--type` | No | Object type (TABL, DDLS). Auto-detected from TADIR if not specified |
|
|
60
|
+
| `--limit` | No | Maximum rows to return (default: 10, max: 100) |
|
|
61
|
+
| `--where` | No | WHERE clause filter (e.g., `CARRID = 'AA'`) |
|
|
62
|
+
| `--columns` | No | Comma-separated column names to display (e.g., `CARRID,CONNID,PRICE`) |
|
|
63
|
+
| `--vertical` | No | Show data in vertical format (one field per line) |
|
|
64
|
+
| `--compact` | No | Truncate values to fit columns (useful for wide tables) |
|
|
65
|
+
| `--json` | No | Output raw JSON only (for scripting) |
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Tasks
|
|
70
|
+
|
|
71
|
+
### 1. Validate Parameters
|
|
72
|
+
|
|
73
|
+
- `--objects` must be specified
|
|
74
|
+
- Object names are converted to uppercase automatically
|
|
75
|
+
- `--limit` must be between 1 and 100 (default: 10)
|
|
76
|
+
- `--type` accepts TABL or DDLS (case-insensitive)
|
|
77
|
+
|
|
78
|
+
### 2. Load Configuration
|
|
79
|
+
|
|
80
|
+
Read `.abapGitAgent` for credentials
|
|
81
|
+
|
|
82
|
+
### 3. Fetch CSRF Token
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
GET /health (with X-CSRF-Token: fetch)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 4. Make Preview Request
|
|
89
|
+
|
|
90
|
+
**Endpoint:** `POST /preview`
|
|
91
|
+
|
|
92
|
+
**Request Body:**
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"objects": ["SFLIGHT", "ZC_CDS_VIEW"],
|
|
96
|
+
"type": "TABL",
|
|
97
|
+
"limit": 10,
|
|
98
|
+
"where": "CARRID = 'AA'",
|
|
99
|
+
"columns": ["CARRID", "CONNID", "PRICE"]
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 5. Display Results
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Output
|
|
108
|
+
|
|
109
|
+
### Table Data - Default (Human-readable)
|
|
110
|
+
|
|
111
|
+
Displays all columns with row count:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
📊 Preview: SFLIGHT (Table)
|
|
115
|
+
|
|
116
|
+
┌──────────┬────────┬──────────┬───────────┬─────────┬─────────┐
|
|
117
|
+
│ CARRID │ CONNID │ FLDATE │ PRICE │ CURRENCY│ PLANETYPE│
|
|
118
|
+
├──────────┼────────┼──────────┼───────────┼─────────┼─────────┤
|
|
119
|
+
│ AA │ 0017 │ 20240201 │ 422.94 │ USD │ 747-400 │
|
|
120
|
+
│ AA │ 0017 │ 20240202 │ 422.94 │ USD │ 747-400 │
|
|
121
|
+
│ AA │ 0017 │ 20240203 │ 445.00 │ USD │ 747-400 │
|
|
122
|
+
│ UA │ 0938 │ 20240201 │ 350.00 │ USD │ 777-300 │
|
|
123
|
+
└──────────┴────────┴──────────┴───────────┴─────────┴─────────┘
|
|
124
|
+
|
|
125
|
+
Showing 4 of 10 rows
|
|
126
|
+
⚠️ Note: 3 more columns hidden (SEATSMAX, SEATSOCC, PAYMENTSUM)
|
|
127
|
+
Use --columns to select specific columns
|
|
128
|
+
Use --json for full data
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Table Data - All Columns Fit
|
|
132
|
+
|
|
133
|
+
When table has 6 or fewer columns, display all:
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
📊 Preview: TADIR (Table)
|
|
137
|
+
|
|
138
|
+
┌──────────┬──────────┬───────┬────────┬────────┐
|
|
139
|
+
│ PGMID │ OBJECT │ OBJNAM│ DEVCLASS│ CTR │
|
|
140
|
+
├──────────┼──────────┼───────┼────────┼────────┤
|
|
141
|
+
│ R3TR │ CLAS │ ZCL_A │ ZABAPGIT│ 000000 │
|
|
142
|
+
│ R3TR │ CLAS │ ZCL_B │ ZABAPGIT│ 000000 │
|
|
143
|
+
└──────────┴──────────┴───────┴────────┴────────┘
|
|
144
|
+
|
|
145
|
+
Showing 2 of 10 rows
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### CDS View Data (Human-readable)
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
📊 Preview: ZC_FLIGHTS (CDS View)
|
|
152
|
+
|
|
153
|
+
┌──────────┬────────┬───────────┬──────────────────────┐
|
|
154
|
+
│ CARRID │ CONNID │ FLDATE │ AIRLINENAME │
|
|
155
|
+
├──────────┼────────┼───────────┼──────────────────────┤
|
|
156
|
+
│ AA │ 0017 │ 20240201 │ American Airlines │
|
|
157
|
+
│ UA │ 0938 │ 20240201 │ United Airlines │
|
|
158
|
+
└──────────┴────────┴───────────┴──────────────────────┘
|
|
159
|
+
|
|
160
|
+
Showing 2 of 10 rows
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### With WHERE Filter
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
📊 Preview: SFLIGHT (filtered, 5 rows)
|
|
167
|
+
|
|
168
|
+
┌──────────┬────────┬──────────┬─────────┬─────────┐
|
|
169
|
+
│ CARRID │ CONNID │ FLDATE │ PRICE │ CURRENCY│
|
|
170
|
+
├──────────┼────────┼──────────┼─────────┼─────────┤
|
|
171
|
+
│ AA │ 0017 │ 20240201 │ 422.94 │ USD │
|
|
172
|
+
│ AA │ 0017 │ 20240202 │ 422.94 │ USD │
|
|
173
|
+
└──────────┴────────┴──────────┴─────────┴─────────┘
|
|
174
|
+
|
|
175
|
+
WHERE: CARRID = 'AA'
|
|
176
|
+
Showing 2 of 2 rows
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Column Selection
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
abapgit-agent preview --objects SFLIGHT --columns CARRID,CONNID,FLDATE,PRICE
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
📊 Preview: SFLIGHT (Table)
|
|
187
|
+
|
|
188
|
+
┌──────────┬────────┬──────────┬───────────┐
|
|
189
|
+
│ CARRID │ CONNID │ FLDATE │ PRICE │
|
|
190
|
+
├──────────┼────────┼──────────┼───────────┤
|
|
191
|
+
│ AA │ 0017 │ 20240201 │ 422.94 │
|
|
192
|
+
│ AA │ 0017 │ 20240202 │ 422.94 │
|
|
193
|
+
└──────────┴────────┴──────────┴───────────┘
|
|
194
|
+
|
|
195
|
+
Showing 2 of 10 rows (columns: CARRID, CONNID, FLDATE, PRICE)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Vertical Format
|
|
199
|
+
|
|
200
|
+
Useful for tables with many columns:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
abapgit-agent preview --objects SFLIGHT --vertical
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
Previewing 1 object(s)
|
|
208
|
+
|
|
209
|
+
Retrieved data
|
|
210
|
+
|
|
211
|
+
📊 Preview: SFLIGHT (Table)
|
|
212
|
+
|
|
213
|
+
Row 1:
|
|
214
|
+
──────────────────────────────
|
|
215
|
+
MANDT: 100
|
|
216
|
+
CARRID: AA
|
|
217
|
+
CONNID: 17
|
|
218
|
+
FLDATE: 2024-10-24
|
|
219
|
+
PRICE: 422.94
|
|
220
|
+
CURRENCY: USD
|
|
221
|
+
PLANETYPE: 747-400
|
|
222
|
+
SEATSMAX: 385
|
|
223
|
+
SEATSOCC: 372
|
|
224
|
+
PAYMENTSUM: 192556.43
|
|
225
|
+
|
|
226
|
+
Row 2:
|
|
227
|
+
──────────────────────────────
|
|
228
|
+
MANDT: 100
|
|
229
|
+
CARRID: AA
|
|
230
|
+
CONNID: 17
|
|
231
|
+
FLDATE: 2024-11-25
|
|
232
|
+
PRICE: 422.94
|
|
233
|
+
CURRENCY: USD
|
|
234
|
+
PLANETYPE: 747-400
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Compact Mode
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
abapgit-agent preview --objects SFLIGHT --compact
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
Previewing 1 object(s)
|
|
245
|
+
|
|
246
|
+
Retrieved data
|
|
247
|
+
|
|
248
|
+
📊 Preview: SPFLI (Table)
|
|
249
|
+
┌───────┬────────┬────────┬───────────┬──────────┬──────────┬───────────┬────────────┬────────┬────────┬──────────┬──────────┬──────────┬────────┬────────┬────────┐
|
|
250
|
+
│ MANDT │ CARRID │ CONNID │ COUNTRYFR │ CITYFROM │ AIRPFROM │ COUNTRYTO │ CITYTO │ AIRPTO │ FLTIME │ DEPTIME │ ARRTIME │ DISTANCE │ DISTID │ FLTYPE │ PERIOD │
|
|
251
|
+
├───────┼────────┼────────┼───────────┼──────────┼──────────┼───────────┼────────────┼────────┼────────┼──────────┼──────────┼──────────┼────────┼────────┼────────┤
|
|
252
|
+
│ 100 │ AA │ 17 │ US │ NEW YORK │ JFK │ US │ SAN FRA... │ SFO │ 361 │ 11:00:00 │ 14:01:00 │ 2572 │ MI │ │ │
|
|
253
|
+
└───────┴────────┴────────┴───────────┴──────────┴──────────┴───────────┴────────────┴────────┴────────┴──────────┴──────────┴──────────┴────────┴────────┴────────┘
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Multiple Objects
|
|
257
|
+
|
|
258
|
+
```
|
|
259
|
+
📊 Preview: 2 Objects
|
|
260
|
+
|
|
261
|
+
1️⃣ SFLIGHT (Table)
|
|
262
|
+
┌──────────┬────────┬───────────┐
|
|
263
|
+
│ CARRID │ CONNID │ FLDATE │
|
|
264
|
+
├──────────┼────────┼───────────┤
|
|
265
|
+
│ AA │ 0017 │ 20240201 │
|
|
266
|
+
└──────────┴────────┴───────────┘
|
|
267
|
+
1 row
|
|
268
|
+
|
|
269
|
+
2️⃣ ZC_CUST (CDS View)
|
|
270
|
+
┌──────────┬──────────┬───────────┐
|
|
271
|
+
│ KUNNR │ NAME │ CITY │
|
|
272
|
+
├──────────┼──────────┼───────────┤
|
|
273
|
+
│ 000001 │ Customer1│ New York │
|
|
274
|
+
└──────────┴──────────┴───────────┘
|
|
275
|
+
1 row
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### JSON Output
|
|
279
|
+
|
|
280
|
+
```json
|
|
281
|
+
{
|
|
282
|
+
"SUCCESS": true,
|
|
283
|
+
"COMMAND": "PREVIEW",
|
|
284
|
+
"MESSAGE": "Retrieved 2 object(s)",
|
|
285
|
+
"OBJECTS": [
|
|
286
|
+
{
|
|
287
|
+
"NAME": "SFLIGHT",
|
|
288
|
+
"TYPE": "TABL",
|
|
289
|
+
"TYPE_TEXT": "Table",
|
|
290
|
+
"ROW_COUNT": 4,
|
|
291
|
+
"ROWS": [
|
|
292
|
+
{
|
|
293
|
+
"CARRID": "AA",
|
|
294
|
+
"CONNID": "0017",
|
|
295
|
+
"FLDATE": "20240201",
|
|
296
|
+
"PRICE": "422.94",
|
|
297
|
+
"CURRENCY": "USD",
|
|
298
|
+
"PLANETYPE": "747-400",
|
|
299
|
+
"SEATSMAX": "400",
|
|
300
|
+
"SEATSOCC": "350",
|
|
301
|
+
"PAYMENTSUM": "145000"
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"CARRID": "AA",
|
|
305
|
+
"CONNID": "0017",
|
|
306
|
+
"FLDATE": "20240202",
|
|
307
|
+
"PRICE": "422.94",
|
|
308
|
+
"CURRENCY": "USD",
|
|
309
|
+
"PLANETYPE": "747-400",
|
|
310
|
+
"SEATSMAX": "400",
|
|
311
|
+
"SEATSOCC": "380",
|
|
312
|
+
"PAYMENTSUM": "155000"
|
|
313
|
+
}
|
|
314
|
+
],
|
|
315
|
+
"FIELDS": [
|
|
316
|
+
{ "FIELD": "CARRID", "TYPE": "CHAR", "LENGTH": 3 },
|
|
317
|
+
{ "FIELD": "CONNID", "TYPE": "NUMC", "LENGTH": 4 },
|
|
318
|
+
{ "FIELD": "FLDATE", "TYPE": "DATS", "LENGTH": 8 },
|
|
319
|
+
{ "FIELD": "PRICE", "TYPE": "CURR", "LENGTH": 16 },
|
|
320
|
+
{ "FIELD": "CURRENCY", "TYPE": "CUKY", "LENGTH": 5 },
|
|
321
|
+
{ "FIELD": "PLANETYPE", "TYPE": "CHAR", "LENGTH": 15 },
|
|
322
|
+
{ "FIELD": "SEATSMAX", "TYPE": "NUMC", "LENGTH": 4 },
|
|
323
|
+
{ "FIELD": "SEATSOCC", "TYPE": "NUMC", "LENGTH": 4 },
|
|
324
|
+
{ "FIELD": "PAYMENTSUM", "TYPE": "CURR", "LENGTH": 16 }
|
|
325
|
+
],
|
|
326
|
+
"TOTAL_ROWS": 10,
|
|
327
|
+
"COLUMNS_DISPLAYED": 6,
|
|
328
|
+
"COLUMNS_HIDDEN": ["SEATSMAX", "SEATSOCC", "PAYMENTSUM"],
|
|
329
|
+
"NOT_FOUND": false,
|
|
330
|
+
"ACCESS_DENIED": false
|
|
331
|
+
}
|
|
332
|
+
],
|
|
333
|
+
"SUMMARY": {
|
|
334
|
+
"TOTAL_OBJECTS": 1,
|
|
335
|
+
"TOTAL_ROWS": 4
|
|
336
|
+
},
|
|
337
|
+
"ERROR": ""
|
|
338
|
+
}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
## Response Structure
|
|
344
|
+
|
|
345
|
+
### JSON Response Schema
|
|
346
|
+
|
|
347
|
+
```json
|
|
348
|
+
{
|
|
349
|
+
"SUCCESS": boolean,
|
|
350
|
+
"COMMAND": "PREVIEW",
|
|
351
|
+
"MESSAGE": "string",
|
|
352
|
+
"OBJECTS": [
|
|
353
|
+
{
|
|
354
|
+
"NAME": "string",
|
|
355
|
+
"TYPE": "TABL|DDLS",
|
|
356
|
+
"TYPE_TEXT": "Table|CDS View",
|
|
357
|
+
"ROW_COUNT": number,
|
|
358
|
+
"TOTAL_ROWS": number,
|
|
359
|
+
"ROWS": [
|
|
360
|
+
{ "FIELD_NAME": "value", ... }
|
|
361
|
+
],
|
|
362
|
+
"FIELDS": [
|
|
363
|
+
{
|
|
364
|
+
"FIELD": "string",
|
|
365
|
+
"TYPE": "string",
|
|
366
|
+
"LENGTH": number
|
|
367
|
+
}
|
|
368
|
+
],
|
|
369
|
+
"COLUMNS_DISPLAYED": number,
|
|
370
|
+
"COLUMNS_HIDDEN": ["string"],
|
|
371
|
+
"NOT_FOUND": boolean,
|
|
372
|
+
"ACCESS_DENIED": boolean
|
|
373
|
+
}
|
|
374
|
+
],
|
|
375
|
+
"SUMMARY": {
|
|
376
|
+
"TOTAL_OBJECTS": number,
|
|
377
|
+
"TOTAL_ROWS": number
|
|
378
|
+
},
|
|
379
|
+
"ERROR": "string"
|
|
380
|
+
}
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
## Error Handling
|
|
386
|
+
|
|
387
|
+
| Error | Message |
|
|
388
|
+
|-------|---------|
|
|
389
|
+
| Table not found | `Table not found: Z_NONEXISTENT` |
|
|
390
|
+
| CDS View not found | `CDS View not found: Z_NONEXISTENT` |
|
|
391
|
+
| Access denied | `Access denied to table: SFLIGHT` |
|
|
392
|
+
| Invalid WHERE clause | `Invalid WHERE clause: <reason>` |
|
|
393
|
+
| Invalid object type | `Unsupported object type: CLAS` |
|
|
394
|
+
| Invalid column name | `Invalid column: INVALID_NAME` |
|
|
395
|
+
|
|
396
|
+
### Error Output
|
|
397
|
+
|
|
398
|
+
```
|
|
399
|
+
❌ Table not found: Z_NONEXISTENT
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
```
|
|
403
|
+
❌ Access denied to table: SFLIGHT
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
---
|
|
407
|
+
|
|
408
|
+
## Object Type Detection
|
|
409
|
+
|
|
410
|
+
### Auto-Detection Rules
|
|
411
|
+
|
|
412
|
+
| Object Name Pattern | Default Type |
|
|
413
|
+
|---------------------|--------------|
|
|
414
|
+
| `ZC_*` or `zc_*` | DDLS (CDS View) |
|
|
415
|
+
| `Z*` | TABL (Table) - fallback |
|
|
416
|
+
| Other | TABL (Table) |
|
|
417
|
+
|
|
418
|
+
### Supported Object Types
|
|
419
|
+
|
|
420
|
+
| Type Code | Type Text | Description |
|
|
421
|
+
|-----------|-----------|-------------|
|
|
422
|
+
| `TABL` | Table | Database table |
|
|
423
|
+
| `DDLS` | CDS View | CDS View/Entity |
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## Implementation
|
|
428
|
+
|
|
429
|
+
### ABAP Tables/Classes Used
|
|
430
|
+
|
|
431
|
+
| Table/Class | Purpose |
|
|
432
|
+
|-------------|---------|
|
|
433
|
+
| **TADIR** | Object directory (verify object exists) |
|
|
434
|
+
| **DD02L** | Table/structure definitions |
|
|
435
|
+
| **DD03L** | Table/structure fields |
|
|
436
|
+
| **DD02V** | Table view with delivery class |
|
|
437
|
+
| **CL_DD_DDL_HANDLER_FACTORY** | Read CDS view data |
|
|
438
|
+
|
|
439
|
+
### Table Data Retrieval (TABL)
|
|
440
|
+
|
|
441
|
+
```abap
|
|
442
|
+
" Get table fields from DD03L
|
|
443
|
+
SELECT fieldname, datatype, leng
|
|
444
|
+
FROM dd03l
|
|
445
|
+
INTO TABLE lt_fields
|
|
446
|
+
WHERE tabname = iv_name
|
|
447
|
+
AND as4local = 'A'
|
|
448
|
+
ORDER BY position.
|
|
449
|
+
|
|
450
|
+
" Build SELECT query
|
|
451
|
+
" Use OPEN SQL with limited fields
|
|
452
|
+
SELECT UP TO lv_limit (lt_fields)
|
|
453
|
+
FROM (iv_name)
|
|
454
|
+
INTO TABLE lt_result
|
|
455
|
+
WHERE (lv_where_clause).
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
### CDS View Data Retrieval (DDLS)
|
|
459
|
+
|
|
460
|
+
```abap
|
|
461
|
+
" Use CDS view directly with OPEN SQL
|
|
462
|
+
" First verify CDS view exists in TADIR
|
|
463
|
+
SELECT SINGLE obj_name FROM tadir
|
|
464
|
+
INTO lv_obj_name
|
|
465
|
+
WHERE obj_name = iv_name
|
|
466
|
+
AND object = 'DDLS'.
|
|
467
|
+
|
|
468
|
+
" Read data from CDS view
|
|
469
|
+
SELECT UP TO lv_limit (lt_fields)
|
|
470
|
+
FROM (iv_name)
|
|
471
|
+
INTO TABLE lt_result
|
|
472
|
+
WHERE (lv_where_clause).
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
### Column Width Calculation
|
|
476
|
+
|
|
477
|
+
```abap
|
|
478
|
+
" Calculate column width based on:
|
|
479
|
+
" 1. Field length from DD03L
|
|
480
|
+
" 2. Max value length in result set
|
|
481
|
+
" 3. Field description length
|
|
482
|
+
" Minimum width: 3 characters
|
|
483
|
+
" Maximum width: 20 characters (truncate with ...)
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
---
|
|
487
|
+
|
|
488
|
+
## Examples
|
|
489
|
+
|
|
490
|
+
```bash
|
|
491
|
+
# Preview a table with default settings
|
|
492
|
+
abapgit-agent preview --objects SFLIGHT
|
|
493
|
+
|
|
494
|
+
# Preview with more rows
|
|
495
|
+
abapgit-agent preview --objects SFLIGHT --limit 50
|
|
496
|
+
|
|
497
|
+
# Preview with filter
|
|
498
|
+
abapgit-agent preview --objects SFLIGHT --where "CARRID = 'AA' AND CONNID = '0017'"
|
|
499
|
+
|
|
500
|
+
# Preview specific columns
|
|
501
|
+
abapgit-agent preview --objects SFLIGHT --columns CARRID,CONNID,FLDATE,PRICE,CURRENCY
|
|
502
|
+
|
|
503
|
+
# Preview CDS view
|
|
504
|
+
abapgit-agent preview --objects ZC_MY_CDS_VIEW
|
|
505
|
+
|
|
506
|
+
# Vertical format for wide tables
|
|
507
|
+
abapgit-agent preview --objects SFLIGHT --vertical
|
|
508
|
+
|
|
509
|
+
# Compact mode
|
|
510
|
+
abapgit-agent preview --objects SFLIGHT --compact
|
|
511
|
+
|
|
512
|
+
# JSON for programmatic use
|
|
513
|
+
abapgit-agent preview --objects SFLIGHT --json
|
|
514
|
+
|
|
515
|
+
# Preview multiple objects
|
|
516
|
+
abapgit-agent preview --objects SFLIGHT,ZSCUSTOMER,ZCF_MY_VIEW
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
## Security Considerations
|
|
522
|
+
|
|
523
|
+
- **Read-only access**: Preview only reads data, no modifications
|
|
524
|
+
- **WHERE clause validation**: Sanitize input to prevent SQL injection
|
|
525
|
+
- Allow only: `=`, `<>`, `>`, `<`, `>=`, `<=`, `LIKE`, `IN`, `AND`, `OR`, `(`, `)`
|
|
526
|
+
- Block: `DELETE`, `UPDATE`, `INSERT`, `DROP`, `TABLE`
|
|
527
|
+
- **Column name validation**: Validate column names against DD03L
|
|
528
|
+
- **Row limit**: Enforce maximum of 100 rows to prevent large result sets
|
package/package.json
CHANGED
package/src/abap-client.js
CHANGED
|
@@ -378,6 +378,24 @@ class ABAPClient {
|
|
|
378
378
|
|
|
379
379
|
return await this.request('POST', '/tree', data, { csrfToken: this.csrfToken });
|
|
380
380
|
}
|
|
381
|
+
|
|
382
|
+
async preview(objects, type = null, limit = 10) {
|
|
383
|
+
// Fetch CSRF token first
|
|
384
|
+
await this.fetchCsrfToken();
|
|
385
|
+
|
|
386
|
+
const data = {
|
|
387
|
+
objects: objects,
|
|
388
|
+
limit: Math.min(Math.max(1, limit), 100)
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
if (type) {
|
|
392
|
+
data.type = type;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
logger.info('Previewing data', { objects, type, limit: data.limit, service: 'abapgit-agent' });
|
|
396
|
+
|
|
397
|
+
return await this.request('POST', '/preview', data, { csrfToken: this.csrfToken });
|
|
398
|
+
}
|
|
381
399
|
}
|
|
382
400
|
|
|
383
401
|
// Singleton instance
|
package/src/agent.js
CHANGED
|
@@ -191,6 +191,25 @@ class ABAPGitAgent {
|
|
|
191
191
|
throw new Error(`Tree command failed: ${error.message}`);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
+
|
|
195
|
+
async preview(objects, type = null, limit = 10) {
|
|
196
|
+
logger.info('Previewing data', { objects, type, limit });
|
|
197
|
+
|
|
198
|
+
try {
|
|
199
|
+
const result = await this.abap.preview(objects, type, limit);
|
|
200
|
+
return {
|
|
201
|
+
success: result.SUCCESS === 'X' || result.success === 'X' || result.success === true,
|
|
202
|
+
command: result.COMMAND || result.command || 'PREVIEW',
|
|
203
|
+
message: result.MESSAGE || result.message || '',
|
|
204
|
+
objects: result.OBJECTS || result.objects || [],
|
|
205
|
+
summary: result.SUMMARY || result.summary || null,
|
|
206
|
+
error: result.ERROR || result.error || null
|
|
207
|
+
};
|
|
208
|
+
} catch (error) {
|
|
209
|
+
logger.error('Preview command failed', { error: error.message });
|
|
210
|
+
throw new Error(`Preview command failed: ${error.message}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
194
213
|
}
|
|
195
214
|
|
|
196
215
|
module.exports = {
|