Skip to Content
avatar image
Former Member

Lookup Code

Hi all,

I need code to do the following:

I am trying to consolidate data from three write optimized DSOs.

DSO1 contains Doc No., Task number, X, Y

DSO2 contains Doc No., Item Number, Z

DSO3 contains Doc No., K, L, M

The consolidated DSO4 should have the following key fields: Doc No., Item No. and Task Number

and data Fields: X, Y, Z, K L, M.

I am planning to create a transformation between DSO1 and the DSO4 and write a start routine to look up other fields.

I need the code to do this consolidation.

Please advice.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    May 11, 2010 at 04:08 PM

    Hi,

    i don't know if exists a better option.

    For me the faster solution is create an expert routine in the transformation.

    1.- Create an internal table with the document numers.

    2.- Select the information with "FOR ALL ENTRIES" command from the DSO2, DSO3

    4.- Create a loop structure and a different loop where insede to create the register of the DSO4

    Regards,

    Dani

    Add comment
    10|10000 characters needed characters exceeded

    • To prevent complex coding you can do the following:

      create a transformation from all 3 DSO to DSO4 mapping mentioned fields.

      DSO1->DSO4.

      map all fields.

      DSO2->DSO4

      map Doc No., Item Number, Z

      in end routine, read DSO4 and fill Task number, X, Y.

      DSO3->DSO4

      map Doc No., K, L, M .

      in end routine read DSO4 and fill task number,item number,x,y,z.

      Loading sequnce.

      Load DSO1, activate

      load DSO2 , activate

      then load DSO3 and activate.

      Sample code for DSO2->DSO4, you can modify this code for other trans.

      types: begin of st_dso4,
                 doc_no type (data element),
                 task no,
                 x,
                 y
                end of st_dso4.
      
      data: lt_dso4 type table of st_dso4,
               lw_dso4 like line of lt_dso4.
      
      select doc no,task number,x,y from (active table of DSO4) into table lt_dso4 for all entries in result_package
      where doc_no = result_package-doc_no.
      
      sort lt_dso4 by doc_no.
      
      loop at result_package assigning <result_fields>.
      
      read table lt_dso4 into lw_dso4 with key
      doc_no = result_package-doc_no binary search.
      if sy-subrc eq 0.
      <result_fields>-taskno = lw_dso4-task no.
      <result_fields>-x = lw_dso4-x.
      <result_fields>-y = lw_dso4-y.
      endif.
      endloop.

      In this method coding is minimal and record splitting is handled properly.Make sure to set KF type as overwrite.

      Edited by: Ananda Theerthan on May 16, 2010 10:26 PM

  • May 17, 2010 at 03:54 AM

    Hi,

    Write the code like below.

    DATA: BEGIN OF t_batch OCCURS 0,
    	material LIKE /BIC/AZIC_O0600-material,
    	plant LIKE /BIC/AZIC_O0600-plant,
    	stor_loc LIKE /BIC/AZIC_O0600-stor_loc,
    	batch LIKE /BIC/AZIC_O0600-batch.
          END OF t_batch.
    
    
    SELECT MATERIAL PLANT STOR_LOC BATCH FROM /BIC/AZIC_O0600 INTO t_batch for all entries in DATA_PACKAGE
    WHERE
     material = DATA_PACKAGE-material  and
     plant    = DATA_PACKAGE-PLANT     and
     stor_loc = DATA_PACKAGE-stor_loc.
    
     ABORT = 0.
    
    
    
    "This code is at field level routine.
    
    SORT t_batch by material batch stor_loc.
    
    Read table t_btach with key material = COMM_STRUCTURE-material
                                plant    = COMM_STRUCTURE-plant    
                                stor_loc = COMM_STRUCTURE-stor_loc.
    
    If sy-subrc = 0.
    
      RESULT = t_batch-PLANT.
    
    else.
      RESULT = ''.
    endif.
    
    ENDIF.
    
    ENDLOOP.

    Thanks

    Reddy

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 17, 2010 at 08:24 AM

    May be you can write this as follows in end routine.

    TYPES: BEGIN OF E_DSO2,

    DOCNO TYPE /BIC/ADSO200-DOCNO,

    ITEMNO TYPE /BIC/ADSO200-ITEMNO,

    Z TYPE /BIC/ADSO200-Z,

    END OF E_DSO2.

    DATA : IT_DSO21 TYPE STANDARD TABLE OF E_DSO2.

    DATA : WA_DSO2 TYPE E_DSO2.

    SELECT DOCNO

    ITEMNO

    Z

    FROM /BIC/ADSO200

    INTO TABLE IT_DSO2

    FOR ALL ENTRIES IN RESULT_PACKAGE

    WHERE DOCNO = RESULT_PACKAGE-DOCNO .

    SORT IT_DSO2

    BY DOCNO.

    LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.

    READ TABLE IT_DOCNO

    WITH KEY DOCNO = <RESULT_FIELDS>-DOCNO

    INTO WA_DOCNO BINARY SEARCH.

    IF sy-subrc EQ 0.

    <RESULT_FIELDS>-ITEMNO = WA_DSO2-ITEMNO.

    <RESULT_FIELDS>-Z = WA_DSO2-Z.

    ENDIF.

    CLEAR wa_DSO2.

    ENDLOOP.

    Same type of code you can use for DSO3 -> DSO4

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 21, 2010 at 02:18 PM

    closing post...

    Add comment
    10|10000 characters needed characters exceeded