hai SDNs,
the story is bit lenghty.,,
but could any one pls help me out..
this is my final output table::
(some of the fiedls not all data)
FINAL TABLE:
CIRCLE X CONTRIBUTION PAID EXCESS PAY_DATE
ANP 3 15574 0 15574 0
ANP 9 11600 0 11600 0
HAR 6 316 0 316 0
KER 6 14052 0 14052 0
KOL 6 453.8 0 453.8 0
MAP 6 981 0 981 0
MAP 7 2741 0 2741 0
ORI 6 795.25 0 795.25 0
PUN 7 1310 6608 -5298 20041116
UPE 6 281.8 0 281.8 0
UPW 6 1695.3 0 1695.3 0
HAR 6 0 158 -158 20040930
KER 6 0 7026 -7026 20040930
PUN 6 0 10000 -10000 20040901
check the alignment it is not correct.
now i have populate the 'paid' and 'pay_date' fields from another table having contents:
GSBER MONAT DMBTR BUDAT
HAR 6 316 20040930
KER 6 7026 20040930
PUN 6 10000 20040901
PUN 8 6608 20041116
xyz 1 2200 20040981
here DMBTR = Paid amt and BUDAT = Pay_date(in above table)
so i have to do this based on conditions, checking both table GSBER and circle (in above table) AND monat = x ( in above table)
here :
case 1:
if both business area and monat are equal then modify the record,
other wise append the new record to final table.
so here i did the part of it:
CODE I have written::
<b>----
*case-1
sort lt_bsis by gsber monat.
sort lt_output by circle x.
loop at lt_bsis into lw_bsis.
lf_monat = lw_bsis-monat - 1.
loop at lt_output into lw_output where x = lf_monat and
circle = lw_bsis-gsber.
lw_output-paid = lw_bsis-dmbtr.
lw_output-pay_date = lw_bsis-budat.
if ( lw_output-paid is not initial ) and ( lw_output-pay_date is not initial ).
modify lt_output from lw_output transporting paid pay_date .
endif.
clear: lw_output, lw_bsis .
endloop.
endloop.
----
*case-2
loop at lt_bsis into lw_bsis.
lf_monat = lw_bsis-monat - 1.
if lf_monat = '00'.
lf_monat = '12'.
endif.
loop at lt_output into lw_output where x <> lf_monat and
circle = lw_bsis-gsber.
if sy-subrc = 0.
lw_output_temp-contribution = ' '.
lw_output_temp-paid = lw_bsis-dmbtr.
lw_output_temp-pay_date = lw_bsis-budat.
lw_output_temp-circle = lw_bsis-gsber.
lw_output_temp-x = lw_bsis-monat.
append lw_output_temp to lt_output_temp .
endif.
clear: lw_output_temp, lw_output, lf_monat.
endloop.
endloop.</b>
this is working fine. YOU CAN SEE THIS IN SECOND TABLE.
THERE 3 records are appended and one is modified.
the condition :
where x = lf_monat and circle <> lw_bsis-gsber.
this condition is not working.
i am unable append this particular record satisfying above condition:
<b>xyz 1 2200 20040981 </b>
thanks in advance
Hi Rama Krishna
I presume the type of fields in lt_bsis and lt_output are same.
Try the below way.
data: wa_output like lt_output.
loop at lt_bsis.
read table lt_output into lt_ouput with key
circle = lt_bsis-gsber
x = monat.
if sy-subrc ne 0.
clear lt_output.
lt_output-circle = lt_bsis-gsber.
lt_output-x = lt_bsis-monat.
lt_output-paid = lt_bsis-dmbtr.
lt_output-pay_date = lt_bsis-budat.
append lt_output.
else.
wa_output-paid = lt_bsis-dmbtr.
wa_output-pay_date = lt_bsis-budat.
modify lt_output from wa_output
transporting paid pay_date.
endif.
endloop.
Check if the above logic works for you.
Thanks
Eswar
Note: Reward for helpful answers.
But you don't have a <i>the condition :
where x = lf_monat and circle <> lw_bsis-gsber.</i>
You only have:
1.
loop at lt_output into lw_output <b>where x = lf_monat and circle = lw_bsis-gsber.</b>
and
2.
loop at lt_output into lw_output <b>where x <> lf_monat and circle = lw_bsis-gsber.</b>
Add a comment