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 SYSUBRC.
   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 EKPOELIKZ.
   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.
     POSCHEDULEPO_ITEM = EBELP.
     POSCHEDULESCHED_LINE = ETENR.
     POSCHEDULESTAT_DATE = STAT_DATE.
     APPEND POSCHEDULE.
     CLEAR POSCHEDULEX.
     POSCHEDULEXPO_ITEM = EBELP.
     POSCHEDULEXSCHED_LINE = ETENR.
     POSCHEDULEXSTAT_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 sysubrc 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_bapireturntype t_bapireturnid t_bapireturnnumber  t_bapireturnmessage INTO EKPO_MSG SEPARATED BY SPACE.
        ENDLOOP.
    

      ENDIF.

ENDFORM.

Regards.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply