on 04-20-2015 6:56 PM
Hello friends
I have a new requirement, but I am unable to resolve it with minimum time spent in a loop and/or the requirement per say.
We have a PSA source with the following fields
Tag | Service No. | ERDAT |
A | 123 | 20150401 |
A | 345 | 20150402 |
A | 567 | 20150420 |
Now we move this in a DSO (key field: Service no.). The user wants another field namely RDR which should populate it according to the following logic:
If for the same tag the ERDAT is within 7 days of previous ERDAT, then RDR = 'yes', else RDR='no'. Also, the first occurrence must be RDR='blank'.
Hence, after end routine, the DSO should look like this:-
Tag | Service No. | ERDAT | RDR |
A | 123 | 20150401 | |
A | 345 | 20150402 | Yes |
A | 567 | 20150420 | No |
Now, the problem is that the source brings in 7 days of data. Hence, all the 7 day old records/line items come up every time DTP fetches the records.
Can you please let me know the logic atleast to handle this scenario. Ive tried several ways but it doesnt give the correct results or in the shortest period of time.
Thanks. issue resolved.
DATA: lv_setag_sr type /BIC/OISETAG_SR.
DATA: lv_dat type /BI0/OIDATE.
DATA: lv_date_diff type i.
SORT RESULT_PACKAGE BY /BIC/SETAG_SR DATE0.
Loop at RESULT_PACKAGE assigning <RESULT_FIELDS>.
if <RESULT_FIELDS>-/BIC/SETAG_SR = lv_setag_sr.
if <RESULT_FIELDS>-dat0 gt lv_dat.
lv_date_diff = <RESULT_FIELDS>-dat0 - lv_dat .
if lv_date_diff le 7.
<RESULT_FIELDS>-/BIC/ZRDR = 'Yes'.
else.
<RESULT_FIELDS>-/BIC/zrdr = 'No'.
endif.
endif.
endif.
lv_setag_sr = <RESULT_FIELDS>-/BIC/SETAG_SR.
lv_dat = <RESULT_FIELDS>-dat0.
EndLoop.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anubhav,
be aware that DTP splits input data by packages (no. of records controlled by the "Package size" field in DTP); could happen that a set of TAGs that you want to evaluate together, come in different packages.
To avoid this, maitain Semantic Group option for the DTP, based on the transformation with the end routine
Regards,
Gabriele
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try this code:
SORT result_package by TAG ERDAT.
data: ls_previous like <result_fields>.
LOOP AT result_package assigning <result_fields>.
if ls_previous-tag = <result_fields>-tag.
if <result_fields>-erdat <= ls_previous-erdat + 7.
<result_fields>-rdr = 'Yes'.
else.
<result_fields>-rdr = 'No'.
endif.
endif.
ls_previous = <result_fields>.
ENDLOOP.
Regards,
Suhas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes. That's the requirement. 1 service tag will have 1 line item created on 1 April. If a new line item with new service number (new line item always has new service number for same tag...condition at r3) is created, then compare its date with previous date.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anubhav,
Do you have multiple records for service tab 345 ? how you are deciding RDR "Yes" for this service tag since this is only one record, your comparing with current date or same service number with other record which is not available in example data, please confirm.
Thank you,
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 |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.