Monday, April 2, 2012

Enhancements to Standard DataSources- 1

Enhancement to Std Data Source ( Non Logistics ) 

In every project there will be always requirement to enhance the Standard Data sources to meet the customer reporting requirement as Standard Data Sources will not have required objects. But the enhancement to these Data Source the procedure is not same for all. While for LO Extractors the procedure is little bit different compare to Master Data and other non LO Cockpit Extractors like Finance or Master Data sources.
In this example we will go through the steps for Non LO extractors. For this let us take Vendor Payments (0FI_AP_4) which falls under Financial Accounting  
The requirement is to enhance the Data Source to get info about USNAM, REF1_HD from table BKPF.

Here is the Step by Step approach.
Source System ECC .
1.    Get the structure name of the Data source associated with. The structure name is DTFIAP_3.
     You can get this from Transaction Code RSA6.
2.    Add the objects to this structure by creating/modifying the structure DTFIAP_3.This can be achieved by ABAP Dictionary .T Code is SE11. Activate the append structure.
 
 


3.    Now we need to GENERATE  the Data Source by going to Post Process of Data Sources (RSA6). While doing this we need to un check the box for UNHIDE otherwise these will not be visible in BI.
 
4.    Now we need to write code to populate these new objects as they are not part of Standard Extraction Program . This can be achieved with the help of USER EXIT program  ZXRSAU01 which is part of Customer Enhancement Project.  The code looks like below.


WHEN '0FI_AP_4'.

    DATAit_dtfiap_3 LIKE dtfiap_3 OCCURS WITH HEADER LINE,
           l_belnr LIKE it_dtfiap_3-belnr,
           l_zbktxt LIKE it_dtfiap_3-zbktxt,
           wf_apindex TYPE sy-tabix.
*DPO Porject changes 12/20/12
    TYPESBEGIN OF t_bseg1,
           belnr TYPE belnr_d,
           buzei TYPE buzei,
           wmwst TYPE wmwst,
           END OF t_bseg1.
    TYPESBEGIN OF t_t052,
           zterm TYPE dzterm,
           text1 TYPE text1_052,
           END OF t_t052.

    DATAlt_bseg1 TYPE STANDARD TABLE OF t_bseg1,
          lv_bseg1 TYPE t_bseg1,
          lt_t052 TYPE TABLE OF t_t052,
          lv_t052 TYPE  t_t052.
* new changes for DPO project defect 13529 03/23/12. from BKPF
    TYPESBEGIN OF t_ap_bkpf,
           belnr TYPE belnr_d,
           usnam type usnam,
            XREF1_HD type XREF1_HD,
           END OF t_ap_bkpf.
datalt_apbkpf type table of  t_ap_bkpf,
      lv_apbkpf type t_ap_bkpf.

* end of changes for DPO project defect 13529 03/23/12
    REFRESH:  it_dtfiap_3lt_t052,lt_bseg1lt_apbkpf.
    it_dtfiap_3[] c_t_data[].

    SELECT belnr buzei wmwst
       INTO  TABLE lt_bseg1
        FROM bseg
       FOR ALL ENTRIES IN it_dtfiap_3
              WHERE  bukrs it_dtfiap_3-bukrs
              AND    gjahr it_dtfiap_3-gjahr
              AND    belnr it_dtfiap_3-belnr
              AND    buzei it_dtfiap_3-buzei.

* TEXTS FOR ZTERM FROM T052U
    SELECT zterm text1 INTO TABLE lt_t052
           FROM t052u CLIENT SPECIFIED
           WHERE spras sy-langu
           AND   mandt sy-mandt.
* get user name and header ref texts from BKPF. This text contains BEST TERMS for the respeicve document.
      SELECT belnr usnam xref1_hd
       INTO  TABLE lt_apbkpf
        FROM bkpf
       FOR ALL ENTRIES IN it_dtfiap_3
              WHERE  bukrs it_dtfiap_3-bukrs
              AND    gjahr it_dtfiap_3-gjahr
              AND    belnr it_dtfiap_3-belnr.


    LOOP AT it_dtfiap_3.
      wf_apindex sy-tabix.
      CLEARl_zbktxt.
      SELECT SINGLE bktxt
         FROM bkpf
      INTO (l_zbktxt)
      WHERE belnr it_dtfiap_3-belnr.

      MOVE:    l_zbktxt TO it_dtfiap_3-zbktxt.

* DDO Changes...
      READ TABLE lt_bseg1 INTO lv_bseg1 WITH KEY
                          belnr it_dtfiap_3-belnr
                          buzei it_dtfiap_3-buzei.

      IF sy-subrc 0.
        it_dtfiap_3-zzmwst lv_bseg1-wmwst.
        CLEAR lv_bseg1.
      ENDIF.
*ZTERM TEXT--DDO PRJECT CHANGES
      READ TABLE lt_t052 INTO lv_t052
              WITH KEY zterm it_dtfiap_3-zterm .
      IF sy-subrc 0.
        it_dtfiap_3-zzterm_text lv_t052-text1.
        CLEAR lv_t052.
      ENDIF.
* get respective  USNAM, XREF1_HD
      READ TABLE lt_APBKPF INTO lv_APBKPF WITH KEY
                          belnr it_dtfiap_3-belnr.
        IF SY-SUBRC 0.
          it_dtfiap_3-ZZUSNAM LV_APBKPF-USNAM.
           it_dtfiap_3-ZZXREF1_HD  LV_APBKPF-XREF1_HD.
          ENDIF.


      MODIFY it_dtfiap_3 INDEX wf_apindex.
      CLEAR  it_dtfiap_3.
    ENDLOOP.

    c_t_data[] it_dtfiap_3[].
    REFRESH:  it_dtfiap_3lt_t052,lt_bseg1,lt_apbkpf.

**************************************************************************************** 

5.    We can test the changes by going to Extract checker ( RSA3 )  or using Test option on the menu of the step from 3 ( RSA6). 

6.    Once  you validate the result against the base Table values , good to replicate the same into BW.Here the base table is BKPF.

Source Table Data for the same

          Cont.. Part 2

No comments:

Post a Comment