Application Development 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: 

BAPI_GOODSMVT_CREATE

former_member200872
Active Participant
0 Kudos

Hello Experts,

Can some one help me with a sample abap program making use of the BAPI function BAPI_GOODSMVT_CREATE to generate Goods Receipts with reference to an outbound delivery.

what are the fields of the internal table i will need to populate and from which tables am i to fetch the relavent data.

Can anyone give me example code.

Thanks

9 REPLIES 9

sachin_mathapati
Contributor
0 Kudos

Hi wajid,

Check this link..

[http://www.sap-img.com/abap/bapi-goodsmvt-create-to-post-goods-movement.htm]

Regards,

Sachin M M

former_member673464
Active Contributor
0 Kudos

hi,

Try the following link

Regards,

Veeresh

0 Kudos

Ravi

could you please give any step by step thing to learn LSMW

I am trying to learn how to use it.

0 Kudos

Hi ,

thanks for the replies. But both these arent suting my requriement . i want to do MIGO with movement type '101' Against delivery No.

Thanks.

0 Kudos

Hi,

You can create the GR document using the BAPI by passing the following fields in the structures and tables for the movement type 101.

pstng_date, doc_date, ref_doc_no(nothing but Outbound delivery number) all these fields are part of GOODSMVT_HEADER

GOODSMVT_CODE should be 01

MATERIAL, PLANT, STGE_LOC, ENTRY_QNT, ENTRY_UOM, PO_NUMBER, PO_ITEM, MOVE_TYPE as 101 in the table GOODSMVT_ITEM

Pass all the above mentioned field values to the BAPI and then you can generate the GR document.

If you are trying to test BAPI, you need to test in FM sequence and the GR document will not be created until you use the BAPI BAPI_TRANSACTION_COMIT.

Thanks,

Mahesh.

0 Kudos

Hi Mahesh ,

Thanks for Your reply. I am passing all the fields tht u have told. this is the error tht iam geting " Update control of movement type is incorrect (entry 101 X X _ L) " .

Thanks.

0 Kudos

Hi Wajid,

I have worked on similar requirement.

The logic in this is

1) From the delivery no get the PO number

2)Now upload the mandatory data from PO to the BAPI as follows.

The code is :

DATA : S_XBLNR TYPE MKPF-XBLNR.

DATA : S_EBELN TYPE EKPO-EBELN.

DATA : S_LFBNR TYPE MSEG-LFBNR.

DATA : IT_MKPF TYPE TABLE OF MKPF.

DATA : WA_MKPF LIKE LINE OF IT_MKPF.

DATA : IT_MSEG TYPE TABLE OF MSEG.

DATA : WA_MSEG LIKE LINE OF IT_MSEG.

DATA : IT_LIPS TYPE TABLE OF LIPS.

DATA : WA_LIPS LIKE LINE OF IT_LIPS.

DATA : IT_VBKD TYPE TABLE OF VBKD.

DATA : WA_VBKD LIKE LINE OF IT_VBKD.

DATA : IT_EKPO TYPE TABLE OF EKPO.

DATA : WA_EKPO LIKE LINE OF IT_EKPO.

DATA : IT_T006 TYPE TABLE OF T006 .

DATA : WA_T006 LIKE LINE OF IT_T006.

DATA : IT_RETURN TYPE TABLE OF BAPIRET2 .

DATA : WA_RETURN LIKE LINE OF IT_RETURN.

DATA :IT_ITEM TYPE TABLE OF BAPI2017_GM_ITEM_CREATE .

DATA: WA_ITEM LIKE LINE OF IT_ITEM.

DATA: IT_SERIAL TYPE BAPI2017_GM_SERIALNUMBER.

DATA: IT_MAT_DOCU TYPE BAPI2017_GM_HEAD_RET-MAT_DOC.

DATA: IT_MAT_DOCU_YR TYPE BAPI2017_GM_HEAD_RET-DOC_YEAR.

DATA: IT_GOODSMVT_HEADER TYPE BAPI2017_GM_HEAD_RET.

DATA : IT_PSTING_DATE TYPE BAPI2017_GM_HEAD_02-PSTNG_DATE.

DATA: S_HEADER TYPE BAPI2017_GM_HEAD_01.

CONSTANTS : S_CODE TYPE BAPI2017_GM_CODE VALUE '01'.

PARAMETERS : S_VBELN LIKE LIPS-VBELN.

SELECT * FROM LIPS INTO TABLE IT_LIPS

WHERE VBELN = S_VBELN.

IF NOT IT_LIPS[] IS INITIAL.

SELECT * FROM VBKD INTO TABLE IT_VBKD

FOR ALL ENTRIES IN IT_LIPS

WHERE VBELN = IT_LIPS-VGBEL.

ENDIF.

IF NOT IT_VBKD[] IS INITIAL.

LOOP AT IT_VBKD INTO WA_VBKD.

MOVE WA_VBKD-BSTKD TO S_EBELN.

ENDLOOP.

ENDIF.

SELECT * FROM EKPO INTO TABLE IT_EKPO

WHERE EBELN = S_EBELN.

IF NOT IT_EKPO[] IS INITIAL.

SELECT * FROM T006 INTO TABLE IT_T006

FOR ALL ENTRIES IN IT_EKPO

WHERE MSEHI = IT_EKPO-MEINS.

ENDIF.

LOOP AT IT_EKPO INTO WA_EKPO.

IF WA_EKPO-LGORT = SPACE.

MOVE '0001' TO WA_EKPO-LGORT.

MODIFY IT_EKPO FROM WA_EKPO.

MODIFY EKPO FROM WA_EKPO.

ENDIF.

MOVE WA_EKPO-EBELN TO WA_ITEM-PO_NUMBER.

MOVE WA_EKPO-EBELP TO WA_ITEM-PO_ITEM.

MOVE '101' TO WA_ITEM-MOVE_TYPE.

MOVE 'B' TO WA_ITEM-MVT_IND.

READ TABLE IT_VBKD INTO WA_VBKD WITH KEY BSTKD = WA_EKPO-EBELN.

IF SY-SUBRC = 0.

READ TABLE IT_LIPS INTO WA_LIPS WITH KEY VGBEL = WA_VBKD-VBELN.

IF SY-SUBRC = 0.

MOVE WA_LIPS-LFIMG TO WA_ITEM-ENTRY_QNT.

ENDIF.

ENDIF.

READ TABLE IT_T006 INTO WA_T006 WITH KEY MSEHI = WA_EKPO-MEINS.

IF SY-SUBRC = 0 .

MOVE WA_T006-ISOCODE TO WA_ITEM-ENTRY_UOM_ISO.

ENDIF.

APPEND WA_ITEM TO IT_ITEM.

CLEAR WA_ITEM.

ENDLOOP.

S_HEADER-PSTNG_DATE = SY-DATUM.

S_HEADER-DOC_DATE = SY-DATUM.

S_HEADER-REF_DOC_NO = S_XBLNR.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

GOODSMVT_HEADER = S_HEADER

GOODSMVT_CODE = S_CODE

IMPORTING

GOODSMVT_HEADRET = IT_GOODSMVT_HEADER

MATERIALDOCUMENT = IT_MAT_DOCU

MATDOCUMENTYEAR = IT_MAT_DOCU_YR

TABLES

GOODSMVT_ITEM = IT_ITEM

RETURN = IT_RETURN.

IF NOT IT_RETURN[] IS INITIAL.

LOOP AT IT_RETURN INTO WA_RETURN.

IF WA_RETURN-TYPE EQ 'E'.

MESSAGE ID SY-MSGID TYPE 'I' NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDLOOP.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

MESSAGE I004(ZME) WITH IT_MAT_DOCU WA_EKPO-EBELN.

ENDIF.

ENDIF.

ENDIF.

In the above code, you can find that some unnecessary data declarations . please delete them.

Also read the function module documentation . It will be very helpful in understanding the code.

Please ask me if you got any further doubts on this.

Thanks,

Vamshi.

Edited by: VAMSHI KRISHNA on Jul 22, 2008 7:38 PM

0 Kudos

Hi,

That error has to be corrected by the functional consultant, and check with your functional consultant you need to pass any other indicator, like special stock or something of that sort for your requirement.

Technically whatever values we are passing at the moment are sufficient and now it is upto the functional consultant to help us.

Thanks,

Mahesh.

Former Member
0 Kudos

Hi Wajid,

refer to the link below for the code:

http://www.sap-img.com/abap/bapi-goodsmvt-create-to-post-goods-movement.htm

With luck,

Pritam.