Skip to Content
0
5 days ago

Billing plan is not linked with Sales Order

105 Views Last edit 5 days ago 2 rev

Hello All,

I have a requirement to create billing plan(Milestones) and link them to each sales order line item. I am using below BAPIs and logic in my program but it’s not working. I observed that billing plan is getting created in tables FPLA and FPLT but is not linked in Sales order under "Billing Plan" tab at line item level. Please help me with your inputs/suggestions. Thanks a lot.

BILLING_SCHEDULE_GENERATE

BILLING_SCHEDULE_GET_NUMBER

BILLING_SCHEDULE_SAVE

SD_SALES_DOCUMENT_SAVE

BAPI_TRANSACTION_COMMIT

SD_SALESDOCUMENT_CHANGE

BAPI_TRANSACTION_COMMIT

REPORT z_billing_plan.

TABLES : vbak.

DATA : ls_vbak TYPE vbak,

ls_mlst TYPE mlst,

lt_vbap TYPE TABLE OF vbap,

ls_vbap TYPE vbap,

ls_veda TYPE vedavb,

lv_fpart TYPE tfpla-fpart,

lv_fkdat TYPE vbkd-fkdat,

lv_fplnr TYPE fpla-fplnr,

lt_fpla_new TYPE TABLE OF fplavb,

lt_fpla_old TYPE TABLE OF fplavb,

lt_fplt_new TYPE TABLE OF fpltvb,

ls_fplt_new TYPE fpltvb,

lt_fplt_old TYPE TABLE OF fpltvb,

ev_fplnr TYPE fpla-fplnr,

ls_order_header_x TYPE bapisdhd1x,

logic_switch TYPE bapisdls,

lt_return12 TYPE TABLE OF bapiret2,

lv_vbeln TYPE vbuk-vbeln,

* lv_salesdocument TYPE bapivbeln-vbeln

lv_salesdocument TYPE bapivbeln-vbeln,

li_headx TYPE bapisdh1x,

li_return TYPE TABLE OF bapiret2,

lv_vgbel TYPE vbap-vgbel,

ls_evbak TYPE vbak,

ls_oikexport TYPE roikexport,

lt_item TYPE TABLE OF bapisditm,

ls_item TYPE bapisditm,

lt_itemx TYPE TABLE OF bapisditmx,

ls_itemx TYPE bapisditmx,

ls_fpla TYPE fpla.

.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS : s_vbeln FOR vbak-vbeln.

PARAMETERS : p_posid TYPE ps_posid.

SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.

SELECT SINGLE * FROM vbak INTO ls_vbak WHERE vbeln IN s_vbeln.

CALL FUNCTION 'CONVERSION_EXIT_ABPSP_INPUT'

EXPORTING

input = p_posid

IMPORTING

output = p_posid

EXCEPTIONS

not_found = 1

OTHERS = 2.

SELECT SINGLE * FROM mlst INTO ls_mlst WHERE pspnr = p_posid.

SELECT * FROM vbap INTO TABLE lt_vbap

WHERE vbeln IN s_vbeln.

LOOP AT lt_vbap INTO ls_vbap.

IF ls_vbap-matnr NE 'SVO_CREATION'.

ls_veda-mandt = '005'.

ls_veda-vbeln = ls_vbap-vbeln.

ls_veda-vposn = ls_vbap-posnr.

lv_fpart = 'Z1'.

ls_item-itm_number = ls_vbap-posnr.

ls_item-material = ls_vbap-matnr.

ls_item-plant = ls_vbap-werks.

ls_item-short_text = ls_vbap-arktx.

APPEND ls_item TO lt_item.

ls_itemx-itm_number = 'X'.

ls_itemx-material = 'X'.

ls_itemx-plant = 'X'.

ls_itemx-short_text = 'X'.

APPEND ls_itemx TO lt_itemx.

CALL FUNCTION 'BILLING_SCHEDULE_GENERATE'

EXPORTING

* I_FPLNR = ' '

* I_WAERS = ' '

i_fpart = lv_fpart "'ZF1'

i_veda = ls_veda

i_fkdat = lv_fkdat

i_upd_fpla = 'X'

* i_upd_fplt = 'X'

* I_KOMK =

* I_KOMP =

* I_KOMPAX =

i_fpla_only = 'X'

* I_FKREL = ' '

* I_VEDA_KOPF =

* I_CREATE_DATES = ' '

* I_KFPLAN = ' '

* I_KFPLNR = ' '

* I_NOMSG = ' '

* I_ABSAGEN = ' '

* I_FPLAA =

IMPORTING

e_fplnr = lv_fplnr

* E_DATALOSS =

* E_UPD_FPLA =

* E_UPD_FPLT =

* E_KOMPAX =

TABLES

fpla_new = lt_fpla_new

fpla_old = lt_fpla_old

fplt_new = lt_fplt_new

fplt_old = lt_fplt_old

** I_FPLTS =

* I_FPLTNP =

* I_KOMV =

* I_TKOMK =

* I_SVBAP =

.

lv_vbeln = s_vbeln-low.

CALL FUNCTION 'BILLING_SCHEDULE_GET_NUMBER'

EXPORTING

i_fplnr = lv_fplnr

i_vbeln = lv_vbeln

* I_AUFPL = ' '

* I_APLZL = ' '

* I_RSNUM = ' '

* I_RSPOS = ' '

IMPORTING

e_fplnr = ev_fplnr

TABLES

fpla_new = lt_fpla_new

fplt_new = lt_fplt_new.

ls_fplt_new-fplnr = ev_fplnr.

ls_fplt_new-fpltr = '000001'.

ls_fplt_new-fpttp = '01'.

ls_fplt_new-fkdat = '20221231'.

ls_fplt_new-fpfix = '1'.

ls_fplt_new-fareg = '1'.

ls_fplt_new-fproz = ls_mlst-fproz.

ls_fplt_new-fakwr = '0'.

ls_fplt_new-faksp = '02'.

ls_fplt_new-fkarv = 'ZF1'.

ls_fplt_new-fksaf = 'A'.

ls_fplt_new-mlstn = ls_mlst-mlst_zaehl.

ls_fplt_new-mlbez = ls_mlst-mlstn.

ls_fplt_new-afdat = '20221231'.

ls_fplt_new-updkz = 'I'.

ls_fplt_new-waers = 'EUR'.

ls_fplt_new-fproz = '100'.

APPEND ls_fplt_new TO lt_fplt_new.

CALL FUNCTION 'BILLING_SCHEDULE_SAVE'

TABLES

fpla_new = lt_fpla_new

fpla_old = lt_fpla_old

fplt_new = lt_fplt_new

fplt_old = lt_fplt_old.

lv_vgbel = s_vbeln-low.

CALL FUNCTION 'SD_SALES_DOCUMENT_SAVE'

EXPORTING

* referenced_document_number = lv_vgbel

* synchron = 'X'

* status_buffer_refresh = 'X'

* requisition_buffer_refresh = 'X'

i_no_messages = ' '

IMPORTING

evbak = ls_evbak.

* e_oikexport = ls_oikexport.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

REFRESH :lt_fpla_new,lt_fpla_old,lt_fplt_new, lt_fplt_old.

ENDIF.

ENDLOOP.

lv_salesdocument = lv_vgbel.

ls_order_header_x-updateflag = 'U'.

* logic_switch-cond_handl = 'X'.

CALL FUNCTION 'SD_SALESDOCUMENT_CHANGE'

EXPORTING

salesdocument = lv_salesdocument

order_header_inx = ls_order_header_x

* logic_switch = logic_switch

TABLES

return = lt_return12

item_in = lt_item

item_inx = lt_itemx.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

Thanks,

Ravindra