Change Invoice/Billing Plan

function zfm_change_invoice_plan.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(FPLNR) LIKE FPLT-FPLNR OPTIONAL
*" VALUE(FPLTR) LIKE FPLT-FPLTR OPTIONAL
*" VALUE(AFDAT_NEW) LIKE FPLT-AFDAT OPTIONAL
*" EXPORTING
*" VALUE(MESSAGE) TYPE CHAR512
*" TABLES
*" INVOICE_PLAN_LIST STRUCTURE ZMMGA_ST_PO_BLANKET_ITEM_INV
*" OPTIONAL
*"----------------------------------------------------------------------
*&Program name and title : Change Invoice Plan
*&Author : Albertus Reinandang
*&Creation date : 28.09.2009
*&Purpose of the program : Oracle Integration
*&SAP version : SAP 4.6C
*&---------------------------------------------------------------------*

data : lv_count type i.

data : lw_fpla like fpla,
lw_fplt like fpltvb,
li_fplt like standard table of fplt with header line,
li_fpla_old like standard table of fplavb with header line,
li_fpla_new like standard table of fplavb with header line,
li_fplt_old like standard table of fpltvb with header line,
li_fplt_new like standard table of fpltvb with header line.

* Collect Invoice Plan
call function 'BILLING_SCHEDULE_READ'
exporting
fplnr = fplnr
tables
* zfpla = li_fpla
zfplt = li_fplt_new.

describe table li_fplt_new lines lv_count.
if lv_count = 0.
message = 'Failed'.
else.
"Set New Value
loop at li_fplt_new where fpltr = fpltr.

li_fplt_new-afdat = afdat_new.
li_fplt_new-updkz = 'U'.
modify li_fplt_new.

endloop.

"Save New Value
call function 'BILLING_SCHEDULE_SAVE'
tables
fpla_new = li_fpla_old
fpla_old = li_fpla_new
fplt_old = li_fplt_old
fplt_new = li_fplt_new.

"Get New Value of Invoice Plan from SAP Table
select *
into corresponding fields of table li_fplt
from fplt
where fplnr = fplnr.

loop at li_fplt.
clear invoice_plan_list.
move-corresponding li_fplt to invoice_plan_list.
append invoice_plan_list.
endloop.
message = 'Succeed'.
endif.
endfunction.

Comments