cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP For DSO Lookup

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

former_member210253
Contributor
0 Kudos

Hi Sam,

Click the radio button correct answer which is most suitable, helpful post for your requirement, then automatically it turns as Answered

Regards,

Babu

ravi_chandra3
Active Contributor
0 Kudos

Hi Sam ,

Is the populated in the target Infoobject , You have to give the exact name which is present in the target dso.then only the values will get populated. Please once check it before closing the thread.

Regards,

RaviChandra     

Former Member
0 Kudos

Hi Ravi

I did give the exact name of the DSO assuming you would have put the other DSO by mistake in the code. And it is getting populated.

Thanks!

Sam

ravi_chandra3
Active Contributor
0 Kudos

Hi Sam,

If the values are populated , then no problem.

Hope now your problem is solved.

Regards,

RaviChandra     

Former Member
0 Kudos

Hi Ravi

Yes the issue is cleared. I appreciate your help!

Thanks

Sam

ravi_chandra3
Active Contributor
0 Kudos

Hi sam,

In SCN , assigning points is the way of saying thanx.

Regards,

RaviChandra     

Answers (4)

Answers (4)

former_member210253
Contributor
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Sudhir

I am getting the following error:

"RESULT_PACKAGE" is a table without a header line and therefore has no component called CRM_OHGUID.

ravi_chandra3
Active Contributor
0 Kudos

Hi sam,

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.

Just make a modifiction in the above code like

loop at result_packge assigning <result_fields>.

if 0CRM_OHGUID = <result_fields>-0CRM_OHGUID.

move itab-0NETVALORD to wa-0NETVALORD.

else delete result packge.

end loop.

and moreover don't use the move statement to copy the data, that will degrade the performance.

Regards,
RaviChandra     

Former Member
0 Kudos

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.

kr_pavankumar
Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Pavan

I am getting the following error:

Unknown column name "0CRM_OHGUID" not determined until runtime, you cannot specify a field list.

ravi_chandra3
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

Hi Ravi

I am getting the following error:

You cannot use an internal table as a work area.

ravi_chandra3
Active Contributor
0 Kudos

Hi Sam ,

Use this select statement

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

Just add the table before itab1 , because you are loading the data into the internal table not in the work area.

Sorry for error that i wrote.

Regards,

RaviChandra     


Former Member
0 Kudos

Hi Ravi

Appreciate the quick response. Now there's another error:

"RESULT_PACKAGE" is a table without a header line and therefore has no component called 0CRM_OHGUID.

The select statement shows an error for 0CRM_OHGUID but when I ignore the '0', it gets cleared and the above error shows up.

ravi_chandra3
Active Contributor
0 Kudos

Hi sam,

Can u paste the code what have you written so that i can understand better .

Regards,

RaviChandra     

ravi_chandra3
Active Contributor
0 Kudos

HI sam,

Please once try with this code , I think it will work for sure....

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

data wa1 like line of itab1.

select * 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 wa1 where 0CRM_OHGUID = <result_fields>-0CRM_OHGUID.

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

endloop.

I think this code won't throw any error..

Regards,

RaviChandra     

Former Member
0 Kudos

Hi Ravi

If I put your code as it is it shows:

1) 0CRM_OHGUID unknown.

2) The 'WHERE' in the READ statement also seems to be an error as it is shown in red and it is suggesting to use 'KEY'

3) And where are we specifying the DSO2 in the code as that is where we have to do a lookup on.

If I ignore the '0' from 0CRM_OHGUID and use 'WITH TABLE KEY' instead OF 'WHERE', the errors get cleared but throws the error:

Specification for component "RECORDMODE" of key "PRIMARY_KEY" of table "ME->ITAB1" is missing or incomplete. Key must be completely provided

Thanks

Sam

ravi_chandra3
Active Contributor
0 Kudos

Hi sam,

Sorry in the read statement you should not have where statement that should be with key , like that statement should be like this

read table itab1 into wa1 with key  0CRM_OHGUID = <result_fields>-0CRM_OHGUID.Please once check whether that dso has 0CRM_OHGUID field or not.


If you want to perform the look up on dso2 then just change the technical name of that dso , it doesn't matter much sam.

Regards,

RaviChandra


Former Member
0 Kudos

H Ravi

I made some modifications in the code and it went through without errors. Primarily, CRM_OHGUID is to be used instead of 0CRM_OHGUID though the DSO has 0CRM_OHGUID. Thanks a lot for the help!

Regards

Sam