Regarding BAPI_GOODSMVT_CREATE
Hi Experts!
I am using BAPI_GOODSMVT_CREATE to create a material document in migo screen using mb01 transaction.
I am getting one error that is whenever i put the quantity in , for example
if ordered quantity is 20 and i put quantity in unit of entry 21 it does not qive me error that p0 exceeded by 1. and post the data.
but after 24 it gives me an error which it has to given earlier 'po exceeded by 4'.
i am using gm_code = 01
with kzbew = B.
also populating fields like
matnr, po, po item, entry_qnt, movement type = 101
posting date, document date and reference document.
so plz help me out with that.
thanks in advance
Hi
Check this and do accordingly
REPORT ZRICH_0001 .
Structures for BAPI
DATA: GM_HEADER TYPE BAPI2017_GM_HEAD_01.
DATA: GM_CODE TYPE BAPI2017_GM_CODE.
DATA: GM_HEADRET TYPE BAPI2017_GM_HEAD_RET.
DATA: GM_ITEM TYPE TABLE OF
BAPI2017_GM_ITEM_CREATE WITH HEADER LINE.
DATA: GM_RETURN TYPE BAPIRET2 OCCURS 0 WITH HEADER LINE.
DATA: GM_RETMTD TYPE BAPI2017_GM_HEAD_RET-MAT_DOC.
CLEAR: GM_RETURN, GM_RETMTD. REFRESH GM_RETURN.
Setup BAPI header data.
GM_HEADER-PSTNG_DATE = SY-DATUM.
GM_HEADER-DOC_DATE = SY-DATUM.
GM_CODE-GM_CODE = '04'. " MB1A
Write 971 movement to table
CLEAR GM_ITEM.
MOVE '412' TO GM_ITEM-MOVE_TYPE .
MOVE 'Q' TO GM_ITEM-SPEC_STOCK.
MOVE '3800533484' TO GM_ITEM-MATERIAL.
MOVE '1' TO GM_ITEM-ENTRY_QNT.
*MOVE 'PC' TO GM_ITEM-ENTRY_UOM.
MOVE '1060' TO GM_ITEM-PLANT.
MOVE '0007' TO GM_ITEM-STGE_LOC.
*MOVE '0901' TO GM_ITEM-MOVE_REAS.
MOVE 'P203601001' TO GM_ITEM-WBS_ELEM.
MOVE 'P203601001' TO GM_ITEM-VAL_WBS_ELEM.
APPEND GM_ITEM.
Call goods movement BAPI
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
GOODSMVT_HEADER = GM_HEADER
GOODSMVT_CODE = GM_CODE
IMPORTING
GOODSMVT_HEADRET = GM_HEADRET
MATERIALDOCUMENT = GM_RETMTD
TABLES
GOODSMVT_ITEM = GM_ITEM
RETURN = GM_RETURN.
IF NOT GM_RETMTD IS INITIAL.
COMMIT WORK AND WAIT.
CALL FUNCTION 'DEQUEUE_ALL'.
ELSE.
COMMIT WORK AND WAIT.
CALL FUNCTION 'DEQUEUE_ALL'.
ENDIF.
WRITE:/ GM_RETMTD.
LOOP AT GM_RETURN.
WRITE:/ GM_RETURN.
ENDLOOP.
check the BAPI_GOODSMVT_CREATE.
Functionality
You can use this method to create a material document for a goods movement.
You can only create one material document each time you call up the method.
You can use a simulation function before posting the goods movement to check how the data is updated in the database. The standard system is configured so that the goods movement is posted immediately without simulating beforehand.
Ensure that you transfer the data in the same way as it is run in the database, for example,
Material number 18-figure with leading zeros
Batches with uppercase letters
Note that for all transactions/events listed below, the posting date is entered in the header data of the material document. In the BAPI2017_GM_HEAD_01 interface, fill the PSTNG_DATE (import structure GOODSMVT_HEADER) field.
Notes
Authorization check check
In the MM Inventory Management component, the method does not execute any authorization checks.
Note that during a posting of a goods movement, depending on the business transaction of the system, authorization objects of other applications can also be checked.
Transfer
The following information about the material document that is to be created is transferred to the method:
a structure with header data
a structure with the code for the movement
a table with the item data
a table with the serial numbers
The posting is carried out in the SAP R/3 via the MB_CREATE_GOODS_MOVEMENT function module.
Confirmations
Messages are returned in the Return parameter. The parameter documentation shows the return codes and their meanings.
Further Information
The method can only carry out your function if no error messages were generated in the Return table. This is the case if the header data and all the items were processed successfully.
Transaction control is not implemented. The calling program therefore has to execute the Commit Work itself after this method has been successfully called (in other words, if no errors were reported in the Return parameter).
Which fields have to be filled during the various transactions/ events?
The following sample scenarios demonstrate which fields have to be filled for which business transactions/events (code).
There are the following types of transactions/events:
1. GM_Code 01: Goods receipt for purchase order
2. GM_Code 02: Goods receipt for production order
3. GM_Code 03: Goods issue
4. GM_Code 04: Transfer posting
5. GM_Code 05: Other goods receipts
6. GM_Code 06: Reversal of goods movements
7. GM_Code 07: Subsequent adjustment to a subcontract order
Entering the movement indicator
Depending on the transaction, you must enter the following in the movement indicator:
GM_Code 01 (Goods receipt for purchase order): B
GM_Code 02 (Goods receipt for production order): F
For all other transactions, you leave the field blank.
For 1: GM_Code 01: Goods receipt for purchase order
Purchase order known
The following fields have to be filled:
Purchase order
Purchase order item
Movement type
Movement indicator
Quantity in unit of entry
ISO code unit of measurement for unit of entry or
quantity proposal
The following fields may have to be filled in some cases (incomplete listing):
Shelf life expiration date (if it has been configured like this in the system)
Reason for movement (if it has been configured like this in the system)
Batch (if the material is handled in batches and batch numbers are not assigned automatically)
Storage location (if a storage location has not been specified in the purchase order item)
The following fields can be filled (incomplete listing):
Stock type
Item text
Unloading point
Delivery completed indicator
You cannot fill the following fields (incomplete listing):
Account assignment fields (account assignment is adopted from the purchase order)
Reservation
Receiving/issuing material
Receiving/issuing plant
Receiving/issuing storage location
In the case of a purchase order item with the "subcontracting" item category, only the GR item in the interface is to be transferred. The system automatically determines GI items.
Purchase order unknown: Shipping notification known
The following fields have to be filled:
Delivery
Delivery item
Movement type
Other fields, such as those under "Purchase order known". The system determines the relevant purchase order item via the delivery/delivery item.
Purchase order unknown: Purchase order should be created automatically
The following fields have to be filled:
Material number
Plant
Storage location
Vendor
Movement type
Movement indicator
Quantity in unit of entry
ISO code unit of measurement for unit of entry
The following fields may have to be filled in some cases (incomplete listing):
Shelf life expiration date (if it has been configured like this in the system)
Reason for movement (if it has been configured like this in the system)
Batch (if the material is handled in batches and batches are not assigned automatically)
The following fields can be filled (incomplete listing):
Stock type
Item text
Unloading point
You cannot fill the following fields (incomplete listing):
Account assignment fields (automatic creation of purchase order items with account assignment is not supported)
Reservation
Receiving/issuing material
Receiving/issuing plant
Receiving/issuing storage location
Purchase order unknown: A purchase order should not be created
The following fields have to be filled:
Material number
Plant
Storage location
Vendor
Movement type
Movement indicator
Quantity in unit of entry
ISO code unit of measurement for unit of entry
The following fields may have to be filled in some cases (incomplete listing):
Shelf life expiration date (if it has been configured like this)
Reason for movement (if it has been configured like this)
Batch (if the material is handled in batches and automatic assignment of batch numbers is not set)
The following fields can be filled (incomplete listing):
Special stock indicator
Item text
Unloading point
Goods recipient
The following fields cannot be filled (incomplete listing):
Account assignment fields (automatic creation of purchase order items with account assignment is not supported)
Reservation
Receiving/issuing material
Receiving/issuing plant
Receiving/issuing storage location
Receiving/issuing batch
The input combinations listed above for the GM_CODE 01 can be combined within an input table so that they can be posted in a material document. Items can also be posted for different purchase orders, provided that all the purchase orders refer to the same vendor.
Transfer of subcontracting components
During the posting of the ordered material of a subcontract order with movement type 101, for the transfer of the subcontracting components, the filled unique identification of the document line (LINE_ID) is also required.
More information on LINE_ID and PARENT_ID
The following fields have to be filled for the components:
Unique identification of the document line
Identification of the immediately superior line
Material number
Plant
Storage location
Quantity in unit of entry
The following fields can be filled for the components:
All other fields in the method that are included in this list.
The following fields cannot be filled for the components:
All fields that are not included in the list above. The movement indicator must be initial.
Additional fields in goods-receipt-based invoice verification
When you post a goods receipt to purchase order with movement type 102, an issue with reference to a previously posted goods issue, the following fields must also be transferred:
REF_DOC_IT (LFPOS): Item of a reference document
REF_DOC (LFBNR): Document number of a reference document
REF_DOC_YR (LFBJA): Fiscal year of a reference document
Only when you transfer these fields is it guaranteed that the reference to the original goods movement stay the same.
For 2 GM_Code 02: Goods receipt for production order
The following fields have to be filled:
Order
Movement type
Movement indicator
Quantity in unit of entry
ISO code unit of measurement for unit of entry or
quantity proposal
The following fields may have to be filled in some cases (incomplete listing):
Shelf life expiration date (if the system has been configured like this)
Reason for movement (if the system has been configured like this)
Batch (if the material is handled in batches and automatic batch number assignment is not set)
Storage location (if storage location has not been specified in the order)
The following fields can be filled (incomplete listing):
Order item (co-product)
Stock type
Item text
Unloading point
"Delivery completed" indicator
The following fields cannot be filled (incomplete listing):
Account assignment fields (the account assignments are adopted from the purchase order)
Reservation
Receiving/issuing material
Receiving/issuing plant
Receiving/issuing storage location
Receiving/issuing batch
For 3 GM_Code 03: Goods issue
Goods issue without reference to a reservation
The following fields have to be filled:
Material number
Plant
Storage location
Movement type
Movement indicator
Quantity in unit of entry
ISO code unit of measurement for unit of entry
The following fields may have to be filled in some cases (incomplete listing):
Special stock (e.g. sales order, project, vendor etc.)
Shelf life expiration date (if the system is configured like this)
Reason for movement (if the system has been configured like this)
Batch (if the material is handled in batches and automatic batch number assignment is not set)
Account assignment fields
The following fields can be filled (incomplete listing):
Special stock indicator
Item text
Unloading point
Goods recipient
The following fields cannot be filled (incomplete listing):
Reservation
Receiving/issuing material
Receiving/issuing plant
Receiving/issuing storage location
Receiving/issuing batch
Goods issue with reference to a reservation
The following fields have to be filled:
Reservation number
Reservation item
Record type of the reservation
Movement indicator
Quantity in unit of entry
ISO code unit of measurement for unit of entry
The following fields may have to be filled in some cases (incomplete listing):
Shelf life expiration date (if this has been configured in the system)
Reason for movement (if this has been configured in the system)
Batch (if the material is handled in batches and automatic batch number assignment is not set)
Storage location (if not planned in the reservation)
The following fields can be filled (incomplete listing):
Special stock indicator
Item text
Unloading point
Goods recipient
The following fields cannot be filled (incomplete listing):
Movement type
Material
Plant
Account assignment fields
For 4 GM_Code 04: Transfer posting
Transfer posting without reference to a reservation
The following fields have to be filled:
Material number
Plant
Storage location
Movement type
Movement indicator
Quantity in unit of entry
ISO code unit of measurement for unit of entry
The following fields may have to be filled in some cases (incomplete listing):
Receiving material
Receiving plant
Receiving storage location
Receiving batch (if material is handled in batches and you want to change batches)
Receiving/issuing special stock (e.g. sales order, project, vendor etc.)
Shelf life expiration date (if this has been configured in the system)
Reason for movement (if this has been configured in the system)
Batch (if the material is handled in batches and automatic batch number assignment is not set)
The following fields can be filled (incomplete listing):
Special stock indicator
Item text
Account assignment fields (for automatic posting lines: Expense/income from stock transfer)
The following fields cannot be filled (incomplete listing):
Reservation
Transfer posting with reference to a reservation
See goods issue with reference to a reservation
For 5 GM_Code 05: Other goods receipts
Other goods receipt without reference to a reservation
See goods issue without reference to a reservation
Other goods receipt with reference to a reservation
See goods issue with reference to a reservation
For 6 GM_Code 06: Reversal of goods movements
You can use the Cancel method to reverse goods movements. But you may also want to cancel a goods movement without referring to a material document (see the Cancel method).
If you want to work without referring to the document, you have to fill the field BAPI_GM_ITEM_CREATE-XSTOB in the interface (import table GOODSMVT_ITEM). In this case, the system converts the movement type assigned in the interface to the reversal movement type. Alternatively, you can set the reversal movement type in the interface. In this case, the BAPI_GM_ITEM_CREATE_XSTOB field must be transferred blank.
If you want to cancel a goods movement with reference to a reservation (without using the Cancel method) you can only transfer the field BAPI_GM_ITEM_CREATE_XSTOB if it is filled. Movement types are not transferred when you post with reference to a reservation, as the movement type is contained in the reservation item.
For 7. GM_Code 07: Subsequent adjustment to a subcontract order
Ordered material of subcontract order
The following fields have to be filled:
Unique identification of document line (can be assigned to anything)
Posting date in document header
Document number of purchasing document
Item number of purchasing document
Material number check
Plant check
Movement type (select movement type 121)
Movement indicator (must be O)
Further entries are not allowed. The entry quantity for the ordered material of a subcontract order must be zero.
Components
The following fields have to be filled:
Unique identification of document line (can be assigned to anything)
Identification of the immediately superior line
Plant
Material number check
Quantity in unit of entry; can also be negative
The following fields can be filled:
Storage location
All other fields in the method that are included in this list.
The following fields may not be filled:
All fields that are not in the list above. The movement indicator must be blank.
More information on LINE_ID and PARENT_ID
Additional fields in goods-receipt-based invoice verification
When you post a subsequent adjustment, the following fields must also be transferred:
REF_DOC_IT (LFPOS): Item of a reference document
REF_DOC (LFBNR): Document number of a reference document
REF_DOC_YR (LFBJA): Fiscal year of a reference document
Only when you transfer these fields is it guaranteed that the reference to the original goods movement stays the same.
Regards
Anji
Similar Messages
-
GOODSMVT_SERIALNUMBER issue
Hi Experts,
I have an issue regarding BAPI_GOODSMVT_CREATE. I have a requirement to create a program and use that bapi in Good Issue with movement type 201
But im having an error "Maintain serial numbers for total quantity"
I've searched for it already but i can't find any solutions regarding the matter.
Please help me with this one. Thanks
Here is my code.
gt_goodsmvt_header-pstng_date = sy-datum.
gt_goodsmvt_header-doc_date = sy-datum.
"Document Header text
gt_goodsmvt_header-header_txt = p_doctxt.
"Goods Movement Code
goodsmvt_code_tmp-gm_code = '03'.
"Material Number
SELECT matnr
INTO gt_goodsmvt_item-material
FROM equi
WHERE equnr EQ p_equnr.
ENDSELECT.
"Plant
SELECT b_werk
INTO gt_goodsmvt_item-plant
FROM eqbs
WHERE equnr EQ p_equnr.
ENDSELECT.
"Sorage Location
SELECT b_lager
INTO gt_goodsmvt_item-stge_loc
FROM eqbs
WHERE equnr EQ p_equnr.
ENDSELECT.
"Movement Type
gt_goodsmvt_item-move_type = '201'.
"Quantity in Unit of Entry
gt_goodsmvt_item-entry_qnt = '1'.
"Unit of Measure
SELECT meins
INTO gt_goodsmvt_item-entry_uom_iso
FROM equi
WHERE equnr EQ p_equnr.
ENDSELECT.
* gt_goodsmvt_item-entry_uom_iso = 'EA'.
"Delivery Completed Indicator
gt_goodsmvt_item-no_more_gr = 'X'.
"Receiving/Issuing Material
SELECT matnr
INTO gt_goodsmvt_item-move_mat
FROM equi
WHERE equnr EQ p_equnr.
ENDSELECT.
"Receiving/Issuing Plant
"wala pa eto ang new plant
gt_goodsmvt_item-move_plant = p_tplnr.
"Receiving/Issuing Storage Location
gt_goodsmvt_item-move_stloc = '0002'.
"Serial Number
SELECT sernr
INTO gt_goodsmvt_serialnumber-serialno
FROM equi
WHERE equnr EQ p_equnr.
ENDSELECT.
* gt_goodsmvt_serialnumber-serialno = p_equnr.
APPEND gt_goodsmvt_item.
APPEND gt_goodsmvt_serialnumber.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = gt_goodsmvt_header
goodsmvt_code = goodsmvt_code_tmp
* testrun = testrun
IMPORTING
goodsmvt_headret = gt_goodsmvt_headret
TABLES
goodsmvt_item = gt_goodsmvt_item
GOODSMVT_SERIALNUMBER = gt_goodsmvt_serialnumber
return = gt_return.
IF gt_return[] IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = l_return.
WRITE:/3 'ASN Number', gt_goodsmvt_item-deliv_numb_to_search,
/3 'Item',gt_goodsmvt_item-deliv_item_to_search.
ELSE.
read table gt_return index 1.
WRITE: '~ERROR~',
/ gt_return-message.
ENDIF.Hi Jepoy
Where are you passing the line number(MATDOC_ITM) in gt_goodsmvt_serialnumber..? Pass to it the reference of gt_goodsmvt_item. Lets say you have one line. So pass here 0001 so that logic understands this serial number is related to which line item
Nabheet -
Regarding : bapi BAPI_GOODSMVT_CREATE
Hi Experts,
I have to use bapi BAPI_GOODSMVT_CREATE with GOODSMVT_CODE = 04. for the transfer posting of articles from unrestricted to block status.
The movement type for customer return is 252 and i have to execute the 344 movement type for such articles using this bapi.
Can anyone help me as to how to use this bapi, how to populate the item table etc.
Thanks,
NaveenHi,
Check the links
[http://www.sap-img.com/abap/bapi-goodsmvt-create-to-post-goods-movement.htm]
[http://www.sap-img.com/abap/bapi-goodsmvt-create-to-post-goods-movement.htm]
They will give you idea.
and please resolve your post as soon as they are answered. Keeping more than 10 unresolved post is against the rule of engagement. Moderator may lock your thread or account.
Name: Naveen Sharma - View user's Business Card
Registered: Mar 1, 2007
Total Posts: 39
Total Questions: 35 (34 unresolved)
Forum Points: 0
Reagrds,
Anirban -
Error while posting a document using the BAPI_GOODSMVT_CREATE
Hi,
i was trying to post the Goods Receipt document ( Tcode MB1C) using the bapi BAPI_GOODSMVT_CREATE
i am passing the item details and Serial number details.
the error triggered was Maintain Serial Numbers for Total Quantity
but i am passing the quantity as 1 ( in item data) and passing one serial number.
is this error because of data problem or am i missing to pass the value to some dependent parameter..?
Please help me out.
Thanks in advance.
SriramHi David,
i was tring to pass the same.
in item table we have we have four item details ( below)
RES_ITEM - Item Number of Reservation/Dependent Requirement
ORDER_ITNO - Order Item Number
S_ORD_ITEM - Item Number in Sales Order ( length mismatch with serial item number)
PO_ITEM - Item Number of Purchasing Document ( length mismatch with serial item number)
out 4 , 2 are ruled out because of length mismatch. and in the reaming two are
RES_ITEM - Item Number of Reservation/Dependent Requirement
ORDER_ITNO - Order Item Number
this is a Goods receipt document, please let me know which field is required to map with item number in the above two.
Regards,
Sriram. -
BAPI_GOODSMVT_CREATE - Error while posting a Material Document
Hi Experts,
We are trying to do the material document posting using the transaction "MB1C" manually in SAP. The movement type which we are using for the same is "261". While doing this is, it is asking for a work order number and the Recipient number. We gave the Recipient Number as "123". Material document is created successfully.
Again using the same transaction "MB1C" , we are trying to do the reversal of the material document which we posted previously against another work order number for the same material and the serial number if the material is serialised and as well as for the non serialised material.
Both this case, in SAP the material document is created succesfully. This is done manually in SAP.
When we are trying to create the material document using the BAPI 'BAPI_GOODSMVT_CREATE', for the above scenario, posting the material document '261' movement type for one work order and the reversal for another work order '262' movement type for the same material (whether it is a serialised or non serialised) we are getting the eror as "RE Qty. transferred exceeded 1 PC: 50,003,695 C001 USED 1200".
We are passing the following at the item level. MATERIAL Number, Plant, STGE_LOC, ENTRY_QNT, MOVE_TYPE, BATCH, ORDERID, RESERV_NO, RES_ITEM, ACTIVITY, XSTOB for reversal.
We are passing the GM_CODE as '05'.
Please let us know what needs to be changed inorder to create the material document properly without getting errors.
Thanks in Advance,
Mohan.Hi,
We fixed this issue by removing the reservation number of the material when we are trying to post the material document with the movement type "262".
The reason for removing the reservation number for the movement type "262"
The reservation number is getting created against a work order when we trying to create the work order in IW32. This reservation number is used for validating the stock while we are trying to consume and doing the reversal.
SAP is allowing us to reverse the consumed quantities only based on the reservartion number and hence we got this error.
To fix this error, if we are trying to reverse a particular material against a different work order for which it has been consumed previiously, remove the reservation number and item number and try posting the material document.
Hope this solution will solve your issue:)
Thanks and Regards,
Mohan. -
Hi Friends,
I need to create a goods receipt for an inbound delivery.
Iam planning to use either MB_CREATE_GOODS_MOVEMENT or BAPI_GOODSMVT_CREATE.
But every time iam getting the error saying that the 101 movement type cant be used.
In my case i need to use both the movement types 101 and 543.
Basically i need to populate both the main item and component material information.
If any one has done this, Can you please give me the sample code.
Regards
SasiHi,
Iam usig the gm_code as 05.
I am paasing the movement indicator ,in that particular field.
lw_goodsmvt_item-material = lw_imseg-matnr.
lw_goodsmvt_item-plant = lw_imseg-werks.
lw_goodsmvt_item-batch = lw_imseg-charg.
IF lw_imseg-sgtxt = 'F'.
lw_goodsmvt_item-move_type = '101'.
lw_goodsmvt_item-mvt_ind = 'B'.
lw_goodsmvt_item-NO_MORE_GR = 1.
lw_goodsmvt_item-stge_loc = lw_imseg-lgort.
ELSEIF lw_imseg-sgtxt = 'C'.
lw_goodsmvt_item-move_type = '543'.
endif.
lw_goodsmvt_item-entry_qnt = lw_imseg-erfmg.
lw_goodsmvt_item-entry_uom = lw_imseg-erfme.
lw_goodsmvt_item-expirydate = lw_imseg-mhdat.
lw_goodsmvt_item-DELIV_NUMB =
lw_goodsmvt_item-DELIV_ITEM =
am i doing something wrong here.
iam gettign the following error message
Goods movement not possible with mvmt type 101
Goods movement not possible with mvmt type 543 -
Error in Bapi_GoodsMvt_Create using Purchase order
Hi Friends,
I am using Bapi_goodsmvt_create for Goods Receipts against Purchase order.
The below code i have given for Goods receipts
It shows the error like
ID : 8J
Err No.:182
Message : Entry 4500000344 00040 0000 not valid; correct entry
Please help me to correct this error.
Thanks
Shankar
===================================
Heading Structure
st_gm_code-gm_code = '01'.
st_gm_header-pstng_date = '20070930'.
st_gm_header-doc_date = '20070930'.
st_gm_header-gr_gi_slip_no = '970015'.
st_gm_header-bill_of_lading = '527213'.
st_gm_header-header_txt = 'AIR'.
st_gm_header-ref_doc_no = '4500000344'.
Tables - ITEM CREATE.
itab_afs_gm_itemx-plant = '2000'.
itab_afs_gm_itemx-deliv_numb = '80100121'.
itab_afs_gm_itemx-stge_loc = '2110'.
itab_afs_gm_itemx-move_stloc = '2110'.
itab_afs_gm_itemx-po_number = '4500000344'.
itab_afs_gm_itemx-po_item = '00040'.
itab_afs_gm_itemx-vendor = '0000650003'.
itab_afs_gm_itemx-vendrbatch = 'ABC123'.
itab_afs_gm_itemx-move_type = '101'.
itab_afs_gm_itemx-mvt_ind = 'B'.
itab_afs_gm_itemx-material = '000000000030000227'.
itab_afs_gm_itemx-entry_qnt = 10.
APPEND itab_afs_gm_itemx .
****&& Grid values
gr_afs-matdoc_itm = '0001'.
gr_afs-grid_value = '205'.
gr_afs-withdrawn_sku = 'X'. "Final issue at sku level
gr_afs-stock_cat = '0000000001000366'.
APPEND gr_afs.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = st_gm_header
goodsmvt_code = st_gm_code
TESTRUN = ' '
IMPORTING
goodsmvt_headret = st_gm_headret
materialdocument = mat_doc
matdocumentyear = doc_year
TABLES
goodsmvt_item = itab_afs_gm_itemx
afs_goodsmvt_sku = gr_afs
return = bapi_return.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
CLEAR itab_afs_gm_itemx.
REFRESH itab_afs_gm_itemx.
CLEAR gr_afs.
REFRESH gr_afs.Hi,
Here is some sample code from one of my programs, which does a 551 movement type. This should get you started. Just check the RETURN table for messages, they should tell you what you are missing.
code
Structures for BAPI
data: gm_header type bapi2017_gm_head_01.
data: gm_code type bapi2017_gm_code.
data: gm_headret type bapi2017_gm_head_ret.
data: gm_item type table of
bapi2017_gm_item_create with header line.
data: gm_return type bapiret2 occurs 0.
data: gm_retmtd type bapi2017_gm_head_ret-mat_doc.
clear: gm_return, gm_retmtd. refresh gm_return.
Setup BAPI header data.
gm_header-pstng_date = sy-datum.
gm_header-doc_date = sy-datum.
gm_code-gm_code = '06'. " MB11
Write 551 movement to table
clear gm_item.
move '551' to gm_item-move_type .
move '000000000040001234' to gm_item-material.
move '1' to gm_item-entry_qnt.
move 'EA' to gm_item-entry_uom.
move '0004' to gm_item-plant.
move '4000' to gm_item-stge_loc.
move '201' to gm_item-move_reas.
Determine cost center per plant
case xresb-werks.
when '0004'.
move '0000041430' to gm_item-costcenter.
when '0006'.
move '0000041630' to gm_item-costcenter.
when '0007'.
move '0000041731' to gm_item-costcenter.
when '0008'.
move '0000041830' to gm_item-costcenter.
endcase.
append gm_item.
Call goods movement BAPI
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = gm_header
goodsmvt_code = gm_code
importing
goodsmvt_headret = gm_headret
materialdocument = gm_retmtd
tables
goodsmvt_item = gm_item
return = gm_return.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
[/code]
Welcome to SDN! Please remember to award points for helpful answers and mark you post as solved when solved completely. Thanks.
REgards,
Raj. -
Goods Receipt Report With 101 movement type using bapi_goodsmvt_create
Dear Abapers,
i am getting some problem, i got requirement like Goods Receipt Report with 101 movement type using
bapi_goodsmvt_create and data should upload through excel sheet.
still facing problems, i have searched sdn forum n sdn code also, but relevant answer i could not find.
What are all the inputs i need to take and please give some valuable inputs to me.
please do help ..... thanks for advance..
Thanks & regards,
Vinay.
Moderator message : Spec dumping is not allowed, show the work you have already done. Thead locked.
Edited by: Vinod Kumar on Sep 27, 2011 10:58 AMDear Abapers,
i am getting some problem, i got requirement like Goods Receipt Report with 101 movement type using
bapi_goodsmvt_create and data should upload through excel sheet.
still facing problems, i have searched sdn forum n sdn code also, but relevant answer i could not find.
What are all the inputs i need to take and please give some valuable inputs to me.
please do help ..... thanks for advance..
Thanks & regards,
Vinay.
Moderator message : Spec dumping is not allowed, show the work you have already done. Thead locked.
Edited by: Vinod Kumar on Sep 27, 2011 10:58 AM -
Regarding Goods Reversal and Goods Issue process for Production orders
Hi,
I have a issue regarding <b>Goods Reversal</b> and <b>Goods Issue</b> process for <b>Production orders</b>.
Actually I am having a Z - Function Module in that i am passing <b>production order number other details</b> to
make the <b>Goods Reversal</b> happen.
The code for the above is as below:
i_mvtit-material = wa_mdfa-matnr.
i_mvtit-plant = i_resb-werks.
i_mvtit-spec_stock = 'Q'. "New
i_mvtit-stge_loc = 'ZWIP'.
i_mvtit-stge_type = i_resb-lgtyp. "New
i_mvtit-batch = i_resb-charg. "New
i_mvtit-orderid = i_resb-aufnr.
i_mvtit-spec_stock = i_resb-sobkz.
i_mvtit-entry_qnt = i_resb-enmng.
i_mvtit-entry_uom = i_resb-erfme.
i_mvtit-entry_uom_iso = i_resb-meins. "New
i_mvtit-wbs_elem = v_frwbs.
i_mvtit-move_type = '262'.
i_mvtit-xstob = 'X'.
i_mvtit-gr_rcpt = i_resb-aufnr. "New
i_mvtit-reserv_no = i_resb-rsnum.
i_mvtit-res_item = i_resb-rspos.
APPEND i_mvtit.
* HEADER ELEMENTS
k_gmvt_code-gm_code = '03'.
k_gmvt_head-pstng_date = sy-datum.
k_gmvt_head-doc_date = sy-datum.
* CREATE GOODS MOVEMENTS
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = k_gmvt_head
goodsmvt_code = k_gmvt_code
TABLES
goodsmvt_item = i_mvtit
return = i_return.
The Above code does the <b>Goods Reversal</b> but then i will update one Z Table with fields like
Production Order Number[AUFNR], Number of Reservation[RSNUM], Item Number of Reservation [RSPOS], Material Number [MATNR], Requirement Quantity [BDMNG], WBS element[PSPNR] etc. If Above BAPI runs sucessfully.
That is happening correctly.
But Then actual issue is i have do <b>Goods Issue</b> for those Z-Table records.
There i will give Production order Number's & Storage Location in Selection-Criteria.
Then i need to do <b>Goods Issue</b> for that order.
The code i had written as follows.
* POPULATE VALUES FOR BAPI CALL
i_mvtit-material = i_zpsi7603_01-matnr.
i_mvtit-plant = i_resb-werks.
i_mvtit-spec_stock = 'Q'. "New
i_mvtit-stge_loc = p_sloc.
i_mvtit-stge_type = i_resb-lgtyp. "New
i_mvtit-batch = i_resb-charg.
i_mvtit-orderid = i_resb-aufnr.
i_mvtit-spec_stock = i_resb-sobkz.
i_mvtit-entry_qnt = i_resb-enmng.
i_mvtit-entry_uom = i_resb-erfme.
i_mvtit-entry_uom_iso = i_resb-meins. "New
i_mvtit-wbs_elem = v_frwbs.
i_mvtit-move_type = c_261.
i_mvtit-mvt_ind = 'F'. "New
i_mvtit-xstob = c_x.
i_mvtit-gr_rcpt = i_resb-aufnr. "New
i_mvtit-reserv_no = i_resb-rsnum.
i_mvtit-res_item = i_resb-rspos.
APPEND i_mvtit.
* HEADER ELEMENTS
k_gmvt_code-gm_code = c_03.
k_gmvt_head-pstng_date = sy-datum.
k_gmvt_head-doc_date = sy-datum.
* CREATE GOODS MOVEMENTS
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = k_gmvt_head
goodsmvt_code = k_gmvt_code
TABLES
goodsmvt_item = i_mvtit
return = i_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = c_x.
READ TABLE i_return INDEX 1.
IF i_return-type EQ c_s.
DELETE FROM zpsi7603_01 WHERE aufnr = i_resb-aufnr AND
rsnum = i_resb-rsnum AND
rspos = i_resb-rspos.
ENDIF.
If i run above code for <b>Goods Issue</b> it is giving error can anybody tell me what changes i need to do to make it work.
The <b>Error Message</b> i am getting is as below:
<b>Qty and / or "delivery completed" ind. or final issue ind. are missing</b>
<b>Error Number for the above is : 264.</b>
Can anybody solve my issue.
Any help will be appreciated.
Thanks in advance.
Thanks & Regards,
Rayeez.Hi,
Thanks boss.
It is working now correctly.
The issue is the i_mvtit-XSTOB should be equal space in case of Goods issue while incase of Reversal it should be equal to X.
Thanks for ur efforts.
I had awarded you points.
Thanks a lot.
Thanks & Regards,
Rayeez. -
Regarding : Material document data and PO data do not match (Plant)
Hi Gurus,
Please go through this BAPI program.
While uploading it is giving an error ' Material document data and PO data do not match (Plant) '.
Please help regarding this issue.For all Other moment types it is working fine except this 351 moment type.
dATA: i_excel TYPE truxs_t_text_data. "work table for excel upload
DATA: BEGIN OF it_itab OCCURS 100,
docdate(10),
postdate(10),
mvt_type(3), "Movement Type
plant(4), "Plant
lgort(4),
pur_doc(10), "Purchase Document No
po_item(3), "Purchase Document Item No
material(18), "Material Number
delnote(16),
erfmg(13),
uom(3),
lfmng(13), "Quantity
batch(10) TYPE c,
vfdat TYPE vfdat,
END OF it_itab.
DATA: it_goodsmvt_head TYPE TABLE OF bapi2017_gm_head_01 INITIAL SIZE 100,
it_goodsmvt_code TYPE TABLE OF bapi2017_gm_code INITIAL SIZE 100,
it_goodsmvt_item TYPE TABLE OF bapi2017_gm_item_create INITIAL SIZE 100.
DATA: wa_goodsmvt_head LIKE LINE OF it_goodsmvt_head,
wa_goodsmvt_code LIKE LINE OF it_goodsmvt_code,
wa_goodsmvt_item LIKE LINE OF it_goodsmvt_item.
DATA: w_mat_doc TYPE bapi2017_gm_head_ret-mat_doc,
w_year TYPE bapi2017_gm_head_ret-doc_year.
DATA: BEGIN OF it_errmsg_goodsmvt OCCURS 10.
INCLUDE STRUCTURE bapiret2.
DATA: END OF it_errmsg_goodsmvt.
DATA : obj_type LIKE bapiache09-obj_type,
obj_key LIKE bapiache09-obj_key,
obj_sys LIKE bapiache09-obj_sys.
DATA: v_date1 TYPE sy-datum.
DATA: v_date2 TYPE sy-datum.
DATA: w_lines TYPE i.
DATA: errflag.
SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME TITLE text-100.
PARAMETERS: p_file TYPE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK bk1.
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 processing
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_line_header = 'X'
i_tab_raw_data = i_excel
i_filename = p_file
TABLES
i_tab_converted_data = it_itab[]
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.
LOOP AT it_itab.
REFRESH it_goodsmvt_head.
REFRESH it_goodsmvt_item.
CONCATENATE it_itab-docdate6(4) it_itab-docdate3(2) it_itab-docdate+0(2) INTO v_date1.
CONCATENATE it_itab-postdate6(4) it_itab-postdate3(2) it_itab-postdate+0(2) INTO v_date2.
wa_goodsmvt_head-pstng_date = v_date2.
wa_goodsmvt_head-doc_date = v_date1.
wa_goodsmvt_head-ref_doc_no = it_itab-delnote.
wa_goodsmvt_head-pr_uname = sy-uname.
APPEND wa_goodsmvt_head TO it_goodsmvt_head.
Maintain it_goodsmvt_code
wa_goodsmvt_code-gm_code = '04'.
Maintain it_goodsmvt_item
*LOOP AT it_itab.
IF wa_goodsmvt_item-po_number IS INITIAL.
wa_goodsmvt_item-po_number = it_itab-pur_doc.
wa_goodsmvt_item-move_type = it_itab-mvt_type.
wa_goodsmvt_item-MOVE_PLANT = it_itab-plant.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = it_itab-material
IMPORTING
output = it_itab-material.
wa_goodsmvt_item-material = it_itab-material.
wa_goodsmvt_item-stge_loc = it_itab-lgort.
wa_goodsmvt_item-po_item = it_itab-po_item.
wa_goodsmvt_item-entry_qnt = it_itab-erfmg.
wa_goodsmvt_item-ENTRY_UOM_ISO = it_itab-uom.
wa_goodsmvt_item-po_pr_qnt = it_itab-lfmng.
wa_goodsmvt_item-batch = it_itab-batch.
wa_goodsmvt_item-expirydate = it_itab-vfdat.
wa_goodsmvt_item-NO_MORE_GR = 'X'.
wa_goodsmvt_item-mvt_ind = 'B'.
APPEND wa_goodsmvt_item TO it_goodsmvt_item.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = wa_goodsmvt_head
goodsmvt_code = wa_goodsmvt_code
IMPORTING
materialdocument = w_mat_doc
TABLES
goodsmvt_item = it_goodsmvt_item
return = it_errmsg_goodsmvt.
Process of commit work
IF it_goodsmvt_head[] IS NOT INITIAL.
DESCRIBE TABLE it_goodsmvt_head LINES w_lines.
ENDIF.
IF it_goodsmvt_item[] IS NOT INITIAL.
DESCRIBE TABLE it_goodsmvt_item LINES w_lines.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
IMPORTING
RETURN =
CLEAR errflag.
READ TABLE it_errmsg_goodsmvt INDEX 1.
IF it_errmsg_goodsmvt-type EQ 'E'.
WRITE:/'Error in function', it_errmsg_goodsmvt-message.
errflag = 'X'.
ELSE.
WRITE:/ it_errmsg_goodsmvt-message.
ENDIF.
IF errflag IS INITIAL.
COMMIT WORK AND WAIT.
IF sy-subrc NE 0.
WRITE:/ 'Error in updating'.
EXIT.
ELSE.
WRITE:/ 'Material Document created successfully and the Document Number for the Material',
wa_goodsmvt_item-material,'is:', w_mat_doc, w_year.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.Hey,
Just wanted to post that in my case this was the error of MVT_IND field in item table. When I made it from 'B' to blank then it worked.
Mine is solved....
Thanks -
Short dump while using FM "BAPI_GOODSMVT_CREATE" in background
Hi Sir,
I am using the FM "BAPI_GOODSMVT_CREATE" to create the Goods movement. While running the program through a job in background, article docu is generated successfully,,but at the same time it gives short dump in ST22.
Short text
Exception condition "CNTL_ERROR" raised.
A RAISE statement in the program "CL_GUI_CUSTOM_CONTAINER=======CP" raised the
exception
condition "CNTL_ERROR".
Since the exception was not intercepted by a superior
program, processing was terminated.
Please tell me what can be the possible reason for the same and how to avoid the same?
Warm regards
KrishanThere's at least one note addressing this. You should be able to find it quite easily.
Rob -
Error while doing PGI for Outbound delivery using BAPI BAPI_GOODSMVT_CREATE
Hi All,
I am getting an below error while doing PGI for outbound delivery using the BAPI BAPI BAPI_GOODSMVT_CREATE:
Goods movement not possible with mvmt type 601
Can anyone suggest me what will be the solution for it?
Regards,
Raghuraman.kI tried with the above BAPI but it is not working.
In my case a delivery has one line item with batch split and other line item without batch split.
Below is my code :
DATA : gwa_header_data TYPE bapiobdlvhdrcon,
gwa_header_ctrl TYPE bapiobdlvhdrctrlcon,
lv_delivery TYPE bapiobdlvhdrcon-deliv_numb,
git_item_data TYPE STANDARD TABLE OF bapiobdlvitemcon,
gwa_item_data TYPE bapiobdlvitemcon,
git_item_ctrl TYPE STANDARD TABLE OF bapiobdlvitemctrlcon,
gwa_item_ctrl TYPE bapiobdlvitemctrlcon,
git_return TYPE STANDARD TABLE OF bapiret2,
gwa_return TYPE bapiret2.
*Header data
gwa_header_data-deliv_numb = '0808000002'.
*Header Control data
gwa_header_ctrl-deliv_numb = '0808000002'.
gwa_header_ctrl-post_gi_flg = 'X'.
*Delivery Number
lv_delivery = '0808000002'.
*Item data and its corresponding control data
gwa_item_data-deliv_numb = '0808000002'.
gwa_item_data-deliv_item = '900002'.
gwa_item_data-dlv_qty = 4.
gwa_item_data-dlv_qty_imunit = 4.
gwa_item_data-fact_unit_nom = 1.
gwa_item_data-fact_unit_denom = 1.
APPEND gwa_item_data TO git_item_data.
gwa_item_ctrl-deliv_numb = '0808000002'.
gwa_item_ctrl-deliv_item = '900002'.
gwa_item_ctrl-chg_delqty = 'X'.
APPEND gwa_item_ctrl TO git_item_ctrl.
gwa_item_data-deliv_numb = '0808000002'.
gwa_item_data-deliv_item = '900003'.
gwa_item_data-dlv_qty = 6.
gwa_item_data-dlv_qty_imunit = 6.
gwa_item_data-fact_unit_nom = 1.
gwa_item_data-fact_unit_denom = 1.
APPEND gwa_item_data TO git_item_data.
gwa_item_ctrl-deliv_numb = '0808000002'.
gwa_item_ctrl-deliv_item = '900003'.
gwa_item_ctrl-chg_delqty = 'X'.
APPEND gwa_item_ctrl TO git_item_ctrl.
gwa_item_data-deliv_numb = '0808000002'.
gwa_item_data-deliv_item = '000020'.
gwa_item_data-dlv_qty = 10.
gwa_item_data-dlv_qty_imunit = 10.
gwa_item_data-fact_unit_nom = 1.
gwa_item_data-fact_unit_denom = 1.
APPEND gwa_item_data TO git_item_data.
gwa_item_ctrl-deliv_numb = '0808000002'.
gwa_item_ctrl-deliv_item = '000020'.
gwa_item_ctrl-chg_delqty = 'X'.
APPEND gwa_item_ctrl TO git_item_ctrl.
BREAK-POINT.
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CONFIRM_DEC'
EXPORTING
header_data = gwa_header_data
header_control = gwa_header_ctrl
delivery = lv_delivery
TABLES
item_data = git_item_data
item_control = git_item_ctrl
return = git_return.
BREAK-POINT.
IF git_return IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF. -
Error while using BAPI BAPI_GOODSMVT_CREATE for Momvent type 321
Hi Guys,
We trying to transfer material from Inspection to Un.Stock by using momvent type 321...In SAP we do QVM1 and do stock postion.
We are using BAPI BAPI_GOODSMVT_CREATE getting this error " E QA 495 Change the inspection stock of material 11036125 in QM only".
Any one have any idea how to overcome this issue.
AtulHi Sachin,
Pass the Item Number of Reservation to GOODSMVT_ITEM-RES_ITEM .
Regards
DKS -
Improve the performance of the 'BAPI_GOODSMVT_CREATE' Bapi
Hi All,
We have a requirement in which we create a material document number for each goods receipt note.
This is done with the help of 'BAPI_GOODSMVT_CREATE' . This BAPI is working perfectly fine and is correctly posting the material document number for each of the goods receipt.
The problem lies in the fact that this BAPI is geting called for each line item of the Purchase order ie it gets called in a loop , due to which this program is taking much longer time to run.
Is there any way or any sap notes which we can use to improve the performance of this BAPI .
Thanks ,
SumitHi,
Why do you call the bapi for each line item. All the line items per document should be processed together.
The standard code is mostly fine. The performance of these standard transactions generally deteriorates if good programming practices are not used in the user exits/badis available in the standard transaction. Check where is the pain point to figure out where the transaction takes more time.
Regards,
Abdullah. -
Error while using BAPI_GOODSMVT_CREATE
Hi friends,
When I do a 301 movement from MIGO transaction using BAPI BAPI_GOODSMVT_CREATE .. I m getting an error "The plant material data is locked by the user".. Can you help me out to solve this and post the goods movement.. it is very urgent requirement... Will reward points for helpfull answers,
Thanks in advance,
Rama..Hi ,
Check the Following :
Is your material is being edited by some user via MM02 etc.
Can you try calling the BAPI FM in Background task ? I guess that might Solve the problem ?
<b>REWARD IF USEFUL</b>
Regards,
Saket Sharma
null
Maybe you are looking for
-
Audio CD not appearing in source list
Since installing the latest version of Itunes I have not been able to get audio cd's to show up in the source list. I am able to eject the disc with the icon in the lower right hand corner and the songs will play if I manually open them in My Compute
-
Safari 6: Email this page, no page title as subject?
In all my other browsers, choosing "email link to this page" creates an email in my default mail program (Outlook 2011) with the page title as a subject line and the link to the page in the body of the email. Safari 6 on 10.8, however, gives the link
-
I just updated my itune on my PC and now it doesn't start. There was no error in installing/upgrading the software but once I rebut the computer the icon appeared but it wouldn't start the program. Did I loose all my music and data? How can I fix t
-
Best External Hard Drive for Carbon Copy Cloner?
I'm about to do a clean install of Leopard on my *Mac Pro* but I want to back up/clone my current system (10.4.11) to an *external hard drive* first. Based on the recommendations of similar users (Logic Studio) -- a clean install is preferable to an
-
Mavericks update, MacBook Pro, short cut buttons not functioning to
After recently installing the OSX mavericks 10.9.3 the shortcut buttons at the top of my keyboard are either not working or are not functioning with the correct button. I checked through the system preferences and found nothing to help me. What can I