|
@@ -0,0 +1,290 @@
|
|
|
|
|
+---
|
|
|
|
|
+name: abap
|
|
|
|
|
+description: ABAP development guidance. Use when creating, modifying, checking, or activating ABAP objects, writing ABAP code, RAP development, CDS views, function modules, classes, or any SAP ABAP coding task.
|
|
|
|
|
+---
|
|
|
|
|
+
|
|
|
|
|
+# ABAP Development Skill
|
|
|
|
|
+
|
|
|
|
|
+This skill provides guidance for working with ABAP code in SAP systems via the `mcp-abap-adt` MCP server.
|
|
|
|
|
+
|
|
|
|
|
+## When to Use
|
|
|
|
|
+
|
|
|
|
|
+- Creating new ABAP objects (classes, tables, CDS views, function modules, etc.)
|
|
|
|
|
+- Modifying existing ABAP code
|
|
|
|
|
+- Checking object syntax for errors
|
|
|
|
|
+- Activating ABAP objects
|
|
|
|
|
+- Debugging ABAP compilation errors
|
|
|
|
|
+- RAP (RESTful ABAP Programming Model) development
|
|
|
|
|
+- CDS view development
|
|
|
|
|
+- ABAP unit testing
|
|
|
|
|
+
|
|
|
|
|
+## Core Principle
|
|
|
|
|
+
|
|
|
|
|
+**ALL ABAP operations go through `mcp-abap-adt` tools. NEVER write ABAP code to local files.**
|
|
|
|
|
+
|
|
|
|
|
+## Object Naming Conventions
|
|
|
|
|
+
|
|
|
|
|
+| Object Type | Format | Example |
|
|
|
|
|
+|------------|--------|---------|
|
|
|
|
|
+| Classes | `ZCL_<prefix>_<desc>` | `ZCL_MY_CLASS` |
|
|
|
|
|
+| Interfaces | `ZIF_<prefix>_<desc>` | `ZIF_MY_INTERFACE` |
|
|
|
|
|
+| Tables | `ZTB_<prefix>_<desc>` | `ZTB_MY_TABLE` |
|
|
|
|
|
+| Structures | `ZST_<prefix>_<desc>` | `ZST_MY_STRUCTURE` |
|
|
|
|
|
+| Data Elements | `ZDE_<prefix>_<desc>` | `ZDE_MY_DATA` |
|
|
|
|
|
+| Domains | `ZDM_<prefix>_<desc>` | `ZDM_MY_DOMAIN` |
|
|
|
|
|
+| CDS Views | `Z<V><underscore>_<desc>` | `ZVW_MY_VIEW` (V4) / `ZRI_MY_VIEW` (V2) |
|
|
|
|
|
+| Behavior Def | Root entity name | `ZI_MY_ENTITY` |
|
|
|
|
|
+| Behavior Impl | `ZBP_<entity>` | `ZBP_MY_ENTITY` |
|
|
|
|
|
+| Function Group | `Z<FG>_<desc>` | `ZFG_TEST` |
|
|
|
|
|
+| Function Module | `Z<FM>_<desc>` | `ZFM_TEST` |
|
|
|
|
|
+| Programs | `Z<desc>` | `ZMY_REPORT` |
|
|
|
|
|
+| Message Class | `Z_MSG_<desc>` | `Z_MSG_ERRORS` |
|
|
|
|
|
+
|
|
|
|
|
+All custom objects must start with `Z` or `Y`.
|
|
|
|
|
+
|
|
|
|
|
+## Standard Workflow Pattern
|
|
|
|
|
+
|
|
|
|
|
+### 1. Plan & Discover
|
|
|
|
|
+- Use `GetPackage` to verify package exists
|
|
|
|
|
+- Use `SearchObject` to check if object already exists
|
|
|
|
|
+- Use `GetWhereUsed` to check dependencies
|
|
|
|
|
+
|
|
|
|
|
+### 2. Create (with `activate: false`)
|
|
|
|
|
+- Create object using `Create*` tool
|
|
|
|
|
+- Include all parameters/fields at creation time when possible
|
|
|
|
|
+- Set `activate: false` unless you're done
|
|
|
|
|
+
|
|
|
|
|
+### 3. Update Source/Code
|
|
|
|
|
+- Use `Update*` or `Update*` with source code
|
|
|
|
|
+- For classes: `UpdateClass` with complete source
|
|
|
|
|
+- For CDS: `UpdateDdl` with DDL source
|
|
|
|
|
+- For behavior: `UpdateBehaviorDefinition` + `UpdateBehaviorImplementation`
|
|
|
|
|
+
|
|
|
|
|
+### 4. Check Syntax
|
|
|
|
|
+- Use `Check*` tool for the object type
|
|
|
|
|
+- Review all errors/warnings
|
|
|
|
|
+- If errors exist: fix source and re-check
|
|
|
|
|
+- If clean: proceed to activation
|
|
|
|
|
+
|
|
|
|
|
+### 5. Activate
|
|
|
|
|
+- Use `Activate*` or `ActivateObjects` (batch)
|
|
|
|
|
+- For dependencies: activate in order (Domain → Data Element → Structure → Table → View → Behavior → Service)
|
|
|
|
|
+
|
|
|
|
|
+### 6. Verify
|
|
|
|
|
+- Use `Get*` to confirm activation
|
|
|
|
|
+- Check `GetInactiveObjects` if needed
|
|
|
|
|
+
|
|
|
|
|
+## RAP Development
|
|
|
|
|
+
|
|
|
|
|
+### Architecture Layers
|
|
|
|
|
+1. **CDS View** (`DDLS`) - Data model with annotations
|
|
|
|
|
+2. **Behavior Definition** (`BDEF`) - Business logic definition
|
|
|
|
|
+3. **Behavior Implementation** (`CLAS` - `ZBP_*`) - ABAP code for behavior
|
|
|
|
|
+4. **Service Definition** (`SRVD`) - Expose the service
|
|
|
|
|
+5. **Service Binding** (`SRVB`) - Define OData/UI binding
|
|
|
|
|
+
|
|
|
|
|
+### Creation Order
|
|
|
|
|
+```
|
|
|
|
|
+CreateDdl → UpdateDdl (DDL source) → CheckDdl → ActivateDdl
|
|
|
|
|
+CreateBehaviorDefinition → CheckBehaviorDefinition → ActivateBehaviorDefinition
|
|
|
|
|
+CreateBehaviorImplementation (ZBP_*) → UpdateBehaviorImplementation → ActivateClass (for ZBP_*)
|
|
|
|
|
+CreateServiceDefinition → CheckServiceDefinition → ActivateServiceDefinition
|
|
|
|
|
+CreateServiceBinding → CheckServiceBinding → ActivateServiceBinding
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+### Key CDS Annotations
|
|
|
|
|
+- `@AbapCatalog.sqlViewName`: SQL view name
|
|
|
|
|
+- `@AccessControl.authorizationCheck`: Authorization check mode
|
|
|
|
|
+- `@EndUserText.label`: Description
|
|
|
|
|
+- `@OData.publish`: Mark for OData exposure
|
|
|
|
|
+- Standard CDS entities: `_comment`, `_association`, `_parameter`
|
|
|
|
|
+
|
|
|
|
|
+### Behavior Definition Patterns
|
|
|
|
|
+- **Managed**: Framework handles CRUD automatically
|
|
|
|
|
+- **Unmanaged**: Full control, write all handlers
|
|
|
|
|
+- **Abstract**: For inheritance scenarios
|
|
|
|
|
+- Include `read`, `create`, `update`, `delete`, `action` definitions as needed
|
|
|
|
|
+
|
|
|
|
|
+## CDS View Development
|
|
|
|
|
+
|
|
|
|
|
+### Structure
|
|
|
|
|
+```
|
|
|
|
|
+@AbapCatalog.sqlViewName: 'ZMYVIEW'
|
|
|
|
|
+@AccessControl.authorizationCheck: #NOT_REQUIRED
|
|
|
|
|
+@EndUserText.label: 'My CDS View'
|
|
|
|
|
+define view Zmy_view as select from my_table {
|
|
|
|
|
+ key client,
|
|
|
|
|
+ key id,
|
|
|
|
|
+ field_name,
|
|
|
|
|
+ status
|
|
|
|
|
+}
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+### Common Patterns
|
|
|
|
|
+- Use `select from` for standard CDS
|
|
|
|
|
+- Use `_as select` for projections
|
|
|
|
|
+- Define associations with `association [0..1|0..*]`
|
|
|
|
|
+- Use `as _association` for navigation properties
|
|
|
|
|
+- Expose parameters with `_parameter` annotation
|
|
|
|
|
+
|
|
|
|
|
+## Class Development
|
|
|
|
|
+
|
|
|
|
|
+### Structure
|
|
|
|
|
+```abap
|
|
|
|
|
+CLASS zcl_my_class DEFINITION
|
|
|
|
|
+ PUBLIC
|
|
|
|
|
+ FINAL
|
|
|
|
|
+ CREATE PUBLIC.
|
|
|
|
|
+
|
|
|
|
|
+ PUBLIC SECTION.
|
|
|
|
|
+ METHODS get_data RETURNING VALUE(rv_result) TYPE string.
|
|
|
|
|
+ METHODS set_data IMPORTING iv_value TYPE string.
|
|
|
|
|
+
|
|
|
|
|
+ PROTECTED SECTION.
|
|
|
|
|
+ PRIVATE SECTION.
|
|
|
|
|
+ DATA my_attr TYPE string.
|
|
|
|
|
+ENDCLASS.
|
|
|
|
|
+
|
|
|
|
|
+CLASS zcl_my_class IMPLEMENTATION.
|
|
|
|
|
+ METHOD get_data.
|
|
|
|
|
+ rv_result = me->my_attr.
|
|
|
|
|
+ ENDMETHOD.
|
|
|
|
|
+ENDCLASS.
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+### Local Types/Definitions
|
|
|
|
|
+- Add types to implementations include via `UpdateLocalTypes`
|
|
|
|
|
+- Add definitions to definitions include via `UpdateLocalDefinitions`
|
|
|
|
|
+- Include methods to main class source via `UpdateClass`
|
|
|
|
|
+
|
|
|
|
|
+## Function Module Development
|
|
|
|
|
+
|
|
|
|
|
+### Structure
|
|
|
|
|
+```abap
|
|
|
|
|
+FUNCTION z_fm_test.
|
|
|
|
|
+*"Local Interface:
|
|
|
|
|
+*" IMPORTING
|
|
|
|
|
+*" VALUE(IV_INPUT) TYPE STRING OPTIONAL
|
|
|
|
|
+*" EXPORTING
|
|
|
|
|
+*" VALUE(EV_OUTPUT) TYPE STRING
|
|
|
|
|
+*" EXCEPTIONS
|
|
|
|
|
+*" ERROR_OCCURRED
|
|
|
|
|
+*"
|
|
|
|
|
+*" ev_output = iv_input.
|
|
|
|
|
+*"
|
|
|
|
|
+* IF ev_output IS INITIAL.
|
|
|
|
|
+*" RAISE error_occurred.
|
|
|
|
|
+*" ENDIF.
|
|
|
|
|
+ENDFUNCTION.
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+### Key Points
|
|
|
|
|
+- Function modules live in function groups
|
|
|
|
|
+- Use `CreateFunctionInclude` + `UpdateFunctionInclude` for include code
|
|
|
|
|
+- Or use `UpdateFunctionModule` which sets complete source
|
|
|
|
|
+- Check using `CheckFunctionModule` which requires function group name
|
|
|
|
|
+
|
|
|
|
|
+## ABAP Message Classes
|
|
|
|
|
+
|
|
|
|
|
+### Creating Messages
|
|
|
|
|
+1. `CreateMessageClass` with class name
|
|
|
|
|
+2. `CreateMessageClassMessage` for each message (number + text)
|
|
|
|
|
+3. Messages use placeholders `&1`, `&2`, `&3`, `&4` for dynamic content
|
|
|
|
|
+
|
|
|
|
|
+### Message Format
|
|
|
|
|
+```
|
|
|
|
|
+CreateMessageClassMessage with:
|
|
|
|
|
+message_class_name = "Z_MSG_ERRORS"
|
|
|
|
|
+msgno = "001"
|
|
|
|
|
+msgtext = "Error: Invalid value for field &1 (&2)"
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+## Common Pitfalls
|
|
|
|
|
+
|
|
|
|
|
+### Naming
|
|
|
|
|
+- Object names are case-insensitive in ABAP but uppercase in ADT tools
|
|
|
|
|
+- Always use uppercase in tool parameters
|
|
|
|
|
+- Custom objects MUST start with `Z` or `Y`
|
|
|
|
|
+
|
|
|
|
|
+### Activation Chain
|
|
|
|
|
+- Domains must be activated before data elements that use them
|
|
|
|
|
+- Data elements before structures that use them
|
|
|
|
|
+- Structures before tables that use them
|
|
|
|
|
+- Behavior Definition before Behavior Implementation
|
|
|
|
|
+- CDS View before Service Definition references it
|
|
|
|
|
+
|
|
|
|
|
+### Transport Handling
|
|
|
|
|
+- `$TMP` = local, no transport request needed
|
|
|
|
|
+- Customer packages need valid `transport_request` number
|
|
|
|
|
+- Create with `CreateTransport` if none exists
|
|
|
|
|
+
|
|
|
|
|
+### Syntax Errors
|
|
|
|
|
+- `Check*` ALWAYS run before `Activate*`
|
|
|
|
|
+- Read error messages carefully - they indicate line numbers and nature
|
|
|
|
|
+- Some errors are fatal, others are warnings
|
|
|
|
|
+- Fix the root cause, not just the symptom
|
|
|
|
|
+- Re-check after fixes
|
|
|
|
|
+
|
|
|
|
|
+### DDL Source Code
|
|
|
|
|
+- For `UpdateDdl`/`UpdateTable`/`UpdateStructure`: provide COMPLETE DDL source
|
|
|
|
|
+- Include all annotations
|
|
|
|
|
+- Use `Get*` (active version) as reference if updating existing object
|
|
|
|
|
+
|
|
|
|
|
+## Batch Operations
|
|
|
|
|
+
|
|
|
|
|
+### Multiple Object Activation
|
|
|
|
|
+When creating many related objects:
|
|
|
|
|
+```
|
|
|
|
|
+1. Create all objects with activate: false
|
|
|
|
|
+2. Update all source code
|
|
|
|
|
+3. Check all objects (Check*)
|
|
|
|
|
+4. Fix any errors (Update*)
|
|
|
|
|
+5. Activate in dependency order using ActivateObjects batch
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+### Object Discovery
|
|
|
|
|
+- `GetPackageTree(parent_name, include_descriptions: true)` - visual tree
|
|
|
|
|
+- `GetPackageContents(package_name, include_subpackages: true)` - recursive flat list
|
|
|
|
|
+- `SearchObject(object_name: "Z*")` - wildcard search across repository
|
|
|
|
|
+- `GetObjectStructure(objecttype: "CLAS/OC", objectname: "ZCL_X")` - object tree for specific object
|
|
|
|
|
+
|
|
|
|
|
+### Version Diff
|
|
|
|
|
+- Use `Get*Versions` to list versions
|
|
|
|
|
+- Use `GetObjectVersionDiff(content_uri_from, content_uri_to)` to compare
|
|
|
|
|
+- Use `Get*VersionSource` to fetch specific version
|
|
|
|
|
+
|
|
|
|
|
+## Performance Tips
|
|
|
|
|
+
|
|
|
|
|
+1. **Batch activation**: Use `ActivateObjects` with multiple objects to save API calls
|
|
|
|
|
+2. **Lazy checking**: Check multiple objects before batch activation
|
|
|
|
|
+3. **Create with parameters**: Set all fields at creation time
|
|
|
|
|
+4. **Source reuse**: Copy existing object source, then modify only what's needed
|
|
|
|
|
+5. **Error accumulation**: Fix all syntax errors before activating anything
|
|
|
|
|
+
|
|
|
|
|
+## Testing
|
|
|
|
|
+
|
|
|
|
|
+### ABAP Unit Tests
|
|
|
|
|
+- Create test class with `CreateClass` + `CreateClassVersion` (final keyword: `TEST_DOUBLE` for doubles)
|
|
|
|
|
+- Create local test class with `UpdateLocalTestClass`
|
|
|
|
|
+- Run with `RunUnitTest` or `CreateUnitTest`
|
|
|
|
|
+- Check results with `GetUnitTestStatus` and `GetUnitTestResult`
|
|
|
|
|
+
|
|
|
|
|
+### CDS Unit Tests
|
|
|
|
|
+- Create with `CreateCdsUnitTest` for CDS view validation
|
|
|
|
|
+- Provides test doubles for dependencies
|
|
|
|
|
+- Run with CDS-specific tooling
|
|
|
|
|
+
|
|
|
|
|
+## Migration & Transport
|
|
|
|
|
+- Use `CreateTransport` to create transport requests
|
|
|
|
|
+- Add objects to transport during creation/modification
|
|
|
|
|
+- Check transport status with `GetTransport`
|
|
|
|
|
+- Use `ListTransports` to find open transport requests
|
|
|
|
|
+
|
|
|
|
|
+## ADT Low-Level Operations
|
|
|
|
|
+
|
|
|
|
|
+For advanced scenarios:
|
|
|
|
|
+- `GetNodeStructureLow`: Navigate object tree with session management
|
|
|
|
|
+- `GetAdtTypes`: Validate object type codes
|
|
|
|
|
+- `RuntimeAnalyzeProfilerTrace`: Profiling & performance analysis
|
|
|
|
|
+- `SqlQuery`: Execute direct SQL queries
|
|
|
|
|
+- `GetTableContents`: Data preview for database tables
|