Tuesday, July 17, 2012

Enhancement to STD Data Source ( Logistics )-2


Continuing with PART1 we will go through the steps to enhance the Data Source in case need arises for adding custom fields added part of SD customization in general they are not part of Standard base structure behind the Data Source. To achieve this  , let us see how can be done.
We will take same Data Source 2LIS_11_VAITM for this too.
1.Before starting this need to find out the structure behind this Data Source. Go to Transaction RSA6 , navigate to the data source and choose display..Remember all the set up tables should be empty before starting this step.
 
2.Now use Tcode SE11 to maintain this structure MC11VA0ITM.. Enter the name of the structure and 
   choose option Display.. Here we cannot add the FIELDS that we need part of  Data Source as this is 
   SAP object. We can do this by adding the APPEND structure .
  So choose Append structure from the menu.The pop up will show you all the structures if any already 
  created. You can use one of them or create a new one if you want separated from other changes.
 
3. I have created append structure  called ZEVENT_APPEND and added a new field ZERDAT with data  
    type ERDAT and activated the structure.
4.The next would be make this column to be  visible at BI level my make this as unhide from RSA6 in change mode.
 
5. Once you uncheck the flag  under HIDE Field column   generate the structure MENU  option under 
   datasource.
6. Now if you test the data source , the value wont be available under the newly added column. since Standard Extract program does not recognize as part of its purview.
7. To populate this column , will take the help of USEREXIT which work like place holders for our custom code as part of STANDARD Extract program. The program name for this is ZXRSAU01 and will add the following code .Now we need to find out from which table the data needs to be populated for newly added columns. In this example ZERDAT is from table VBAP.
 when '2LIS_11_VAITM'.

    data: lt_vaitm type table of mc11va0itm,
          lv_vaitm type mc11va0itm.
     types: begin of ty_vbap,
            vbeln type vbeln,
            posnr type posnr,
           zerdate type erdat,
             end of ty_vbap.
data: it_vbap type standard table of ty_vbap,
          wa_vbap type ty_vbap,
          wf_index type sy-tabix..
lt_vaitm[] = c_t_data[] .
    refresh: c_t_data[].
    if not lt_vaitm[] is initial..
select vbeln posnr zerdat from VBAP
                  into table it_vbap
              for all entries in lt_vaitm
               where vbeln = lt_vaitm-vbeln
               and   posnr = lt_vaitm-posnr.
    loop at lt_vaitm into lv_vaitm.
        wf_vindex = sy-tabix.
read table it_vbap into wa_vbap with keylt_vaitm-vbeln
                                           posnr = lt_vaitm-posnr..
if sy-subrc = 0.
 lv_vaitm-zerdat = wa_vbap-zerdat.
 endif.
 modify lt_vaitm from lv_vaitm index wf_vindex .
 clear lv_vaitm.
endloop.
 c_t_data[] = lt_vaitm[].
      refresh: lt_vaitm.

Save the code and activate the program.
8. Now you are ready to test the extractor again. Goto RSA3 and test the same,you should see some data in the ZERDAT column.


No comments:

Post a Comment