6 Replies Latest reply: Jul 7, 2008 1:53 PM by Dzed Maroz RSS

BAPI_GOODSMVT_CREATE movement type 344

Sudhakara Reddy
Currently Being Moderated

Hi , i want to convert unristricted stock to block stock, so i use movement 344. the thing is ,it is creating document but commit work and wait is failing. i am geeting mail in sap mailbox, updation is failed like that. i am not able to see that document, but bapi is creating document, but is not saving to database.

 

what should be reason. i am providing sample of my code.

 

PERFORM within_warehouse_convert

               USING l_lqua '344'.

 

FORM within_warehouse_convert

    USING wa2_lqua TYPE lqua

          l_bwlvs  TYPE ltak-bwlvs.

*Decalre Variables

  DATA :

  wa_header    LIKE bapi2017_gm_head_01,

  wa_header1   LIKE bapi2017_gm_head_ret,

  l_code       LIKE bapi2017_gm_code,

  l_belnr      LIKE bapi2017_gm_head_ret-mat_doc,

  l_gjahr      LIKE bapi2017_gm_head_ret-doc_year,

  it_items     LIKE bapi2017_gm_item_create OCCURS 0 WITH HEADER LINE,

  it_return    LIKE bapiret2 OCCURS 0 WITH HEADER LINE,

  l_uom        LIKE t006-msehi,

  l_uom_iso    LIKE t006-isocode,

  l_text(100),

  l_error.

  • Assign Variables

  CLEAR wa_header.

  wa_header-pstng_date = sy-datum.

  wa_header-doc_date = sy-datum.

  wa_header-header_txt = 'Converted to Blocked'.

  l_code = '04'.

  REFRESH :

   it_items, it_return.

  CLEAR :

   wa_header1, l_belnr, l_gjahr, l_error,l_uom.

  SELECT SINGLE meins INTO l_uom FROM mara

   WHERE matnr = wa2_lqua-matnr.

  CALL FUNCTION 'SAP_TO_ISO_MEASURE_UNIT_CODE'

       EXPORTING

            sap_code    = l_uom

       IMPORTING

            iso_code    = l_uom_iso

       EXCEPTIONS

            not_found   = 1

            no_iso_code = 2

            OTHERS      = 3.

  IF sy-subrc <> 0.

    MESSAGE s001 WITH 'Unable to convert Units of Mesaurement'.

  ELSE.

    it_items-entry_uom_iso  = l_uom_iso.

    it_items-material       = wa2_lqua-matnr.

    it_items-plant          = wa2_lqua-werks.

    it_items-stge_loc       = wa2_lqua-lgort.

    it_items-batch          = wa2_lqua-charg.

    it_items-move_plant     = wa2_lqua-werks.

    it_items-move_stloc     = wa2_lqua-lgort.

    it_items-spec_stock     = wa2_lqua-sobkz.

    it_items-sales_ord      = wa2_lqua-sonum(10).

    it_items-s_ord_item     = wa2_lqua-sonum+10(6).

    it_items-val_sales_ord  = wa2_lqua-sonum(10).

    it_items-val_s_ord_item = wa2_lqua-sonum+10(6).

    it_items-item_text      = 'Converted to Blocked'.

    it_items-move_type      = l_bwlvs.

    it_items-entry_qnt      = wa2_lqua-gesme.

    APPEND it_items.

  •   Call BAPI Goods movement

    CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

         EXPORTING

              goodsmvt_header  = wa_header

              goodsmvt_code    = l_code

              testrun          = l_test

         IMPORTING

              goodsmvt_headret = wa_header1

              materialdocument = l_belnr

              matdocumentyear  = l_gjahr

         TABLES

              goodsmvt_item    = it_items

              return           = it_return.

    CLEAR l_error.

    LOOP AT it_return WHERE type = 'E' OR type = 'A'.

      MESSAGE i001 WITH it_return-message text-001.

      l_error = 'X'.

      EXIT.

    ENDLOOP.

  •   Call Commit BAPI.

    IF l_error = ' '.

      CLEAR : it_return.

      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

           EXPORTING

                wait   = 'X'

           IMPORTING

                return = it_return.

      IF it_return-type = 'E' OR it_return-type = 'A'.

        MESSAGE i001 WITH it_return-message.

        l_error = 'X'.

        CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

        EXIT.

      ENDIF.

    ENDIF.

  ENDIF.

ENDFORM.                    " within_warehouse_convert

Actions