Skip to Content
author's profile photo Former Member
Former Member

ABAP For DSO Lookup

Hi Friends

I am new to BW and ABAP. I have a scenario where I have to do a lookup from one DSO to another DSO. The scenario is as follows:

DSO 1 : YPCNTOHD with Key Field 0CRM_OHGUID

DSO 2 : ZPCNTO01 with Key Field 0CRM_OHGUID and 0CRM_ITMGUI

Field available in both the DSO is 0NETVALORD.

DSO 1 has to do a lookup on DSO 2 inorder to get the 0netvalord values populated based on the key field 0CRM_OHGUID.

Please help me with a sample code in detail as to how this could be done. I tried doing this using the new DSO Lookup function as I am working on the 7.3 Environment. But since 0CRM_GUI did not have any values in DSO 1 as it is not a Key Field, it did not work. The only option is using a routine.

Thanks and Appreciate

Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 26, 2012 at 08:47 PM

    The question is answered. How do I update it and close the posting?

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 26, 2012 at 04:00 AM

    Hi sam,

    Plz refer the below code in the end routine.

    data itab1 type standard table of /bic/a<dso1>00.

    data wa1 like line of itab1.

    select * from /bic/a<dso1>00 into itab1 for all entries in result_package where 0CRM_OHGUID = <result_fields>-0CRM_OHGUID.

    loop at result_package assigning <result_fields>.

    read table itab1 into wa1 where 0CRM_OHGUID = RESULT_PACKAGE-0CRM_OHGUID.

    <result_fields>-0NETVALORD = wa1-0NETVALORD.

    endloop.

    Please once execute the code and revert backin case of any error.

    Regards,
    RaviChandra.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 26, 2012 at 05:44 PM

    HI sam,

    write the code in end routine.

    types:begin of ls_str,

    z0CRM_OHGUID type 0CRM_OHGUID,

    z0NETVALORD type 0NETVALORD,

    end of ls_str

    data:itab type table of ls_str.

    data wa type ls_str.

    select 0CRM_OHGUID 0NETVALORD

    from /bic/a<dso1>00

    into table itab1 for all entries in result_package

    where 0CRM_OHGUID = RESULT_PACKAGE-0CRM_OHGUID.

    loop at result_package assigning <result_fields>.

    read table itab1 into wa where z0CRM_OHGUID = <result_fields>-0CRM_OHGUID.

    If sy-subrc=0.

    <result_fields>-0NETVALORD = wa-z0NETVALORD.

    endif.

    endloop.

    Regards,

    Babu.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Babu

      I made some modifications in the code you posted and it went through without errors. Primarily, at the declaration and secondly, CRM_OHGUID is to be used instead of 0CRM_OHGUID though the DSO has 0CRM_OHGUID. Lastly, "sy-subrc = 0". Thanks a lot for the help!

      Regards

      Sam

  • Posted on Jul 26, 2012 at 04:10 AM

    Hi

    strart routine:

    DATA:IT_DSO2 type standard table of /BIc/ADSO200,

    WA_DSO2 type /BIc/ADSO00.

    SELECT 0crm_ohguid 0netvalord from /BIc/ADSO200 into corresponding

    fields of table IT_dso2.

    -------------------------------------------------

    field routine for 0NETVALORD:

    READ TABLE IT_dso2 INTO WA_dso2

    WITH KEY 0crm_ohguid = SOURCE_FIELDS-/BI0/0crm_ohguid.

    IF SY-SUBRC = 0.

    RESULT = WA_dso2-/BI0/0netvalord .

    CLEAR WA_dso2.

    ENDIF.

    -- KRPK

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 26, 2012 at 05:52 AM

    Hi,

    We can use end routine.Declere the internal table with requied fields.

    type:begin of itab

    Z0CRM_OHGUID type 0CRM_OHGUID,

    Z0NETVALORD type 0NETVALORD,

    end of itab.

    select 0CRM_OHGUID

    0NETVALORD

    from DSO2 into corresponding fields of table itab

    where 0CRM_OHGUID = result_packege-0CRM_OHGUID.

    loop at result_packge into WA.

    if 0CRM_OHGUID = itab-0CRM_OHGUID.

    move itab-0NETVALORD to wa-0NETVALORD.

    else delete result packge.

    end loop.

    Append WA to result_packege.

    Regards

    Sudhir Kumar

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member T Ravi Chandra

      Hi Sai,

      Pls check this code.

      type:begin of itab

      Z0CRM_OHGUID type 0CRM_OHGUID,

      Z0NETVALORD type 0NETVALORD,

      end of itab.

      select 0CRM_OHGUID

      0NETVALORD

      from DSO2 into table itab

      where 0CRM_OHGUID = result_packege-0CRM_OHGUID.

      loop at result_packge into WA.

      if 0CRM_OHGUID = itab-Z0CRM_OHGUID.

      move itab-Z0NETVALORD to wa-0NETVALORD.

      end if.

      end loop.

      Append WA to result_packege.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.