2013 May 24 11:48 AM
Hi experts,
Let’s say I have some records arriving from my source as following :
Source Table:
Account | Functional Area | Profit Center | Amount |
60000 | 00 | 10001 | 50,00 |
60000 | 05 | 20002 | 130,00 |
70000 | 13 | 30001 | -450,00 |
In my target I want to add one more field that I am going to deduce from a table with the following conditions:
Transformation Table:
Account | Functional Area Range from | Functional Area Range To | Profit Center Range from | Profit Center Range To | Virtual Account |
60000 | 03 | 10001 | 10010 | AX | |
60000 | 04 | 10 | 20001 | 20010 | AY |
70000 | 11 | 20 | 30000 | 30010 | BX |
The red cell means empty or initial.
So the difficulty that I am having is that is to test 2 ranges in order to deduce the Virtual Account into my target which will be as following:
Target Table:
Account | Functional Area | Profit Center | Amount | Virtual Account |
60000 | 00 | 10001 | 50,00 | AX |
60000 | 05 | 20002 | 130,00 | AY |
70000 | 13 | 30001 | -450,00 | BX |
Do you think that an abap program can be efficient in my case?
I tought about the following:
Read Transformation table with key account = Source Table- account
Test that Functional area of source table is between Functional Area Range from and TO
And Profit Center in source tale is between Profit Center Range from and To
And then deduce the virtual account
Thanks for your support.
Amine
2013 May 24 3:09 PM
data: r_functionalarea type range of functionalarea,
r_profitcentre type range of profitcentre.
r_functionalarea-sign = 'I'
r_functionalarea-option = 'BT'.
r_profitcentre-sign = 'I'
r_profitcentre-option = 'BT'.
loop at transformationtable into workarea_transform.
r_profitcentre-low = workarea-profitcentrefrom.
r_profitcentre-high = workarea-profitcentreto.
r_functionalarea-low = workarea-funtionalareafrom.
r_functionalarea-high = workarea-funtionalareato.
loop at source_table into workarea_source where account = workarea-account
functionalarea IN r_functionalarea
profitcenter in r_profitcentre
move-corresponding workarea_transform to workarea_target.
move-corresponding workarea_source to workarea_target.
append workarea_target to target_table.
clear: workarea_target,workarea_source.
endloop.
clear: r_profitcentre-low, r_profitcentre-high, r_functionalarea-low, r_functionalarea-high.
clear: workarea_transform.
endloop.
Hi experts,
Let’s say I have some records arriving from my source as following :
Source Table:
Account | Functional Area | Profit Center | Amount |
60000 | 00 | 10001 | 50,00 |
60000 | 05 | 20002 | 130,00 |
70000 | 13 | 30001 | -450,00 |
In my target I want to add one more field that I am going to deduce from a table with the following conditions:
Transformation Table:
Account | Functional Area Range from | Functional Area Range To | Profit Center Range from | Profit Center Range To | Virtual Account |
60000 | 03 | 10001 | 10010 | AX | |
60000 | 04 | 10 | 20001 | 20010 | AY |
70000 | 11 | 20 | 30000 | 30010 | BX |
The red cell means empty or initial.
So the difficulty that I am having is that is to test 2 ranges in order to deduce the Virtual Account into my target which will be as following:
Target Table:
Account | Functional Area | Profit Center | Amount | Virtual Account |
60000 | 00 | 10001 | 50,00 | AX |
60000 | 05 | 20002 | 130,00 | AY |
70000 | 13 | 30001 | -450,00 | BX |
Do you think that an abap program can be efficient in my case?
I tought about the following:
Read Transformation table with key account = Source Table- account
Test that Functional area of source table is between Functional Area Range from and TO
And Profit Center in source tale is between Profit Center Range from and To
And then deduce the virtual account
Thanks for your support.
Amine
2013 May 24 12:20 PM
Hi Amine,
I think that the process u mentioned is good but , i guess u need to hav another field other that account for comparision.
the reason is each time in the loop (Source table), when u read (transformation table), only first entry with account matched will be fetched.
as in case of account 6000 , the below will be read twice in loop (for the first two records)
60000 | 03 | 10001 | 10010 | AX |
it would be better if u have one more field other than account for comparision..
Regards,
Azhar
2013 May 24 2:35 PM
Thank Azhar,
I agree with you, but i have to read the 2 ranges also in order to deduce the virtual account.
I think that if i find a way how to read and test 2 ranges, my issue will be solved.
Amine
2013 May 24 2:39 PM
Hello Amine,
Would a Corrrect use of Collet Statement be helpful ?
Thanks an Regards,
Anup
2013 May 24 2:45 PM
Hi Anup,
What do you mean? I am not familiar with this abap command?
Amine
2013 May 24 4:26 PM
Hello Amine ,
Sorry it was a typo its 'Collect ' , I assume you are trying to Consolidate the data in the target table .
2013 May 24 4:53 PM
Exaclty Anup,
I want to consolidate the data as explained with the tables in my initial question.
Thanks.
Amine
2013 May 24 5:08 PM
Yes.. so in that case apart from your Amount all are Non-Numeric fields so you can use Collect Statement efficiently to build your target table.
2013 May 24 3:09 PM
data: r_functionalarea type range of functionalarea,
r_profitcentre type range of profitcentre.
r_functionalarea-sign = 'I'
r_functionalarea-option = 'BT'.
r_profitcentre-sign = 'I'
r_profitcentre-option = 'BT'.
loop at transformationtable into workarea_transform.
r_profitcentre-low = workarea-profitcentrefrom.
r_profitcentre-high = workarea-profitcentreto.
r_functionalarea-low = workarea-funtionalareafrom.
r_functionalarea-high = workarea-funtionalareato.
loop at source_table into workarea_source where account = workarea-account
functionalarea IN r_functionalarea
profitcenter in r_profitcentre
move-corresponding workarea_transform to workarea_target.
move-corresponding workarea_source to workarea_target.
append workarea_target to target_table.
clear: workarea_target,workarea_source.
endloop.
clear: r_profitcentre-low, r_profitcentre-high, r_functionalarea-low, r_functionalarea-high.
clear: workarea_transform.
endloop.
2013 May 24 3:16 PM
2013 May 24 6:11 PM
Hi Peter,
How can i manage the start of a range when it's empty?
Account | Functional Area Range from | Functional Area Range To |
60000 | 03 |
Normally that means:
Account | Functional Area Range from |
60000 | |
60000 | 01 |
60000 | 02 |
60000 | 03 |
Thanks.
Amine
2013 May 24 6:26 PM
Dear amine lamkaissi
Go with your approach that's easy i think
for your previous question , i think following method will work
while looping that particular field show empty value right , based on that you can increase the counter, and do the deduction , add one more extra field use counter, like count = count +1 .
for example if particular field value is empty , then made it like '00' in program.
Regards,
Bastin.G
2013 May 24 6:37 PM
Dear Bastin,
Actually it was a mistake, it's more like this
Normally that means:
Account | Functional Area Range from |
60000 | |
60000 | 00 |
60000 | 01 |
60000 | 02 |
60000 | 03 |
Empty, 00, 01, 02, 03
Thanks.
Amine
2013 May 24 6:44 PM
Dear amine lamkaissi
Add one more column in internal table call like status
if values empty means add '00' in that column and sort it,
then finally use delete adjacent duplicates from internal table command
and finally you will get it unique numbers
Regards,
Bastin.G
2013 May 24 7:23 PM
Let me explain clearly,
For example values empty means pass '00' to different column which u newly added in ITAB.
then for other functional values pass the same values to that column while looping.
then you will get internal table like,
60000 - > 00
60000 ->00
60000->01
60000->02
60000->03
now you can sort the internal table then use delete adjacent syntax you will get desired values hope it helps
Regards,
Bastin.G
2013 May 27 4:37 PM
Hi Peter,
In this code:
loop at source_table into workarea_source where account = workarea-account
functionalarea IN r_functionalarea
profitcenter in r_profitcentre
You meant the follwing right?
loop at source_table into workarea_source where account = workarea_target-account
functionalarea IN r_functionalarea
profitcenter in r_profitcentre
Thanks.
Amine
2013 May 28 10:59 AM
I think the correct code should be:
loop at source_table into workarea_source where account = workarea_transform-account functionalarea IN r_functionalarea profitcenter in r_profitcentre
workarea_transform is the work area of the outer loop.
2013 May 28 11:10 AM
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |