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

BAPI_GOODSMVT_CREATE

jopa
Participant
0 Likes
2,378

Hi,

I am using BAPI_GOODSMVT_CREATE

how to get material document item?

anyway material document is collected but I want material document Item also with this

Please reply me

Thanks in advance

11 REPLIES 11
Read only

Former Member
0 Likes
2,132

Hi,

You can pass the line item values in structure BAPI2017_GM_ITEM_CREATE.

Thanks,

Read only

0 Likes
2,132

Hi

Once we pass the item data material document is created and there is no line item for it in the export parameters

Read only

0 Likes
2,132

Hi Joseph,

There are following EXPORT parameters:

GOODSMVT_HEADRET -- Combination of Material Document Number/Material Document Year

MATERIALDOCUMENT -- Number of Material Document

MATDOCUMENTYEAR -- Material Document Year

Could you please explain what exactly you want and what is your requirement?

Thanks & Regards,

Anil Salekar

Read only

0 Likes
2,132

Hi,

what u are saying is perfect. how to get material document item?

suppose under one material document if i want 5 material document itmes to be created how to create?

Read only

0 Likes
2,132

Hi,

You could either fire a select from the table 'MSEG'

OR

Try the following FMs and see if they work for you:

BAPI_GOODSMVT_GETDETAIL - This should be what you are looking for.

Else try these:

/SAPHT/GOODS_MVMT_READ

BAPI_GOODSMVT_GETITEMS

Hope this helps

Wenonah

Read only

0 Likes
2,132

Hi Joseph,

What I understood is you have 5 line items and you want to post those 5 line items in same material document.

So follow the following steps:

1. Loop at items line.

Populate goodsmvt_header with header data like Delivery Note No, document date, posting date, PO No, Some Ref No, etc from first line item.

2. Populate goodsmvt_item with item data. Polulate fields like PO No, Item NO, Material, Production Date, Batch No, Goods Recepient, quantity, uom, movement type, plant, quantity in entry quantity same as quantity , UOM in ISO same as UOM, Movement Indicator, storage location, etc.

3. Populate goodsmvt_code with Goods Movement Code

4. At last call FM 'BAPI_GOODSMVT_CREATE' .

Thanks & Regards,

Anil Salekar

Read only

Former Member
Read only

Former Member
0 Likes
2,132

Hi Joseph,

You can use FM as follows:

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

goodsmvt_header = wa_gr_header

goodsmvt_code = wa_gr_code

  • TESTRUN = ' '

  • GOODSMVT_REF_EWM =

IMPORTING

goodsmvt_headret = wa_gr_headrt

materialdocument = wa_gr_matdoc

matdocumentyear = wa_gr_matdocyear

TABLES

goodsmvt_item = it_gr_item

  • GOODSMVT_SERIALNUMBER =

return = it_return

  • GOODSMVT_SERV_PART_DATA =

  • EXTENSIONIN =

Thanks & Regards,

Anil Salekar

Read only

0 Likes
2,132

Hi Anil,

If i pass header data same for 2 records and item changes it has to create one material document and two line items under this material document yes?

it is createing two mateial documents

I am using the below code

LOOP AT gt_data INTO wa_data.

lwa_bapi_header-doc_date = sy-datum.

lwa_bapi_header-pstng_date = wa_data-bldat.

IF lwa_bapi_header-pstng_date IS INITIAL.

lwa_bapi_header-pstng_date = sy-datum.

ENDIF.

lwa_bapi_header-ref_doc_no = wa_data-xblnr.

lwa_bapi_header-ver_gr_gi_slip = space.

lwa_bapi_code = lv_bapi_code.

wa_item1-material = wa_data-matnr.

wa_item1-plant = wa_data-werks.

wa_item1-stge_loc = wa_data-lgort.

wa_item1-move_type = '201'.

wa_item1-spec_stock = space. "SOBKZ

wa_item1-ENTRY_QNT = wa_data-erfmg. "ERFMG

*wa_item-ENTRY_UOM = "ERFME

*wa_item-QUANTITY = "MENGE

*wa_item-BASE_UOM = "MEINS

*wa_item-dmbtr =

*wa_item-MVT_IND = "SHKZG_MIGO

*wa_item-STCK_TYPE = "MIGO_INSMK

*wa_item-name1 =

*wa_item-lgobe =

wa_item1-item_text = wa_data-sgtxt.

*wa_item-GL_ACCOUNT = .

wa_item1-orderid = wa_data-aufnr.

wa_item1-costcenter = wa_data-kostl.

APPEND wa_item1 TO gt_item1.

CLEAR: wa_item1.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

goodsmvt_header = lwa_bapi_header

goodsmvt_code = lwa_bapi_code

testrun = c_testrun

  • GOODSMVT_REF_EWM =

IMPORTING

  • GOODSMVT_HEADRET =

materialdocument = lwa_bapi_ret02

  • MATDOCUMENTYEAR =

TABLES

goodsmvt_item = gt_item1

  • GOODSMVT_SERIALNUMBER =

return = l_bapi_ret01

  • GOODSMVT_SERV_PART_DATA =

  • EXTENSIONIN =

.

Read only

0 Likes
2,132

Hi Joseph,

Ensure that your table defination is correct. Then you can use AT NEW and AT END OF event as follows:

*******Following is the CODE I am using......I have removed some part of code.....

TYPES : BEGIN OF t_gr_data,

***All Header Fields*********

***All Item Fields*********

END OF t_gr_data.

DATA : wa_gr_data TYPE t_gr_data,

DATA : it_gr_data TYPE STANDARD TABLE OF t_gr_data WITH HEADER LINE.

DATA : lwa_gr_data LIKE wa_gr_data.

LOOP AT it_gr_data INTO lwa_gr_data.

MOVE lwa_gr_data TO wa_gr_data.

*******some header field as per your logic

AT NEW Header-Field.

*Populate Header Data

*Delivery Note No.

*document date

*posting date

*Delivery Note No.

*Bill of Lading Ocean

  • Bill Of Ladding Air

*Populate Goods Movement Code.

ENDAT.

*Populate Item Data

*Purchase Order Number

*Item No

*Material

  • Production Date

  • Goods Recipient

  • Batch

*quantity

*UOM

*MovementType

*Plant

*Quantity in Unit Of Entry

*Unit of Entry

*ISO code for unit of measurement

*Movement Indicator.

*storage Location

APPEND wa_gr_item TO it_gr_item.

AT END OF Header Field.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

goodsmvt_header = wa_gr_header

goodsmvt_code = wa_gr_code

  • TESTRUN = ' '

  • GOODSMVT_REF_EWM =

IMPORTING

goodsmvt_headret = wa_gr_headrt

materialdocument = wa_gr_matdoc

matdocumentyear = wa_gr_matdocyear

TABLES

goodsmvt_item = it_gr_item

  • GOODSMVT_SERIALNUMBER =

return = it_return

  • GOODSMVT_SERV_PART_DATA =

  • EXTENSIONIN =

.

IF sy-subrc EQ 0.

IF NOT wa_gr_matdoc IS INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

EXPORTING

wait = 'X'

  • WAIT =

  • IMPORTING

  • RETURN = .

.

ENDIF.

ENDIF.

REFRESH : it_gr_item,

it_temp1.

CLEAR : wa_gr_header,

wa_gr_item ,

wa_gr_matdoc,

wa_temp1.

ENDAT.

ENDLOOP.

Thanks & Regards,

Anil Salekar

Read only

Former Member
0 Likes
2,132

hi

that is correct ..

use this link.

.

~linganna