cancel
Showing results for 
Search instead for 
Did you mean: 

SAP BW End Routine Help

anubhav_kumar2
Explorer
0 Kudos

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

TagService No.    ERDAT
A12320150401
A34520150402
A56720150420

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:-

TagService No.     ERDAT           RDR
A12320150401
A34520150402   Yes
A56720150420       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.

Accepted Solutions (0)

Answers (5)

Answers (5)

anubhav_kumar2
Explorer
0 Kudos

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.

gabrielenosatti
Explorer
0 Kudos

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

former_member185132
Active Contributor
0 Kudos

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

anubhav_kumar2
Explorer
0 Kudos

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.

ccc_ccc
Active Contributor
0 Kudos

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