Hi,
I have three queries in APD with three set of data respectively as table 1, table 2 and table 3
Table 1
Store | Dept | Sales (Total Last 3 periods) | Store Ratio |
---|---|---|---|
Store 1 | Bath | 303 | 0.2523 (303/1201) |
Store 1 | HDW | 898 | 0.7477 (898/1201) |
Total: 1201 |
Table 2
Comp Store | Dept | Sales (Total Last 3 periods) | Store Ratio |
---|---|---|---|
Store 4 | Bath | 645 | 0.2689 (645/3630) |
Store 7 | HDW | 2985 | 0.7754 (2985/3630) |
Total: 3630 |
Requirement:
Select Store = Store 1 and Dept = HDW where Ratio =0.2523 then find the close match in Table 2 Store Ratio. When the closest Store Ratio matches is found then the historic sales for the matched Comp Store for period 4, 5 and 6 from Table 3 (Which is another BW Query) should be added to Store 1 as the Store 1 which is non comp store would not have any sales in last year. I.e cloning/copying/replacing the data for the Stores sales for future period 4, 5 and 6 should be done from historic Comp Store. And the logic would be same for rest of the stores by department between two tables.
Table 3
Comp Store | Dept | Last Year Month | Historic Sales |
---|---|---|---|
Store 4 | Bath | 4 | 230 |
Store 4 | Bath | 5 | 240 |
Store 4 | Bath | 6 | 250 |
Store 7 | HDW | 4 | 1050 |
Store 7 | HDW | 5 | 1110 |
Store 7 | HDW | 6 | 1100 |
The Final expected result table would look similar to below:
Table 4
Store | Comp store | Dept | Month | Historic Sales Comp Store (Last year) |
---|---|---|---|---|
Store 1 | Store 4 | Bath | 4 | 230 |
Store 1 | Store 7 | HDW | 4 | 1100 |
Store 1 | Store 4 | Bath | 5 | 240 |
Store 1 | Store 7 | HDW | 5 | 1050 |
Store 1 | Store 4 | Bath | 6 | 250 |
Store 1 | Store 7 | HDW | 6 | 1110 |
Question:
What Transformation would be appropriate to use to get the desired result. If ABAP Routine is the option can anyone help me with the code?
Many Thanks in advance
Regards
Sandhya