on 07-25-2012 9:03 PM
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
The question is answered. How do I update it and close the posting?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
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
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.