abapgit-agent 1.2.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 +440 -1
- package/CLAUDE.md +354 -16
- package/INSTALL.md +6 -11
- package/README.md +10 -0
- package/RELEASE_NOTES.md +57 -0
- package/abap/CLAUDE.md +340 -0
- package/abap/copilot-instructions.md +28 -0
- package/abap/zcl_abgagt_agent.clas.abap +2 -2
- package/abap/zcl_abgagt_cmd_factory.clas.abap +1 -0
- package/abap/zcl_abgagt_command_inspect.clas.abap +255 -36
- package/abap/zcl_abgagt_command_preview.clas.abap +386 -0
- package/abap/zcl_abgagt_command_preview.clas.xml +15 -0
- package/abap/zcl_abgagt_command_view.clas.abap +3 -1
- 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/zcl_abgagt_util.clas.abap +2 -2
- package/abap/zcl_abgagt_viewer_ddls.clas.abap +83 -0
- package/abap/zcl_abgagt_viewer_ddls.clas.xml +15 -0
- package/abap/zcl_abgagt_viewer_ttyp.clas.abap +93 -0
- package/abap/zcl_abgagt_viewer_ttyp.clas.xml +15 -0
- package/abap/zif_abgagt_command.intf.abap +2 -1
- package/abap/zif_abgagt_viewer.intf.abap +2 -1
- package/bin/abapgit-agent +447 -40
- package/docs/commands.md +5 -0
- package/docs/preview-command.md +528 -0
- package/docs/view-command.md +94 -2
- package/package.json +1 -1
- package/src/abap-client.js +18 -0
- package/src/agent.js +19 -0
package/docs/commands.md
CHANGED
|
@@ -14,6 +14,7 @@ All available CLI commands for abapGit Agent.
|
|
|
14
14
|
| [tree](tree-command.md) | ✅ | Display package hierarchy tree |
|
|
15
15
|
| [unit](unit-command.md) | ✅ | Run AUnit tests |
|
|
16
16
|
| [view](view-command.md) | ✅ | View ABAP object source code from system |
|
|
17
|
+
| [preview](preview-command.md) | 🔄 | Preview table/CDS view data |
|
|
17
18
|
| [health](health-command.md) | ✅ | Health check |
|
|
18
19
|
| [status](status-command.md) | ✅ | Status check |
|
|
19
20
|
|
|
@@ -70,6 +71,10 @@ abapgit-agent tree --package $MY_PACKAGE
|
|
|
70
71
|
abapgit-agent view --objects ZCL_MY_CLASS
|
|
71
72
|
abapgit-agent view --objects SFLIGHT --type TABL
|
|
72
73
|
|
|
74
|
+
# Preview table/CDS view data
|
|
75
|
+
abapgit-agent preview --objects SFLIGHT
|
|
76
|
+
abapgit-agent preview --objects ZC_MY_CDS_VIEW --type DDLS
|
|
77
|
+
|
|
73
78
|
# Check configuration
|
|
74
79
|
abapgit-agent status
|
|
75
80
|
|
|
@@ -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/docs/view-command.md
CHANGED
|
@@ -28,6 +28,8 @@ abapgit-agent view --objects ZIF_MY_INT --type INTF
|
|
|
28
28
|
abapgit-agent view --objects ZMY_STRUCT --type STRU
|
|
29
29
|
abapgit-agent view --objects ZMY_TABLE --type TABL
|
|
30
30
|
abapgit-agent view --objects ZMY_DTEL --type DTEL
|
|
31
|
+
abapgit-agent view --objects ZMY_TTYP --type TTYP
|
|
32
|
+
abapgit-agent view --objects ZC_MY_CDS_VIEW --type DDLS
|
|
31
33
|
|
|
32
34
|
# View multiple objects
|
|
33
35
|
abapgit-agent view --objects ZCL_CLASS1,ZCL_CLASS2,ZIF_INTERFACE1
|
|
@@ -49,7 +51,7 @@ abapgit-agent view --objects ZCL_MY_CLASS --json
|
|
|
49
51
|
| Parameter | Required | Description |
|
|
50
52
|
|-----------|----------|-------------|
|
|
51
53
|
| `--objects` | Yes | Comma-separated list of object names (e.g., `ZCL_MY_CLASS,ZIF_MY_INTERFACE`) |
|
|
52
|
-
| `--type` | No | Object type for all objects (CLAS, INTF, TABL, STRU, DTEL). Auto-detected from TADIR if not specified |
|
|
54
|
+
| `--type` | No | Object type for all objects (CLAS, INTF, TABL, STRU, DTEL, TTYP, DDLS). Auto-detected from TADIR if not specified |
|
|
53
55
|
| `--json` | No | Output raw JSON only (for scripting) |
|
|
54
56
|
|
|
55
57
|
---
|
|
@@ -185,6 +187,36 @@ DATA ELEMENT S_CARR_ID:
|
|
|
185
187
|
└────────────────────┴──────────────────────────────────────────┘
|
|
186
188
|
```
|
|
187
189
|
|
|
190
|
+
### Table Type Definition (TTYP)
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
📖 DDL2DDICWARNINGS (Table Type)
|
|
194
|
+
Table Type DDL2DDICWARNINGS in SDDL_BASIC_FUNCTIONS
|
|
195
|
+
|
|
196
|
+
Line Type: DDL2DDICERR
|
|
197
|
+
Access Mode: STANDARD
|
|
198
|
+
Key Definition: WITH KEY
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### CDS View Definition (DDLS)
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
📖 ZC_MY_CDS_VIEW (CDS View)
|
|
205
|
+
CDS View ZC_MY_CDS_VIEW in $PACKAGE
|
|
206
|
+
|
|
207
|
+
@AbapCatalog.sqlViewName: 'ZCMYVIEW'
|
|
208
|
+
@AbapCatalog.compiler.compareFilter: true
|
|
209
|
+
@AccessControl.authorizationCheck: #NOT_REQUIRED
|
|
210
|
+
@EndUserText.label: 'My CDS View'
|
|
211
|
+
define view ZC_MY_CDS_VIEW as select from tdevc
|
|
212
|
+
{
|
|
213
|
+
key devclass as Devclass,
|
|
214
|
+
parentcl as ParentPackage,
|
|
215
|
+
ctext as Description
|
|
216
|
+
}
|
|
217
|
+
where devclass not like '$%'
|
|
218
|
+
```
|
|
219
|
+
|
|
188
220
|
### Multiple Objects
|
|
189
221
|
|
|
190
222
|
```
|
|
@@ -240,7 +272,7 @@ DATA ELEMENT S_CARR_ID:
|
|
|
240
272
|
"OBJECTS": [
|
|
241
273
|
{
|
|
242
274
|
"NAME": "string",
|
|
243
|
-
"TYPE": "CLAS|INTF|TABL|STRU|DTEL",
|
|
275
|
+
"TYPE": "CLAS|INTF|TABL|STRU|DTEL|TTYP|DDLS",
|
|
244
276
|
"TYPE_TEXT": "string",
|
|
245
277
|
"DESCRIPTION": "string",
|
|
246
278
|
"DOMAIN": "string", // For DTEL
|
|
@@ -307,6 +339,8 @@ DATA ELEMENT S_CARR_ID:
|
|
|
307
339
|
| `TABL` | Table | Database table |
|
|
308
340
|
| `STRU` | Structure | Structure type |
|
|
309
341
|
| `DTEL` | Data Element | Data element/domain type |
|
|
342
|
+
| `TTYP` | Table Type | Table type definition |
|
|
343
|
+
| `DDLS` | CDS View | CDS View/Entity definition |
|
|
310
344
|
|
|
311
345
|
---
|
|
312
346
|
|
|
@@ -325,6 +359,9 @@ abapgit-agent view --objects SFLIGHT --type TABL
|
|
|
325
359
|
# View data element
|
|
326
360
|
abapgit-agent view --objects S_CARR_ID --type DTEL
|
|
327
361
|
|
|
362
|
+
# View CDS view definition
|
|
363
|
+
abapgit-agent view --objects ZC_MY_CDS_VIEW --type DDLS
|
|
364
|
+
|
|
328
365
|
# View multiple objects
|
|
329
366
|
abapgit-agent view --objects ZCL_CONFIG,ZIF_LOGGER,ZCL_UTILS
|
|
330
367
|
|
|
@@ -350,6 +387,7 @@ abapgit-agent view --objects sflight --type tabl
|
|
|
350
387
|
| **DD02L** | Table/structure definitions |
|
|
351
388
|
| **DD03L** | Table/structure fields |
|
|
352
389
|
| **DD04L** | Data element definitions |
|
|
390
|
+
| **DD40L** | Table type definitions |
|
|
353
391
|
|
|
354
392
|
### Class Source Retrieval (CLAS)
|
|
355
393
|
|
|
@@ -407,3 +445,57 @@ SELECT SINGLE rollname, ddtext, datatype, leng, decimals
|
|
|
407
445
|
INTO (lv_domain, lv_desc, lv_type, lv_len, lv_decimals)
|
|
408
446
|
WHERE rollname = iv_name.
|
|
409
447
|
```
|
|
448
|
+
|
|
449
|
+
### Table Type Retrieval (TTYP)
|
|
450
|
+
|
|
451
|
+
```abap
|
|
452
|
+
" Get TTYP details from DD40L
|
|
453
|
+
SELECT SINGLE rowtype accessmode keydef FROM dd40l
|
|
454
|
+
INTO (lv_linetype, lv_tabprottype, lv_keydef)
|
|
455
|
+
WHERE typename = iv_name
|
|
456
|
+
AND as4local = 'A'.
|
|
457
|
+
|
|
458
|
+
" Convert codes to text:
|
|
459
|
+
" - Access mode: T=STANDARD, S=SORTED, H=HASHED
|
|
460
|
+
" - Key definition: D=WITH KEY, N=NO KEY
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
### CDS View Retrieval (DDLS)
|
|
464
|
+
|
|
465
|
+
```abap
|
|
466
|
+
" Use DDL handler to read CDS view source
|
|
467
|
+
lo_handler = cl_dd_ddl_handler_factory=>create( ).
|
|
468
|
+
|
|
469
|
+
" First try to read inactive version (get_state = 'M')
|
|
470
|
+
TRY.
|
|
471
|
+
lo_handler->read(
|
|
472
|
+
EXPORTING
|
|
473
|
+
name = lv_ddls_name
|
|
474
|
+
get_state = 'M'
|
|
475
|
+
IMPORTING
|
|
476
|
+
ddddlsrcv_wa = ls_ddlsrcv ).
|
|
477
|
+
|
|
478
|
+
IF ls_ddlsrcv-source IS NOT INITIAL.
|
|
479
|
+
lv_found = abap_true.
|
|
480
|
+
ENDIF.
|
|
481
|
+
|
|
482
|
+
CATCH cx_dd_ddl_check.
|
|
483
|
+
" Ignore - will try active version
|
|
484
|
+
ENDTRY.
|
|
485
|
+
|
|
486
|
+
" If no inactive version, try active version
|
|
487
|
+
IF lv_found = abap_false.
|
|
488
|
+
TRY.
|
|
489
|
+
lo_handler->read(
|
|
490
|
+
EXPORTING
|
|
491
|
+
name = lv_ddls_name
|
|
492
|
+
get_state = 'A'
|
|
493
|
+
IMPORTING
|
|
494
|
+
ddddlsrcv_wa = ls_ddlsrcv ).
|
|
495
|
+
CATCH cx_dd_ddl_check.
|
|
496
|
+
" Not found
|
|
497
|
+
ENDTRY.
|
|
498
|
+
ENDIF.
|
|
499
|
+
|
|
500
|
+
" Source code is in ls_ddlsrcv-source
|
|
501
|
+
```
|