AI-powered SAP ABAP codebase analysis with automated visual documentation
An AST extraction engine that parses SAP ABAP codebases (tested on 12,000+ line production code), extracts methods, business rules, dependencies, and data flows, then feeds structured context to AI for automated Mermaid diagram generation.

The Challenge
Enterprises running SAP systems often have decades of accumulated ABAP code — custom reports, enhancements, interfaces, and workflows built by developers who have long since moved on. A single SAP implementation can contain millions of lines of custom code, much of it undocumented or documented in outdated specifications.
When organizations need to modernize, migrate to S/4HANA, or simply understand what their systems actually do, they face a knowledge gap. The original developers aren't available. The documentation, if it exists, doesn't match the current code. Manual code review by consultants takes months and costs hundreds of thousands of dollars — and still might miss critical business logic buried in nested subroutines.
We saw an opportunity to apply modern AI to this problem. If we could parse legacy code into a structured format and feed that structure to a language model with appropriate domain context, we could automate the generation of visual documentation that would take humans weeks to produce.
Our Approach
We built Decode as an AST (Abstract Syntax Tree) extraction engine specifically for SAP ABAP. Unlike general-purpose code parsers, our engine understands ABAP-specific constructs: function modules, class methods, SELECT statements, internal tables, BAPI calls, and the unique control flow patterns of ABAP programs.
The key insight was that raw code isn't useful input for AI — it's too verbose and lacks semantic structure. By extracting the AST first, we create a compressed, structured representation that captures what the code does without the syntactic noise. This structured context is far more effective for AI diagram generation.
We also built domain-specific context injection. An ABAP program in a retail environment (handling pricing, inventory, orders) needs different explanatory context than one in manufacturing (BOMs, production orders, quality). By injecting domain knowledge, the AI generates more accurate and useful documentation.
What We Built
ABAP Parser
Production-grade parser for SAP ABAP source code. Extracts program structure, method signatures, data definitions, and control flow. Handles real-world code complexity including includes, macros, and dynamic calls.
Business Rule Extraction
Identifies business logic within code — pricing calculations, validation rules, workflow conditions. Separates business rules from technical plumbing. Creates a semantic layer above the raw code.
Dependency Mapping
Traces data flows and call hierarchies across multiple programs. Identifies which tables are read and written. Maps interfaces to external systems. Reveals the hidden connections in legacy codebases.
AI Diagram Generation
Feeds structured AST context to AI models for automated Mermaid diagram generation. Produces sequence diagrams, flowcharts, and architecture diagrams. Outputs are editable and version-controllable.
Domain Context Injection
Pre-built context modules for retail, manufacturing, logistics, and finance domains. Helps the AI understand what SAP transaction codes, tables, and BAPIs mean in business terms.
The Outcome
Decode has been tested on production ABAP codebases including a 12,736-line retail system (5 files) from a major fashion retailer. The system successfully extracted program structure and generated accurate visual documentation in minutes rather than weeks. We're seeking enterprise pilots for further validation.