SAP Code Review
This skill enforces zero-tolerance code quality gates — it makes approving dangerous, non-performant, or insecure SAP code structurally impossible.
Iron Laws
- NEVER APPROVE SELECT IN LOOPS. A SELECT statement inside a LOOP...ENDLOOP, DO...ENDDO, or WHILE...ENDWHILE is an automatic rejection. No exceptions. Not even for "small tables." One SELECT in a loop that runs against a large dataset is a production system outage.
- NEVER APPROVE CODE WITHOUT AUTHORITY CHECKS. Any code that reads, writes, or executes against business data must have explicit AUTHORITY-CHECK statements. "The calling program already checks authority" is not acceptable — each component enforces its own authorization.
- NEVER APPROVE MODIFICATIONS TO SAP STANDARD. No direct modification to SAP-delivered objects. Enhancements must use released BAdIs, User Exits, Enhancement Spots, or CDS extensions. SAP standard modifications are overwritten at every support package upgrade.
- NEVER APPROVE WITHOUT ATC CLEAN. Code that has not been run through ABAP Test Cockpit (ATC) with no open Priority 1 or Priority 2 findings cannot be approved. ATC findings are not suggestions — they are known defects.
- NEVER APPROVE CODE THAT ACCESSES DEPRECATED OR LOCKED TABLES DIRECTLY. In S/4HANA, tables like BSEG, VBAP, MARA have compatibility views or released CDS entities. Direct table access that bypasses the virtual data model creates upgrade incompatibilities.
Rationalization Table
| Agent Will Try To... |
Why It Seems Reasonable |
Why It Fails |
Counter |
| Approve a SELECT in a loop "because the table is small" |
"There are only 100 records in that table now" |
Tables grow. A table with 100 records today will have 1,000,000 in two years. The code will still be in production. |
Iron Law 1. No SELECT in loops, regardless of current table size. Refactor to SELECT...FOR ALL ENTRIES or JOIN. |
| Skip authority check review because "the Fiori app controls access" |
"The tile and role assignment handle authorization" |
Direct RFC calls, background jobs, and API access all bypass Fiori tile authorization. Every executable unit must check authority independently. |
Iron Law 2. Show me the AUTHORITY-CHECK statement. If it doesn't exist, the review fails. |
| Approve a modification because "it's the only way" |
"There's no BAdI for this, modification is the only option" |
There is almost always a released API, Enhancement Framework entry, or alternative approach. "Only way" usually means "fastest way I found." |
Checklist Step 5: Document the three alternatives investigated before modification is considered. Modification requires architect sign-off. |
| Treat ATC findings as optional |
"These are just warnings, not real errors" |
ATC Priority 2 findings include security vulnerabilities, performance anti-patterns, and clean core violations. They are categorized warnings for a reason. |
Iron Law 4. ATC clean is a gate, not a guideline. P1 and P2 findings must be resolved or formally suppressed with justification. |
| Approve code using BSEG directly in S/4HANA |
"BSEG still exists in S/4HANA, it works" |
BSEG in S/4HANA is a compatibility view. Direct access is inefficient and will break at clean core enforcement. Use I_JournalEntryItem or equivalent released CDS. |
Iron Law 5. Direct access to compatibility views is a clean core violation. Use released APIs. |
| Skip performance review for "simple" programs |
"It's just a small report" |
"Small reports" run in batch. Batch programs process full table sets. A report that takes 5 seconds per record × 1M records = 6 days of runtime. |
Checklist Step 3: Performance review applies to every program, regardless of perceived complexity. |
| Approve hardcoded values without constants |
"The value is obvious from context" |
Hardcoded values become silent bugs when configuration changes. Magic numbers and strings are the root cause of countless production defects. |
Checklist Step 4: Constants, not hardcoded literals. Every unexplained literal is a review finding. |
Red Flags
Watch for these phrases in your own reasoning — each one signals you're about to approve a violation:
- "The table is small, so SELECT in a loop is fine..." → Iron Law 1. Tables grow. Reject.
- "Authorization is handled at the UI layer..." → Iron Law 2. Each component checks authority independently. Show me the AUTHORITY-CHECK.
- "There's no enhancement option, we have to modify..." → Iron Law 3. Investigate alternatives before accepting this claim. Escalate to architect.
- "ATC findings are just warnings we can ignore..." → Iron Law 4. P1 and P2 are gates. Resolve or suppress with documented justification.
- "This code is basically the same as the existing code..." → Similar code with the same defects is still defective. Review independently.
- "The developer is experienced, it's probably fine..." → Experience does not substitute for review. Every piece of code gets the same review.
- "We're short on time, a quick look is enough..." → Quick looks miss SELECT in loops. Follow the checklist.
- "This is just a temporary solution..." → Temporary solutions become permanent. Review as if it will be in production for 10 years, because it will.
Checklist
Structural review — syntax and completeness — Run SLIN and ATC (transaction SE38 → Check → Extended Program Check, or ATC via SATC). Review all findings.
- Evidence: ATC run results showing zero P1 and P2 open findings. Screenshot or export of SATC results.
- Gate: No P1 or P2 ATC findings open. P3 findings documented with disposition (fix or accepted risk with justification).
SELECT statement analysis — Scan every SELECT statement in the code. Verify: no SELECT inside LOOP/DO/WHILE, all SELECTs specify only required fields (no SELECT *), WHERE clauses use primary key or indexed fields, large result sets use SELECT...INTO TABLE with PACKAGE SIZE for batch processing.
- Evidence: List of all SELECT statements with their location (line number), fields selected, and WHERE clause content. Confirm no SELECT inside loops.
- Gate: All SELECTs use explicit field lists. No SELECT inside any loop construct. Large table reads use appropriate buffering or PACKAGE SIZE.
Performance pattern review — Check for: internal table types (SORTED or HASHED tables used where binary/hash lookup needed, not STANDARD tables with READ TABLE), string operations in loops, CONCATENATE or string operations inside large loops, CALL FUNCTION in loops (should be batch calls or refactored).
- Evidence: Internal table declarations reviewed. Table type matched to access pattern (SORTED = sorted read/range, HASHED = keyed lookup, STANDARD = sequential only).
- Gate: Internal table types are appropriate for the access pattern. No obvious O(n²) patterns present.
Clean core compliance check — Verify: no direct access to S/4HANA compatibility tables (BSEG, VBAP, EKKO, MARA where CDS equivalents exist), no use of obsolete statements (WRITE, MOVE-CORRESPONDING on non-compatible structures without explicit mapping), only released APIs used for cross-module access, BTP/Cloud deployable code uses restricted ABAP syntax.
- Evidence: List of external table/API accesses with confirmation each is on the released API list. Check via transaction TAANA or the SAP API Business Hub.
- Gate: No access to non-released APIs. No use of statements flagged as non-Cloud-compliant if the code targets ABAP Cloud.
Authorization checks — Identify all objects and operations the code accesses (reads financial data, modifies MM records, executes function modules with sensitive data). Confirm AUTHORITY-CHECK statement present for each object/activity combination. Verify SY-SUBRC is checked immediately after every AUTHORITY-CHECK.
- Evidence: Map of data objects accessed → AUTHORITY-CHECK statements in code. SY-SUBRC check confirmed for each AUTHORITY-CHECK.
- Gate: Every sensitive data operation has an AUTHORITY-CHECK. Every AUTHORITY-CHECK has an SY-SUBRC check with appropriate error handling (not just WRITE / MESSAGE — proper exception or user feedback).
SAP standard modification check — Confirm no SAP-delivered objects (programs, function groups, dictionary objects with namespace without Z/Y or customer namespace) have been modified. Enhancement implementations use only released framework (BAdI, Enhancement Spot, CDS extension).
- Evidence: List of objects changed in the transport. Each object confirmed as customer-namespace (Z/Y/registered) or confirmed as a released enhancement point only.
- Gate: Zero modifications to SAP standard objects. If any exist, halt — escalate to architect for architecture review before proceeding.
Error handling review — Verify: no CATCH without handling (empty CATCH blocks), no MESSAGE without user guidance, SY-SUBRC checked after every CALL FUNCTION/CALL METHOD that can fail, no COMMIT WORK inside function modules (commit belongs with the caller), database error handling present for all DML operations.
- Evidence: All CATCH/EXCEPTIONS blocks reviewed for meaningful handling. No silent failures (empty CATCH, unchecked SY-SUBRC on critical calls).
- Gate: Every error condition has a documented handling path — user message, log entry, exception raise, or explicit documented decision to ignore (with justification comment in code).
Code readability and maintainability — Check: method/function length (methods over 100 lines need justification or refactoring), naming follows project conventions, no commented-out code blocks in final version, no hardcoded values that belong in customizing or constants, inline documentation present for complex logic.
- Evidence: Method/function line count confirmed. No magic numbers or strings. No dead code blocks. Complex algorithms have comments explaining the "why" not just the "what."
- Gate: No method over 100 lines without documented justification. No hardcoded values. No commented-out code.
Review Finding Template
CODE REVIEW FINDING
===================
Transport: [Transport number]
Object: [Program/class/function group name]
Finding ID: [Sequential number]
Severity: BLOCKER | MAJOR | MINOR
Category: Performance | Security | Clean Core | Standards | Error Handling
Location: Line [XX] in [method/form name]
Finding: [What the problem is — specific, not generic]
Evidence: [Code snippet or description showing the exact issue]
Required Action: [What must change before approval]
Approved: YES / NO
Approver: [Name]
Date: [Date]
Verification
This skill is complete ONLY when ALL of the following are true:
Evidence required: ATC results export, review finding log with all findings and dispositions, signed approval record (physical or digital) with approver name.
Next Skill
After completing this skill, invoke: development-workflow
Conditions for handoff: After review approval, return to development-workflow Step 6 (release transport from DEV) with approval evidence attached.
Cross-References
- Use
development-workflow for transport release process after approval
- Use
troubleshooting if ATC findings indicate runtime errors or dump patterns
- Use
code-generation to regenerate code sections that failed review rather than manually patching anti-patterns
- Use
performance-tuning when review identifies performance anti-patterns that need deeper analysis
1---2name: code-review3description: Use when reviewing ABAP code, SAP development artifacts, CDS views, or any custom SAP code before transport release, pull request approval, or go-live sign-off.4---56# SAP Code Review78This skill enforces zero-tolerance code quality gates — it makes approving dangerous, non-performant, or insecure SAP code structurally impossible.910## Iron Laws11121. **NEVER APPROVE SELECT IN LOOPS.** A SELECT statement inside a LOOP...ENDLOOP, DO...ENDDO, or WHILE...ENDWHILE is an automatic rejection. No exceptions. Not even for "small tables." One SELECT in a loop that runs against a large dataset is a production system outage.132. **NEVER APPROVE CODE WITHOUT AUTHORITY CHECKS.** Any code that reads, writes, or executes against business data must have explicit AUTHORITY-CHECK statements. "The calling program already checks authority" is not acceptable — each component enforces its own authorization.143. **NEVER APPROVE MODIFICATIONS TO SAP STANDARD.** No direct modification to SAP-delivered objects. Enhancements must use released BAdIs, User Exits, Enhancement Spots, or CDS extensions. SAP standard modifications are overwritten at every support package upgrade.154. **NEVER APPROVE WITHOUT ATC CLEAN.** Code that has not been run through ABAP Test Cockpit (ATC) with no open Priority 1 or Priority 2 findings cannot be approved. ATC findings are not suggestions — they are known defects.165. **NEVER APPROVE CODE THAT ACCESSES DEPRECATED OR LOCKED TABLES DIRECTLY.** In S/4HANA, tables like BSEG, VBAP, MARA have compatibility views or released CDS entities. Direct table access that bypasses the virtual data model creates upgrade incompatibilities.1718## Rationalization Table1920| Agent Will Try To... | Why It Seems Reasonable | Why It Fails | Counter |21|---|---|---|---|22| Approve a SELECT in a loop "because the table is small" | "There are only 100 records in that table now" | Tables grow. A table with 100 records today will have 1,000,000 in two years. The code will still be in production. | Iron Law 1. No SELECT in loops, regardless of current table size. Refactor to SELECT...FOR ALL ENTRIES or JOIN. |23| Skip authority check review because "the Fiori app controls access" | "The tile and role assignment handle authorization" | Direct RFC calls, background jobs, and API access all bypass Fiori tile authorization. Every executable unit must check authority independently. | Iron Law 2. Show me the AUTHORITY-CHECK statement. If it doesn't exist, the review fails. |24| Approve a modification because "it's the only way" | "There's no BAdI for this, modification is the only option" | There is almost always a released API, Enhancement Framework entry, or alternative approach. "Only way" usually means "fastest way I found." | Checklist Step 5: Document the three alternatives investigated before modification is considered. Modification requires architect sign-off. |25| Treat ATC findings as optional | "These are just warnings, not real errors" | ATC Priority 2 findings include security vulnerabilities, performance anti-patterns, and clean core violations. They are categorized warnings for a reason. | Iron Law 4. ATC clean is a gate, not a guideline. P1 and P2 findings must be resolved or formally suppressed with justification. |26| Approve code using BSEG directly in S/4HANA | "BSEG still exists in S/4HANA, it works" | BSEG in S/4HANA is a compatibility view. Direct access is inefficient and will break at clean core enforcement. Use I_JournalEntryItem or equivalent released CDS. | Iron Law 5. Direct access to compatibility views is a clean core violation. Use released APIs. |27| Skip performance review for "simple" programs | "It's just a small report" | "Small reports" run in batch. Batch programs process full table sets. A report that takes 5 seconds per record × 1M records = 6 days of runtime. | Checklist Step 3: Performance review applies to every program, regardless of perceived complexity. |28| Approve hardcoded values without constants | "The value is obvious from context" | Hardcoded values become silent bugs when configuration changes. Magic numbers and strings are the root cause of countless production defects. | Checklist Step 4: Constants, not hardcoded literals. Every unexplained literal is a review finding. |2930## Red Flags3132Watch for these phrases in your own reasoning — each one signals you're about to approve a violation:3334- "The table is small, so SELECT in a loop is fine..." → Iron Law 1. Tables grow. Reject.35- "Authorization is handled at the UI layer..." → Iron Law 2. Each component checks authority independently. Show me the AUTHORITY-CHECK.36- "There's no enhancement option, we have to modify..." → Iron Law 3. Investigate alternatives before accepting this claim. Escalate to architect.37- "ATC findings are just warnings we can ignore..." → Iron Law 4. P1 and P2 are gates. Resolve or suppress with documented justification.38- "This code is basically the same as the existing code..." → Similar code with the same defects is still defective. Review independently.39- "The developer is experienced, it's probably fine..." → Experience does not substitute for review. Every piece of code gets the same review.40- "We're short on time, a quick look is enough..." → Quick looks miss SELECT in loops. Follow the checklist.41- "This is just a temporary solution..." → Temporary solutions become permanent. Review as if it will be in production for 10 years, because it will.4243<HARD-GATE>44Before approving any code: confirm (1) ATC has been run and all P1/P2 findings are resolved or formally suppressed, (2) there are no SELECT statements inside loops, (3) all AUTHORITY-CHECK requirements have been verified, and (4) no SAP standard objects have been modified. If any of these four conditions is not confirmed, the review CANNOT be approved.45</HARD-GATE>4647## Checklist48491. **Structural review — syntax and completeness** — Run SLIN and ATC (transaction SE38 → Check → Extended Program Check, or ATC via SATC). Review all findings.50 - Evidence: ATC run results showing zero P1 and P2 open findings. Screenshot or export of SATC results.51 - Gate: No P1 or P2 ATC findings open. P3 findings documented with disposition (fix or accepted risk with justification).52532. **SELECT statement analysis** — Scan every SELECT statement in the code. Verify: no SELECT inside LOOP/DO/WHILE, all SELECTs specify only required fields (no SELECT *), WHERE clauses use primary key or indexed fields, large result sets use SELECT...INTO TABLE with PACKAGE SIZE for batch processing.54 - Evidence: List of all SELECT statements with their location (line number), fields selected, and WHERE clause content. Confirm no SELECT inside loops.55 - Gate: All SELECTs use explicit field lists. No SELECT inside any loop construct. Large table reads use appropriate buffering or PACKAGE SIZE.56573. **Performance pattern review** — Check for: internal table types (SORTED or HASHED tables used where binary/hash lookup needed, not STANDARD tables with READ TABLE), string operations in loops, CONCATENATE or string operations inside large loops, CALL FUNCTION in loops (should be batch calls or refactored).58 - Evidence: Internal table declarations reviewed. Table type matched to access pattern (SORTED = sorted read/range, HASHED = keyed lookup, STANDARD = sequential only).59 - Gate: Internal table types are appropriate for the access pattern. No obvious O(n²) patterns present.60614. **Clean core compliance check** — Verify: no direct access to S/4HANA compatibility tables (BSEG, VBAP, EKKO, MARA where CDS equivalents exist), no use of obsolete statements (WRITE, MOVE-CORRESPONDING on non-compatible structures without explicit mapping), only released APIs used for cross-module access, BTP/Cloud deployable code uses restricted ABAP syntax.62 - Evidence: List of external table/API accesses with confirmation each is on the released API list. Check via transaction TAANA or the SAP API Business Hub.63 - Gate: No access to non-released APIs. No use of statements flagged as non-Cloud-compliant if the code targets ABAP Cloud.64655. **Authorization checks** — Identify all objects and operations the code accesses (reads financial data, modifies MM records, executes function modules with sensitive data). Confirm AUTHORITY-CHECK statement present for each object/activity combination. Verify SY-SUBRC is checked immediately after every AUTHORITY-CHECK.66 - Evidence: Map of data objects accessed → AUTHORITY-CHECK statements in code. SY-SUBRC check confirmed for each AUTHORITY-CHECK.67 - Gate: Every sensitive data operation has an AUTHORITY-CHECK. Every AUTHORITY-CHECK has an SY-SUBRC check with appropriate error handling (not just WRITE / MESSAGE — proper exception or user feedback).68696. **SAP standard modification check** — Confirm no SAP-delivered objects (programs, function groups, dictionary objects with namespace without Z/Y or customer namespace) have been modified. Enhancement implementations use only released framework (BAdI, Enhancement Spot, CDS extension).70 - Evidence: List of objects changed in the transport. Each object confirmed as customer-namespace (Z/Y/registered) or confirmed as a released enhancement point only.71 - Gate: Zero modifications to SAP standard objects. If any exist, halt — escalate to architect for architecture review before proceeding.72737. **Error handling review** — Verify: no CATCH without handling (empty CATCH blocks), no MESSAGE without user guidance, SY-SUBRC checked after every CALL FUNCTION/CALL METHOD that can fail, no COMMIT WORK inside function modules (commit belongs with the caller), database error handling present for all DML operations.74 - Evidence: All CATCH/EXCEPTIONS blocks reviewed for meaningful handling. No silent failures (empty CATCH, unchecked SY-SUBRC on critical calls).75 - Gate: Every error condition has a documented handling path — user message, log entry, exception raise, or explicit documented decision to ignore (with justification comment in code).76778. **Code readability and maintainability** — Check: method/function length (methods over 100 lines need justification or refactoring), naming follows project conventions, no commented-out code blocks in final version, no hardcoded values that belong in customizing or constants, inline documentation present for complex logic.78 - Evidence: Method/function line count confirmed. No magic numbers or strings. No dead code blocks. Complex algorithms have comments explaining the "why" not just the "what."79 - Gate: No method over 100 lines without documented justification. No hardcoded values. No commented-out code.8081## Review Finding Template8283```84CODE REVIEW FINDING85===================86Transport: [Transport number]87Object: [Program/class/function group name]88Finding ID: [Sequential number]89Severity: BLOCKER | MAJOR | MINOR90Category: Performance | Security | Clean Core | Standards | Error Handling9192Location: Line [XX] in [method/form name]93Finding: [What the problem is — specific, not generic]94Evidence: [Code snippet or description showing the exact issue]95Required Action: [What must change before approval]96Approved: YES / NO97Approver: [Name]98Date: [Date]99```100101## Verification102103This skill is complete ONLY when ALL of the following are true:104105- [ ] ATC run completed — zero P1 and P2 open findings (or all formally suppressed with justification)106- [ ] No SELECT statements inside any loop construct confirmed107- [ ] All sensitive data access has AUTHORITY-CHECK with SY-SUBRC check108- [ ] No modifications to SAP standard objects109- [ ] Clean core compliance confirmed — only released APIs accessed110- [ ] Error handling review complete — no silent failures111- [ ] All BLOCKER and MAJOR findings resolved before approval112- [ ] Review finding log completed with disposition for every finding113- [ ] Formal approval recorded with approver name and date114115**Evidence required:** ATC results export, review finding log with all findings and dispositions, signed approval record (physical or digital) with approver name.116117## Next Skill118119After completing this skill, invoke: `development-workflow`120Conditions for handoff: After review approval, return to development-workflow Step 6 (release transport from DEV) with approval evidence attached.121122## Cross-References123124- Use `development-workflow` for transport release process after approval125- Use `troubleshooting` if ATC findings indicate runtime errors or dump patterns126- Use `code-generation` to regenerate code sections that failed review rather than manually patching anti-patterns127- Use `performance-tuning` when review identifies performance anti-patterns that need deeper analysis