In most of my projects, the CMOD enhancement spot for standard BW extractors, include program of FM EXIT_SAPLRSAP_00* had hundreds of lines code dumped in a single include program. It caused confusion and lead to unintentionally modify the wrong block of code sometimes. This would result in additional effort in correcting the code that was modified in wrong place and resulted in re-testing the code again.
The code block would look like below with several lines of code under each WHEN:
Case i_datasource. When <datasource-1>. <Code line-1>. <Code line-2>. : <Code line-n>. When <datasource-2>. <Code line-1>. <Code line-2>. : <Code line-n>. When <datasource-3>. <Code line-1>. <Code line-2>. : <Code line-n>. When <datasource-4>. <Code line-1>. <Code line-2>. : <Code line-n>. End Case.
Disadvantage of this approach are
- Hundreds & in some project thousands of lines of code in single program
- Navigation to a block of code becomes difficult
- Creates confusion during modification of code to developers
- Program gets locked by one developer and others must wait.
- An error in one block of code results in error of whole program especially during transports
- Not easy to read the program code
To overcome these issues, we can modularise the code by separating each DataSource enhancement into individual function modules. The Include program would then contain only few lines of code to call required FM dynamically based on the extractor calling the enhancement.
Different types of enhancement exit and how to create are discussed here.
I am taking the example of exit EXIT_SAPLRSAP_001 for transaction data and corresponding Include program ZXRSAU01.
To implement this in your project:
Step-1: create a new function group
Step-2: Fix a naming format for all enhancement FMs for enhancement.
Eg: ZBW_<DataSource Name>
Step-3: write the fixed lines of code in include program to dynamically call the corresponding enhancement FM.
All the enhancement FM should be named like below examples:
Step-4: Creating function modules for each extractor enhancement
Use corresponding exit FM as template and copy the import, Export, Table, Exception. In this case use FM EXIT_SAPLRSAP_001 as template.
Using this approach, the advantages are:
- The code is limited to few numbers of lines in Include ZXRSAU01.
- Each extractor enhancement is stored in individual FMs.
ZBW_ENHANCE function group
– ZBW_0FI_GL_10 function module
– ZBW_0FI_GL_14 function module
– ZBW_2LIS_02_HDR function module
– ZBW_2LIS_02_ITM function module
- Enhancement code can be maintained in parallel for different extractors at the same time by different developers.
- Any incomplete code can be skipped from transporting to next system by skipping that FM.