Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
pallab_haldar
Active Participant
7,045
In this Blog I will describe about the Master Data Lookups in SAP BW.  Using this blog a new developer can understand the lookup  mechanism and Copy and customize the code from the blog in very easy way. Which will help in their initial time to develop BW data flow.

1. Master Data Lookup :  We can lookup Master data from the Master data infoobject (P Table)  from  -.

  • Field lookup routine : Not recommended as if there is 40 row record in a packet 40 times lookup. Slow the dataflow performance.

  • From SAP BW start routine: Used for data preparation.

  • End Routine: Simple and easiest way to lookup master data from End routine. I will use this method to lookup.

  • Expert routine : This also we can use for Master data look up.


Master Data look up using End Routine:

In our requirement , in our ADSO Material(0Material) is there we need PLANT(0PLANT), WORKCENTER(0WORKCENTER) and Work Center responsible person(WRKCT_RESP).

  • Populate PLANT by lookup the P table of  0MAT_PLANT using MATERIAL(MATNR).

  • Using the populated PLANT as lookup key populate WORKCENTER(WORKCENTER) and Work Center responsible person(WRKCT_RESP) from P table of  0WORKCENTER infoobject.


Steps:

1.  Add Infoobject which need to populate in the Target i.e. for our case it is ADSO. Activate it.


2. Edit the respective transformation to the target ADSO and add it  to Routine .Then open the routine and start to develop lookup program.

 


 

3. Now Start to add the code below code in end routine. -



    TYPES: BEGIN OF ls_plnt,
MAT_PLANT TYPE /BI0/OIMAT_PLANT,
PLANT TYPE /BI0/OIPLANT,
END OF ls_plnt,
BEGIN OF ls_wctr,
PLANT TYPE /BI0/OIPLANT,
WORKCENTER TYPE /BI0/OIWORKCENTER,
WRKCT_RESP TYPE /BI0/OIWRKCT_RESP,
END OF ls_wctr.


DATA: lt_plnt TYPE STANDARD TABLE OF ls_plnt,
wa_plnt TYPE ls_plnt,
lt_wctr TYPE STANDARD TABLE OF ls_wctr,
wa_wctr TYPE ls_wctr.


*----------------------------------------------------------------------
*prepare Plant master data
SELECT MAT_PLANT PLANT FROM
/BI0/PMAT_PLANT
INTO CORRESPONDING FIELDS OF TABLE lt_plnt FOR ALL ENTRIES IN
RESULT_PACKAGE
WHERE MAT_PLANT = RESULT_PACKAGE-MATERIAL.

*Populate Plant and workcenter from material master data
CLEAR wa_plnt.
LOOP at RESULT_PACKAGE ASSIGNING <result_fields>.
READ TABLE lt_plnt INTO wa_plnt
WITH KEY MAT_PLANT = <result_fields>-MATERIAL .
IF sy-subrc = 0.
<result_fields>-PLANT = wa_plnt-PLANT.
ENDIF.
ENDLOOP.

*----------------------------------------------------------------------*
*prepare workcenter master data

SELECT PLANT WORKCENTER WRKCT_RESP FROM
/BI0/PWORKCENTER
INTO CORRESPONDING FIELDS OF TABLE lt_wctr FOR ALL ENTRIES IN
RESULT_PACKAGE
WHERE PLANT = RESULT_PACKAGE-PLANT.

*populate from material master data

CLEAR wa_wctr.

LOOP at RESULT_PACKAGE ASSIGNING <result_fields>.
READ TABLE lt_wctr INTO wa_wctr
WITH KEY PLANT = <result_fields>-PLANT .
IF sy-subrc = 0.
<result_fields>-WORKCENTER = wa_wctr-WORKCENTER.
<result_fields>-WRKCT_RESP = wa_wctr-WRKCT_RESP.
ENDIF.
ENDLOOP.
*--------------------------------------------------------

4. The sub steps inside the ABAP code describe below -




  1. Create local structure.

  2. create work area of type work structure.

  3. Lookup on P table using material as a lookup key.

  4. Populate the PLANT field in the result set.

  5. Repeat similar 4 step to populate WorkCentre and responsible person in result set only use prepopulated PLANT as lookup key.


 

Now anybody can customize and write their own code which will save the development time.

In next Blog I will describe about the Transaction data look up in BW i.e. from one ADSO to another ADSO.

 
3 Comments
Labels in this area