Hello, attached an example to change the date statistics of distributions (variable SLFDT ), you just have to pass the parameters and call the routine.
EXAMPLE:
FORM CHANGE_SLFDT USING EBELN EBELP ETENR STAT_DATE.
DATA: ERROR TYPE SY-SUBRC.
DATA: POSCHEDULE LIKE BAPIMEPOSCHEDULE OCCURS 0 WITH HEADER LINE.
DATA: POSCHEDULEX LIKE BAPIMEPOSCHEDULX OCCURS 0 WITH HEADER LINE.
DATA : l_msgty TYPE c,
l_msgid(2) TYPE c,
l_msgno(3) TYPE c,
l_msgtx(100) TYPE c,
l_errflag TYPE c.
CONSTANTS: c_x TYPE c VALUE 'X',
c_hyp TYPE c VALUE '-',
c_err TYPE bdc_mart VALUE 'E'.
DATA : BEGIN OF t_bapireturn OCCURS 0.
INCLUDE STRUCTURE bapiret2.
DATA : END OF t_bapireturn.
DATA: WA_EKPO LIKE EKPO.
DATA: ELIKZ_AUX LIKE EKPO-ELIKZ.
DATA: EKPO_MSG TYPE STRING.
DATA: i_return TYPE bapiret2 OCCURS 0 WITH HEADER LINE,
wa_message TYPE c LENGTH 100.
CLEAR: t_bapireturn.
REFRESH: t_bapireturn.
CLEAR POSCHEDULE.
REFRESH POSCHEDULE.
CLEAR POSCHEDULEX.
REFRESH POSCHEDULEX.
* Load PARAMETERS
CLEAR POSCHEDULE.
POSCHEDULE-PO_ITEM = EBELP.
POSCHEDULE-SCHED_LINE = ETENR.
POSCHEDULE-STAT_DATE = STAT_DATE.
APPEND POSCHEDULE.
CLEAR POSCHEDULEX.
POSCHEDULEX-PO_ITEM = EBELP.
POSCHEDULEX-SCHED_LINE = ETENR.
POSCHEDULEX-STAT_DATE = 'X'.
APPEND POSCHEDULEX.
*Call BAPI
CALL FUNCTION 'BAPI_PO_CHANGE'
exporting
purchaseorder = EBELN
TESTRUN = ''
TABLES
RETURN = t_bapireturn
POSCHEDULE = POSCHEDULE
POSCHEDULEX = POSCHEDULEX.
READ TABLE t_bapireturn WITH KEY type = c_err TRANSPORTING NO FIELDS.
IF sy-subrc NE 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = c_x.
ELSE.
CLEAR EKPO_MSG.
LOOP AT t_bapireturn WHERE TYPE = C_ERR.
CONCATENATE EKPO_MSG 'ERROR //' t_bapireturn-type t_bapireturn-id t_bapireturn-number t_bapireturn-message INTO EKPO_MSG SEPARATED BY SPACE.
ENDLOOP.
ENDIF.
ENDFORM.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
2 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 |