on 08-14-2015 12:39 PM
Hi experts
Below is a screen from a master data table in ERP.
Key fields VTREF and SETFLAG.
The data field MDRKD is a date field.
In BW extracted a transformation should generate time dependent records, example for VTREF = 0001:
0001 F 26.01.2005 23.03.2005
0001 P 24.03.2005 10.02.2005
and so forth...
Is there any coding sample for such a requirement?
Thanks
T.
Hi Thomas,
I don't have a coding example available but the logic should not be too difficult.
You have to sort the data package on key fields in ascending order and time field in descending order. Then you loop over the data package.
You need variables to record the previously processed key fields in order to detect a new combination and to start the Valid To with 31/12/9999. You also need a variable to record the previously processed Valid From date. The Valid To date for the next time slice of the same combination will be the previously processed Valid From date + 1 day.
Note: if the data load would split up in more than one data package, then you will need Semantic Grouping on the key fields in order to keep the groups in the same data package.
Best regards,
Sander
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi all
We have done the sorting in the start routine.
The endroutine also works fine, except when having duplicates in field MDRKD.
You can see the duplicates in the screen above.
We don't need these two lines at all. How can we get rid off these lines? What is the proper
ABAP coding?
Thanks
T.
IF RESULT_PACKAGE[] IS NOT INITIAL.
LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
IF WA_TARGET-FC_VTREF IS NOT INITIAL.
IF WA_TARGET-FC_VTREF = <RESULT_FIELDS>-FC_VTREF
AND WA_TARGET-DATEFROM < <RESULT_FIELDS>-DATEFROM.
WA_TARGET-DATETO = <RESULT_FIELDS>-DATEFROM - 1.
ELSE.
WA_TARGET-DATETO = '99991231'.
ENDIF.
APPEND WA_TARGET TO ITAB_TARGET.
CLEAR: <result_fields>.
ENDIF.
WA_TARGET = <RESULT_FIELDS>.
ENDLOOP.
REFRESH RESULT_PACKAGE.
RESULT_PACKAGE[] = ITAB_TARGET[].
ENDIF.
Hi Thomas,
The trick must be to sort the RESULT_PACKAGE on key field(s) in ascending order and date field in descending order. After that delete adjacent duplicates comparing the key field(s). If I understand it correctly, the only key field to take into account is VTREF.
Coding could then look like this:
SORT RESULT_PACKAGE BY VTREF ASCENDING MDRKD DESCENDING.
DELETE ADJACENT DUPLICATES FROM RESULT_PACKAGE COMPARING VTREF.
Best regards,
Sander
Hi Sander
We need to delete the duplicates completely.
DELETE ADJACENT is not enough.
Key field is VTREF and SETFLAG.
In the example below you can see one key field VTREF value (covered) and two SETFLAG values, F and P. Data field MDRDD is 11.02.2009.
We don't need these two lines, both have to be deleted.
Therefore DELETE ADJACENT is not the right coding...
Any ideas?
Thanks
T.
Hi Thomas,
That's not an easy requirement but could the following approach work for you:
Best regards,
Sander
Load it via a time dependent datasource and the system will automatically do this for you give the valid from date as the date mentioned.
BR,
Suyash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Suyash
I have only one date field, DATETO. DATEFROM has to be generated.
Check the screen above or
how to set datasource time dependant? | SCN
Regards
T
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.