2023 Mar 14 12:39 PM
Hi everyone,
I'm trying to change some billing plan information on a contract.
First of all I create the SD contract with the BAPI BAPI_CONTRACT_CREATEFROMDATA and it works perfectly.
At this point I have to change the Rule for Origin of Next Billing/Invoice Date (fpla-PERIO) and the billing date to dates.
to change the FPLA-PERIO use in this order:
SD_SALES_DOCUMENT_READ
BILLING_SCHEDULE_READ
SD_SALES_BILLINGPLAN_READ
then I change the data
SD_SALES_DOCUMENT_SAVE
BAPI_TRANSACTION_COMMIT
data lt_fplt type table of fpltvb.<br> data ls_fpla type fpla.<br> data ls_fplnr type fpla-fplnr.<br> data lt_zfplt type table of fpltvb.<br> data lt_zfpla type table of fplavb.<br>
<br> call function 'SD_SALES_DOCUMENT_READ'<br> exporting<br> document_number = iv_vbeln.<br><br> select single fplnr into ls_fplnr from fpla where vbeln = iv_vbeln.<br><br> call function 'BILLING_SCHEDULE_READ'<br> exporting<br> fplnr = ls_fplnr <br>tables<br> zfpla = lt_zfpla<br> zfplt = lt_zfplt.<br><br> check lt_zfpla[] is not initial.<br><br> read table lt_zfpla index 1 assigning field-symbol(<ls_zfpla>).<br> move-corresponding <ls_zfpla> to ls_fpla.<br><br> call function 'SD_SALES_BILLINGPLAN_READ'<br> exporting<br> i_vbeln = iv_vbeln<br> i_posnr = '00010'<br> importing<br> e_fpla = ls_fpla<br> tables<br> e_fplt = lt_fplt<br> exceptions<br> no_billingplan_allowed = 1<br> no_billingplan_found = 2<br> others = 3.<br> check sy-subrc = 0.<br><br> case iv_frequenza.<br> when '1'. ls_fpla-perio = '53'. " Mensile<br> when '2'. ls_fpla-perio = '91'. " Annuale<br> when '3'. ls_fpla-perio = 'Z5'. " Trimestrale<br> when '4'. ls_fpla-perio = 'Z6'. " Semestrale<br> when '5'. ls_fpla-perio = 'Z4'. " Bimestrale<br> when others.<br> endcase.<br><br> call function 'SD_SALES_BILLINGPLAN_CHANGE'<br> exporting<br> i_vbeln = iv_vbeln<br> i_posnr = '000010'<br> i_fpla = ls_fpla<br> i_create_dates = 'X'.<br><br> call function 'SD_SALES_DOCUMENT_SAVE' <br>exporting<br> i_no_messages = ' '.<br> <br> bapi_transaction_commit( ).<br> commit work and wait.
while for the billing date in dates I use in this order:
select * from fpla into corresponding fields of table lt_piani_fatt_old where vbeln = iv_vbeln.<br> move-corresponding lt_piani_fatt_old[] to lt_piani_fatt_new[].<br><br> select * from fplt<br> for all entries in @lt_piani_fatt_old<br> where fplnr = @lt_piani_fatt_old-fplnr<br> into corresponding fields of table @lt_piani_fatt_scadenze_old.<br> move-corresponding lt_piani_fatt_scadenze_old[] to lt_piani_fatt_scadenze_new[].<br><br><br> loop at lt_piani_fatt_scadenze_new assigning field-symbol(<ls_new_perio>).<br> <ls_new_perio>-updkz = 'U'.<br><br> case iv_frequenza.<br> when '1'. <ls_new_perio>-perio = '53'. " Mensile<br> when '2'. <ls_new_perio>-perio = '91'. " Annuale<br> when '3'. <ls_new_perio>-perio = 'Z5'. " Trimestrale<br> when '4'. <ls_new_perio>-perio = 'Z6'. " Semestrale<br> when '5'. <ls_new_perio>-perio = 'Z4'. " Bimestrale<br> when others.<br> endcase.<br> endloop.<br><br> clear: lv_righe, lv_righe_max.<br><br> loop at lt_piani_fatt_new assigning field-symbol(<ls_piano>).<br> select * from fplt into corresponding fields of table lt_temp where fplnr = <ls_piano>-fplnr.<br> describe table lt_temp lines lv_righe.<br><br> data lv_fplnr type fpla-fplnr.<br> lv_fplnr = <ls_piano>-fplnr.<br><br> if lv_righe > lv_righe_max.<br> lv_rif_piano_con_fatt = <ls_piano>-fplnr.<br> lv_righe_max = lv_righe.<br> endif.<br><br> <ls_piano>-updkz = 'U'.<br> case iv_frequenza.<br> when '1'. <ls_new_perio>-perio = '53'. " Mensile<br> when '2'. <ls_new_perio>-perio = '91'. " Annuale<br> when '3'. <ls_new_perio>-perio = 'Z5'. " Trimestrale<br> when '4'. <ls_new_perio>-perio = 'Z6'. " Semestrale<br> when '5'. <ls_new_perio>-perio = 'Z4'. " Bimestrale<br> when others.<br> endcase.<br> endloop.<br><br> loop at lt_piani_fatt_scadenze_new assigning field-symbol(<ls>) where fplnr = lv_rif_piano_con_fatt.<br><br> if <ls>-afdat < sy-datum.<br> <ls>-updkz = 'U'.<br> <ls>-afdat = sy-datum.<br> <ls>-faksp = sy-datum.<br> endif.<br> endloop.<br><br> call function 'BILLING_SCHEDULE_SAVE'<br> tables<br> fpla_new = lt_piani_fatt_new<br> fpla_old = lt_piani_fatt_old<br> fplt_new = lt_piani_fatt_scadenze_new<br> fplt_old = lt_piani_fatt_scadenze_old.<br><br> call function 'SD_SALES_DOCUMENT_SAVE'<br> exporting<br> i_no_messages = ' '.<br><br> call function 'BAPI_TRANSACTION_COMMIT'<br> exporting<br> wait = 'X'.<br><br> commit work and wait.<br>
After all these changes unfortunately I have an error in billing.
When I try to do a billing simulation with transaction VF04, I get the following error:
"No billing plan date found"
Schedule Line Number 0350
Counter in Control Tables 00
Message Identification VF
System Message Number 350
Output Type I
Group Type
Does anyone have any idea where the error is?
2023 Mar 15 1:55 PM
2023 Mar 15 3:39 PM
Hi,
No, I don't use it.
What tables or values should I consider of the BAPI to change the two data I need?
2023 Mar 15 4:03 PM
2023 Mar 16 7:21 AM