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/abap/CLAUDE.md CHANGED
@@ -4,6 +4,30 @@ This file provides guidelines for **generating ABAP code** in abapGit repositori
4
4
 
5
5
  **Use this file as a template**: Copy it to your ABAP repository root when setting up new projects with Claude Code.
6
6
 
7
+ ## Quick Reference
8
+
9
+ ```bash
10
+ # After editing ABAP files:
11
+ git add . && git commit -m "feat: description" && git push
12
+ abapgit-agent pull --files abap/zcl_my_class.clas.abap
13
+
14
+ # If pull fails with syntax error:
15
+ abapgit-agent inspect --files abap/zcl_my_class.clas.abap
16
+
17
+ # Explore tables/views:
18
+ abapgit-agent preview --objects ZTABLE
19
+ abapgit-agent view --objects ZTABLE --type TABL
20
+ abapgit-agent tree --package $MY_PACKAGE
21
+ ```
22
+
23
+ ## Common Workflow
24
+
25
+ 1. Generate/edit ABAP code
26
+ 2. Push to git: `git add . && git commit && git push`
27
+ 3. Activate in ABAP: `abapgit-agent pull --files file.clas.abap`
28
+ 4. Check for errors - fix if needed
29
+ 5. Repeat
30
+
7
31
  ## ABAP Syntax Validation
8
32
 
9
33
  This is an ABAP project. **Do not attempt local syntax validation** - ABAP code can only be validated in an SAP system.
@@ -23,6 +47,58 @@ This is an ABAP project. **Do not attempt local syntax validation** - ABAP code
23
47
  4. **"Error updating where-used list" = SYNTAX ERROR** - This is NOT a warning!
24
48
  5. If Failed Objects > 0, there are syntax errors - fix them before proceeding
25
49
 
50
+ ## Inspect Command (Syntax Check)
51
+
52
+ Use the `inspect` command to perform syntax validation on ABAP objects and CDS views.
53
+
54
+ ### Usage
55
+ ```bash
56
+ # Syntax check single file
57
+ abapgit-agent inspect --files abap/zcl_my_class.clas.abap
58
+
59
+ # Syntax check multiple files
60
+ abapgit-agent inspect --files abap/zcl_class1.clas.abap,abap/zcl_class2.clas.abap
61
+
62
+ # Syntax check CDS view
63
+ abapgit-agent inspect --files abap/zc_my_view.ddls.asddls
64
+ ```
65
+
66
+ ### Supported Object Types
67
+
68
+ | Type | Description | Validation Method |
69
+ |------|-------------|------------------|
70
+ | CLAS | Class | Code Inspector (SCI) |
71
+ | INTF | Interface | Code Inspector (SCI) |
72
+ | PROG | Program | Code Inspector (SCI) |
73
+ | DDLS | CDS View/Entity | DDL Handler |
74
+
75
+ ### CDS Views (DDLS) Validation
76
+
77
+ For CDS views, the inspect command uses `CL_DD_DDL_HANDLER_FACTORY`:
78
+ - Checks **inactive version first** (`get_state = 'M'`)
79
+ - Falls back to active version if no inactive version exists
80
+ - Uses `get_errors()` and `get_warnings()` methods for detailed error information
81
+
82
+ ### Examples
83
+
84
+ **Passed:**
85
+ ```
86
+ ✅ CLAS ZCL_MY_CLASS - Syntax check passed
87
+ ```
88
+
89
+ **With Warnings:**
90
+ ```
91
+ ⚠️ DDLS ZC_MY_VIEW - Syntax check passed with warnings (4):
92
+ Line 9 : ParentPackage
93
+ Line 11 : SoftwareComponent
94
+ ```
95
+
96
+ **Failed:**
97
+ ```
98
+ ❌ DDLS ZC_MY_VIEW - Syntax check failed (1 error(s)):
99
+ Line 21, Column 12: Error message text
100
+ ```
101
+
26
102
  ## Fast Iteration Workflow
27
103
 
28
104
  For quick ABAP code changes:
@@ -80,6 +156,12 @@ abapgit-agent view --objects ZMY_DTEL --type DTEL
80
156
  # View a class definition
81
157
  abapgit-agent view --objects ZCL_MY_CLASS
82
158
 
159
+ # View an interface definition
160
+ abapgit-agent view --objects ZIF_MY_INTERFACE
161
+
162
+ # View a table type definition
163
+ abapgit-agent view --objects ZMY_TTYP --type TTYP
164
+
83
165
  # View multiple objects
84
166
  abapgit-agent view --objects ZCL_CLASS1,ZCL_CLASS2,ZIF_INTERFACE1
85
167
 
@@ -87,6 +169,41 @@ abapgit-agent view --objects ZCL_CLASS1,ZCL_CLASS2,ZIF_INTERFACE1
87
169
  abapgit-agent view --objects ZMY_TABLE --type TABL --json
88
170
  ```
89
171
 
172
+ ### When to Use View Command
173
+
174
+ AI assistant SHOULD call `view` command when:
175
+
176
+ - User asks to "check", "look up", or "explore" an unfamiliar object
177
+ - Working with a table/structure and you don't know the field names/types
178
+ - Calling a class/interface method and you don't know the parameters
179
+ - User provides an object name that may not exist in the git repository
180
+
181
+ **Example workflow:**
182
+ ```
183
+ User: "Check if SFLIGHT table has a PRICE field"
184
+
185
+ Assistant: <calls `abapgit-agent view --objects SFLIGHT --type TABL`>
186
+ → Shows table structure with all fields including PRICE
187
+ ```
188
+
189
+ ## Explore Package Structure
190
+
191
+ Use the `tree` command to display package hierarchy from ABAP system:
192
+
193
+ ```bash
194
+ # Display package hierarchy
195
+ abapgit-agent tree --package $MY_PACKAGE
196
+
197
+ # With object counts
198
+ abapgit-agent tree --package $MY_PACKAGE --include-objects
199
+
200
+ # Limit depth
201
+ abapgit-agent tree --package $MY_PACKAGE --depth 2
202
+
203
+ # JSON output for scripting
204
+ abapgit-agent tree --package $MY_PACKAGE --json
205
+ ```
206
+
90
207
  **Table Output Example:**
91
208
  ```
92
209
  TABLE ZCAIS_D1:
@@ -111,6 +228,122 @@ DATA ELEMENT ZMY_DTEL:
111
228
  |----------------+----------------+----------+----------------+----------------------|
112
229
  ```
113
230
 
231
+ **Table Type Output Example:**
232
+ ```
233
+ 📖 ZMY_TTYP (Table Type)
234
+ Table Type ZMY_TTYP in $PACKAGE
235
+
236
+ Line Type: ZMY_STRUCTURE
237
+ Access Mode: STANDARD
238
+ Key Definition: WITH KEY
239
+ ```
240
+
241
+ ## CLI Commands Reference
242
+
243
+ This section documents the available CLI commands for ABAP development.
244
+
245
+ ### Pull Command
246
+
247
+ Pull and activate ABAP objects from git repository.
248
+
249
+ ```bash
250
+ # Pull all files
251
+ abapgit-agent pull
252
+
253
+ # Pull specific files (faster)
254
+ abapgit-agent pull --files abap/zcl_my_class.clas.abap
255
+
256
+ # Pull with transport request
257
+ abapgit-agent pull --files abap/zcl_my_class.clas.abap --transport DEVK900001
258
+ ```
259
+
260
+ ### Inspect Command
261
+
262
+ Run syntax check on ABAP objects.
263
+
264
+ ```bash
265
+ # Syntax check single file
266
+ abapgit-agent inspect --files abap/zcl_my_class.clas.abap
267
+
268
+ # Syntax check multiple files
269
+ abapgit-agent inspect --files abap/zcl_class1.clas.abap,abap/zcl_class2.clas.abap
270
+
271
+ # Syntax check CDS view
272
+ abapgit-agent inspect --files abap/zc_my_view.ddls.asddls
273
+ ```
274
+
275
+ ### Unit Command
276
+
277
+ Run ABAP unit tests.
278
+
279
+ ```bash
280
+ # Run unit tests for test class
281
+ abapgit-agent unit --files abap/zcl_my_test.clas.testclasses.abap
282
+
283
+ # Run unit tests for package
284
+ abapgit-agent unit --package $MY_PACKAGE
285
+ ```
286
+
287
+ ### Tree Command
288
+
289
+ Display package hierarchy.
290
+
291
+ ```bash
292
+ # Display package tree
293
+ abapgit-agent tree --package $MY_PACKAGE
294
+
295
+ # With object counts
296
+ abapgit-agent tree --package $MY_PACKAGE --include-objects
297
+
298
+ # JSON output
299
+ abapgit-agent tree --package $MY_PACKAGE --json
300
+ ```
301
+
302
+ ### View Command
303
+
304
+ View ABAP object definitions directly from the system.
305
+
306
+ ```bash
307
+ # View table structure
308
+ abapgit-agent view --objects ZMY_TABLE --type TABL
309
+
310
+ # View class definition
311
+ abapgit-agent view --objects ZCL_MY_CLASS
312
+
313
+ # View CDS view
314
+ abapgit-agent view --objects ZC_MY_CDS_VIEW --type DDLS
315
+
316
+ # JSON output
317
+ abapgit-agent view --objects ZCL_MY_CLASS --json
318
+ ```
319
+
320
+ ### Preview Command
321
+
322
+ Preview data from tables or CDS views.
323
+
324
+ ```bash
325
+ # Preview table data
326
+ abapgit-agent preview --objects SFLIGHT
327
+
328
+ # Preview with row limit
329
+ abapgit-agent preview --objects SFLIGHT --limit 5
330
+
331
+ # Preview with WHERE filter
332
+ abapgit-agent preview --objects SFLIGHT --where "CARRID = 'AA'"
333
+
334
+ # Preview specific columns
335
+ abapgit-agent preview --objects SFLIGHT --columns CARRID,PRICE,FLDATE
336
+
337
+ # Vertical format (for wide tables)
338
+ abapgit-agent preview --objects SFLIGHT --vertical
339
+
340
+ # Compact mode (truncated values)
341
+ abapgit-agent preview --objects SFLIGHT --compact
342
+
343
+ # JSON output
344
+ abapgit-agent preview --objects SFLIGHT --json
345
+ ```
346
+
114
347
  ## JSON Handling - ALWAYS Use /ui2/cl_json
115
348
 
116
349
  **CRITICAL**: Always use `/ui2/cl_json` for JSON serialization and deserialization.
@@ -369,6 +602,113 @@ Common object types in this project:
369
602
  - `TABL` - Tables
370
603
  - `DDLS` - Data Definitions
371
604
 
605
+ ## Creating CDS Views (DDLS)
606
+
607
+ CDS views (Data Definition Language Source) require specific file naming and structure for abapGit.
608
+
609
+ ### File Naming
610
+
611
+ CDS views require **two files**:
612
+
613
+ | File | Description |
614
+ |------|-------------|
615
+ | `zc_my_view.ddls.asddls` | DDL source code |
616
+ | `zc_my_view.ddls.xml` | XML metadata |
617
+
618
+ **Important:** Do NOT use `.ddls.abap` extension - use `.ddls.asddls` for the source.
619
+
620
+ ### DDL Source File (`.ddls.asddls`)
621
+
622
+ ```abap
623
+ @AbapCatalog.sqlViewName: 'ZCMYVIEW'
624
+ @AbapCatalog.compiler.compareFilter: true
625
+ @AccessControl.authorizationCheck: #NOT_REQUIRED
626
+ @EndUserText.label: 'My CDS View'
627
+ define view ZC_My_View as select from tdevc
628
+ {
629
+ key devclass as Devclass,
630
+ parentcl as ParentPackage,
631
+ ctext as Description
632
+ }
633
+ where devclass not like '$%'
634
+ ```
635
+
636
+ ### XML Metadata File (`.ddls.xml`)
637
+
638
+ ```xml
639
+ <?xml version="1.0" encoding="utf-8"?>
640
+ <abapGit version="v1.0.0" serializer="LCL_OBJECT_DDLS" serializer_version="v1.0.0">
641
+ <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
642
+ <asx:values>
643
+ <DDLS>
644
+ <DDLNAME>ZC_MY_VIEW</DDLNAME>
645
+ <DDLANGUAGE>E</DDLANGUAGE>
646
+ <DDTEXT>My CDS View</DDTEXT>
647
+ </DDLS>
648
+ </asx:values>
649
+ </asx:abap>
650
+ </abapGit>
651
+ ```
652
+
653
+ ### Key Points
654
+
655
+ 1. **Avoid reserved words** - Field names like `PACKAGE`, `CLASS`, `INTERFACE` are reserved in CDS. Use alternatives like `PackageName`, `ClassName`.
656
+
657
+ 2. **Pull all files to activate** - When activating CDS views, use `abapgit-agent pull` (not single file) to ensure proper activation:
658
+ ```bash
659
+ abapgit-agent pull # Pull all files
660
+ ```
661
+
662
+ 3. **System support** - CDS views require SAP systems with CDS capability (S/4HANA, SAP BW/4HANA, or ABAP 7.51+). Older systems will show error: "Object type DDLS is not supported by this system"
663
+
664
+ ### Debugging Activation Errors
665
+
666
+ When pull shows generic errors like "Activation cancelled. Check the inactive objects":
667
+
668
+ 1. **Check in ADT/Eclipse** - Open the DDL source in ADT and run syntax check for detailed errors
669
+ 2. **Pull all files** - Sometimes `abapgit-agent pull` (all files) works better than single file for CDS views
670
+
671
+ ## Creating CDS View Entities
672
+
673
+ CDS View Entities (`define view entity`) are the modern replacement for CDS Views with additional features like **associations for OData navigation**.
674
+
675
+ ### Differences from CDS Views
676
+
677
+ | Aspect | CDS View | View Entity |
678
+ |--------|----------|-------------|
679
+ | Syntax | `define view` | `define view entity` |
680
+ | Associations | No | Yes (exposed for navigation) |
681
+ | OData/Navigation | Requires separate service | Auto-exposes associations |
682
+ | ABAP Version | 7.40+ | 7.55+ / S/4HANA Cloud |
683
+
684
+ ### DDL Source File with Association
685
+
686
+ ```abap
687
+ @EndUserText.label: 'Package Hierarchy'
688
+ @AccessControl.authorizationCheck: #NOT_REQUIRED
689
+ define view entity ZC_Pkg_Hierarchy_VE
690
+ as select from tdevc
691
+ association [0..1] to tdevc as _Parent
692
+ on _Parent.devclass = $projection.ParentPackage
693
+ {
694
+ key devclass as PackageName,
695
+ parentcl as ParentPackage,
696
+ ctext as Description,
697
+ dlvunit as SoftwareComponent,
698
+
699
+ // Exposed associations
700
+ _Parent
701
+ }
702
+ where devclass not like '$%'
703
+ ```
704
+
705
+ ### Key Points for View Entities
706
+
707
+ 1. **Association syntax**: Use `$projection` to reference fields in the current entity
708
+ 2. **Association cardinality**: `[0..1]`, `[1..1]`, `[0..n]`, `[1..n]`
709
+ 3. **Expose associations**: Add the association name at the end of the SELECT to expose it for OData navigation
710
+ 4. **Activation warnings**: Search help warnings are informational and don't block activation
711
+
372
712
  ## Naming Conventions
373
713
 
374
714
  - Use `Z_` or `Y_` prefix for custom objects
@@ -10,6 +10,34 @@ You are working on an ABAP project using abapGit for version control.
10
10
  | `abapgit-agent pull --files <file>` | Pull and activate specific file only |
11
11
  | `abapgit-agent inspect --files <file>` | Syntax check ABAP source |
12
12
  | `abapgit-agent unit --files <file>` | Run AUnit tests |
13
+ | `abapgit-agent tree --package <package>` | Display package hierarchy |
14
+ | `abapgit-agent view --objects <name>` | View object definitions |
15
+
16
+ ## Explore Unknown Objects
17
+
18
+ **Before working with unfamiliar objects, use `view` command:**
19
+
20
+ ```bash
21
+ # Check table structure
22
+ abapgit-agent view --objects ZMY_TABLE --type TABL
23
+
24
+ # Check class definition
25
+ abapgit-agent view --objects ZCL_UNKNOWN_CLASS
26
+
27
+ # Check interface
28
+ abapgit-agent view --objects ZIF_UNKNOWN_INTERFACE
29
+
30
+ # Check data element
31
+ abapgit-agent view --objects ZMY_DTEL --type DTEL
32
+ ```
33
+
34
+ ## When to Use View Command
35
+
36
+ AI assistant SHOULD call `view` command when:
37
+ - User asks to "check", "look up", or "explore" an unfamiliar object
38
+ - Working with a table/structure and you don't know the fields
39
+ - Calling a class/interface method and you don't know the parameters
40
+ - You need to verify an object exists before using it
13
41
 
14
42
  ## Key ABAP Rules
15
43
 
@@ -389,8 +389,8 @@ CLASS zcl_abgagt_agent IMPLEMENTATION.
389
389
  ENDIF.
390
390
  ENDIF.
391
391
 
392
- " Error/Abort/Warning messages - add to failed objects
393
- IF ls_msg-type = 'E' OR ls_msg-type = 'A' OR ls_msg-type = 'W'.
392
+ " Error/Abort messages - add to failed objects (warnings are not failures)
393
+ IF ls_msg-type = 'E' OR ls_msg-type = 'A'.
394
394
  APPEND ls_object TO rs_result-failed_objects.
395
395
  ENDIF.
396
396
  ENDLOOP.
@@ -29,6 +29,7 @@ CLASS zcl_abgagt_cmd_factory IMPLEMENTATION.
29
29
  ( command = zif_abgagt_command=>gc_import class_name = 'ZCL_ABGAGT_COMMAND_IMPORT' )
30
30
  ( command = zif_abgagt_command=>gc_tree class_name = 'ZCL_ABGAGT_COMMAND_TREE' )
31
31
  ( command = zif_abgagt_command=>gc_view class_name = 'ZCL_ABGAGT_COMMAND_VIEW' )
32
+ ( command = zif_abgagt_command=>gc_preview class_name = 'ZCL_ABGAGT_COMMAND_PREVIEW' )
32
33
  ).
33
34
  ENDMETHOD.
34
35