2011 Apr 08 8:40 PM
Using VA42, I have to create the Billing Plan for contract line items.
I find many Function Modules and BAPIs to update the existing Billing Plan for the contract line.
Any idea about how to create one? Any BAPI/FM?
Pranu
Using VA42, I have to create the Billing Plan for contract line items.
I find many Function Modules and BAPIs to update the existing Billing Plan for the contract line.
Any idea about how to create one? Any BAPI/FM?
Pranu
2011 Apr 09 6:20 AM
You can update billing plan using following Function module.
*&---------------------------------------------------------------------*
*& UPDATE Billing Plan
*&---------------------------------------------------------------------*
i_bapi_view-header = 'X'.
i_bapi_view-item = 'X'.
i_bapi_view-partner = 'X'.
i_bapi_view-contract = 'X'.
i_bapi_view-sdcond = 'X'.
i_bapi_view-sdcond_add = 'X'.
i_bapi_view-billplan = 'X'.
i_bapi_view-configure = 'X'.
sales_documents-vbeln = v_order.
APPEND sales_documents.
CALL FUNCTION 'BAPISDORDER_GETDETAILEDLIST'
EXPORTING
i_bapi_view = i_bapi_view
TABLES
sales_documents = sales_documents
order_headers_out = order_headers_out
order_items_out = order_items_out
order_contracts_out = order_contracts_out
order_billingplans_out = order_billingplans_out
order_billingdates_out = order_billingdates_out
order_partners_out = order_partners_out
order_conditions_out = order_conditions_out.
LOOP AT order_billingplans_out WHERE itm_number = '000000'.
hfplnr = order_billingplans_out-bill_plan.
ENDLOOP.
LOOP AT tab WHERE kbetr IS NOT INITIAL.
LOOP AT order_conditions_out WHERE itm_number = tab-itm_number
AND cond_type = 'ZZRE'.
MOVE-CORRESPONDING order_conditions_out TO cond_ch.
IF order_conditions_out-cond_type = 'ZZRE'.
cond_ch-cond_value = tab-kbetr.
APPEND cond_ch.
ENDIF.
ENDLOOP.
ENDLOOP.
* Read the billing plan
CALL FUNCTION 'BILLING_SCHEDULE_READ'
EXPORTING
fplnr = hfplnr
TABLES
zfpla = hfpla
zfplt = hfplt.
MOVE hfpla TO hfpla2.
*READ TABLE zfpla2 INDEX 1.
hfpla2-lodat = p_stat.
hfpla2-tndat = p_end.
hfpla2-rfpln = ''.
hfpla2-lodar = ''.
hfpla2-tndar = ''.
hfpla2-fpart = p_bplan.
hfpla2-perio = p_bplan.
hfpla2-horiz = p_hori.
*** Very important to set field updkz = 'U' ***
hfpla2-updkz = 'U'. "--> UPDATE!!
APPEND hfpla2.
CLEAR pos.
CALL FUNCTION 'BILLING_SCHEDULE_SAVE'
TABLES
fpla_new = hfpla2
fpla_old = hfpla
fplt_new = hfplt " --> NEW
fplt_old = hfplt.
CALL FUNCTION 'SD_SALES_DOCUMENT_SAVE'
EXPORTING
i_no_messages = ' '.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
*&---------------------------------------------------------------------*
*& END OF UPDATE Billing Plan Header level
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& UPDATE Billing Plan Item level
*&---------------------------------------------------------------------*
LOOP AT zbill.
MOVE v_order TO doc .
CALL FUNCTION 'SD_SALES_DOCUMENT_READ'
EXPORTING
document_number = doc.
MOVE zbill-itm_number TO pos.
CALL FUNCTION 'SD_SALES_BILLINGPLAN_READ'
EXPORTING
i_vbeln = doc
i_posnr = pos
IMPORTING
e_fpla = e_fpla
TABLES
e_fplt = e_fplt
EXCEPTIONS
no_billingplan_allowed = 1
no_billingplan_found = 2
OTHERS = 3.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Read the billing plan
CALL FUNCTION 'BILLING_SCHEDULE_READ'
EXPORTING
fplnr = e_fpla-fplnr
* I_VFKDAT =
* I_BFKDAT =
TABLES
zfpla = zfpla
zfplt = zfplt.
* Upddate the ZFPLT2 table with the new values
*MOVE zfplt TO zfplt2.
MOVE zfpla TO zfpla2.
*READ TABLE zfpla2 INDEX 1.
zfpla2-lodat = zbill-datesfrom.
zfpla2-tndat = zbill-datesto.
zfpla2-rfpln = ''.
zfpla2-lodar = ''.
zfpla2-tndar = ''.
zfpla2-fpart = p_bplan.
zfpla2-horiz = p_hori.
*** Very important to set field updkz = 'U' ***
zfpla2-updkz = 'U'. "--> UPDATE!!
APPEND zfpla2.
ENDLOOP.
CLEAR pos.
CALL FUNCTION 'BILLING_SCHEDULE_SAVE'
TABLES
fpla_new = zfpla2
fpla_old = zfpla
fplt_new = zfplt " --> NEW
fplt_old = zfplt.
CALL FUNCTION 'SD_SALES_DOCUMENT_SAVE'
EXPORTING
i_no_messages = ' '.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
Edited by: Krupaji on Apr 9, 2011 7:21 AM
2011 Apr 09 6:24 AM
I know I can update. Thanks.
But my question is how to create.
As a conversion and cut over, the contracts are created and now I want to create the billing plans.
Pranu
2011 Apr 09 7:04 AM
when u create contract order automatically billing plan created above code u can update billing plan
2011 Apr 11 5:39 AM
2011 Apr 11 9:59 PM
Your Function Modules will work if the Billing Plan Number is available.
In other words, it will update the existing Billing Plans that are present in FPLT table.
In the FM you gave, we have to pass the Billing Plan Number (FPLNR). FPLNR is available in VBKD.
This will return the Plan Details and I can edit it.
What My Question is:
1. How to create one.
My contract does does not have FPLNR in VBKD and FPLT is empty.
I want to create the Billing Plan so that the FPLNR will be created and FPLT will be populated.
The Plan B for me is to run BDC but I am more intrested in FM or BAPI.
Any help would be appretiated.
Pranu
2015 Nov 04 3:14 AM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |