This file tracks architectural changes, modernizations, and optimizations made to the DynAbap repository during our pair-programming sessions.
Project Objective: We are extending an existing customer-specific printing program with a highly flexible, dynamic printing system tailored for repairs.
The foundational requirements for this dynamic framework were derived from Reparaturbericht - Definitionen.pdf, which mandated the deprecation of hardcoded logic in the legacy /CELLAG/ALCAREP02 program in favor of a table-driven architecture.
Key implementations bridging these requirements include:
/CTDI/REP_FORMS: Realizes the proposedZCTDI_REP_FORMlogic to dynamically map Forms and Classes based on access sequences (Contract -> SKZ -> AKZ)./CTDI/REP_RESULT: Realizes the proposedZCTDI_REP_RESULTto map repair outcome texts dynamically, integrating the Tauschfall (exchange flag) logic./CTDI/REP_PROJEC: Realizes the proposedZCTDI_REP_PROJECTto store sub-project mapping data.
FORM print_new: Serves as the crucial bridge and entry point between the legacy program and the new object-oriented framework.- Migration Shift: Historically used as a fallback mechanism; with the full migration to the new architecture,
/ctdi/cx_no_config_foundhas been promoted to a first-class missing configuration error raised byget_config_from_dbwhen no configuration is resolved, causing execution to terminate and report the missing setup. - New Logic Takeover: When a new form and class are successfully resolved, the new framework takes full control of data retrieval and form rendering, completely bypassing the legacy subroutines.
- Migration Shift: Historically used as a fallback mechanism; with the full migration to the new architecture,
- Base Class Inheritance Pattern: Shifted the print framework architecture to an inheritance model extending
/CTDI/CL_PRINT_DRIVER_BASErather than a flat interface model. - Global Constants: Replaced hardcoded class name strings with a centralized
gc_base_classconstant in the Customizing Engine class to improve maintainability. - Custom Parameter Registration:
- Overhauled how custom form data is passed to dynamic Smart Forms and Adobe Forms.
- Added an explicit
iv_kindparameter (abap_func_exporting,abap_func_tables, etc.) to theregister_custom_parametermethod. This offloads the responsibility of defining the parameter type to the subclass, completely removing the need for slow, dynamicFUPARAREFdatabase lookups at runtime.
- Device Type Fallback: Updated the
SSF_GET_DEVICE_TYPEfallback logic to default to the system standard PDF deviceYPDFinstead of the non-existentSAPDEFAULTif resolution fails. - Template Method and Decoupled Action Hooks (2026-06-18):
- Extracted duplicated business logic, error handling, and logging boilerplate from the subclass
read_datamethods into a centralized template method in the base class/CTDI/CL_PRINT_DRIVER_BASE. - Introduced three protected, parameter-less action hooks (
unpack_io_data,fetch_data_from_db, andmap_and_register_data) to decouple subclass-specific state/provider instantiation from the base class execution flow. - Refactored
/CTDI/CL_PRINT_DRIVER_CTDI,/CTDI/CL_PRINT_DRIVER_LEGACY, and/CTDI/CL_PRINT_DRIVER_TEMPLATEto redefine and implement the new action hooks.
- Extracted duplicated business logic, error handling, and logging boilerplate from the subclass
- Unified Logger Migration (2026-06-18):
- Migrated
/ctdi/cl_print_driver_logto internally wrap the system standard/HPC/CL_UAPPL_LOGclass. - Deleted the redundant copy class
/CTDI/APP_LOGto keep the codebase dry and clean. - Kept all static APIs (
log_info,log_error, etc.) intact to avoid changing any calling code in the print drivers. - Replaced text-only exception logging with proper object/stack trace logging using standard
BAL_LOG_EXC_ADDunder the hood.
- Migrated
- Robust Exception Handling & Clean Code (2026-07-11):
- get_text Redefinition: Redefined the standard
get_text( )method in/ctdi/cx_print_error,/ctdi/cx_print_driver_error, and/ctdi/cx_no_config_foundto dynamically return the custommessageattribute if populated. This bridges custom error messages with standard SAP application log displays (BAL_LOG_EXC_ADD). - Exception Hierarchy Optimization: Set
/ctdi/cx_print_driver_errorto inherit directly from/ctdi/cx_print_error(instead ofcx_static_check). This eliminates duplicate attribute declarations andget_textimplementations through inheritance. - Defensive Guards: Added input validations for
iv_repair_idat the beginning offactoryandget_config_from_dbto raise exceptions immediately on empty parameters. - Spooler Safety: Added a catch-all call to
FP_JOB_CLOSEinsideexecute_adobeform's dynamic call catch block to guarantee Adobe Form spooler session closure and prevent subsequent locks. - Fast-Failure in Development: Replaced generic
CATCH cx_rootinread_datawith checked exception filtersCATCH cx_static_check cx_dynamic_check. This lets programming/runtime bugs (cx_no_check) fail loud as dumps in dev/QA while production maintains its boundary safety nets.
- get_text Redefinition: Redefined the standard
- In-Memory Configuration Resolution: Refactored
get_config_from_dbto select all potential/ctdi/rep_formsfallback hierarchies into an internal table at once. It now resolves the correct hierarchy (Contract -> SKZ -> AKZ) via in-memoryREAD TABLElookups instead of executing multipleSELECTqueries. - SD/QM Selects Consolidation (2026-07-11):
- In
get_kddata(/ctdi/cl_print_data_legacy), combined the three separate SD sequential queries (VBKD,VBAK,VBAP) and the notification query (QMEL) into a singleLEFT OUTER JOINonVBAK,VBAP,VBKD, andQMEL. Unused fields were pruned.
- In
- VBAK Self-Join & AFRU Filtering (2026-07-11):
- In
resolve_contract(/ctdi/cl_print_driver_base), replaced two sequential SD database calls with a single self-join onVBAKto resolve contract IDs. Combined this with database-level push-down filtering for confirmations onAFRU(stokz = @spaceandstzhl = '00000000') to save database roundtrips and avoid internal table loops in memory.
- In
- Unwrapping Legacy Breaks (2026-07-11):
- Replaced the direct, uncatchable
MESSAGE e...statements insideget_astatus_datawith proper/ctdi/cx_print_driver_errorraises usingMESSAGE ... INTO DATA(...)to capture legacy message class descriptions. This avoids abrupt transaction terminations/spool failures and wraps them in clean catching flows.
- Replaced the direct, uncatchable
- Strict SQL OpenSQL: Modernized all OpenSQL queries across
/CTDI/CL_PRINT_DRIVER_BASEand/CTDI/CL_PRINT_CUST_ENGINE. Moved allINTOandINTO TABLEclauses to the absolute end of theSELECTstatements, guaranteeing forward compatibility with strict-SQL ABAP environments while maintaining 100% data integrity. - ABAPLint Configuration: Generated a robust
abaplint.jsonpipeline configuration natively targeted for ABAP 7.50. Successfully suppressed non-standard, subjective formatting rules (like penalizing Hungarian notationlv_,ls_,lt_) and eliminated false-positive warnings dictating 7.52+ specific syntaxes (such asRAISE EXCEPTION NEW). The codebase now passes checks with zero major issues.
- SAP System: Local containerized SAP A4H instance (
ghcr.io/marianfoo/arc-1:latest). - Connection Details:
- URL:
http://localhost:50000 - Client:
001 - User:
DEVELOPER - Password:
ABAPtr2023#00
- URL:
- Docker Integration: Managed via
docker-compose.yamlexposing necessary ports. - CLI Tooling:
vsp.exeis configured via the.envfile (Tool Mode:hyperfocused, Transports Enabled) to interact with the local ABAP environment.
- Function Module Signatures: Always check the MCP server (e.g., using
abap-mcp-servertools likesap_get_object_detailsorsap_search_objects) to verify the exact signatures, definitions, and types of standard SAP Function Modules before assuming them. This prevents type mismatch errors and ensures robust integrations.