cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Not able to create goods issue with BAPI_GOODSMVT_CREATE with 351 mvt type

Yashwanth3
Explorer
0 Likes
1,314

Hi Everyone,

when I am trying to create goods issue using BAPI_GOODSMVT_CREATE with movement type 351 against STO (Stock transport order) and I am getting error message saying, 'Goods movement not possible with mvmt type 351'. kindly help me.

Code:

lwa_goodsmvt_header-pstng_date = '20250108'.
lwa_goodsmvt_header-doc_date = '20250108'.
*lwa_goodsmvt_header- = '70002413'.
st_goodsmvt_code-gm_code = '03'.

*Item data
lwa_goodsmvt_item-material = 'PB500145'.
lwa_goodsmvt_item-po_number = '70002413'.
lwa_goodsmvt_item-po_item = '00001'.
lwa_goodsmvt_item-entry_qnt = '1'.
lwa_goodsmvt_item-entry_uom = 'EA'.
* lwa_goodsmvt_item-batch = <lwa_itm>-charg.
lwa_goodsmvt_item-prod_date = '20250108'.
lwa_goodsmvt_item-move_type = '351'.
lwa_goodsmvt_item-plant = 'XXXX'. "Hiding plant
*lwa_goodsmvt_item-stge_loc = '0001'.
lwa_goodsmvt_item-mvt_ind = lc_b.
lwa_goodsmvt_item-stck_type = 'F'.
APPEND lwa_goodsmvt_item TO lt_goodsmvt_item.
CLEAR: lwa_goodsmvt_item.

CLEAR:lw_mblnr.

* BAPI for Post Goods Receipt
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = lwa_goodsmvt_header
goodsmvt_code = st_goodsmvt_code
IMPORTING
materialdocument = lw_mblnr
TABLES
goodsmvt_item = lt_goodsmvt_item
return = lt_ret.

READ TABLE lt_ret INTO lwa_return WITH KEY type = lc_e.
IF sy-subrc EQ 0.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
lwa_return-type = lc_e.
APPEND lwa_return TO lt_return.
CLEAR: lwa_return.

ELSE.
* saving Goods issue
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = lc_x.

endif.

Thanks in advance.

 

Accepted Solutions (0)

Answers (1)

Answers (1)

RaymondGiuseppi
Active Contributor

Read first

for allowed codes and how to use them with this BAPI.

Usually I checked for the required code(s) in those two tables:

  • T158B "Check Table: Movement Type for Transaction Code" to find transactions allowed so correct gm_code to use in BAPI
  • T158G "MMIM: Possible Codes for BAPI Goods Movement" Else BAPI not allowed
Yashwanth3
Explorer
0 Likes
still issue: Can you post any sample code for STO with movement type 351
RaymondGiuseppi
Active Contributor
0 Likes

Which gm_code did you try? 04

Yashwanth3
Explorer
0 Likes
st_goodsmvt_code-gm_code = '03'. "goods issue
RaymondGiuseppi
Active Contributor
0 Likes
Try 04 for transfer
Yashwanth3
Explorer
0 Likes
I tried gm_code 1 ,2,3,4,5 . but no luck
RaymondGiuseppi
Active Contributor
0 Likes
which error did you get in RETURN (also post more relevant part of code) for 04
Yashwanth3
Explorer
0 Likes
lwa_goodsmvt_header-pstng_date = '20250108'. lwa_goodsmvt_header-doc_date = '20250108'. *lwa_goodsmvt_header- = '70002413'. st_goodsmvt_code-gm_code = '03'. *Item data lwa_goodsmvt_item-material = 'PB500145'. lwa_goodsmvt_item-po_number = '70002413'. lwa_goodsmvt_item-po_item = '00001'. lwa_goodsmvt_item-entry_qnt = '1'. lwa_goodsmvt_item-entry_uom = 'EA'. * lwa_goodsmvt_item-batch = <lwa_itm>-charg. lwa_goodsmvt_item-prod_date = '20250108'. lwa_goodsmvt_item-move_type = '351'. lwa_goodsmvt_item-plant = 'XXXX'. "Hiding plant *lwa_goodsmvt_item-stge_loc = '0001'. lwa_goodsmvt_item-mvt_ind = lc_b. lwa_goodsmvt_item-stck_type = 'F'. APPEND lwa_goodsmvt_item TO lt_goodsmvt_item. CLEAR: lwa_goodsmvt_item. CLEAR:lw_mblnr. * BAPI for Post Goods Receipt CALL FUNCTION 'BAPI_GOODSMVT_CREATE' EXPORTING goodsmvt_header = lwa_goodsmvt_header goodsmvt_code = st_goodsmvt_code IMPORTING materialdocument = lw_mblnr TABLES goodsmvt_item = lt_goodsmvt_item return = lt_ret. READ TABLE lt_ret INTO lwa_return WITH KEY type = lc_e. IF sy-subrc EQ 0. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. lwa_return-type = lc_e. APPEND lwa_return TO lt_return. CLEAR: lwa_return. ELSE. * saving Goods issue CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = lc_x. endif.
Yashwanth3
Explorer
0 Likes

lwa_goodsmvt_header-pstng_date = '20250109'.

lwa_goodsmvt_header-doc_date = '20250109'.

lwa_goodsmvt_header- = '70002413'.

st_goodsmvt_code-gm_code = '04'.

Item data lwa_goodsmvt_item-material = 'PB500145'.

lwa_goodsmvt_item-po_number = '70002413'.

lwa_goodsmvt_item-po_item = '00001'.

lwa_goodsmvt_item-entry_qnt = '1'.

lwa_goodsmvt_item-entry_uom = 'EA'.

 

. lwa_goodsmvt_item-prod_date = '20250109'.

lwa_goodsmvt_item-move_type = '351'.

lwa_goodsmvt_item-plant = 'XXXX'.  "hiding plant

lwa_goodsmvt_item-stge_loc = '0001'.

lwa_goodsmvt_item-mvt_ind = lc_b.

lwa_goodsmvt_item-stck_type = 'F'.

APPEND lwa_goodsmvt_item TO lt_goodsmvt_item.

CLEAR: lwa_goodsmvt_item. CLEAR:lw_mblnr.

* BAPI for Post Goods Receipt

CALL FUNCTION 'BAPI_GOODSMVT_CREATE

 EXPORTING

goodsmvt_header = lwa_goodsmvt_header

goodsmvt_code = st_goodsmvt_code

IMPORTING materialdocument = lw_mblnr

TABLES goodsmvt_item = lt_goodsmvt_item

return = lt_ret.

READ TABLE lt_ret INTO lwa_return WITH KEY type = lc_e.

IF sy-subrc EQ 0.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

lwa_return-type = lc_e.

APPEND lwa_return TO lt_return.

CLEAR: lwa_return.

ELSE. * saving Goods issue

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING wait = lc_x.

endif.


error:Purchase order xxxxxx

does not exist

RaymondGiuseppi
Active Contributor
0 Likes
Try to add leading zeroes to STO / PO number
Yashwanth3
Explorer
0 Likes
tried but getting this error 'Material document data and po data do not match(plant)'