BAPI_GOODSMVT_CREATE costcenter error

Hi,
I try to use BAPI_GOODSMVT_CREATE for goods movement of type 201.
When I had to send COSTCENTER parameter with the BAPI, Iit started to give errors such like "Cost center xxxx/yyyy does not exist on dd.mm.yyyy." but I'm sure that cost center exists in this period. Probabily error is something else. So I think I have to send some other parameters to BAPI but I'm not sure which one. Here I my parameters :
gmhead-pstng_date = sy-datum.
gmhead-doc_date   = sy-datum.
gmhead-pr_uname   = sy-uname.
gmhead-ref_doc_no = DOC_ID.
gmcode-gm_code  = GM_CODE.
itab-mvt_ind    = ''.
itab-plant      = '0001'.
itab-material   = PART_NO.
itab-entry_qnt  = AMOUNT.
itab-entry_uom  = ''.
itab-move_type  = MOVE_TYPE.
itab-stge_loc   = STORAGE.
itab-move_stloc = STORAGE_MOVE.
itab-batch      = BATCH.
itab-spec_stock = SPEC_STOCK.
itab-vendor     = CONS.
itab-costcenter = COSTCENTER.
So do you have any idea what can be the error? Before I sent costcenter to the BAPI, everything was correct.
Thanks...

Unfortunately I have another problem now.
When the SPEC_STOCK is "K", I give the vendor to the BAPI. But this time I get error
"Account XXXXXXXXXX requires an assignment to a CO object"
And again it is possible to make goods movement by MB1A transaction. And also it was possible to run BAPI before I give COSTCENTER parameter with special stock "K". So I think it has to be given a default value for some parameter. But I have no idea which one..
Thanks...

Similar Messages

  • BAPI_GOODSMVT_CREATE new error

    Hi Gurus,
            I m trying to create a goods receipt thr'
    BAPI_GOODSMVT_CREATE,
    Here is the code-
    *& Header data
        REFRESH goodsmvmt_header.
        goodsmvmt_header-pstng_date = sy-datum.
        goodsmvmt_header-doc_date = sy-datum.
        goodsmvmt_header-ref_doc_no = 'Test'
        APPEND goodsmvmt_header.
    *& Process the type of movement
        REFRESH goodsmvmt_code.
        goodsmvmt_code-gm_code = '01'.
        APPEND goodsmvmt_code.
    *& Process the line items for the material document
        REFRESH goodsmvmt_item.
        goodsmvmt_item-PO_NUMBER = display_itab-ebeln.
        goodsmvmt_item-PO_ITEM = display_itab-ebelp.
        goodsmvmt_item-MVT_IND = 'B'.
        goodsmvmt_item-material = display_itab-matnr.
        goodsmvmt_item-plant = display_itab-werks.     
        goodsmvmt_item-stge_loc = display_itab-lgort. 
        goodsmvmt_item-entry_qnt = display_itab-menge.
        goodsmvmt_item-move_type = '101'.        
        goodsmvmt_item-STCK_TYPE = space.
       goodsmvmt_item-SPEC_STOCK = '+'.
        APPEND goodsmvmt_item.
    *& Refreshing document and return tables
        REFRESH goodsmvmt_document.
        REFRESH goodsmvmt_return.
    *& call function bapi....
        CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
          EXPORTING
            goodsmvt_header  = goodsmvmt_header
            goodsmvt_code    = goodsmvmt_code
          IMPORTING
            goodsmvt_headret = goodsmvmt_document
          TABLES
            goodsmvt_item    = goodsmvmt_item
            return           = goodsmvmt_return.
    This is giving me following error in return parameter-
    <b>Inconsistency between a document field and the prof. segment number</b>
    Any help will be appriciated.
    Prasad

    Hi Prasad,
    Please go through the following code which is working good without any inconsistency errors.
    Hope this will be helpful for you.
    INITIALIZATION.
    START-OF-SELECTION.
    Mandatory Include for Client Check
      INCLUDE ZZIMANDT.
      E_HEADER-PSTNG_DATE = SY-DATUM.
      E_HEADER-DOC_DATE = SY-DATUM.
      APPEND E_HEADER.
    Opening the Data file
      PERFORM READ_WIRELESS_DATA.
      PERFORM MATCH_ORDERS.
      PERFORM CLEAR_INPUT_FILES.
    TOP-OF-PAGE.
      FORMAT COLOR COL_HEADING ON.
      WRITE : / SY-VLINE,
               15 'Wireless Resale Daily Processing Report',
               90 SY-VLINE.
      ULINE 0(90).
      WRITE : / SY-VLINE,
               2 'Svc Ord',
              13 SY-VLINE,
              14 'Material',
              25 SY-VLINE,
              26 'Qty',
              32 SY-VLINE,
              33 'Ord date',
              42 SY-VLINE,
              43 'Gl Acct',
              54 SY-VLINE,
              55 'Co',
              60 SY-VLINE,
              61 'Sub Mkt',
              68 SY-VLINE,
              69 'Result',
              85 SY-VLINE,
              86 'MVT',
              90 SY-VLINE.
    ULINE 0(90).
    END-OF-PAGE.
    END-OF-SELECTION.
    END OF PROGRAM ******************************
    FORM READ_WIRELESS_DATA.
      OPEN DATASET U_MERC FOR INPUT IN TEXT MODE.
      OPEN DATASET F_CSTR FOR INPUT IN TEXT MODE.
      OPEN DATASET F_CTEL FOR INPUT IN TEXT MODE.
      PERFORM SPLIT_FILE.
      CLOSE DATASET F_CSTR.
      CLOSE DATASET F_CTEL.
      CLOSE DATASET U_MERC.
    ENDFORM.
    *&      Form  SPLIT_FILE
          text
    -->  p1        text
    <--  p2        text
    FORM SPLIT_FILE.
      DO.
        READ DATASET U_MERC  INTO OMSDATA.
        IF OMSDATA-RECORD IS INITIAL.
          EXIT.
        ELSE.
          APPEND OMSDATA.
          CLEAR OMSDATA.
        ENDIF.
      ENDDO.
      LOOP AT OMSDATA.
        SPLIT OMSDATA-RECORD AT ',' INTO
           I_OMSW-ZSERVICE_ORD
           I_OMSW-ZMATNR
           I_OMSW-ZQTY
           I_OMSW-ZORD_DT
           I_OMSW-ZGL_ACCT
           I_OMSW-ZBUKRS
           I_OMSW-ZSUB_MKT
           I_OMSW-ZCURR_DT
           I_OMSW-ZCURR_TIME.
        I_OMSW-ZPROCESS_FLAG = ' '.
        UNPACK I_OMSW-ZMATNR TO I_OMSW-ZMATNR.
        UNPACK I_OMSW-ZGL_ACCT TO I_OMSW-ZGL_ACCT.
        APPEND I_OMSW .
        CLEAR I_OMSW.
      ENDLOOP.
      SELECT * FROM ZMMOMSW INTO I_OMSW WHERE ZPROCESS_FLAG = ' '.
        APPEND I_OMSW.
        CLEAR I_OMSW.
      ENDSELECT.
      SORT I_OMSW.
      DELETE ADJACENT DUPLICATES FROM I_OMSW.
      DO.
        READ DATASET F_CSTR  INTO CELLSTAR.
        IF CELLSTAR-RECORD IS INITIAL.
          EXIT.
        ELSE.
          APPEND CELLSTAR.
          CLEAR CELLSTAR.
        ENDIF.
      ENDDO.
      LOOP AT CELLSTAR.
        SPLIT CELLSTAR-RECORD AT ',' INTO
           I_WRLS-ZSERVICE_ORD
           I_WRLS-ZMATNR
           I_WRLS-ZQTY
           I_WRLS-ZORD_DT.
        CONCATENATE 'S' I_WRLS-ZSERVICE_ORD INTO I_WRLS-ZSERVICE_ORD.
        I_WRLS-ZCURR_DT = SY-DATUM.
        I_WRLS-ZCURR_TIME = SY-UZEIT.
        I_WRLS-ZPROCESS_FLAG = ' '.
        I_WRLS-ZMAT_TYPE = 'C'.
        UNPACK I_WRLS-ZMATNR TO I_WRLS-ZMATNR.
        APPEND I_WRLS.
        CLEAR I_WRLS.
      ENDLOOP.
      REFRESH CELLSTAR.
      FREE CELLSTAR.
      DO.
        READ DATASET F_CTEL  INTO CTEL.
        IF CTEL-RECORD IS INITIAL.
          EXIT.
        ELSE.
          APPEND CTEL.
          CLEAR CTEL.
        ENDIF.
      ENDDO.
      LOOP AT CTEL.
        SPLIT CTEL-RECORD AT ',' INTO
         I_WRLS-ZSERVICE_ORD
         I_WRLS-ZMATNR
         I_WRLS-ZQTY
         I_WRLS-ZORD_DT.
        I_WRLS-ZCURR_DT = SY-DATUM.
        I_WRLS-ZCURR_TIME = SY-UZEIT.
        I_WRLS-ZPROCESS_FLAG = ' '.
        I_WRLS-ZMAT_TYPE = 'O'.
        CONCATENATE 'S' I_WRLS-ZSERVICE_ORD INTO I_WRLS-ZSERVICE_ORD.
        UNPACK I_WRLS-ZMATNR TO I_WRLS-ZMATNR.
        APPEND I_WRLS.
        CLEAR I_WRLS.
      ENDLOOP.
      SELECT * FROM ZMMWRLS INTO I_WRLS WHERE ZPROCESS_FLAG = ' '.
        APPEND I_WRLS.
        CLEAR I_WRLS.
      ENDSELECT.
      SORT I_WRLS.
      DELETE ADJACENT DUPLICATES FROM I_WRLS.
      REFRESH CTEL.
      FREE CTEL.
    ENDFORM.                               " SPLIT_FILE
    *&      Form  MATCH_ORDERS
          text
    -->  p1        text
    <--  p2        text
    FORM MATCH_ORDERS.
      LOOP AT I_OMSW.
        OMS_INDX = SY-TABIX.
        LOOP AT I_WRLS WHERE ZSERVICE_ORD = I_OMSW-ZSERVICE_ORD
                             AND  ZMATNR = I_OMSW-ZMATNR
                             AND  ZPROCESS_FLAG = ' '.
                  WRLS_INDX = SY-TABIX.
        ENDLOOP.
        IF SY-SUBRC = 0.
          I_OMSW-ZPROCESS_FLAG = 'X'.
          PERFORM UPDATE_ZMMOMSW.
          I_WRLS-ZPROCESS_FLAG = 'X'.
          CONCATENATE I_OMSW-ZBUKRS I_OMSW-ZSUB_MKT+2(3)
                       INTO I_WRLS-ZKOSTL.
          PERFORM UPDATE_ZMMWRLS.
          PERFORM UPDATE_ZMMWMCH.
          CLEAR OMS_INDX.
          CLEAR WRLS_INDX.
          COMMIT WORK.
          IF I_WRLS-ZMAT_TYPE = 'C'.
            PERFORM BUILD_101_MVT.
            PERFORM GOODS_MVT.
            WAIT UP TO 5 SECONDS.
            PERFORM BUILD_201_MVT.
            PERFORM GOODS_MVT.
          ELSE.
            PERFORM BUILD_201_MVT.
            PERFORM GOODS_MVT.
          ENDIF.
          WAIT UP TO 5 SECONDS.
        ELSE.
          I_OMSW-ZPROCESS_FLAG = ' '.
          PERFORM UPDATE_ZMMOMSW.
        ENDIF.
      ENDLOOP.
      COMMIT WORK.
      LOOP AT I_WRLS WHERE ZPROCESS_FLAG = ' '.
         MOVE-CORRESPONDING I_WRLS TO ZMMWRLS.
         MODIFY ZMMWRLS.
      ENDLOOP.
      ULINE 0(90).
    ENDFORM.                               " MATCH_ORDERS
    *&      Form  GOODS_MVT
          text
    -->  p1        text
    <--  p2        text
    FORM GOODS_MVT.
      CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
           EXPORTING
                GOODSMVT_HEADER       = E_HEADER
                GOODSMVT_CODE         = W_CODE
          IMPORTING
               GOODSMVT_HEADRET      = I_HEADER
               MATERIALDOCUMENT      = W_DOC_NUM
               MATDOCUMENTYEAR       = W_YEAR
           TABLES
                GOODSMVT_ITEM         = I_MSEG
            GOODSMVT_SERIALNUMBER =
                RETURN                = W_RETURN
      IF W_RETURN-TYPE = ' '.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
       EXPORTING
            WAIT    =
          IMPORTING
               RETURN  = W_COMMIT_RETURN.
          WRITE: / SY-VLINE,
                  2(10) I_OMSW-ZSERVICE_ORD,
                13 SY-VLINE,
                14(8) I_OMSW-ZMATNR,
                25 SY-VLINE,
                26(5) I_OMSW-ZQTY,
                32 SY-VLINE,
                33(8) I_OMSW-ZORD_DT,
                42 SY-VLINE,
                43(10) I_OMSW-ZGL_ACCT,
                54 SY-VLINE,
                55(4) I_OMSW-ZBUKRS,
                60 SY-VLINE,
                61(5) I_OMSW-ZSUB_MKT,
                68 SY-VLINE,
                69(15) 'Post Successful',
                85 SY-VLINE,
                86 W_MVT,
                90 SY-VLINE.
      ELSE.
         WRITE: / SY-VLINE,
                 2(10) I_OMSW-ZSERVICE_ORD,
                13 SY-VLINE,
                14(8) I_OMSW-ZMATNR,
                25 SY-VLINE,
                26(5) I_OMSW-ZQTY,
                32 SY-VLINE,
                33(8) I_OMSW-ZORD_DT,
                42 SY-VLINE,
                43(10) I_OMSW-ZGL_ACCT,
                54 SY-VLINE,
                55(4) I_OMSW-ZBUKRS,
                60 SY-VLINE,
                61(5) I_OMSW-ZSUB_MKT,
                68 SY-VLINE,
                69(15) 'Posting Failed',
                85 SY-VLINE,
                86 W_MVT,
                90 SY-VLINE.
      ENDIF.
      CLEAR W_MVT.
      IF W_COMMIT_RETURN-TYPE NE ' '.
        CLEAR W_COMMIT_RETURN.
        REFRESH W_COMMIT_RETURN.
        CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
             IMPORTING
                  RETURN = W_COMMIT_RETURN.
    ENDIF.
      CLEAR W_DOC_NUM.
      CLEAR W_YEAR.
      CLEAR I_MSEG.
      REFRESH I_MSEG.
    ENDFORM.                               " GOODS_MVT.
    *&      Form  BUILD_101_MVT
          text
    -->  p1        text
    <--  p2        text
    FORM BUILD_101_MVT.
      W_CODE = '01'.
      I_MSEG-MATERIAL = I_WRLS-ZMATNR.
      I_MSEG-PLANT = '1295'.
      I_MSEG-STGE_LOC = '2000'.
      I_MSEG-MOVE_TYPE = '101'.
      W_MVT = '101'.
      I_MSEG-ENTRY_QNT = I_WRLS-ZQTY.
      I_MSEG-ENTRY_UOM = 'EA'.
      I_MSEG-PO_NUMBER = P_PO.
      I_MSEG-MVT_IND = 'B'.
      SELECT SINGLE EBELP FROM EKPO INTO W_EBELP
                        WHERE EBELN = P_PO AND
                        MATNR = I_WRLS-ZMATNR.
      I_MSEG-PO_ITEM = W_EBELP.
      APPEND I_MSEG.
      CLEAR I_MSEG.
      CLEAR W_EBELP.
    ENDFORM.                               " BUILD_101_MVT
    *&      Form  BUILD_201_MVT
          text
    -->  p1        text
    <--  p2        text
    FORM BUILD_201_MVT.
      W_CODE = '03'.
      I_MSEG-MATERIAL = I_WRLS-ZMATNR.
      I_MSEG-PLANT = '1295'.
      I_MSEG-STGE_LOC = '2000'.
      I_MSEG-MOVE_TYPE = '201'.
      W_MVT = '201'.
      I_MSEG-ENTRY_QNT = I_WRLS-ZQTY.
      I_MSEG-ENTRY_UOM = 'EA'.
      I_MSEG-COSTCENTER = I_WRLS-ZKOSTL.
      I_MSEG-GL_ACCOUNT = I_OMSW-ZGL_ACCT.
      I_MSEG-MVT_IND = ' '.
      APPEND I_MSEG.
      CLEAR I_MSEG.
    ENDFORM.                               " BUILD_201_MVT
    *&      Form  clear_input_files
          text
    -->  p1        text
    <--  p2        text
    FORM CLEAR_INPUT_FILES.
      OPEN DATASET U_MERC FOR OUTPUT IN TEXT MODE.
      OPEN DATASET F_CSTR FOR OUTPUT IN TEXT MODE.
      OPEN DATASET F_CTEL FOR OUTPUT IN TEXT MODE.
      TRANSFER W_CELLSTAR TO F_CSTR.
      TRANSFER W_CELLSTAR TO F_CTEL.
      TRANSFER W_MERC TO U_MERC.
      CLOSE DATASET F_CSTR.
      CLOSE DATASET F_CTEL.
      CLOSE DATASET U_MERC.
    ENDFORM.                               " clear_input_files
    *&      Form  UPDATE_ZMMOMSW
          text
    -->  p1        text
    <--  p2        text
    FORM UPDATE_ZMMOMSW.
      MODIFY I_OMSW INDEX OMS_INDX.
      MOVE-CORRESPONDING I_OMSW TO ZMMOMSW.
      MODIFY ZMMOMSW.
    ENDFORM.                               " UPDATE_ZMMOMSW
    *&      Form  UPDATE_ZMMWRLS
          text
    -->  p1        text
    <--  p2        text
    FORM UPDATE_ZMMWRLS.
      MODIFY I_WRLS INDEX WRLS_INDX.
      MOVE-CORRESPONDING I_WRLS TO ZMMWRLS.
      MODIFY ZMMWRLS.
    ENDFORM.                               " UPDATE_ZMMWRLS
    *&      Form  UPDATE_ZMMWMCH
          text
    -->  p1        text
    <--  p2        text
    FORM UPDATE_ZMMWMCH.
      MOVE-CORRESPONDING I_OMSW TO ZMMWMCH.
      ZMMWMCH-ZKOSTL = I_WRLS-ZKOSTL.
      ZMMWMCH-ZMAT_TYPE = I_WRLS-ZMAT_TYPE.
      ZMMWMCH-ZPROCESS_FLAG = ' '.
      MODIFY ZMMWMCH.
    ENDFORM.                               " UPDATE_ZMMWMCH

  • Bapi_goodsmvt_create: no error return, but no document created!

    Hi guys!
    I have i weired problem.
    I'm using the bapi_goodsmvt_create to create a goods receipt document for a standard order.
    The simulation works fine, no error or warning return, the bapi_goodsmvt_create  without simulation flag works fine, bapi_transaction_commit returns no error as well, BUT: the document was not created.
    Any idea about the problem?

    Commit the work ..
    This code might help u
    CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
        EXPORTING
          goodsmvt_header       = wa_header
          goodsmvt_code         = wa_gm_code
        IMPORTING
          goodsmvt_headret      = tbl_export
          materialdocument      = matdoc
          matdocumentyear       = year
        TABLES
          goodsmvt_item         = tbl_item
          goodsmvt_serialnumber = tbl_serial
          return                = return.
      WRITE AT 10 'STATUS OF BAPI UPLOAD' COLOR 2 INTENSIFIED ON .
      SKIP 2.
      LOOP AT return ASSIGNING <fs_return>.
        IF <fs_return>-type EQ 'E'.
          WRITE AT 10 'Error in function:' COLOR 6 INTENSIFIED OFF.
          WRITE AT 28 <fs_return>-message .
          SKIP 1.
          err_flag = 'X'.
        ELSE.
          WRITE AT 10 <fs_return>-message .
          SKIP 1.
        ENDIF.
      ENDLOOP.
      IF err_flag IS INITIAL.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
        IF sy-subrc NE 0.
          WRITE:/ 'Error in updating'.
          EXIT.
        ELSE.
          WRITE:/
    'Number of Material Document created through BAPI:',tbl_export-mat_doc.
          WRITE:/ 'Material Document Year':, tbl_export-doc_year.
        ENDIF.
      ENDIF.

  • BAPI_GOODSMVT_CREATE giving error  purchase order is locked by user

    I am calling multiple times BAPI_GOODSMVT_CREATE for same Purchase order to post goods receipt.
    first goods receipt created successfully but second one has given the error the Purchase order is lockecd by USER 'XXXX' .
    i am calling 'BAPI_TRANSACTION_COMMIT after each BAPI BAPI_GOODSMVT_CREATE.
    i tried with passing parameter WAIT = 'X' in 'BAPI_TRANSACTION_COMMIT. then also getting same error message.
    please any one tell me the solution

    Hi
    1. Check all the call is handled the release function(JCO.releaseClient(client)) for each call.
    2. And check in finally
    finally {
         try {
         if (client != null) {
           JCO.removeClientPool(SID);
           JCO.releaseClient(client);
         if(client.isAlive()){
              client.disconnect();
           JCO.releaseClient(client);                    }
         } catch (JCO.Exception ex) { }
    Kind Regards
    Mukesh

  • Calling multiple times BAPI_GOODSMVT_CREATE getting error

    Hi Friends,
    I am calling multiple times BAPI_GOODSMVT_CREATE for same Purchase order to post goods receipt.
    for the first 4 times it is creating the GR successfully, but then it returning the message 'No goods receipt possible for purchase order 4500001004 01350'.
    Please help.
    Thanks
    Ravi

    Use Wait up to statement in loop.
    Ex:
    loop at it_filedir1.
        REFRESH I_TAB.
        CLEAR I_TAB.
       REFRESH I_TAB2.
       REFRESH ITAB1.
        data: g_file(100) type c .
        name = it_filedir1-name.
        concatenate: gfile '\' name into g_file.
        data : i_tab1(500).
        OPEN DATASET g_file FOR INPUT IN TEXT MODE
                                         ENCODING DEFAULT
                                         IGNORING CONVERSION ERRORS.
        IF SY-SUBRC EQ 0.
          DO.
            READ DATASET g_file INTO i_tab1.
            if sy-subrc = 0.
              split i_tab1 at ',' into  I_TAB-SOL_DOCNO I_TAB-SOL_DOCDT
               I_TAB-GI_TXN_TYPE I_TAB-WERKS I_TAB-LGOBE I_TAB-MATNR
               I_TAB-ERFMG I_TAB-ERFME.
            else.
              exit.
            endif.
            APPEND I_TAB.
            clear I_TAB.
          ENDDO.
        ENDIF.
        CLOSE DATASET g_file.
        concatenate: hfile '\' name into h_file.
        REFRESH I_MAIN.
        CLEAR I_MAIN.
        I_MAIN[] = I_TAB[].
        REFRESH I_OUT.
        CLEAR I_TAB.
        I_OUT[] = I_TAB[].
        DELETE ADJACENT DUPLICATES FROM I_TAB COMPARING SOL_DOCNO.
        SORT I_TAB BY SOL_DOCNO.
        LOOP AT I_TAB.
          count = sy-tabix.
          SELECT SINGLE * FROM ZMM_GI_WIP
                                    WHERE GI_NO = I_TAB-SOL_DOCNO AND
                                    GI_DATE = I_TAB-SOL_DOCDT.
          IF SY-SUBRC = 0.
            I_TAB-FLAG = 'C'.
            modify i_tab index count.
            CONCATENATE 'ERROR  GI : ' I_TAB-SOL_DOCNO
            '  WAS ALREADY UPLOADED' INTO I_MSG1.
            APPEND I_MSG1.
            CLEAR I_TAB-FLAG.
            CONTINUE.
          ELSE.
            CONCATENATE I_TAB-SOL_DOCDT+4(2)
                        I_TAB-SOL_DOCDT+6(2)
                        I_TAB-SOL_DOCDT+2(2)
                        I_TAB-SOL_DOCDT+0(2)
                        INTO G_DATE.
            gmhead-pstng_date = G_DATE.
            gmhead-doc_date = sy-datum.
            gmhead-pr_uname = sy-uname.
    "01 - MB01 - Goods Receipts for Purchase Order
            gmcode-gm_code = '03'.
            refresh itab.
            clear itab.
            SORT I_MAIN BY SOL_DOCNO.
            LOOP AT I_MAIN WHERE SOL_DOCNO = I_TAB-SOL_DOCNO.
              IF I_MAIN-GI_TXN_TYPE = 'RMGI'.
                itab-move_type  = '291'.
              ENDIF.
              itab-mvt_ind    = ' '.
              itab-plant      = I_MAIN-WERKS.
              itab-material   = I_MAIN-MATNR.
              itab-entry_qnt  = I_MAIN-ERFMG.
             itab-stge_loc   = 'OMR1'.
    itab-move_stloc = pcitab-recv_loc.
              itab-stge_loc   = I_MAIN-LGOBE.
              itab-ENTRY_UOM = I_MAIN-ERFME.
              IF I_MAIN-WERKS = 'OMR'.
                itab-TR_PART_BA = '11'.
              ELSEIF I_MAIN-WERKS = 'OMR'.
                itab-TR_PART_BA = '12'.
              ENDIF.
              append itab.
            ENDLOOP.
            if not itab[] is initial.
              call function 'BAPI_GOODSMVT_CREATE'
               exporting
                   goodsmvt_header             = gmhead
                   goodsmvt_code               = gmcode
                 *   TESTRUN                     = ' '
              IMPORTING
                  goodsmvt_headret            = mthead
             *   MATERIALDOCUMENT            =
      MATDOCUMENTYEAR             =
               tables
                 goodsmvt_item               = itab
      GOODSMVT_SERIALNUMBER       =
                return                      = errmsg.
              clear errflag.
              loop at errmsg.
                if errmsg-type eq 'E'.
                  write:/'Error in function', errmsg-message.
                  errflag = 'X'.
                else.
                  write:/ errmsg-message.
                endif.
                move errmsg-message to i_msg1.
                append i_msg1.
              endloop.
              if errflag is initial.
                CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
              EXPORTING
                WAIT          =
              IMPORTING
                RETURN        =
               commit work and wait.
                if sy-subrc ne 0.
                  write:/ 'Error in updating'.
                  exit.
                else.
                  write:/ mthead-mat_doc, mthead-doc_year.
                  ZMM_GI_WIP-GI_NO = I_TAB-SOL_DOCNO.
                  ZMM_GI_WIP-GI_DATE = I_TAB-SOL_DOCDT.
                  INSERT ZMM_GI_WIP.
                  COMMIT WORK.
                  I_TAB-FLAG = 'C'.
                  MODIFY I_TAB INDEX COUNT.
                  CONCATENATE mthead-mat_doc  mthead-doc_year
                             into i_msg1.
                  append i_msg1.
                 perform upd_sta.
                endif.
              endif.
            endif.
          ENDIF.
           wait up to 20 seconds.
        ENDLOOP.

  • Goods issue using bapi  BAPI_GOODSMVT_CREATE getting error E M7

    HI  consultants,
    While  posting goods issue using bapi BAPI_GOODSMVT_CREATE . Running the batch job(zprogram) to post the goods issue . The goods issue is been posted by passing  goods receipt data's.
    while processing 3 goods receipt , 2 works fine one goods receipt getting  E M 7 300 NO ITEMS ARE TRANSFERED error.
    when i  processing one by one all the 3 goods receipt is working fine and process sucessfully. While processing in bulk ,i am getting this issue.
    If anybody faces this same problem or knows the solution .Please post the answer.
    The way i am passing the parameter to bapi given bellow.
        WA_GOODSMVT_CODE-GM_CODE = C_03.
    *--populate header data
        WA_GOODSMVT_HEADER-DOC_DATE   = WA_MKPF-BLDAT.
        WA_GOODSMVT_HEADER-PSTNG_DATE = WA_MKPF-BUDAT.
    *--populate item data      
    *-- call the bapi for posting goods issue
                 IT_GOODSMVT_ITEM-NETWORK     = WA_RESBP-AUFNR.
                IT_GOODSMVT_ITEM-RESERV_NO   = WA_RESBP-RSNUM.
                IT_GOODSMVT_ITEM-RES_ITEM    = WA_RESBP-RSPOS.
                IT_GOODSMVT_ITEM-ACTIVITY    = WA_RESBP-VORNR.
                IT_GOODSMVT_ITEM-MOVE_TYPE   = C_281.
                IT_GOODSMVT_ITEM-ENTRY_QNT   = WA_RESBP-NET.
    *--get the item details
                  IT_GOODSMVT_ITEM-MATERIAL   = WA_MSEG-MATNR.
                  IT_GOODSMVT_ITEM-PLANT      = WA_MSEG-WERKS.
                  IT_GOODSMVT_ITEM-STGE_LOC   = WA_MSEG-LGORT.
                  IT_GOODSMVT_ITEM-ENTRY_UOM  = WA_MSEG-ERFME.
                  CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
                    EXPORTING
                      INPUT  = WA_MSEG-PS_PSP_PNR
                    IMPORTING
                      OUTPUT = WA_PSPHI_TEMP.
                  IT_GOODSMVT_ITEM-WBS_ELEM   = WA_PSPHI_TEMP.
                  APPEND IT_GOODSMVT_ITEM.  
                CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
                  EXPORTING
                    GOODSMVT_HEADER  = WA_GOODSMVT_HEADER
                    GOODSMVT_CODE    = WA_GOODSMVT_CODE
                  IMPORTING
                    MATERIALDOCUMENT = WA_MATERIALDOCUMENT
                  TABLES
                    GOODSMVT_ITEM    = IT_GOODSMVT_ITEM
                    RETURN           = IT_RETURN.
    With Regards,
    Ambrose Mohandoss.

    Problem solved.

  • BAPI_GOODSMVT_CREATE - Amount_SV Error

    Dear All
    I am creating the material movement documetn 561 (MB1C) using BAPI_GOODSMVT_CREATE. 
    I am passing Price to the field AMOUNT_SV.
    Howeever, the BAPI returns me the error saying
    IMSEG-WAERS initial v., currency amount 100.0000 in AMOUNT_SV was transferred without a currency
    Can someone help me where to set the Currenty reference in this BAPI. 
    I searched the forum and not able to find it.
    <removed by moderator>
    Regards,
    Venkat
    Edited by: Thomas Zloch on Jan 9, 2012

    Hi
    I verified the above function in SE37 and it returns SAR .. which is correct.
    Upon debugging, in curency determination routine it is returning Blank.
    Is there anything related to the move ment indicator - B.. 
    I am doing this for movement type 561
    Regards,
    Venkat

  • BAPI_GOODSMVT_CREATE - printing error

    Hi,
          Iam using  "BAPI_GOODSMVT_CREATE" to create transfer posting document (for T-code MB1B). The document is created perfectly. My issue is, Iam not able to print that document in MB90.
         In MB1B transaction, there is a Print check box in screen. If it is ticked, document created via MB1B is able to print using transaction MB90. But when using above BAPI, I could not find any suitable field to pass this print tick value.
         How to print documents created through this BAPI. Any help is appreciated.
    regards,
    Nagaraj.

    hi
    good
    Please take a look at this links for sample coding of BAPI_GOODSMVT_CREATE.
    http://www.sap-img.com/abap/bapi-goodsmvt-create-to-post-goods-movement.htm
    http://www.4ap.de/abap/bapi_goodsmvt_create.php
    thanks
    mrutyun^

  • Bapi_goodsmvt_create bapi error

    Hi friends,
                    I developed a bapi for Post Goods Issue (PGI). The BAPI is throwing an error at the Movement Type. The error is ' Goods movement is not possible with mvmt type 601'.
    This BAPI should be triggered in the background when VL01N transaction is run. Also please suggest me if we need any userexits / BADIs.  I went through badis. But of no use.
    Thanks and Regards,
    Murali Krishna .T

    Hi Vinod,
                   Thanks alot for your reply. I have used the BAPI    BAPI_OUTB_DELIVERY_CONFIRM_DEC. But when I run, it is not displaying any message from return table.
    I have passed both the header and item details.
    Thanks and Best regards,
    Murali

  • Cannot use BAPI_GOODSMVT_CREATE in MB_DOCUMENT_BEFORE_UPDATE

    Hi experts,
    I need to do enhance to post additional 313 movement after post 962 movement.
    I picked up MB_DOCUMENT_BEFORE_UPDATE to be triggered after press save button and used BAPI_GOODSMVT_CREATE to post 313.
    The problem is BAPI_GOODSMVT_CREATE returned error 'Enter Plant'!.
    All parameters were already tested with SE37 and it worked great.
    I did a lot debugging and found that all MSEG data were mysteriously cleared after it run 'PERFORM fusszeile_wa_pruefen(sapmm07m) USING x.' in source code SAPLMBWL.
    After that, I tried a new way. I submitted my Z program ,which call BAPI_GOODSMVT_CREATE with exactly same parameter, in BADI and it returned error that material ... batch ... is already locked.
    I'm not sure that is it possible to post additional material document in this BADI(MB_DOCUMENT_BEFORE_UPDATE).
    Best regards,
    Amornpon

    Thanks for reply.
    I did create FM and called it in BADI but it gave the same result as I called BAPI directly from enhance program.
    and what do you mean 'NEW TASK'  Is that you mean call function in update task?
    I did try call function in update task but it didn't work.
    The problem is BAPI function returned that Mat XXX  Batch XXX is alreay locked by XXX and also cannot get created material doc number.

  • Unable to transfer post the document using BAPI "BAPI_GOODSMVT_CREATE"

    Hi Experts,
    I am unable to post the document using BAPI "BAPI_GOODSMVT_CREATE", getting error "_Sales order stock --- does not exist_"
    details are stated below:
    GM_CODE : 04, it is working fine for the scenario with same saleorder number and line item, but when i give same sale order number and different line item, then i am getting the above error.
    Example : Posting from Saleorder A with line item 100 to saleorder A with lineitem 100 its working fine, but when we are posting
                    from Saleorder A with lineitem 100 to saleorder A with line item 200 it is not working.
    Also When I trying to do with the transaction MB1B manually, it is working fine. kindly suggest me.
    Needed Urgently....
    Appreciate for you early response.
    Regards,
    Sathya.
    Edited by: Sathyanarayana Raghavendra on May 6, 2010 1:00 PM

    Hi,
    Hi Did you call Function BAPI_TRANSACTION_COMMIT' after calling the BAPI.    ?
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = c_x.
    Regards,
    Jovito.

  • Confirm PO updated in table before GR

    Hi All,
    I have program to create PO via BAPI_PO_CREATE and followed by BAPI_GOODSMVT_CREATE to do GR.
    When there is little PO line items, after PO created, no problem in create material document through BAPI_GOODSMVT_CREATE  but when PO line items alot (50 ~ 200 lines), even after PO created, BAPI_GOODSMVT_CREATE has error in create GR.
    Currently I use key word wait up to few seconds in do loop before BAPI_GOODSMVT_CREATE but i think in the loop to check total line items created in table is more secured.
    May I know what table I need to check to confirm all PO line item added in table and PO number created in table then only I proceed with BAPI_GOODSMVT_CREATE.
    Thanks
    Rgds

    Hello,
    PO line table is EKPO. But you may try the following:
    After PO is created through BAPI_PO_CREATE, you should make a synchronous commit (COMMIT WORK AND WAIT) before calling BAPI_GOODSMVT_CREATE.  This ensures PO has been saved before proceeding to make Goods Receipt.
    Thanks,
    Venu

  • Error in Bapi_GoodsMvt_Create using Purchase order

    Hi Friends,
    I am using Bapi_goodsmvt_create for Goods Receipts against Purchase order.
    The below code i have given for Goods receipts
    It shows the error like
    ID : 8J
    Err No.:182
    Message : Entry 4500000344 00040 0000 not valid; correct entry
    Please help me to correct this error.
    Thanks
    Shankar
    ===================================
    Heading Structure
    st_gm_code-gm_code          = '01'.
    st_gm_header-pstng_date = '20070930'.
    st_gm_header-doc_date = '20070930'.
    st_gm_header-gr_gi_slip_no = '970015'.
    st_gm_header-bill_of_lading = '527213'.
    st_gm_header-header_txt = 'AIR'.
    st_gm_header-ref_doc_no = '4500000344'.
    Tables - ITEM CREATE.
    itab_afs_gm_itemx-plant = '2000'.
    itab_afs_gm_itemx-deliv_numb = '80100121'.
    itab_afs_gm_itemx-stge_loc = '2110'.
    itab_afs_gm_itemx-move_stloc = '2110'.
    itab_afs_gm_itemx-po_number = '4500000344'.
    itab_afs_gm_itemx-po_item = '00040'.
    itab_afs_gm_itemx-vendor = '0000650003'.
    itab_afs_gm_itemx-vendrbatch = 'ABC123'.
    itab_afs_gm_itemx-move_type = '101'.
    itab_afs_gm_itemx-mvt_ind = 'B'.
    itab_afs_gm_itemx-material = '000000000030000227'.
    itab_afs_gm_itemx-entry_qnt = 10.
    APPEND itab_afs_gm_itemx .
    ****&& Grid values
    gr_afs-matdoc_itm     = '0001'.
    gr_afs-grid_value = '205'.
    gr_afs-withdrawn_sku = 'X'. "Final issue at sku level
    gr_afs-stock_cat = '0000000001000366'.
    APPEND gr_afs.
    CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
      EXPORTING
        goodsmvt_header           = st_gm_header
        goodsmvt_code             = st_gm_code
      TESTRUN                     = ' '
    IMPORTING
       goodsmvt_headret           = st_gm_headret
       materialdocument            = mat_doc
       matdocumentyear             =  doc_year
      TABLES
        goodsmvt_item             = itab_afs_gm_itemx
       afs_goodsmvt_sku           = gr_afs
        return                    = bapi_return.
    IF sy-subrc = 0.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.
    ENDIF.
    CLEAR itab_afs_gm_itemx.
    REFRESH itab_afs_gm_itemx.
    CLEAR gr_afs.
    REFRESH gr_afs.

    Hi,
    Here is some sample code from one of my programs, which does a 551 movement type. This should get you started. Just check the RETURN table for messages, they should tell you what you are missing.
    code
    Structures for BAPI
    data: gm_header type bapi2017_gm_head_01.
    data: gm_code type bapi2017_gm_code.
    data: gm_headret type bapi2017_gm_head_ret.
    data: gm_item type table of
    bapi2017_gm_item_create with header line.
    data: gm_return type bapiret2 occurs 0.
    data: gm_retmtd type bapi2017_gm_head_ret-mat_doc.
    clear: gm_return, gm_retmtd. refresh gm_return.
    Setup BAPI header data.
    gm_header-pstng_date = sy-datum.
    gm_header-doc_date = sy-datum.
    gm_code-gm_code = '06'. " MB11
    Write 551 movement to table
    clear gm_item.
    move '551' to gm_item-move_type .
    move '000000000040001234' to gm_item-material.
    move '1' to gm_item-entry_qnt.
    move 'EA' to gm_item-entry_uom.
    move '0004' to gm_item-plant.
    move '4000' to gm_item-stge_loc.
    move '201' to gm_item-move_reas.
    Determine cost center per plant
    case xresb-werks.
    when '0004'.
    move '0000041430' to gm_item-costcenter.
    when '0006'.
    move '0000041630' to gm_item-costcenter.
    when '0007'.
    move '0000041731' to gm_item-costcenter.
    when '0008'.
    move '0000041830' to gm_item-costcenter.
    endcase.
    append gm_item.
    Call goods movement BAPI
    call function 'BAPI_GOODSMVT_CREATE'
    exporting
    goodsmvt_header = gm_header
    goodsmvt_code = gm_code
    importing
    goodsmvt_headret = gm_headret
    materialdocument = gm_retmtd
    tables
    goodsmvt_item = gm_item
    return = gm_return.
    call function 'BAPI_TRANSACTION_COMMIT'
    exporting
    wait = 'X'.
    [/code]
    Welcome to SDN! Please remember to award points for helpful answers and mark you post as solved when solved completely. Thanks.
    REgards,
    Raj.

  • Error in updating 311 movement using BAPI_GOODSMVT_CREATE

    Hi All,
    I need hlep to understand the problem in doing a transfer.
    SAP MII is doing a 311 type movement using BAPI_GOODSMVT_CREATE. BAPI is returning the response back to MII. Once the BAPI is commited it shall make transfer inside SAP. But it does not reflect the movement while checking under HUMO.
    under SM13 it say " SSFCOMPOSER 323"  error in address output (name not filled)
    MII is getting this reponse back as a result of BAPI execution.
    <?xml version="1.0" encoding="UTF-8"?>
    <BAPI_GOODSMVT_CREATE>
    <INPUT><GOODSMVT_CODE><GM_CODE>04</GM_CODE></GOODSMVT_CODE><GOODSMVT_HEADER><PSTNG_DATE>2010-07-03</PSTNG_DATE><DOC_DATE>2010-07-03</DOC_DATE><REF_DOC_NO/><BILL_OF_LADING/><GR_GI_SLIP_NO/><PR_UNAME/><HEADER_TXT/><VER_GR_GI_SLIP/><VER_GR_GI_SLIPX/><EXT_WMS/><REF_DOC_NO_LONG/><BILL_OF_LADING_LONG/><BAR_CODE/></GOODSMVT_HEADER><GOODSMVT_REF_EWM><REF_DOC_EWM/><LOGSYS/><GTS_SCRAP_NO/></GOODSMVT_REF_EWM><TESTRUN/></INPUT>
    <OUTPUT><GOODSMVT_HEADRET><MAT_DOC/><DOC_YEAR>0000</DOC_YEAR></GOODSMVT_HEADRET><MATDOCUMENTYEAR>0000</MATDOCUMENTYEAR><MATERIALDOCUMENT/></OUTPUT>
    <TABLES><EXTENSIONIN/><GOODSMVT_ITEM><item><MATERIAL>130116</MATERIAL><PLANT>2715</PLANT><STGE_LOC>LINE</STGE_LOC><BATCH>96</BATCH><MOVE_TYPE>311</MOVE_TYPE><STCK_TYPE/><SPEC_STOCK/><VENDOR/><CUSTOMER/><SALES_ORD/><S_ORD_ITEM>000000</S_ORD_ITEM><SCHED_LINE>0000</SCHED_LINE><VAL_TYPE/><ENTRY_QNT>96.000</ENTRY_QNT><ENTRY_UOM/><ENTRY_UOM_ISO/><PO_PR_QNT>0</PO_PR_QNT><ORDERPR_UN/><ORDERPR_UN_ISO/><PO_NUMBER/><PO_ITEM>00000</PO_ITEM><SHIPPING/><COMP_SHIP/><NO_MORE_GR/><ITEM_TEXT/><GR_RCPT/><UNLOAD_PT/><COSTCENTER/><ORDERID/><ORDER_ITNO>0000</ORDER_ITNO><CALC_MOTIVE/><ASSET_NO/><SUB_NUMBER/><RESERV_NO>0000000000</RESERV_NO><RES_ITEM>0000</RES_ITEM><RES_TYPE/><WITHDRAWN/><MOVE_MAT/><MOVE_PLANT>2715</MOVE_PLANT><MOVE_STLOC>J01</MOVE_STLOC><MOVE_BATCH>96</MOVE_BATCH><MOVE_VAL_TYPE/><MVT_IND/><MOVE_REAS>0000</MOVE_REAS><RL_EST_KEY/><REF_DATE>0000-00-00</REF_DATE><COST_OBJ/><PROFIT_SEGM_NO>0000000000</PROFIT_SEGM_NO><PROFIT_CTR/><WBS_ELEM/><NETWORK/><ACTIVITY/><PART_ACCT/><AMOUNT_LC>0</AMOUNT_LC><AMOUNT_SV>0</AMOUNT_SV><REF_DOC_YR>0000</REF_DOC_YR><REF_DOC/><REF_DOC_IT>0000</REF_DOC_IT><EXPIRYDATE>0000-00-00</EXPIRYDATE><PROD_DATE>0000-00-00</PROD_DATE><FUND/><FUNDS_CTR/><CMMT_ITEM/><VAL_SALES_ORD/><VAL_S_ORD_ITEM>000000</VAL_S_ORD_ITEM><VAL_WBS_ELEM/><GL_ACCOUNT/><IND_PROPOSE_QUANX/><XSTOB/><EAN_UPC/><DELIV_NUMB_TO_SEARCH/><DELIV_ITEM_TO_SEARCH>000000</DELIV_ITEM_TO_SEARCH><SERIALNO_AUTO_NUMBERASSIGNMENT/><VENDRBATCH/><STGE_TYPE/><STGE_BIN/><SU_PL_STCK_1>0</SU_PL_STCK_1><ST_UN_QTYY_1>0</ST_UN_QTYY_1><ST_UN_QTYY_1_ISO/><UNITTYPE_1/><SU_PL_STCK_2>0</SU_PL_STCK_2><ST_UN_QTYY_2>0</ST_UN_QTYY_2><ST_UN_QTYY_2_ISO/><UNITTYPE_2/><STGE_TYPE_PC/><STGE_BIN_PC/><NO_PST_CHGNT/><GR_NUMBER/><STGE_TYPE_ST/><STGE_BIN_ST/><MATDOC_TR_CANCEL/><MATITEM_TR_CANCEL>0000</MATITEM_TR_CANCEL><MATYEAR_TR_CANCEL>0000</MATYEAR_TR_CANCEL><NO_TRANSFER_REQ/><CO_BUSPROC/><ACTTYPE/><SUPPL_VEND/><MATERIAL_EXTERNAL/><MATERIAL_GUID/><MATERIAL_VERSION/><MOVE_MAT_EXTERNAL/><MOVE_MAT_GUID/><MOVE_MAT_VERSION/><FUNC_AREA/><TR_PART_BA/><PAR_COMPCO/><DELIV_NUMB/><DELIV_ITEM>000000</DELIV_ITEM><NB_SLIPS>000</NB_SLIPS><NB_SLIPSX/><GR_RCPTX/><UNLOAD_PTX/><SPEC_MVMT/><GRANT_NBR/><CMMT_ITEM_LONG/><FUNC_AREA_LONG/><LINE_ID>000000</LINE_ID><PARENT_ID>000000</PARENT_ID><LINE_DEPTH>00</LINE_DEPTH><QUANTITY>0</QUANTITY><BASE_UOM/><LONGNUM/></item></GOODSMVT_ITEM><GOODSMVT_SERIALNUMBER/><GOODSMVT_SERV_PART_DATA><item><LINE_ID>000000</LINE_ID><RET_AUTH_NUMBER/><DELIV_NUMBER/><DELIV_ITEM>000000</DELIV_ITEM><HU_NUMBER>115934300024</HU_NUMBER><INSPOUT_GUID/><EVENT/><DATE>0000-00-00</DATE><TIME>00:00:00</TIME><ZONLO/><TIMESTAMP>0</TIMESTAMP><SCRAP_INDICATOR/><KEEP_QUANTITY>0</KEEP_QUANTITY><GTS_STOCK_TYPE/><MOVE_GTS_STOCK_TYPE/></item></GOODSMVT_SERV_PART_DATA><RETURN><item><TYPE>S</TYPE><ID>L9</ID><NUMBER>514</NUMBER><MESSAGE>Delivery 80817129 created</MESSAGE><LOG_NO/><LOG_MSG_NO>000000</LOG_MSG_NO><MESSAGE_V1>80817129</MESSAGE_V1><MESSAGE_V2/><MESSAGE_V3/><MESSAGE_V4/><PARAMETER>GOODSMVT_HEADER</PARAMETER><ROW>0</ROW><FIELD/><SYSTEM>SP1330</SYSTEM></item></RETURN></TABLES>
    </BAPI_GOODSMVT_CREATE>

    PL Stock in transit exceeded by 200 UNT : 10000000125 3065 0005"
    the code does not matter, it is the process and the stock situation that does not allow the creation of the movement.
    you cannot receive e.g. 200 from in-transit stock  if you only have nothing in transit.
    First the goods issue has to be  performed in the shipping plant.

  • BAPI_GOODSMVT_CREATE mb11 movement type no error

    i want to 201 movement. i know gm_code 06. (MB11 movement type) when i run the code there is  no error.
    but gives me movement number. when i look at mb51 there is no data. so what could be the
    reason. also i have manuely entered data to se37 with function BAPI_GOODSMVT_CREATE. same thing happen.
    and of course at the continue of code there is commit and work bapi.
    my code like:
      data   i_tab TYPE TABLE OF ZPM_FUEL_EXT WITH HEADER LINE.
      DATA : goodsmvt_header TYPE bapi2017_gm_head_01,
             goodsmvt_code   TYPE bapi2017_gm_code,
             goodsmvt_headret TYPE bapi2017_gm_head_ret,
             materialdocument TYPE bapi2017_gm_head_ret-mat_doc,
             matdocumentyear  TYPE bapi2017_gm_head_ret-doc_year,
             goodsmvt_item   TYPE TABLE OF bapi2017_gm_item_create WITH HEADER LINE ,
             return       TYPE TABLE OF bapiret2 WITH HEADER LINE .
    data: begin of gmcode.
    include structure bapi2017_gm_code.
    data: end of gmcode.
    gmcode-gm_code = '06'.
      goodsmvt_header-pstng_date = sy-datum.
      goodsmvt_header-doc_date   = sy-datum.
      goodsmvt_header-pr_uname   = sy-uname.
      SELECT * from ZPM_FUEL_EXT INTO i_tab where STATE = ''.
        goodsmvt_item-material                 =  i_tab-matnr.
        goodsmvt_item-mvt_ind                 =  ''.
        goodsmvt_item-plant                      =  i_tab-werks.
        goodsmvt_item-stge_loc                =  i_tab-lgort.
        goodsmvt_item-move_type            =  i_tab-bwart = "   '201'.
        goodsmvt_item-entry_qnt              =  i_tab-amount.
        goodsmvt_item-entry_uom            =  i_tab-MEINS.
        goodsmvt_item-COSTCENTER       =  i_tab-KOSTL.
        goodsmvt_item-GL_ACCOUNT      =  i_tab-SAKNR.  "   '7300200001'.
        goodsmvt_item-ORDERID              =  i_tab-AUFNR.  "    'A27BC307'.
        goodsmvt_item-PAR_COMPCO     =  i_tab-BUKRS.
        APPEND  goodsmvt_item.
      ENDSELECT.
      CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
        EXPORTING
          goodsmvt_header     = goodsmvt_header
          goodsmvt_code        = gmcode
        IMPORTING
          goodsmvt_headret    = goodsmvt_headret" testrun = 'X'
        TABLES
          goodsmvt_item          = goodsmvt_item
          return                         = return.
    thanks for your help.

    Hi,
    You need to commit the transacton using function module "BAPI_TRANSACTION_COMMIT".
    If you want to check it via SE37 ,enter function module name & go to menu:
    Function Module->Test-> Test Sequences
    Enter function module names:
    BAPI_GOODSMVT_CREATE
    BAPI_TRANSACTION_COMMIT
    AftereExecuting first function module, system displays output of the functon module.
    when you click on back button the system allows to you execte second funtion module
    Give WAIT = 'X". Execute it. The document will be saved.
    Regards,
    Sudhakar Rayala

Maybe you are looking for