SAP BLOG Modularising BW Extractor Enhancement in to Function Module

SAP Blog

Kayıtlı Üye
Katılım
22 Ara 2017
Mesajlar
1,368
Tepki puanı
7
Puanları
6
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:

Kod:
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

  1. Hundreds & in some project thousands of lines of code in single program
  2. Navigation to a block of code becomes difficult
  3. Creates confusion during modification of code to developers
  4. Program gets locked by one developer and others must wait.
  5. An error in one block of code results in error of whole program especially during transports
  6. 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

Eg: ZBW_ENHANCE



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.

blog_image-1.jpg


Include ZXRSAU01​



All the enhancement FM should be named like below examples:

  • ZBW_0FI_GL_10
  • ZBW_0FI_GL_14
  • ZBW_2LIS_02_HDR
  • ZBW_2LIS_02_ITM



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:

  1. The code is limited to few numbers of lines in Include ZXRSAU01.
  2. 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
  3. Enhancement code can be maintained in parallel for different extractors at the same time by different developers.
  4. Any incomplete code can be transported to next system by just skipping that FM.

Okumaya devam et...
 
Üst