abapgit-agent 1.7.2 → 1.8.1
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/README.md +26 -8
- package/abap/CLAUDE.md +146 -26
- package/abap/guidelines/00_index.md +8 -0
- package/abap/guidelines/01_sql.md +28 -0
- package/abap/guidelines/02_exceptions.md +8 -0
- package/abap/guidelines/03_testing.md +8 -0
- package/abap/guidelines/04_cds.md +151 -36
- package/abap/guidelines/05_classes.md +8 -0
- package/abap/guidelines/06_objects.md +8 -0
- package/abap/guidelines/07_json.md +8 -0
- package/abap/guidelines/08_abapgit.md +52 -3
- package/abap/guidelines/09_unit_testable_code.md +8 -0
- package/abap/guidelines/10_common_errors.md +95 -0
- package/bin/abapgit-agent +61 -2852
- package/package.json +21 -5
- package/src/agent.js +205 -16
- package/src/commands/create.js +102 -0
- package/src/commands/delete.js +72 -0
- package/src/commands/health.js +24 -0
- package/src/commands/help.js +111 -0
- package/src/commands/import.js +99 -0
- package/src/commands/init.js +321 -0
- package/src/commands/inspect.js +184 -0
- package/src/commands/list.js +143 -0
- package/src/commands/preview.js +277 -0
- package/src/commands/pull.js +278 -0
- package/src/commands/ref.js +96 -0
- package/src/commands/status.js +52 -0
- package/src/commands/syntax.js +340 -0
- package/src/commands/tree.js +209 -0
- package/src/commands/unit.js +133 -0
- package/src/commands/view.js +215 -0
- package/src/commands/where.js +138 -0
- package/src/config.js +11 -1
- package/src/utils/abap-http.js +347 -0
- package/src/utils/git-utils.js +58 -0
- package/src/utils/validators.js +72 -0
- package/src/utils/version-check.js +80 -0
- package/src/abap-client.js +0 -526
- /package/src/{ref-search.js → utils/abap-reference.js} +0 -0
package/README.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: abapGit Agent
|
|
3
|
+
nav_order: 1
|
|
4
|
+
permalink: /
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# abapGit Agent
|
|
2
8
|
|
|
3
9
|
A local agent that enables AI coding tools (Claude, Copilot, etc.) to automatically pull and activate ABAP code from git repositories using REST API.
|
|
@@ -25,7 +31,7 @@ git clone https://github.com/user/abap-project.git
|
|
|
25
31
|
cd abap-project
|
|
26
32
|
|
|
27
33
|
# 3. Initialize configuration
|
|
28
|
-
abapgit-agent init --folder /
|
|
34
|
+
abapgit-agent init --folder /src/ --package ZMY_PACKAGE
|
|
29
35
|
|
|
30
36
|
# 4. Edit .abapGitAgent with credentials
|
|
31
37
|
|
|
@@ -47,7 +53,7 @@ See [Creating New ABAP Projects](INSTALL.md#creating-new-abap-projects) to set u
|
|
|
47
53
|
|
|
48
54
|
```bash
|
|
49
55
|
# Initialize local configuration for existing git repo
|
|
50
|
-
abapgit-agent init --folder /
|
|
56
|
+
abapgit-agent init --folder /src/ --package ZMY_PACKAGE
|
|
51
57
|
|
|
52
58
|
# Create online repository in ABAP
|
|
53
59
|
abapgit-agent create
|
|
@@ -69,7 +75,7 @@ abapgit-agent pull
|
|
|
69
75
|
abapgit-agent pull --branch develop
|
|
70
76
|
|
|
71
77
|
# Pull specific files only (fast iteration)
|
|
72
|
-
abapgit-agent pull --files zcl_my_class.clas.abap,zif_my_intf.intf.abap
|
|
78
|
+
abapgit-agent pull --files src/zcl_my_class.clas.abap,src/zif_my_intf.intf.abap
|
|
73
79
|
|
|
74
80
|
# Override git URL if needed
|
|
75
81
|
abapgit-agent pull --url https://github.com/user/repo --branch main
|
|
@@ -87,21 +93,32 @@ abapgit-agent import --message "feat: add new feature"
|
|
|
87
93
|
### Validation Commands
|
|
88
94
|
|
|
89
95
|
```bash
|
|
90
|
-
#
|
|
91
|
-
|
|
96
|
+
# Check syntax of local source files BEFORE commit (fast, no activation)
|
|
97
|
+
# Supported: CLAS, INTF, PROG, DDLS (CDS Views)
|
|
98
|
+
abapgit-agent syntax --files src/zcl_my_class.clas.abap
|
|
99
|
+
abapgit-agent syntax --files src/zc_my_view.ddls.asddls
|
|
100
|
+
|
|
101
|
+
# Syntax check with ABAP Cloud mode
|
|
102
|
+
abapgit-agent syntax --files src/zcl_my_class.clas.abap --cloud
|
|
103
|
+
|
|
104
|
+
# Syntax check multiple files
|
|
105
|
+
abapgit-agent syntax --files src/zcl_class.clas.abap,src/zc_view.ddls.asddls
|
|
106
|
+
|
|
107
|
+
# Inspect source file for issues (after activation)
|
|
108
|
+
abapgit-agent inspect --files src/zcl_my_class.clas.abap
|
|
92
109
|
|
|
93
110
|
# Run AUnit tests for test classes
|
|
94
|
-
abapgit-agent unit --files
|
|
111
|
+
abapgit-agent unit --files src/zcl_my_test.clas.testclasses.abap
|
|
95
112
|
|
|
96
113
|
# Run tests for multiple test classes
|
|
97
|
-
abapgit-agent unit --files
|
|
114
|
+
abapgit-agent unit --files src/zcl_test1.clas.testclasses.abap,src/zcl_test2.clas.testclasses.abap
|
|
98
115
|
```
|
|
99
116
|
|
|
100
117
|
### Explore Commands
|
|
101
118
|
|
|
102
119
|
```bash
|
|
103
120
|
# Display package hierarchy tree
|
|
104
|
-
abapgit-agent tree --package $MY_PACKAGE
|
|
121
|
+
abapgit-agent tree --package '$MY_PACKAGE'
|
|
105
122
|
|
|
106
123
|
# View object definitions from ABAP system (classes, interfaces, tables, data elements)
|
|
107
124
|
abapgit-agent view --objects ZCL_MY_CLASS
|
|
@@ -158,6 +175,7 @@ npm run pull -- --url <git-url> --branch main
|
|
|
158
175
|
| delete Command | [docs/delete-command.md](docs/delete-command.md) |
|
|
159
176
|
| import Command | [docs/import-command.md](docs/import-command.md) |
|
|
160
177
|
| pull Command | [docs/pull-command.md](docs/pull-command.md) |
|
|
178
|
+
| syntax Command | [docs/syntax-command.md](docs/syntax-command.md) |
|
|
161
179
|
| inspect Command | [docs/inspect-command.md](docs/inspect-command.md) |
|
|
162
180
|
| unit Command | [docs/unit-command.md](docs/unit-command.md) |
|
|
163
181
|
| tree Command | [docs/tree-command.md](docs/tree-command.md) |
|
package/abap/CLAUDE.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: ABAP Project Guidelines
|
|
4
|
+
nav_order: 1
|
|
5
|
+
parent: ABAP Development
|
|
6
|
+
---
|
|
7
|
+
|
|
1
8
|
# ABAP Project Guidelines - Template
|
|
2
9
|
|
|
3
10
|
This file provides guidelines for **generating ABAP code** in abapGit repositories.
|
|
@@ -78,14 +85,48 @@ The folder is configured in `.abapGitAgent` (property: `folder`):
|
|
|
78
85
|
|
|
79
86
|
---
|
|
80
87
|
|
|
81
|
-
### 4.
|
|
88
|
+
### 4. Use Syntax Command Before Commit (for CLAS, INTF, PROG)
|
|
82
89
|
|
|
83
90
|
```
|
|
84
|
-
❌ WRONG: Make changes →
|
|
85
|
-
✅ CORRECT: Make changes →
|
|
91
|
+
❌ WRONG: Make changes → Commit → Push → Pull → Find errors → Fix → Repeat
|
|
92
|
+
✅ CORRECT: Make changes → Run syntax → Fix locally → Commit → Push → Pull → Done
|
|
86
93
|
```
|
|
87
94
|
|
|
88
|
-
**
|
|
95
|
+
**For CLAS, INTF, PROG files**: Run `syntax` command BEFORE commit to catch errors early.
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Check syntax of local code (no commit/push needed)
|
|
99
|
+
abapgit-agent syntax --files src/zcl_my_class.clas.abap
|
|
100
|
+
|
|
101
|
+
# Check multiple INDEPENDENT files
|
|
102
|
+
abapgit-agent syntax --files src/zcl_utils.clas.abap,src/zcl_logger.clas.abap
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**For other types (DDLS, FUGR, TABL, etc.)**: Skip syntax, proceed to commit/push/pull.
|
|
106
|
+
|
|
107
|
+
**Why use syntax command?**
|
|
108
|
+
- Catches syntax errors BEFORE polluting git history with fix commits
|
|
109
|
+
- No broken inactive objects in ABAP system
|
|
110
|
+
- Faster feedback loop - fix locally without commit/push/pull cycle
|
|
111
|
+
- Works even for NEW objects that don't exist in ABAP system yet
|
|
112
|
+
|
|
113
|
+
**⚠️ Important: Syntax checks files independently**
|
|
114
|
+
|
|
115
|
+
When checking multiple files, each is validated in isolation:
|
|
116
|
+
- ✅ **Use for**: Multiple independent files (bug fixes, unrelated changes)
|
|
117
|
+
- ❌ **Don't use for**: Files with dependencies (interface + implementing class)
|
|
118
|
+
|
|
119
|
+
**For dependent files, skip `syntax` and use `pull` instead:**
|
|
120
|
+
```bash
|
|
121
|
+
# ❌ BAD - Interface and implementing class (may show false errors)
|
|
122
|
+
abapgit-agent syntax --files src/zif_my_intf.intf.abap,src/zcl_my_class.clas.abap
|
|
123
|
+
|
|
124
|
+
# ✅ GOOD - Use pull instead for dependent files
|
|
125
|
+
git add . && git commit && git push
|
|
126
|
+
abapgit-agent pull --files src/zif_my_intf.intf.abap,src/zcl_my_class.clas.abap
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Note**: `inspect` still runs against ABAP system (requires pull first). Use `syntax` for pre-commit checking.
|
|
89
130
|
|
|
90
131
|
---
|
|
91
132
|
|
|
@@ -219,48 +260,127 @@ abapgit-agent unit --files src/zcl_test1.clas.testclasses.abap,src/zcl_test2.cla
|
|
|
219
260
|
3. Write code → place in correct folder (e.g., src/zcl_*.clas.abap)
|
|
220
261
|
│
|
|
221
262
|
▼
|
|
222
|
-
4.
|
|
263
|
+
4. Syntax check (for CLAS, INTF, PROG only)
|
|
223
264
|
│
|
|
224
|
-
|
|
225
|
-
|
|
265
|
+
├─► CLAS/INTF/PROG → abapgit-agent syntax --files <file>
|
|
266
|
+
│ │
|
|
267
|
+
│ ├─► Errors? → Fix locally (no commit needed), re-run syntax
|
|
268
|
+
│ │
|
|
269
|
+
│ └─► Clean ✅ → Proceed to commit
|
|
270
|
+
│
|
|
271
|
+
└─► Other types (DDLS, FUGR, TABL, etc.) → Skip syntax, go to commit
|
|
272
|
+
│
|
|
273
|
+
▼
|
|
274
|
+
5. Commit and push → git add . && git commit && git push
|
|
226
275
|
│
|
|
227
276
|
▼
|
|
228
|
-
6.
|
|
229
|
-
- **Do NOT run inspect before commit/push/pull** - ABAP validates on pull
|
|
230
|
-
- **Do NOT run unit before pull** - Tests run against ABAP system, code must be activated first
|
|
231
|
-
- **"Error updating where-used list"** → This is a **SYNTAX ERROR** (check inspect for details)
|
|
232
|
-
- Objects NOT in "Activated Objects" but in "Failed Objects Log" → Syntax error (check inspect)
|
|
233
|
-
- Objects NOT appearing at all → XML metadata issue (check XML format in 08_abapgit.md)
|
|
277
|
+
6. Activate → abapgit-agent pull --files src/file.clas.abap
|
|
234
278
|
│
|
|
235
279
|
▼
|
|
236
|
-
7.
|
|
280
|
+
7. Verify → Check pull output
|
|
281
|
+
- **"Error updating where-used list"** → SYNTAX ERROR (use inspect for details)
|
|
282
|
+
- Objects in "Failed Objects Log" → Syntax error (use inspect)
|
|
283
|
+
- Objects NOT appearing at all → XML metadata issue (check 08_abapgit.md)
|
|
237
284
|
│
|
|
238
285
|
▼
|
|
239
|
-
8.
|
|
286
|
+
8. (Optional) Run unit tests → abapgit-agent unit --files <testclass> (AFTER successful pull)
|
|
240
287
|
```
|
|
241
288
|
|
|
289
|
+
**Syntax Command - Supported Object Types:**
|
|
290
|
+
|
|
291
|
+
| Object Type | Syntax Command | What to Do |
|
|
292
|
+
|-------------|----------------|------------|
|
|
293
|
+
| CLAS (classes) | ✅ Supported | Run `syntax` before commit |
|
|
294
|
+
| CLAS (test classes: .testclasses.abap) | ✅ Supported | Run `syntax` before commit |
|
|
295
|
+
| INTF (interfaces) | ✅ Supported | Run `syntax` before commit |
|
|
296
|
+
| PROG (programs) | ✅ Supported | Run `syntax` before commit |
|
|
297
|
+
| DDLS (CDS views) | ✅ Supported | Run `syntax` before commit (requires annotations) |
|
|
298
|
+
| FUGR (function groups) | ❌ Not supported | Skip syntax, use `pull` then `inspect` |
|
|
299
|
+
| TABL/DTEL/DOMA/MSAG/SHLP | ❌ Not supported | Skip syntax, just `pull` |
|
|
300
|
+
| All other types | ❌ Not supported | Skip syntax, just `pull` |
|
|
301
|
+
|
|
242
302
|
**IMPORTANT**:
|
|
303
|
+
- **Use `syntax` BEFORE commit** for CLAS/INTF/PROG/DDLS - catches errors early, no git pollution
|
|
304
|
+
- **Syntax checks files INDEPENDENTLY** - no cross-file dependency support (e.g., interface definition not available when checking implementing class)
|
|
305
|
+
- **For dependent files** (interface + class, class + using class): Skip `syntax`, use `pull` directly
|
|
306
|
+
- **DDLS requires proper annotations** - CDS views need `@AbapCatalog.sqlViewName`, view entities don't
|
|
243
307
|
- **ALWAYS push to git BEFORE running pull** - abapGit reads from git
|
|
244
|
-
- **Use inspect AFTER pull**
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
308
|
+
- **Use `inspect` AFTER pull** for unsupported types or if pull fails
|
|
309
|
+
|
|
310
|
+
**Working with mixed file types:**
|
|
311
|
+
When modifying multiple files of different types (e.g., 1 class + 1 CDS view):
|
|
312
|
+
1. Run `syntax` on supported files only (CLAS, INTF, PROG) - **only if they're independent**
|
|
313
|
+
2. Commit ALL files together (including unsupported types)
|
|
314
|
+
3. Push and pull ALL files together
|
|
315
|
+
|
|
316
|
+
Example:
|
|
317
|
+
```bash
|
|
318
|
+
# Check syntax on independent class and interface only (skip CDS, skip if dependent)
|
|
319
|
+
abapgit-agent syntax --files src/zcl_my_class.clas.abap,src/zif_my_intf.intf.abap
|
|
320
|
+
|
|
321
|
+
# Commit and push all files including CDS
|
|
322
|
+
git add src/zcl_my_class.clas.abap src/zif_my_intf.intf.abap src/zc_my_view.ddls.asddls
|
|
323
|
+
git commit -m "feat: add class, interface, and CDS view"
|
|
324
|
+
git push
|
|
325
|
+
|
|
326
|
+
# Pull all files together
|
|
327
|
+
abapgit-agent pull --files src/zcl_my_class.clas.abap,src/zif_my_intf.intf.abap,src/zc_my_view.ddls.asddls
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
**When to use syntax vs inspect vs view**:
|
|
331
|
+
- **syntax**: Check LOCAL code BEFORE commit (CLAS, INTF, PROG only)
|
|
332
|
+
- **inspect**: Check ACTIVATED code AFTER pull (all types, runs Code Inspector)
|
|
333
|
+
- **view**: Understand object STRUCTURE (not for debugging errors)
|
|
334
|
+
|
|
335
|
+
### Quick Decision Tree for AI
|
|
336
|
+
|
|
337
|
+
**When user asks to modify/create ABAP code:**
|
|
248
338
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
339
|
+
```
|
|
340
|
+
1. Identify file extension(s) AND dependencies
|
|
341
|
+
├─ .clas.abap or .clas.testclasses.abap → CLAS ✅ syntax supported (if independent)
|
|
342
|
+
├─ .intf.abap → INTF ✅ syntax supported (if independent)
|
|
343
|
+
├─ .prog.abap → PROG ✅ syntax supported
|
|
344
|
+
├─ .ddls.asddls → DDLS ✅ syntax supported (requires proper annotations)
|
|
345
|
+
└─ All other extensions → ❌ syntax not supported
|
|
346
|
+
|
|
347
|
+
2. Check for dependencies:
|
|
348
|
+
├─ Interface + implementing class? → Dependencies exist
|
|
349
|
+
├─ Class A uses class B? → Dependencies exist
|
|
350
|
+
├─ New objects that don't exist in ABAP system? → Check if they depend on each other
|
|
351
|
+
└─ Unrelated bug fixes across files? → No dependencies
|
|
352
|
+
|
|
353
|
+
3. For SUPPORTED types (CLAS/INTF/PROG/DDLS):
|
|
354
|
+
├─ Independent files → Run syntax → Fix errors → Commit → Push → Pull
|
|
355
|
+
└─ Dependent files → Skip syntax → Commit → Push → Pull
|
|
356
|
+
|
|
357
|
+
4. For UNSUPPORTED types (FUGR, TABL, etc.):
|
|
358
|
+
Write code → Skip syntax → Commit → Push → Pull → (if errors: inspect)
|
|
359
|
+
|
|
360
|
+
5. For MIXED types (some supported + some unsupported):
|
|
361
|
+
Write all code → Run syntax on independent supported files ONLY → Commit ALL → Push → Pull ALL
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
**Error indicators after pull:**
|
|
365
|
+
- ❌ **"Error updating where-used list"** → SYNTAX ERROR - run `inspect` for details
|
|
366
|
+
- ❌ **Objects in "Failed Objects Log"** → SYNTAX ERROR - run `inspect`
|
|
367
|
+
- ❌ **Objects NOT appearing at all** → XML metadata issue (check `ref --topic abapgit`)
|
|
368
|
+
- ⚠️ **"Activated with warnings"** → Code Inspector warnings - run `inspect` to see details
|
|
253
369
|
|
|
254
370
|
### Commands
|
|
255
371
|
|
|
256
372
|
```bash
|
|
257
|
-
# 1.
|
|
373
|
+
# 1. Syntax check LOCAL code BEFORE commit (CLAS, INTF, PROG only)
|
|
374
|
+
abapgit-agent syntax --files src/zcl_my_class.clas.abap
|
|
375
|
+
abapgit-agent syntax --files src/zcl_class1.clas.abap,src/zif_intf1.intf.abap
|
|
376
|
+
|
|
377
|
+
# 2. Pull/activate AFTER pushing to git
|
|
258
378
|
abapgit-agent pull --files src/zcl_class1.clas.abap,src/zcl_class2.clas.abap
|
|
259
379
|
|
|
260
|
-
#
|
|
380
|
+
# 3. Inspect AFTER pull (for errors or unsupported types)
|
|
261
381
|
abapgit-agent inspect --files src/zcl_class1.clas.abap
|
|
262
382
|
|
|
263
|
-
# Run unit tests (
|
|
383
|
+
# Run unit tests (after successful pull)
|
|
264
384
|
abapgit-agent unit --files src/zcl_test1.clas.testclasses.abap,src/zcl_test2.clas.testclasses.abap
|
|
265
385
|
|
|
266
386
|
# View object definitions (multiple objects)
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Overview
|
|
4
|
+
nav_order: 1
|
|
5
|
+
parent: ABAP Coding Guidelines
|
|
6
|
+
grand_parent: ABAP Development
|
|
7
|
+
---
|
|
8
|
+
|
|
1
9
|
# ABAP Coding Guidelines Index
|
|
2
10
|
|
|
3
11
|
This folder contains detailed ABAP coding guidelines that can be searched using the `ref` command.
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: SQL Best Practices
|
|
4
|
+
nav_order: 2
|
|
5
|
+
parent: ABAP Coding Guidelines
|
|
6
|
+
grand_parent: ABAP Development
|
|
7
|
+
---
|
|
8
|
+
|
|
1
9
|
# ABAP SQL Best Practices
|
|
2
10
|
|
|
3
11
|
**Searchable keywords**: SELECT, FROM, WHERE, ABAP SQL, Open SQL, host variable, @ prefix, range table, INTO, UP TO, OFFSET, GROUP BY, JOIN
|
|
@@ -82,6 +90,26 @@ SELECT object obj_name FROM tadir ...
|
|
|
82
90
|
|
|
83
91
|
---
|
|
84
92
|
|
|
93
|
+
## 6. Modern ABAP SQL (with FIXPT)
|
|
94
|
+
|
|
95
|
+
When `<FIXPT>X</FIXPT>` is in class XML (default for modern ABAP):
|
|
96
|
+
|
|
97
|
+
```abap
|
|
98
|
+
" ✅ Required syntax
|
|
99
|
+
SELECT carrid, connid, fldate " Commas required
|
|
100
|
+
FROM sflight
|
|
101
|
+
INTO TABLE @lt_result " @ for host variables
|
|
102
|
+
WHERE carrid = @lv_carrier. " @ for parameters
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Common errors**:
|
|
106
|
+
- Missing commas → Add between all SELECT fields
|
|
107
|
+
- Missing @ → Add to all ABAP variables (not DB columns)
|
|
108
|
+
|
|
109
|
+
**Why FIXPT**: Without it, decimals treated as integers in calculations.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
85
113
|
## See Also
|
|
86
114
|
- **Constructor Expressions** (05_classes.md) - for VALUE #(), FILTER, FOR loops
|
|
87
115
|
- **Internal Tables** - for filtering and iteration patterns
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Exception Handling
|
|
4
|
+
nav_order: 3
|
|
5
|
+
parent: ABAP Coding Guidelines
|
|
6
|
+
grand_parent: ABAP Development
|
|
7
|
+
---
|
|
8
|
+
|
|
1
9
|
# Exception Handling - Classical vs Class-Based
|
|
2
10
|
|
|
3
11
|
**Searchable keywords**: exception, RAISING, TRY, CATCH, cx_static_check, cx_dynamic_check, EXCEPTIONS, sy-subrc, class-based exception, classical exception
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Unit Testing
|
|
4
|
+
nav_order: 4
|
|
5
|
+
parent: ABAP Coding Guidelines
|
|
6
|
+
grand_parent: ABAP Development
|
|
7
|
+
---
|
|
8
|
+
|
|
1
9
|
# Unit Testing
|
|
2
10
|
|
|
3
11
|
**Searchable keywords**: unit test, AUnit, test class, cl_abap_unit_assert, FOR TESTING, setup, teardown, RISK LEVEL, DURATION, CDS test double, CL_CDS_TEST_ENVIRONMENT
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: CDS Views
|
|
4
|
+
nav_order: 5
|
|
5
|
+
parent: ABAP Coding Guidelines
|
|
6
|
+
grand_parent: ABAP Development
|
|
7
|
+
---
|
|
8
|
+
|
|
1
9
|
# Creating CDS Views
|
|
2
10
|
|
|
3
11
|
**Searchable keywords**: CDS, DDL, DDLS, CDS view, @AbapCatalog, @AccessControl, association, projection, consumption
|
|
@@ -13,6 +21,77 @@
|
|
|
13
21
|
|
|
14
22
|
CDS views (Data Definition Language Source) require specific file naming and structure for abapGit.
|
|
15
23
|
|
|
24
|
+
### CDS View vs View Entity: When to Use Which
|
|
25
|
+
|
|
26
|
+
**IMPORTANT**: When creating CDS views, use **View Entity** by default unless explicitly requested otherwise.
|
|
27
|
+
|
|
28
|
+
| User Request | Create Type | Why |
|
|
29
|
+
|--------------|-------------|-----|
|
|
30
|
+
| "Create CDS view" | CDS View Entity (modern) | Default for new development |
|
|
31
|
+
| "Create CDS view for..." | CDS View Entity (modern) | Recommended approach |
|
|
32
|
+
| "Create legacy CDS view" | CDS View (legacy) | Only if explicitly requested |
|
|
33
|
+
| "Create CDS view with sqlViewName" | CDS View (legacy) | Explicit legacy request |
|
|
34
|
+
|
|
35
|
+
### Key Differences
|
|
36
|
+
|
|
37
|
+
| Aspect | CDS View (Legacy) | CDS View Entity (Modern) |
|
|
38
|
+
|--------|-------------------|-------------------------|
|
|
39
|
+
| **Syntax** | `define view` | `define view entity` |
|
|
40
|
+
| **@AbapCatalog.sqlViewName** | ✅ Required | ❌ Not allowed (will fail) |
|
|
41
|
+
| **Creates SQL View** | Yes (DDLS + SQL view) | No (DDLS only) |
|
|
42
|
+
| **XML SOURCE_TYPE** | `V` | `W` |
|
|
43
|
+
| **ABAP Version** | 7.40+ | 7.55+ / S/4HANA Cloud |
|
|
44
|
+
| **Parameter Syntax** | `:param` or `$parameters.param` | `$parameters.param` only |
|
|
45
|
+
| **Use For** | Legacy systems, existing code | New development, S/4HANA |
|
|
46
|
+
|
|
47
|
+
### XML Metadata: The Key Difference
|
|
48
|
+
|
|
49
|
+
The XML metadata differs only in the `SOURCE_TYPE` field:
|
|
50
|
+
|
|
51
|
+
**CDS View Entity XML (RECOMMENDED - use by default):**
|
|
52
|
+
```xml
|
|
53
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
54
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_DDLS" serializer_version="v1.0.0">
|
|
55
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
56
|
+
<asx:values>
|
|
57
|
+
<DDLS>
|
|
58
|
+
<DDLNAME>ZC_MY_ENTITY</DDLNAME>
|
|
59
|
+
<DDLANGUAGE>E</DDLANGUAGE>
|
|
60
|
+
<DDTEXT>My CDS View Entity</DDTEXT>
|
|
61
|
+
<SOURCE_TYPE>W</SOURCE_TYPE>
|
|
62
|
+
</DDLS>
|
|
63
|
+
</asx:values>
|
|
64
|
+
</asx:abap>
|
|
65
|
+
</abapGit>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**CDS View XML (Legacy - only if explicitly requested):**
|
|
69
|
+
```xml
|
|
70
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
71
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_DDLS" serializer_version="v1.0.0">
|
|
72
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
73
|
+
<asx:values>
|
|
74
|
+
<DDLS>
|
|
75
|
+
<DDLNAME>ZC_MY_VIEW</DDLNAME>
|
|
76
|
+
<DDLANGUAGE>E</DDLANGUAGE>
|
|
77
|
+
<DDTEXT>My CDS View</DDTEXT>
|
|
78
|
+
<SOURCE_TYPE>V</SOURCE_TYPE>
|
|
79
|
+
</DDLS>
|
|
80
|
+
</asx:values>
|
|
81
|
+
</asx:abap>
|
|
82
|
+
</abapGit>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**SOURCE_TYPE values:**
|
|
86
|
+
- `W` = View Entity (modern, no SQL view created)
|
|
87
|
+
- `V` = View (legacy, creates SQL view)
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Creating CDS Views (DDLS)
|
|
92
|
+
|
|
93
|
+
CDS views (Data Definition Language Source) require specific file naming and structure for abapGit.
|
|
94
|
+
|
|
16
95
|
### File Naming
|
|
17
96
|
|
|
18
97
|
CDS views require **two files**:
|
|
@@ -26,6 +105,20 @@ CDS views require **two files**:
|
|
|
26
105
|
|
|
27
106
|
### DDL Source File (`.ddls.asddls`)
|
|
28
107
|
|
|
108
|
+
**CDS View Entity (RECOMMENDED - use by default):**
|
|
109
|
+
```abap
|
|
110
|
+
@AccessControl.authorizationCheck: #NOT_REQUIRED
|
|
111
|
+
@EndUserText.label: 'My CDS View Entity'
|
|
112
|
+
define view entity ZC_My_Entity as select from tdevc
|
|
113
|
+
{
|
|
114
|
+
key devclass as Devclass,
|
|
115
|
+
parentcl as ParentPackage,
|
|
116
|
+
ctext as Description
|
|
117
|
+
}
|
|
118
|
+
where devclass not like '$%'
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**CDS View (Legacy - only if explicitly requested):**
|
|
29
122
|
```abap
|
|
30
123
|
@AbapCatalog.sqlViewName: 'ZCMYVIEW'
|
|
31
124
|
@AbapCatalog.compiler.compareFilter: true
|
|
@@ -40,55 +133,34 @@ define view ZC_My_View as select from tdevc
|
|
|
40
133
|
where devclass not like '$%'
|
|
41
134
|
```
|
|
42
135
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
47
|
-
<abapGit version="v1.0.0" serializer="LCL_OBJECT_DDLS" serializer_version="v1.0.0">
|
|
48
|
-
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
49
|
-
<asx:values>
|
|
50
|
-
<DDLS>
|
|
51
|
-
<DDLNAME>ZC_MY_VIEW</DDLNAME>
|
|
52
|
-
<DDLANGUAGE>E</DDLANGUAGE>
|
|
53
|
-
<DDTEXT>My CDS View</DDTEXT>
|
|
54
|
-
</DDLS>
|
|
55
|
-
</asx:values>
|
|
56
|
-
</asx:abap>
|
|
57
|
-
</abapGit>
|
|
58
|
-
```
|
|
136
|
+
**Note the key differences:**
|
|
137
|
+
- View Entity: No `@AbapCatalog.sqlViewName`, uses `define view entity`
|
|
138
|
+
- View (legacy): Has `@AbapCatalog.sqlViewName`, uses `define view`
|
|
59
139
|
|
|
60
140
|
### Key Points
|
|
61
141
|
|
|
62
142
|
1. **Avoid reserved words** - Field names like `PACKAGE`, `CLASS`, `INTERFACE` are reserved in CDS. Use alternatives like `PackageName`, `ClassName`.
|
|
63
143
|
|
|
64
|
-
2. **
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
144
|
+
2. **Workflow for creating CDS views** - See `../CLAUDE.md` for complete workflow guidance:
|
|
145
|
+
- Independent CDS views: `syntax → commit → pull --files`
|
|
146
|
+
- Dependent CDS views (with associations to NEW views): Create underlying view first, then dependent view
|
|
147
|
+
- See CLAUDE.md section on "Working with dependent objects"
|
|
68
148
|
|
|
69
149
|
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"
|
|
70
150
|
|
|
71
|
-
###
|
|
151
|
+
### Activating CDS Views
|
|
72
152
|
|
|
73
|
-
|
|
153
|
+
**For standard workflow, see `../CLAUDE.md`**
|
|
74
154
|
|
|
75
|
-
|
|
76
|
-
|
|
155
|
+
**CDS-specific notes:**
|
|
156
|
+
- Single independent DDLS file: `abapgit-agent pull --files src/zc_view.ddls.asddls`
|
|
157
|
+
- CDS views with associations to OTHER NEW views: Create target view first (see `../CLAUDE.md` for workflow)
|
|
77
158
|
|
|
78
|
-
##
|
|
159
|
+
## CDS View Entity Features
|
|
79
160
|
|
|
80
|
-
CDS View Entities
|
|
161
|
+
CDS View Entities are the modern replacement for CDS Views with enhanced features like **associations for OData navigation**.
|
|
81
162
|
|
|
82
|
-
###
|
|
83
|
-
|
|
84
|
-
| Aspect | CDS View | View Entity |
|
|
85
|
-
|--------|----------|-------------|
|
|
86
|
-
| Syntax | `define view` | `define view entity` |
|
|
87
|
-
| Associations | No | Yes (exposed for navigation) |
|
|
88
|
-
| OData/Navigation | Requires separate service | Auto-exposes associations |
|
|
89
|
-
| ABAP Version | 7.40+ | 7.55+ / S/4HANA Cloud |
|
|
90
|
-
|
|
91
|
-
### DDL Source File with Association
|
|
163
|
+
### Associations in View Entities
|
|
92
164
|
|
|
93
165
|
```abap
|
|
94
166
|
@EndUserText.label: 'Package Hierarchy'
|
|
@@ -130,6 +202,49 @@ When working with CDS view syntax (arithmetic, built-in functions, aggregations,
|
|
|
130
202
|
|
|
131
203
|
---
|
|
132
204
|
|
|
205
|
+
## Selecting from CDS Views in Classes
|
|
206
|
+
|
|
207
|
+
### Best Practice: Use CDS View Entity as Type
|
|
208
|
+
|
|
209
|
+
```abap
|
|
210
|
+
" ✅ RECOMMENDED - Use view entity directly
|
|
211
|
+
TYPES ty_results TYPE STANDARD TABLE OF zc_my_view WITH DEFAULT KEY.
|
|
212
|
+
|
|
213
|
+
METHOD get_data.
|
|
214
|
+
SELECT * FROM zc_my_view INTO TABLE @rt_results.
|
|
215
|
+
ENDMETHOD.
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Benefits**: No field mismatches, 33% less code, auto-sync with CDS changes.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
### Alternative: Manual Structure Definition
|
|
223
|
+
|
|
224
|
+
Only when you need to hide/transform fields:
|
|
225
|
+
|
|
226
|
+
```abap
|
|
227
|
+
" Use data elements from underlying tables
|
|
228
|
+
TYPES: BEGIN OF ty_custom,
|
|
229
|
+
carrierid TYPE s_carr_id, " ✅ Data element
|
|
230
|
+
connid TYPE s_conn_id, " ✅ NOT: TYPE c LENGTH 3
|
|
231
|
+
END OF ty_custom.
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
**Find data elements**:
|
|
235
|
+
```bash
|
|
236
|
+
abapgit-agent view --objects SFLIGHT --type TABL
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**Match field names**:
|
|
240
|
+
```bash
|
|
241
|
+
abapgit-agent preview --objects ZC_MY_VIEW --limit 1
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Calculated fields**: Use `TYPE decfloat34` for division/complex math.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
133
248
|
## See Also
|
|
134
249
|
- **Unit Testing** (03_testing.md) - for CDS Test Double Framework
|
|
135
250
|
- **abapGit** (08_abapgit.md) - for CDS XML metadata templates
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Classes & Objects
|
|
4
|
+
nav_order: 6
|
|
5
|
+
parent: ABAP Coding Guidelines
|
|
6
|
+
grand_parent: ABAP Development
|
|
7
|
+
---
|
|
8
|
+
|
|
1
9
|
# ABAP Classes and Objects
|
|
2
10
|
|
|
3
11
|
**Searchable keywords**: CLASS, DEFINITION, PUBLIC, CREATE OBJECT, NEW, METHOD, INTERFACES, inheritance, FINAL, ABSTRACT
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Naming Conventions
|
|
4
|
+
nav_order: 7
|
|
5
|
+
parent: ABAP Coding Guidelines
|
|
6
|
+
grand_parent: ABAP Development
|
|
7
|
+
---
|
|
8
|
+
|
|
1
9
|
# ABAP Object Naming Conventions
|
|
2
10
|
|
|
3
11
|
**Searchable keywords**: naming convention, Z prefix, namespace, object type, CLAS, INTF, PROG, TABL, DDLS
|