Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem in executing BAPI_GOODSMVT_CREATE

Former Member
0 Likes
4,343

Hello Experts,

I have created STO. From STO  I have created an Inbound Delivery.Now I have to do PGR by using BAPI_GOODSMVT_CREATE.

I am passing

  GOODSMVT_CODE  01

GOODSMVT_ITEM

  Material

  Plant

  Storage Location

  Batch

  Move _Type - 109  (As mentioned by Functional)

  Entry_QNT

  Entry_UOM

  PO_Number

  PO_Item

  No_More_GR

  MVT_IND - B

  DELIV_NUMB_TO_SEARCH

  DELIV_ITEM_TO_SEARCH

But error message getting populated in IT_RETURN

E M7                   036 No goods receipt possible for purchase order 5700000855 00010

Can anyone solve this problem??

One more query is this the correct BAPI to do PGR via tcode VL32N??

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,423

HI,

STO receiving falls under Goods Issuing, So you need to give Goods MVT code = 3

Please refer the FM documentation

Thanks,

Prakash

14 REPLIES 14
Read only

Former Member
0 Likes
3,423

This message was moderated.

Read only

0 Likes
3,423

Seems like im passing all the parameters mentioned in all discussions.

Even if I dont pass the PO Number and PO Item,passing only the inbound delivery number and item

then also same error message being generated in IT_RETURN,

Im stuck .

Please help out to solve this iisue

Read only

Former Member
0 Likes
3,424

HI,

STO receiving falls under Goods Issuing, So you need to give Goods MVT code = 3

Please refer the FM documentation

Thanks,

Prakash

Read only

0 Likes
3,423

If I give Goods MVT Code = 3

Error message is populated as "Goods movement not possible with mvmt type 109"

Any idea??

Read only

0 Likes
3,423

Hi Puja,

generally goods movement are of two types

101- for inbound delivery

102-outbound delivery

can you please share your code you have written in BAPI_GOODSMVT_CREATE.

Read only

0 Likes
3,423

Hi please check this sample code. it creates goods movement using this BAPIits just that its a upload program. you can modify by your requirement.


TYPE-POOLS: truxs.
PARAMETERS: p_file
TYPE  rlgrap-filename.
TYPES:
BEGIN OF t_datatab,
col1(30)   
TYPE c,
col2(30)   
TYPE c,
col3(30)   
TYPE c,
col4(30)   
TYPE c,
col5(30)   
TYPE c,
col6(30)   
TYPE c,
col7(30)   
TYPE c,
col8(30)   
TYPE c,
col9(30)   
TYPE c,
col10(30)   
TYPE c,
col11(30)   
TYPE c,
END OF t_datatab.

DATA: it_datatab
type standard table of t_datatab,
wa_datatab
type t_datatab.

DATA: it_raw
TYPE truxs_t_text_data.

* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name =
'P_FILE'
IMPORTING
file_name  = p_file.


***********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
*     I_FIELD_SEPERATOR        =
i_line_header            = 
'X'
i_tab_raw_data           =  it_raw      
" WORK TABLE
i_filename               =  p_file
TABLES
i_tab_converted_data     = it_datatab[]   
"ACTUAL DATA
EXCEPTIONS
conversion_failed        =
1
OTHERS                   = 2.

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.


*** Create batch upload using BAPI_GOODSMVT_CREATE

PERFORM CREATE_BATCH_UPLOAD.


*&---------------------------------------------------------------------*
*&      Form  CREATE_BATCH_UPLOAD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM CREATE_BATCH_UPLOAD .

DATA : GT_GOODSMVT_HEADER  LIKE BAPI2017_GM_HEAD_01.

DATA : GOODSMVT_ITEM  TYPE TABLE OF BAPI2017_GM_ITEM_CREATE,
WA_GOODSMVT_ITEM
TYPE BAPI2017_GM_ITEM_CREATE,
*       L_RETURN LIKE BAPIRET2,
RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.

TYPES : BEGIN OF ITAB,
MATNR
TYPE MATNR,
WERKS
TYPE WERKS_D,
CHARG
TYPE CHARG_D,
END OF ITAB.
DATA : IT_ITAB TYPE STANDARD TABLE OF ITAB,
WA_ITAB
TYPE ITAB.
DATA : MATERIALDOCUMENT TYPE BAPI2017_GM_HEAD_RET-MAT_DOC.
*       MATDOCUMENTYEAR TYPE  BAPI2017_GM_HEAD_RET-DOC_YEAR.

*DATA : GT_GOODSMVT_HEARRET LIKE BAPI2017_GM_HEAD_RET.

DATA : V_LINES TYPE CHAR4,
GOODSMVT_CODE
TYPE BAPI2017_GM_CODE VALUE '04'.



GT_GOODSMVT_HEADER-PSTNG_DATE = SY-DATUM.
GT_GOODSMVT_HEADER-DOC_DATE   = SY-DATUM.

LOOP AT IT_DATATAB INTO WA_DATATAB.

WA_GOODSMVT_ITEM-MATERIAL = wa_datatab-col7.
WA_GOODSMVT_ITEM-MOVE_BATCH = wa_datatab-col10.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT         = WA_GOODSMVT_ITEM-MOVE_BATCH
IMPORTING
OUTPUT        = WA_GOODSMVT_ITEM-MOVE_BATCH
.


WA_GOODSMVT_ITEM-PLANT = wa_datatab-col4.
WA_GOODSMVT_ITEM-STGE_LOC = wa_datatab-col5.
WA_GOODSMVT_ITEM-BATCH = wa_datatab-col9.
WA_GOODSMVT_ITEM-MOVE_TYPE = wa_datatab-col3.
WA_GOODSMVT_ITEM-ENTRY_QNT = wa_datatab-col8.
WA_GOODSMVT_ITEM-MOVE_STLOC = wa_datatab-col6.
WA_GOODSMVT_ITEM-ITEM_TEXT = wa_datatab-col11.
APPEND WA_GOODSMVT_ITEM TO GOODSMVT_ITEM.
CLEAR WA_GOODSMVT_ITEM.
ENDLOOP.





select MATNR WERKS CHARG from MCHB into table it_itab for all entries in GOODSMVT_ITEM
where matnr = GOODSMVT_ITEM-MATERIAL and
charg = GOODSMVT_ITEM-MOVE_BATCH.         
" GOODSMVT_ITEM-MOVE_BATCH.

DESCRIBE TABLE GOODSMVT_ITEM LINES V_LINES.


IF IT_ITAB[] IS  INITIAL.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
GOODSMVT_HEADER               = GT_GOODSMVT_HEADER
GOODSMVT_CODE                 = GOODSMVT_CODE
*   TESTRUN                       = ' '
*   GOODSMVT_REF_EWM              =
IMPORTING
*    GOODSMVT_HEADRET              = GT_GOODSMVT_HEARRET
MATERIALDOCUMENT              = MATERIALDOCUMENT
*    MATDOCUMENTYEAR               = MATDOCUMENTYEAR
TABLES
GOODSMVT_ITEM                 = GOODSMVT_ITEM
*   GOODSMVT_SERIALNUMBER         =
RETURN                        = RETURN
*   GOODSMVT_SERV_PART_DATA       =
*   EXTENSIONIN                   =
.

IF RETURN[] IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT          = 'X'
*  IMPORTING
*    RETURN        = l_return
.
WRITE : TEXT-001 , MATERIALDOCUMENT.
WRITE : TEXT-005 , V_LINES.
ELSE.

WRITE: TEXT-002 ,
/ RETURN-MESSAGE.
ENDIF.

ELSE.
WRITE : TEXT-003.
ULINE.
Loop at it_itab into wa_itab.
WRITE : TEXT-004 , wa_itab-matnr , wa_itab-charg.
ENDLOOP.
ENDIF.

ENDFORM.                   
" CREATE_BATCH_UPLOAD

Read only

0 Likes
3,423

         CLEAR wa_goodsmvt_item.

         LOOP AT it_lips ASSIGNING <lfs_lips> .

           READ TABLE it_likp INTO wa_likp WITH KEY vbeln = wa_lips-vbeln

                                                    BINARY SEARCH.

           IF sy-subrc = 0.

             wa_goodsmvt_item-material             = <lfs_lips>-matnr.

             wa_goodsmvt_item-plant                = <lfs_lips>-werks.

             wa_goodsmvt_item-stge_loc             = <lfs_lips>-lgort.

             wa_goodsmvt_item-batch                = <lfs_lips>-charg.

             wa_goodsmvt_item-move_type            = '109'

             wa_goodsmvt_item-vendor               = <lfs_likp>-lifnr.

             wa_goodsmvt_item-entry_qnt            = <lfs_lips>-lfimg .

             wa_goodsmvt_item-entry_uom            = <lfs_lips>-meins.

             wa_goodsmvt_item-no_more_gr           = 'X'.

             wa_goodsmvt_item-po_number            = <lfs_lips>-vbeln.

             wa_goodsmvt_item-po_item              =  <lfs_lips>-vgpos.

             wa_goodsmvt_item-mvt_ind              = 'B'.

             wa_goodsmvt_item-deliv_numb_to_search = <lfs_lips>-vbeln.

             wa_goodsmvt_item-deliv_item_to_search = <lfs_lips>-posnr.

             wa_goodsmvt_item-deliv_numb           = <lfs_lips>-vbeln.

             wa_goodsmvt_item-deliv_item           = <lfs_lips>-posnr.

             wa_goodsmvt_item-vendrbatch           = <lfs_lips>-lichn.

             APPEND wa_goodsmvt_item TO it_goodsmvt_item.

             CLEAR wa_goodsmvt_item.

           ENDIF.

         ENDLOOP.

       ENDIF.

     ENDIF.

     DATA : lv_message TYPE bapi_msg,

        lv_mblnr TYPE char10,

        lv_mjahr TYPE numc4.

     DATA: wa_mvt_hdr TYPE bapi2017_gm_head_01,

        wa_mvt_cd  TYPE bapi2017_gm_code.

     FIELD-SYMBOLS <fs_return> TYPE bapiret2.

     CLEAR wa_mvt_hdr.

     CLEAR: wa_mvt_cd.

     CLEAR wa_likp.

     READ TABLE it_likp INTO wa_likp INDEX 1.

     IF sy-subrc = 0.

       wa_mvt_hdr-doc_date = sy-datum.

       wa_mvt_hdr-pstng_date = sy-datum.

       wa_mvt_hdr-ref_doc_no = wa_likp-vbeln.

       wa_mvt_hdr-pr_uname   = sy-uname.

     ENDIF.

     wa_mvt_cd = '01'.

     CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

       EXPORTING

         goodsmvt_header         = wa_mvt_hdr

         goodsmvt_code           = wa_mvt_cd

       IMPORTING

*       GOODSMVT_HEADRET        =

         materialdocument        = lv_mblnr

         matdocumentyear         = lv_mjahr

       TABLES

         goodsmvt_item           = it_goodsmvt_item

*       GOODSMVT_SERIALNUMBER   =

         return                  = it_return

*       GOODSMVT_SERV_PART_DATA =

*       EXTENSIONIN             =

       .

This is the code i have written.

I am trying to execute the bapi stand alone from se37 by directly passing the value on a trial basis before finalizing the code.

Please help.

Read only

0 Likes
3,423

Hi Puja,

please check these things,

1. Schedule line has been released for purchase order 5700000855 00010.

2. Please do it manually, and see is it  creating or not

3. Please change the movement type other than 109, (ask to your functional)

4. Please see the PO item field

please check these things and revert .

Read only

0 Likes
3,423

Thanks Sanjeev for all the info.

Actually its just been few months I have started to work in SAP.

1.Can you please mention the steps to check Schedule line has been released for that PO??

2.From tcode VL32N ,PGR can be done manually by clicking on Post Goods Receipt button.

4.Can you please mention what should I check in the PO item field??

Read only

0 Likes
3,423

Hi Puja,

no problem , because some day i was also at the same platform , you are dealing with.

Wait for others reply, till  i am seeing your issue, i will revert with your answers.

Read only

0 Likes
3,423

Hi Sanjeev,

Thanks for the support and the effort you are showing.

Read only

0 Likes
3,423

Hi Puja,

1. Your PO is released or not , please check transaction ME29N

2. Please change movement type to 101, ans see the result.

3. Check what is scheduled line delivery date (it must be today or previous, no latter date

   should be there)

4. Have you used bapi_transaction_commit after using 'BAPI_GOODSMVT_CREATE

do like this

SE37 -> FUNCTION MODULE -> TEST -> TEST SEQUENCE

A second sub screen will get displayed, in first line write BAPI_GOODSMVT_CREATE

and in the second line write BAPI_TRANSACTION_COMMIT

5.  Please see SAP Note 520813, and then revert what you have got by doing these all

Also, please see this link, which might suit you

BAPI_GOODSMVT_CREATE to post Goods Movement

Read only

srikanthv2
Participant
0 Likes
3,423

Hi Puja,

I think, please pass the purchase order number like below code.

in your code:

wa_goodsmvt_item-po_number            = <lfs_lips>-vbeln.



instead of above code write :

wa_goodsmvt_item-po_number            = <lfs_lips>-VGBEL.


May it will helps you,


Regards,

Sri..

Read only

0 Likes
3,423

Hi Srikanth,

Initially I was getting another error but then I passed LIPS-VGBEL as po_number when I was executing the BAPI stand alone from se37 and then I am getting the error as posted above.

Thanks for the effort.