Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Need help in ABAP

Former Member
0 Likes
1,663

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,485

Yeah Sharmistha Biswas ,

You are proceeding in the correct direction . Please let me know if that worked .

Regards ,

Dhera kamlesh H. R.

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

12 REPLIES 12
Read only

Former Member
0 Likes
1,485

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

Read only

0 Likes
1,485

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

([email protected])

Read only

0 Likes
1,485

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

Read only

0 Likes
1,485

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

Read only

Former Member
0 Likes
1,485

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.

Read only

0 Likes
1,485

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

Read only

Former Member
0 Likes
1,486

Yeah Sharmistha Biswas ,

You are proceeding in the correct direction . Please let me know if that worked .

Regards ,

Dhera kamlesh H. R.

Read only

0 Likes
1,485

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

Read only

0 Likes
1,485

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.

Read only

0 Likes
1,485

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

Read only

0 Likes
1,485

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.

Read only

0 Likes
1,485

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