Hi Amit,
I was testing the above code everything was fine but few records are drop after the routine.
Example I have 6000093 is Sales Document with Line 90001, 90002, 9003 but After Updating the Data I am seeing only the Latest Line Item.
I.e Sales Document 6000093 with 90001 Sales Item. Please advice on the same.
I have both Document and Line Items as Keys in the DSO.
Below id the Code I have
ypes: BEGIN OF ty_AZSD_O13600,
/BIC/ZBILL_DOC type /BIC/OIZBILL_DOC,
/BIC/ZBILL_ITM type /BIC/OIZBILL_ITM,
KNART type /BI0/OIKNART,
KNVAL type /BI0/OIKNVAL,
end of ty_AZSD_O13600.
data : it_AZSD_O13600 type STANDARD TABLE OF ty_AZSD_O13600.
data : wa_AZSD_O13600 type ty_AZSD_O13600,
WA_result_package type _ty_s_TG_1.
If not RESULT_PACKAGE[] is INITIAL.
select /BIC/ZBILL_DOC
/BIC/ZBILL_ITM
KNART
KNVAL
from /BIC/AZSD_O13600
into TABLE it_AZSD_O13600 FOR ALL ENTRIES IN RESULT_PACKAGE
where /BIC/ZBILL_DOC eq RESULT_PACKAGE-/BIC/ZBILL_DOC
and /BIC/ZBILL_ITM eq RESULT_PACKAGE-/BIC/ZBILL_ITM.
if sy-subrc eq 0.
sort it_AZSD_O13600 by /BIC/ZBILL_DOC /BIC/ZBILL_ITM.
endif.
Endif.
LOOP AT RESULT_PACKAGE ASSIGNING <result_fields> .
* if not it_AZSD_O13600[] is INITIAL and
* not RESULT_PACKAGE[] is INITIAL.
*LOOP AT RESULT_PACKAGE ASSIGNING <result_fields> .
* clear: wa_result_package.
* clear:wa_AZSD_O13600.
*loop at RESULT_PACKAGE into <result_fields>.
LOOP AT it_AZSD_O13600 INTO WA_AZSD_O13600
WHERE /BIC/ZBILL_DOC = <RESULT_FIELDS>-/BIC/ZBILL_DOC.
<RESULT_FIELDS>-/BIC/ZBILL_ITM =
WA_AFSD_O13600-/BIC/ZBILL_ITM.
* read table it_AFSD_O13600 into wa_AFSD_O13600
* with key /BIC/ZBILL_DOC =
* <result_fields>-/BIC/ZBILL_DOC
* /BIC/ZBILL_ITM =
*<result_fields>-/BIC/ZBILL_ITM binary
* search .
if sy-subrc eq 0.
If wa_AZSD_O13600-KNART eq 'ZKF0' or
wa_AZSD_O13600-KNART eq 'ZKF1' OR
wa_AZSD_O13600-KNART eq 'ZKF3' OR
wa_AZSD_O13600-KNART eq 'ZKF4' OR
wa_AZSD_O13600-KNART eq 'ZKF5' OR
wa_AZSD_O13600-KNART eq 'ZKF6'.
<result_fields>-/BIC/ZHACHG = wa_AFSD_O13600-KNVAL .
elseif
wa_AZSD_O13600-KNART eq 'ZKF7' or
wa_AZSD_O13600-KNART eq 'ZKF8' .
<result_fields>-/BIC/ZACTF = wa_AZSD_O13600-KNVAL .
endif.
endif.
endloop.