2006 Dec 08 5:00 AM
Hi All,
I'm working in SAP BW. I have created a query which I am using in Analysis process designer which feeds data to a transactional ODS.
In the APD the condition made on the query cannot be reached. I want to create a transformation between a query and a transactional ODS that should fetch me TOP 10 materials (as per their sales value)
In the APD the condition made on the query cannot be reached (like TOP N Materials).
I got a ABAP routine to sort the result (in a step of APD). It was like this:
DATA: ls_source TYPE y_source_fields,
ls_target TYPE y_target_fields.
data: rank(4) type N.
sort ls_source descending by KYF_0002.
clear rank.
loop at ls_source into ls_source.
add 1 to rank.
MOVE-CORRESPONDING ls_source TO ls_target.
ls_target-key(10) = ls_target-BPARTNER.
ls_target-key+10(4) = ls_target-MDCHBWCCO__FRCHSHOP.
ls_target-RANKING = rank.
APPEND ls_target TO et_target.
ENDLOOP.
I have been trying for quite sometime to understand and customize this code as per my requirement but my lack of knowledge in ABAP has impaired me.
I need help in suggesting what all in this code is generic and what is specific to the sender's system which I should replace, and with what.
Please help !
Thanks,
Sharmishtha
2006 Dec 08 8:47 AM
Yeah Sharmistha Biswas ,
You are proceeding in the correct direction . Please let me know if that worked .
Regards ,
Dhera kamlesh H. R.
2006 Dec 08 5:35 AM
Hi,
The code which you sent looks like Values fetched from Source and passed to target. This code is generic.
1) first you need to move values from ls_source to ls_target.
2) here if you look at ls_target-key(10) = ls_target-BPARTNER.
you can find the first 10 character of ls_target-key is moved to ls_target-BPARTNER and next 4 Character of LS_SOURCE is been passed to ls_target-MDCHBWCCO__FRCHSHOP and other field of ls_target are filled with rank value which gets incremented one by one.
thus the whole code is generic and i don't think you would require any more additions.
Thanks,
Prashanth
2006 Dec 08 5:55 AM
Hi Prashanth,
Thanks a lot.
But I'm not versed in ABAP at all.
Can you pl send me some docs which could help me undertsand the code?
Because when I checked this code it is throwing me error
Syntax error: "LS_SOURCE" is not an internal table - the "OCCURS n" specification is missing.
Thanks for your help !
Regards,
Sharmishtha
2006 Dec 08 6:52 AM
Hi,
Change
DATA: ls_source TYPE y_source_fields,
ls_target TYPE y_target_fields.
to
DATA: ls_source like table of y_source_fields with headerline,
ls_target like table of y_target_fields with header line..
Now it should work.
Thanks,
Prashanth
2006 Dec 08 7:48 AM
Hi,
Thanks for your help.
But it is nowl throwing a new error
It says," Syntax error: The system expected a key specification in the form "KEY k1 ... kn", "TABLE LINE", or "DEFAULT KEY". -"
Please suggest !
Regards,
Sharmishtha
2006 Dec 08 7:36 AM
Hi Sharmishtha Biswas ,
if u want the TOP 10 materials , use
APPEND target_table SORTED BY sales_value .
where ,
target_table : an internal table with OCCURS 10 in the declaration
sales_value : a field in target_table
Regards ,
Dhera Kamlesh H. R.
2006 Dec 08 7:55 AM
Thanks Kamlesh,
Do you mean to say that I copy the lines of the code that you've given insted of APPEND ls_target TO et_target. ?
Also, I believe I shall have to replace "sales_value" with the name of the sales key figure .
Correct me if I'm wrong.
Thanks,
SB
2006 Dec 08 8:47 AM
Yeah Sharmistha Biswas ,
You are proceeding in the correct direction . Please let me know if that worked .
Regards ,
Dhera kamlesh H. R.
2006 Dec 08 9:18 AM
Hi Kamlesh,
It still didn't work.
It is throwing the same error:
Syntax error: The system expected a key specification in the form "KEY k1 ... kn", "TABLE LINE", or "DEFAULT KEY". -
Regards,
Sharmishtha
2006 Dec 08 9:48 AM
Yeah Sharmistha Biswas ,
I am so sorry that I haven't told you to NOT to use the SORT command .
Please do not use that SORT command , delete that entire statement .
Proceed and see , and do tell me what's the status .
Regards ,
Dhera Kamlesh H. R.
2006 Dec 08 10:20 AM
Kamlesh,
Now, my code looks like this, but still gives the same error
DATA: ls_source like table of y_source_fields with headerline,
ls_target like table of y_target_fields with header line.
data: rank(4) type N.
loop at ls_source into ls_source.
add 1 to rank.
MOVE-CORRESPONDING ls_source TO ls_target.
ls_target-key(10) = ls_target-BPARTNER.
ls_target-key+10(4) = ls_target-MDCHBWCCO__FRCHSHOP.
ls_target-RANKING = rank.
APPEND target_table SORTED BY sales_value .
where ,
target_table : an internal table with OCCURS 10 in the declaration
sales_value : a field in target_table
ENDLOOP.
Regards,
SB
2006 Dec 08 11:05 AM
Sharmishtha Biswas ,
I have modified your code , see if it works :
DATA: ls_source like table of y_source_fields with header line,
ls_target like table of y_target_fields with header line.
"data : rank TYPE N(4) .
loop at ls_source .
"add 1 to rank.
MOVE-CORRESPONDING ls_source TO ls_target.
ls_target-key(10) = ls_target-BPARTNER.
ls_target-key+10(4) = ls_target-MDCHBWCCO__FRCHSHOP.
"ls_target-RANKING = rank.
APPEND ls_target SORTED BY ____________ .
ENDLOOP.
Copy and paste the above code in the place of your code .
Remove all _s (underscores) after SORTED BY .
Specify the field of "y_target_fields" table , which represent "sales" ,
instead (after SORTED BY)
Regards ,
Dhera Kamlesh H. R.
2006 Dec 08 11:57 AM
Kamlesh,
I must thank you a lot !
I believe the code you've sent is absolutely correct but my lack of knowledge of certain things is leaving me with some errors.
I'll try to debug as I very well understand that its not the fault of the code.
I am unable to assign the correct source fields.
Thanks for all your help !
Best regards,
Sharmishtha Biswas
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |