EXTENSIONIN structures of BAPI_GOODSMVT_CREATE.

呼延景同
2023-12-01

you can update LSMNG quantity using EXTENSIONIN structures of BAPI_GOODSMVT_CREATE.

The steps are the following:

Add LSMNG field in BAPI_TE_XMSEG structure create an appending structure (char field)

By SE19 transaction create the Enhancement Spot starting from MB_GOODSMOVEMENT

Define the Badi Implementation choosing MB_BAPI_GOODSMVT_CREATE Badi Definition implementing a new customer class.

Remember to choose to copy the class with the source code of methods.

In The method IF_EX_MB_Hi, you can update LSMNG quantity using EXTENSIONIN structures of BAPI_GOODSMVT_CREATE. The steps are the following: Add LSMNG field in BAPI_TE_XMSEG structure create an appending structure (char field) By SE19 transaction create the Enhancement Spot starting from MB_GOODSMOVEMENT Define the Badi Implementation choosing MB_BAPI_GOODSMVT_CREATE Badi Definition implementing a new customer class.

Remember to choose to copy the class with the source code of methods.

In the method IF_EX_MB_BAPI_GOODSMVT_CREATE~EXTENSIONIN_TO_MATDOC you will find the following source code:

  DATA:     c_lenstruc          TYPE i VALUE 30,    

   wa_bapi_mb_header   TYPE bapi_te_xmkpf,    

   wa_bapi_mb_item     TYPE bapi_te_xmseg,    

   wa_extension_in     TYPE bapiparex.  

   FIELD-SYMBOLS:               TYPE imseg.  

   CHECK NOT extension_in[] IS INITIAL.

  * Analyze IMSEG for document structure and assign LINE_IDs if necessary  

   CALL METHOD cl_mmim_line_id_manager=>analyze_mb_create    

          CHANGING       ct_imseg          = ct_imseg[]    

             EXCEPTIONS       duplicate_line_id = 1      

             OTHERS            = 2.  

  LOOP AT extension_in INTO wa_extension_in.    

     CASE wa_extension_in-structure.

* extension of MKPF      

     WHEN 'BAPI_TE_XMKPF'.        

     MOVE wa_extension_in+c_lenstruc TO wa_bapi_mb_header.        

     MOVE-CORRESPONDING wa_bapi_mb_header TO cs_imkpf.

* extension of MSEG      

    WHEN 'BAPI_TE_XMSEG'.        

    MOVE wa_extension_in+c_lenstruc TO wa_bapi_mb_item.        

    READ TABLE ct_imseg           WITH KEY line_id = wa_bapi_mb_item-matdoc_itm           ASSIGNING   <fs_imseg>.        

      IF sy-subrc EQ 0.          

         MOVE-CORRESPONDING wa_bapi_mb_item TO   <fs_imseg>.       

       ENDIF.   

     ENDCASE.  

    ENDLOOP.

Then you have to call BAPI_GOODSMVT_CREATE using extensionin in the following way:

* Fill   goodsmvt_header structures

  goodsmvt_header-........

* Fill    goodsmvt_item-position

  Loop at it_position.

         goodsmvt_item-..........

          wf_line_id = wf_line_id + 1.

          goodsmvt_item-line_id wf_line_id.

          APPEND goodsmvt_item.

        CLEAR extensionin.
        MOVE 'BAPI_TE_XMSEG'    TO extensionin-structure.
        MOVE wf_line_id+2(4)    TO extensionin-valuepart1+14(4).
        MOVE LSMNG              TO extensionin-valuepart1+18(16).
        APPEND extensionin.

endloop.

        CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
        EXPORTING
          goodsmvt_header               goodsmvt_header
          goodsmvt_code                 goodsmvt_code
*         TESTRUN                       = ' '
          goodsmvt_ref_ewm              goodsmvt_ref_ewm
        IMPORTING
*         GOODSMVT_HEADRET              =
          materialdocument              materialdocument
          matdocumentyear               matdocumentyear
        TABLES
          goodsmvt_item                 goodsmvt_item
*         GOODSMVT_SERIALNUMBER         =
          return                        return
          extensionin                   extensionin.

 类似资料:

相关阅读

相关文章

相关问答