cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with Transfer posting in BAPI BAPI_GOODSMVT_CREATE

ronald_cadena
Explorer
0 Kudos
1,161

Greetings Experts,

I was asked to check a client program that help transferring goods using the BAPI BAPI_GOODSMVT_CREATE, but for some reason is failing, even though this is a copy of another program that works perfectly using the same BAPI but in that case for “Goods issue”, I was wondering if maybe we are filling the data incorrectly or we could be missing some key data, this is the current logic the program is executing:

      REFRESH: lti_goodsmvt_item.
      lwa_goodsmvt_header-gr_gi_slip_no = gwa_movimiento_im-no_documento.
      LOOP AT im_o_md->gwa_ajuste_inventario-movimientos[]
              ASSIGNING FIELD-SYMBOL(<fs_movimiento>) ##NEEDED "#EC CI_CALLTA
              WHERE no_documento = gwa_movimiento_im-no_documento.

        CLEAR: lv_fecha.
        lv_fecha = <fs_movimiento>-fecha_movimiento.
        CONDENSE lv_fecha NO-GAPS.
        lwa_goodsmvt_header-pstng_date = lv_fecha+0(8).

        CLEAR: lv_fecha.
        lv_fecha = <fs_movimiento>-fecha_movimiento.
        CONDENSE lv_fecha NO-GAPS.
        lwa_goodsmvt_header-doc_date = lv_fecha+0(8).

        lwa_goodsmvt_header-header_txt = <fs_movimiento>-no_transferencia_alpina.

        CLEAR: lwa_goodsmvt_item, gv_flag.
        READ TABLE gtd_materiales INTO DATA(lwa_materiales) WITH KEY material_ean = <fs_movimiento>-material_ean.
        IF sy-subrc = 0.
          lwa_goodsmvt_item-material = lwa_materiales-descripcion.
          lwa_goodsmvt_item-move_mat = lwa_materiales-descripcion.
        ENDIF.

        READ TABLE gtd_causal INTO DATA(lwa_causal) WITH KEY causal = <fs_movimiento>-causal.
        IF sy-subrc = 0.
          lwa_goodsmvt_item-move_type = lwa_causal-no_documento.
          lwa_goodsmvt_item-move_reas = lwa_causal-no_transferencia_alpina.
        ENDIF.

        CONVERT TIME STAMP <fs_movimiento>-fecha_vencimiento TIME ZONE sy-zonlo INTO DATE lwa_goodsmvt_item-expirydate.

        CLEAR: lwa_homo_werks.
    READ TABLE lti_homo_werks INTO lwa_homo_werks WITH KEY zwerkslr = <fs_movimiento>-org_origen.

        READ TABLE ltd_causal INTO DATA(lwa_causal_1) WITH KEY casual = <fs_movimiento>-causal.
        IF sy-subrc = 0.

          IF <fs_movimiento>-org_destino = space.

            CASE lwa_causal_1-devol.
              WHEN 'X'.
                lwa_goodsmvt_item-plant      = lwa_homo_werks-zwerksd.
                lwa_goodsmvt_item-stge_loc   = lwa_homo_werks-zlgortd.
                lwa_goodsmvt_item-move_plant = lwa_homo_werks-zwerkso.
                lwa_goodsmvt_item-move_stloc = lwa_homo_werks-zlgorto.

              WHEN OTHERS.
                lwa_goodsmvt_item-plant    = lwa_homo_werks-zwerksd.
                lwa_goodsmvt_item-stge_loc = lwa_homo_werks-zlgortd.

            ENDCASE.

          ELSE.

            lwa_goodsmvt_item-plant    = lwa_homo_werks-zwerksd.
            lwa_goodsmvt_item-stge_loc = lwa_homo_werks-zlgortd.

            CLEAR: lwa_homo_werks.
            READ TABLE lti_homo_werks INTO lwa_homo_werks WITH KEY zwerkslr = <fs_movimiento>-org_destino.

            lwa_goodsmvt_item-move_plant = lwa_homo_werks-zwerksd.
            lwa_goodsmvt_item-move_stloc = lwa_homo_werks-zlgortd.

          ENDIF.

        ENDIF.

    READ TABLE lti_t001k INTO lwa_T001k WITH KEY bwkey = lwa_goodsmvt_item-plant
    lv_bukrs = lwa_T001k-bukrs.

        CLEAR: lv_param_id, lv_bukrs.
        lv_param_id = 'LOTE'.

        CLEAR: lwa_parameters, lv_sysubrc.
        zcl_bc_parameters=>get_parameter( "#EC CI_SEL_NESTED or "#EC CI_SROFC_NESTED
         EXPORTING
           im_v_wricef = 'IM_LOTELR'
           im_v_id     = lv_param_id
           im_v_bukrs  = lv_bukrs
         IMPORTING
           ex_wa_param = lwa_parameters
           ex_v_subrc  = lv_sysubrc ).


        IF lwa_parameters-valor <> space.
          lwa_goodsmvt_item-batch = lwa_parameters-valor.
          lwa_goodsmvt_item-move_batch = lwa_parameters-valor.
        ENDIF.

        lwa_goodsmvt_item-entry_qnt = <fs_movimiento>-cantidad.

        CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT' ##FM_SUBRC_OK
          EXPORTING
            input          = <fs_movimiento>-unidad_medida
            language       = sy-langu
          IMPORTING
            output         = lwa_goodsmvt_item-entry_uom
          EXCEPTIONS
            unit_not_found = 1
            OTHERS         = 2.

        APPEND lwa_goodsmvt_item TO lti_goodsmvt_item.
      ENDLOOP.

      REFRESH: lti_return.
      CLEAR: lv_materialdocument, lv_matdocumentyear.
      CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
        EXPORTING
          goodsmvt_header  = lwa_goodsmvt_header
          goodsmvt_code    = '04'
        IMPORTING
          materialdocument = lv_materialdocument
          matdocumentyear  = lv_matdocumentyear
        TABLES
          goodsmvt_item    = lti_goodsmvt_item
          return           = lti_return.

If we execute it in a test run, it works perfectly, the return table is empty and it seems like it was a success, but if we do a real run, then we get the following error message “VL581 - Assign a goods receiving point to the inbound delivery”, I’m not entirely sure what to do with said error, maybe we are missing some key data in the BAPI or the system is lacking some sort of configuration, but the user tell us he can manually create this transfer in the transaction MIGO without issues.

I manage to track said error in this INCLUDE “FV50XF0B_INB_DELIV_REC_POINT_C” for program “SAPMV50A”, it seems like is related to the table LIKP, but not sure why is it assigning that data in this case.

Any help would be greatly appreciated.

Additional information:

The example that we are checking is using the movement type “301”, maybe that could be affecting the BAPI behavior

View Entire Topic
p244500
Active Contributor
0 Kudos

Hi,

I think system try to assine good receiving point. Before assign the goods receiving point, you must define the plant and storage location. You will find information on this in the structure maintenance of the enterprise structure, where plants and storage locations in the general logistics and materials management areas are defined.

Regards,

Nawa.