You are on page 1of 4

How to change Billing Plan Data in

Sales Order or Contract

Normally you can create Sales Order or Contract document


using BAPI_SALESORDER_CREATEFROMDAT2 for Sales Order
and BAPI_CONTRACT_CREATEFROMDATA. But you can’t insert or
change Billing Plan data using those BAPI directly.

You can change or insert billing plan data after Sales Order or Contract
doc finish created. then you can use 2 function module i.e
BILLING_SCHEDULE_READ and BILLING_SCHEDULE_SAVE to change
or insert billing plan data.

Subroutine below is the ABAP source code to change billing plan data
in sales document.

1 FORM fm_change_billing_plan USING fu_salesdocument.

3 DATA :

4 li_fpla_old TYPE TABLE OF fplavb,

5 li_fplt_old TYPE TABLE OF fpltvb,

6 li_fpla_new TYPE TABLE OF fplavb,

7 li_fplt_new TYPE TABLE OF fpltvb,

8 lw_fplt_new TYPE fpltvb.

10 DATA : lv_fplnr TYPE fplnr,

11 lv_fpltr TYPE fpltr.

12

13 DATA : lw_fpla_old TYPE fplavb,

14 lw_fpla_new TYPE fplavb,

15 lw_fpla TYPE fpla.

16

17 DATA : li_vbkdvb TYPE TABLE OF vbkdvb,


18 lw_vbkdvb TYPE vbkdvb,

19 lv_fplnr_head TYPE fplnr.

20

21 DATA : li_vbkd TYPE TABLE OF vbkd,

22 lw_vbkd TYPE vbkd.

23

24 CONSTANTS : co_ebelp TYPE posnr_va VALUE '000010'.

25

26 REFRESH : li_fplt_new.

27 CLEAR : lv_fpltr.

28

29 CALL FUNCTION 'SD_VBKD_READ_WITH_VBELN'

30 EXPORTING

31 i_vbeln = fu_salesdocument

32 TABLES

33 et_vbkdvb = li_vbkdvb

34 et_vbkd = li_vbkd

35 EXCEPTIONS

36 record_not_found = 1

37 OTHERS = 2.

38

39

40 READ TABLE li_vbkd INTO lw_vbkd WITH KEY posnr = co_ebelp.

41 IF sy-subrc EQ 0.

42

43 CALL FUNCTION 'BILLING_SCHEDULE_READ'

44 EXPORTING

45 fplnr = lw_vbkd-fplnr

46 TABLES

47 zfpla = li_fpla_old

48 zfplt = li_fplt_old

49 EXCEPTIONS

50 error_message = 1.

51

52 li_fpla_new[] = li_fpla_old[].

53
54

55 LOOP AT gi_con_bill_plan INTO gw_con_bill_plan.

56 ADD 1 TO lv_fpltr.

57 lw_fplt_new-mandt = sy-mandt.

58 lw_fplt_new-fplnr = lw_vbkd-fplnr.

59 lw_fplt_new-fpltr = lv_fpltr.

60 lw_fplt_new-updkz = 'I'.

61 lw_fplt_new-fkdat = gw_con_bill_plan-afdat.

62 lw_fplt_new-fpttp = gw_con_bill_plan-fpttp.

63 lw_fplt_new-fproz = gw_con_bill_plan-fproz.

64 lw_fplt_new-tetxt = gw_con_bill_plan-tetxt.

65 lw_fplt_new-fareg = gw_con_bill_plan-fareg.

66

67 IF gw_con_bill_plan-curr = 'IDR'.

68 lw_fplt_new-fakwr = gw_con_bill_plan-fakwr / 100.

69 ELSE.

70 lw_fplt_new-fakwr = gw_con_bill_plan-fakwr.

71 ENDIF.

72

73 APPEND lw_fplt_new TO li_fplt_new.

74 ENDLOOP.

75

76

77 CALL FUNCTION 'BILLING_SCHEDULE_SAVE'

78 TABLES

79 fpla_new = li_fpla_new

80 fpla_old = li_fpla_old

81 fplt_new = li_fplt_new

82 fplt_old = li_fplt_old.

83

84 COMMIT WORK AND WAIT.

85

86 ENDIF.

87

88 ENDFORM.
Incoming search terms:

 bapi sap FPLT

 add new field in billing plan tab of sales order

 sap fplnr

 billing_schedule_save

 sap billing bapi

 FKDAT

 FPLT table

 sap bapi sales order billing plan

 BAPI BILLING PLAN CHANGE IN SAP SALES ORDER

 create contract with billing plan sap

You might also like