Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Change Billing Plan Header End-date

former_member188001
Active Participant
0 Likes
850

All,

I have a requirement wherein, we need to change the enddate on the billing plan header level. I tried using the following functions, see the attached code, but it does not work.


LOOP AT gt_order_item_in INTO gs_order_item_in.

                 CALL FUNCTION 'SD_SALES_DOCUMENT_READ'

                   EXPORTING

                     document_number = gs_vbak-vbeln.

                 CALL FUNCTION 'SD_SALES_BILLINGPLAN_READ'

                   EXPORTING

                     i_vbeln                = gs_vbak-vbeln

                     i_posnr                = gs_order_item_in-itm_number

                   IMPORTING

                     e_fpla                 = gs_fpla

                   TABLES

                     e_fplt                 = gt_fplt

                   EXCEPTIONS

                     no_billingplan_allowed = 1

                     no_billingplan_found   = 2

                     OTHERS                 = 3.

                 IF sy-subrc <> 0.

                   MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

                           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

                 ENDIF.

                 CALL FUNCTION 'BILLING_SCHEDULE_READ'

                   EXPORTING

                     fplnr = gs_fpla-fplnr

                   TABLES

                     zfpla = gt_zfpla

                     zfplt = gt_zfplt.

*             Move to temp table

                 MOVE gt_zfplt[] TO gt_zfplt_temp[].

                 DELETE gt_zfplt_temp WHERE fkdat GT '20141231'.

                 SORT gt_zfplt_temp BY fkdat DESCENDING.

                 CLEAR gs_fplt.

                 READ TABLE gt_zfplt_temp INTO gs_fplt INDEX  1.

                 MOVE gt_zfpla[] TO gt_fpla_new[].

                 CLEAR gs_fpla.

                 READ TABLE gt_fpla_new INTO gs_fpla INDEX 1.

                 gs_fpla-endat = gs_fplt-nfdat.

                 MODIFY gt_fpla_new FROM gs_fpla INDEX 1.

                 CALL FUNCTION 'BILLING_SCHEDULE_SAVE'

                   TABLES

                     fpla_new = gt_fpla_new  " --> NEW

                     fpla_old = gt_zfpla

                     fplt_new = gt_zfplt

                     fplt_old = gt_zfplt.

                 CALL FUNCTION 'SD_SALES_DOCUMENT_SAVE'.

                 CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

                   EXPORTING

                     wait = 'X'.

                 CLEAR: gs_order_item_in, gs_fpla, gt_fplt,gt_zfpla,gt_zfplt,gt_zfplt_temp,gt_fpla_new .

               ENDLOOP.

Regards,

Salil

1 ACCEPTED SOLUTION
Read only

former_member188001
Active Participant
0 Likes
678

Found it myself.

You need to populate  updkz with I/U/D.

All,

I have a requirement wherein, we need to change the enddate on the billing plan header level. I tried using the following functions, see the attached code, but it does not work.


LOOP AT gt_order_item_in INTO gs_order_item_in.

                 CALL FUNCTION 'SD_SALES_DOCUMENT_READ'

                   EXPORTING

                     document_number = gs_vbak-vbeln.

                 CALL FUNCTION 'SD_SALES_BILLINGPLAN_READ'

                   EXPORTING

                     i_vbeln                = gs_vbak-vbeln

                     i_posnr                = gs_order_item_in-itm_number

                   IMPORTING

                     e_fpla                 = gs_fpla

                   TABLES

                     e_fplt                 = gt_fplt

                   EXCEPTIONS

                     no_billingplan_allowed = 1

                     no_billingplan_found   = 2

                     OTHERS                 = 3.

                 IF sy-subrc <> 0.

                   MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

                           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

                 ENDIF.

                 CALL FUNCTION 'BILLING_SCHEDULE_READ'

                   EXPORTING

                     fplnr = gs_fpla-fplnr

                   TABLES

                     zfpla = gt_zfpla

                     zfplt = gt_zfplt.

*             Move to temp table

                 MOVE gt_zfplt[] TO gt_zfplt_temp[].

                 DELETE gt_zfplt_temp WHERE fkdat GT '20141231'.

                 SORT gt_zfplt_temp BY fkdat DESCENDING.

                 CLEAR gs_fplt.

                 READ TABLE gt_zfplt_temp INTO gs_fplt INDEX  1.

                 MOVE gt_zfpla[] TO gt_fpla_new[].

                 CLEAR gs_fpla.

                 READ TABLE gt_fpla_new INTO gs_fpla INDEX 1.

                 gs_fpla-endat = gs_fplt-nfdat.

                 MODIFY gt_fpla_new FROM gs_fpla INDEX 1.

                 CALL FUNCTION 'BILLING_SCHEDULE_SAVE'

                   TABLES

                     fpla_new = gt_fpla_new  " --> NEW

                     fpla_old = gt_zfpla

                     fplt_new = gt_zfplt

                     fplt_old = gt_zfplt.

                 CALL FUNCTION 'SD_SALES_DOCUMENT_SAVE'.

                 CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

                   EXPORTING

                     wait = 'X'.

                 CLEAR: gs_order_item_in, gs_fpla, gt_fplt,gt_zfpla,gt_zfplt,gt_zfplt_temp,gt_fpla_new .

               ENDLOOP.

Regards,

Salil

1 REPLY 1
Read only

former_member188001
Active Participant
0 Likes
679

Found it myself.

You need to populate  updkz with I/U/D.