***Declared workareas & Tables for Billing plan
data :ls_zfpla_old like fplavb,
ls_zfpla2_new like fplavb,
ls_zfplt_old like fpltvb ,
ls_zfplt2_new like fpltvb ,
ls_ifplt like fpltvb.
data :lt_zfpla_old type table of fplavb,
lt_zfpla2_new type table of fplavb ,
lt_zfplt_old type table of fpltvb ,
lt_zfplt2_new type table of fpltvb .
types:
begin of ty_fpla,
fplnr type fplnr,
fpltr type fpltr,
fptyp type fptyp,
vbeln type vbeln,
end of ty_fpla.
data:
ls_fpla type ty_fpla,
lt_fpla type table of ty_fpla.
data : g_contract_no type vbeln,
lv_count type i,
lv_tabix type sy-index,
g_fplnr type fplnr,
g_fpltr type fpltr.
Select * into CORRESPONDING FIELDS OF TABLE lt_fpla
from fpla
where vbeln eq g_cont.
loop at lt_fpla into ls_fpla.
* Read the billing plan
if ls_fpla-fplnr is not initial.
call function 'BILLING_SCHEDULE_READ'
EXPORTING
fplnr = ls_fpla-fplnr
TABLES
zfpla = lt_zfpla_old
zfplt = lt_zfplt_old.
endif.
ENDLOOP.
lt_zfplt2_new[] = lt_zfplt_old[].
lt_zfpla2_new[] = lt_zfpla_old[].
Loop at lt_zfplt2_new into ls_zfplt2_new.
if G_UNBLOCK = '1'.
AT NEW FPLNR.
READ TABLE lt_zfplt2_new into ls_zfplt2_new INDEX SY-TABIX.
ls_zfplt2_new-faksp = ' '.
ls_zfplt2_new-updkz = 'U'.
MODIFY lt_zfplt2_new from ls_zfplt2_new.
ENDAT.
ELSE.
AT NEW FPLNR.
READ TABLE lt_zfplt2_new into ls_zfplt2_new INDEX SY-TABIX.
g_fplnr = ls_zfplt2_new-fplnr.
g_fpltr = ls_zfplt2_new-fpltr.
g_fpltr = g_fpltr + ( g_unblock - 1 ).
ENDAT.
IF ls_zfplt2_new-fplnr = g_fplnr and ls_zfplt2_new-fpltr = g_fpltr.
READ TABLE lt_zfplt2_new into ls_zfplt2_new INDEX SY-TABIX.
ls_zfplt2_new-faksp = ' '.
ls_zfplt2_new-updkz = 'U'.
MODIFY lt_zfplt2_new from ls_zfplt2_new.
ENDIF.
ENDIF.
Endloop.
**Update the billing plan details(Billing date)
if lt_zfpla2_new is not initial.
call function 'BILLING_SCHEDULE_SAVE' "IN UPDATE TASK
tables
fpla_new = lt_zfpla2_new "--> NEW
fpla_old = lt_zfpla_old
fplt_new = lt_zfplt2_new " --> NEW
fplt_old = lt_zfplt_old.
endif.
if sy-subrc eq 0.
call function 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = ' '. "'X'.
endif.
clear: ls_fpla.
refresh lt_zfplt2_new[].
refresh lt_zfplt_old[].
refresh lt_zfpla_old[].
refresh lt_zfpla2_new[].
* endloop.
describe table lt_fpla lines lv_count.
write:/ 'Successfully updated records :', lv_count.
No comments:
Post a Comment