on 12-19-2014 4:50 PM
Hi Expets,
I have one requirement need to calculate sales Ratio and will be updated to target DSO.
Data flow is from Infocube to DSO .
All calculation has to be done in start routine and end routine.
My source_package having data like this.
Sales Office | Material | Sales |
SO1 | M1 | 100 |
SO2 | M1 | 200 |
SO1 | M2 | 300 |
SO1 | M3 | 100 |
SO2 | M1 | 100 |
Calculation by using Start Routine:
Sales will summarize based on sales office.
Sales Office | Material | Sales | Total Sales base on sales off and material wise |
SO1 | M1 | 100 | 500 |
SO1 | M2 | 300 | 500 |
SO1 | M3 | 100 | 500 |
SO2 | M1 | 100 | 300 |
Then need to calculate Ratio based on individual material sales value.
Sales Office | Material | Total | Ratio |
SO1 | M1 | 500 | 100/500 |
SO1 | M2 | 500 | 300/300 |
SO1 | M3 | 500 | 100/500 |
SO2 | M1 | 300 | 300/300 |
And final Ratio will be update to target DSO.
Please share some inputs.
Thanks,
Somesh.
Hi Somesh,
Here is the solution to your requirement.
Data in Infocube
DATA:
t_temp TYPE STANDARD TABLE OF _ty_s_tg_1,
w_temp TYPE _ty_s_tg_1.
DATA: w_saloffice TYPE /bic/saloffice ' (data element of sales office),
w_sal TYPE /bi0/oitotal.
CLEAR: t_temp.
t_temp[] = RESULT_PACKAGE[].
SORT RESULT_PACKAGE BY /bic/saloffice /bic/material.
SORT t_temp BY /bic/saloffice /bic/material.
LOOP AT RESULT_PACKAGE ASSIGNING <result_fields>.
IF sy-tabix EQ 1.
w_saloffice = <result_fields>-/bic/saloffice.
ENDIF.
IF w_saloffice NE <result_fields>-/bic/saloffice.
CLEAR: w_saloffice, w_sal.
w_saloffice = <result_fields>-/bic/saloffice.
ENDIF.
LOOP AT t_temp INTO w_temp WHERE /bic/saloffice =
<result_fields>-/bic/saloffice.
w_sal = w_temp-total + w_sal.
ENDLOOP.
IF sy-subrc EQ 0.
DELETE t_temp WHERE /bic/saloffice EQ w_saloffice.
ENDIF.
<result_fields>-/bic/ratio = <result_fields>-total / w_sal.
ENDLOOP.
clear: t_temp.
After executing DTP above code will process in end routine , will data in DSO as like blow(as per requirement)
Purchase document = Sales office
Test 1 = Material
Try this.
Regards,
Nanda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
10 | |
9 | |
9 | |
6 | |
5 | |
5 | |
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.