Introduction:
The transaction code ES31 is used to update the rate category at the installation level. In this article we shall work out updating the rate category at the installation level through programming.
Steps through SAP transaction ES31:
ES31 Initial Screen
Under Installation Time-dependent data section, provide new rate category and click ‘SAVE’.
Steps through a program: Sample Code
DATA : wa_obj TYPE isu01_instln,
wa_auto TYPE isu01_instln_auto,
l_installation TYPE anlage,
l_new_rate_category TYPE tariftyp.
*-----Open the Installation in change mode-----*
CALL FUNCTION 'ISU_S_INSTLN_PROVIDE'
EXPORTING
x_anlage = l_installation "Pass Installation Number Here!
x_keydate = '20160105' "This is the Key Date
x_wmode = '2' "Open up the installation in change mode
IMPORTING
y_obj = wa_obj
y_auto = wa_auto
EXCEPTIONS
not_found = 1
invalid_keydate = 2
foreign_lock = 3
not_authorized = 4
invalid_wmode = 5
general_fault = 6
OTHERS = 7.
IF sy-subrc NE 0.
*--------------Handle failures
RETURN.
ELSE.
SORT wa_obj-eanlh BY bis DESCENDING.
READ TABLE wa_obj-eanlh INDEX 1
ASSIGNING FIELD-SYMBOL(<lfs_eanlh>).
<lfs_eanlh>-tariftyp = l_new_rate_category. "Pass the new rate category here!
ENDIF.
*-----Instructions to save the changes-----*
wa_auto-contr-okcode = 'SAVE'.
wa_auto-contr-use-okcode = 'X'.
wa_obj-auto-contr-use-okcode = 'X'.
wa_obj-auto-contr-okcode = 'SAVE'.
*-----Provide the updated values and instructions for update-----*
CALL FUNCTION 'ISU_S_INSTLN_CHANGE'
EXPORTING
x_anlage = l_installation
x_keydate = '20160105'
x_prorate = 'X'
x_upd_online = 'X'
x_no_dialog = 'X'
x_auto = wa_auto
x_obj = wa_obj
EXCEPTIONS
not_found = 1
foreign_lock = 2
not_authorized = 3
cancelled = 4
input_error = 5
general_fault = 6
OTHERS = 7.
IF sy-subrc NE 0.
*---------------Handle failures
ENDIF.