Transformation: Issue in End-Routine
Dear all ;
Currently I’m having an issue in the end routine and I hope you can help me.
The goal is, in a transformation between 2 DSOs, populate a counter.
In DSO 1 (source) I have as key the Delivery and Shipment (1:1) were in DSO 2 (target) the Delivery and Material. I can have multiple materials per delivery and the counter should be populated in all.
In the start routine:
TYPES: BEGIN OF s_odgi,
deliv_numb TYPE /bi0/oideliv_numb,
/material TYPE //bi0/oimaterial,
END OF s_odgi.
DATA: it_odgi TYPE SORTED TABLE OF s_odgi
WITH NON-UNIQUE KEY deliv_numb,
wa_odgi TYPE s_odgi.
DATA: it_odgi_aux TYPE STANDARD TABLE OF s_odgi,
wa_odgi_aux TYPE s_odgi.
DATA: t_sp TYPE STANDARD TABLE OF _ty_s_sc_1 .
t_sp = SOURCE_PACKAGE .
SORT t_sp BY deliv_numb .
DELETE ADJACENT DUPLICATES FROM t_sp COMPARING deliv_numb .
DELETE t_sp WHERE deliv_numb IS INITIAL .
SELECT deliv_numb material
INTO TABLE it_odgi_aux FROM /BIC/ADSO1V00
FOR ALL ENTRIES IN t_sp
WHERE deliv_numb = t_sp-deliv_numb.
SORT it_odgi_aux BY deliv_numb material.
* DELETE ADJACENT DUPLICATES FROM it_odgi_aux COMPARING
it_odgi = it_odgi_aux.
In the transformation:
ZCOUNTER as constant 1
In the End-Routine:
LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
LOOP AT it_odgi INTO wa_odgi
WHERE DELIV_NUMB = <RESULT_FIELDS>-DELIV_NUMB.
IF sy-subrc = 0.
I also try this one :
LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>
WHERE DELIV_NUMB IS NOT INITIAL.
READ TABLE it_odgi INTO wa_odgi
WITH TABLE KEY DELIV_NUMB = <RESULT_FIELDS>-DELIV_NUMB.
IF sy-subrc = 0.
<RESULT_FIELDS>-/material = wa_ODGI-material.
But the result is the same : one the last material of the sort will be delivered.
I note the different materials are in it_odgi but the loop will overwrite the last one.
Can anyone help?
Thanks in advance