+++> 6. Logic for DSO Look-Up

Sample Scenario for DSO Lookup


METHOD end_routine.
*=== Segments ===

    FIELD-SYMBOLS:
      <RESULT_FIELDS>    TYPE _ty_s_TG_1.

    DATA:
      MONITOR_REC     TYPE rstmonitor.

*$*$ begin of routine - insert your code only below this line        *-*
... "insert your code here
*--  fill table "MONITOR" with values of structure "MONITOR_REC"
*-   to make monitor entries
... "to cancel the update process
*    raise exception type CX_RSROUT_ABORT.

data : itab type standard table of /bic/aZvtest_300,
       wa like line of itab.

select from /bic/aZvtest_300 into corresponding fields of table itab
  for all entries in RESULT_PACKAGE
  where  CUSTOMER = RESULT_PACKAGE-CUSTOMER AND
       MATERIAL = RESULT_PACKAGE-MATERIAL.

  LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
    READ TABLE ITab INTO WA WITH KEY
    MATERIAL = <RESULT_FIELDS>-MATERIAL
    CUSTOMER = <RESULT_FIELDS>-CUSTOMER.

    IF SY-SUBRC = 0.
      <RESULT_FIELDS>-AB_NETPR = WA-AB_NETPR.
      <RESULT_FIELDS>-AB_CURRCY = 'INR'.
    ENDIF.

endloop.
=============================================================================
Scenario 1.
The following is the proposed  data flow for bringing the condition master data based on condition types  ZF00 and ZFSR.  KONP table with the required fields will be pulled into BW from R/3.  In the R/3 production system currently KONP table has 580 records for the condition types ZF00 and ZFSR.   The required condition record tables such as A506, A566 and A658 are also to be pulled in individually into BW.  KONP datasource will be staged in a DSO which can be used as a look up table to fetch values such as freight rate / service tax based on the condition record number from A506, A566 and A658.  All can consolidated into one DSO and pushed into consolidated info cube for WH & LO.

Key fields of final dso :  Vendor, Validity end date of the condition record, condition record number, start date, plant, region, city code, sales org.
Data fields of final dso :  KBETR ( Value from KONP table ).

METHOD end_routine.
*=== Segments ===

    FIELD-SYMBOLS:
      <RESULT_FIELDS>    TYPE _ty_s_TG_1.

    DATA:
      MONITOR_REC     TYPE rstmonitor.

*$*$ begin of routine - insert your code only below this line        *-*
... "insert your code here
*--  fill table "MONITOR" with values of structure "MONITOR_REC"
*-   to make monitor entries
... "to cancel the update process
*    raise exception type CX_RSROUT_ABORT.
TYPES : BEGIN OF TY_A658,
        CONDRECNO TYPE /BI0/OICONDRECNO,
        /BIC/ZCONDAMT TYPE /BIC/OIZCONDAMT,
        /BIC/ZCONDUNIT TYPE /BIC/OIZCONDUNIT,
        END OF TY_A658.

 DATA:  IT_A658 TYPE STANDARD TABLE OF TY_A658,
        WA_A658 TYPE TY_A658.

 SELECT CONDRECNO /BIC/ZCONDAMT /BIC/ZCONDUNIT FROM /BIC/ADKONP00
   INTO TABLE IT_A658
 FOR ALL ENTRIES IN RESULT_PACKAGE
   WHERE CONDRECNO =  CONDRECNO.
   LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.

     READ TABLE IT_A658 INTO WA_A658 WITH KEY CONDRECNO =
     <RESULT_FIELDS>-CONDRECNO.

     IF SY-SUBRC = 0.

     <RESULT_FIELDS>-/BIC/ZCONDAMT = WA_A658-/BIC/ZCONDAMT.
     <RESULT_FIELDS>-/BIC/ZCONDUNIT = WA_A658-/BIC/ZCONDUNIT.

     ENDIF.

     ENDLOOP.

Scenario 2:
I have DSO1 and DSO2 .I am loading data from DSO1 to DSO3. But I need some more additional data from DSO2 . So , i need to write a Routine in Transformations while sending data from DSO1 to DSO3 and needs to look up to DSO2 for some additional fields.
All the 3 DSO 's have the same Key Fields.
solution : declare lt_lookup as a table with structure having required fields.
then select data from dso2 and store it in lt_lookup
sort lt_lookup by keyfield.
loop at result_package assigning <result_fields>
read table lt_lookup into wa with key
key1 = <result_fields>-key1 binary search.
if sy-subrc eq 0.
<result_fields>-field1 = wa-field1.
endif.
endloop

=============================================================================
Scenario 3.
I have scenario in BI with transformation. We have two DSOs with different fields.
DSO1 (ZCUS_O10) has fields 0CUSTOMER, Sold-To Party, 0Plant, Market, Region, Postal Code.
DSO2 (ZCUS_O16) has fields Tank Ship To, GMMNO, Meter Ship To, Storage Object.

now I need to insert DSO2 couple of fields (Tank Ship to & GMMNO) into DSO1 where Tank Ship to = 0CUSTOMER index by Meter Ship To.

Coding Logic:
DATA : BEGIN OF I_T_CCATTR,
a(2) TYPE char,
b(2) type char,
END OF I_T_CCATTR.
DATA: INT_T_CCATTR LIKE TABLE OF I_T_CCATTR.
IF RESULT_PACKAGE[] IS NOT INITIAL.
SELECT a b
INTO CORRESPONDING FIELDS OF TABLE INT_T_CCATTR
FROM /BI0/PXXXXXXXX.
FOR ALL ENTRIES IN RESULT_PACKAGE
WHERE a = RESULT_PACKAGE-a
AND OBJVERS = 'A'.
ENDIF.

********* SORT TO BE ABLE TO USE BINARY SEARCH

SORT INT_T_CCATTR BY a.

LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.

READ TABLE INT_T_CCATTR INTO I_T_CCATTR
WITH KEY a = <RESULT_FIELDS>-a BINARY SEARCH.

<RESULT_FIELDS>-b = I_T_CCATTR-b .

ENDLOOP.


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