2007 Sep 21 12:47 PM
hi experts,
i am Creating a GOODS RECEIPT using BAPI w.r.t PO.
my problem is for an order 12 qun is there but iam passing all parameters to BAPI
but i have created 4 times GOODS RECEIPT for each time 2 qun .Now when iam trying to create for remaining 4 qun at a time Now error is like this
<b>6000004139 N M7 022 PL Stock in transit exceeded by 2 NO : 105720036000400 2011 F100 M</b>
i check for other po also if i give quantity more then 2 it is showing like this error message
regards,
satheesh.
hi experts,
i am Creating a GOODS RECEIPT using BAPI w.r.t PO.
my problem is for an order 12 qun is there but iam passing all parameters to BAPI
but i have created 4 times GOODS RECEIPT for each time 2 qun .Now when iam trying to create for remaining 4 qun at a time Now error is like this
<b>6000004139 N M7 022 PL Stock in transit exceeded by 2 NO : 105720036000400 2011 F100 M</b>
i check for other po also if i give quantity more then 2 it is showing like this error message
regards,
satheesh.
2007 Sep 21 12:59 PM
Check with your functional consulatant,
there must be configuaration not to accept more than 2 quantity.
2007 Sep 21 1:11 PM
sir,
i checked it taking more than 2 also.
but quantity which is at purchase order is not possible to create GR for all quntity
but if u go to transaction MB01 check quantity then it is showing some value ie correct value what value po consists minus wat quantity we created GR.
i will send my code also check plzzz.
report zstock_in_transit_gr no standard page heading.
Data Section
************************************************************************
************************************************************************
*TABLES
************************************************************************
tables: mkpf . " Material Document
************************************************************************
Internal Tables
************************************************************************
data: begin of i_po_gr occurs 0,
doc_date(8),
post_date(8),
werks(4),
lgort(4),
matnr(18),
ebeln(10),
ebelp(6),
menge(20),
meins(3),
batchno(10),
end of i_po_gr.
data: begin of i_po occurs 0,
ebeln(10) type c,
flag(1) type c,
message(100) type c,
end of i_po.
data: v_charg like mchb-charg.
*Internal table for BAPI
data: goodsmvt_header like bapi2017_gm_head_01,
goodsmvt_code like bapi2017_gm_code ,
materialdocument like bapi2017_gm_head_ret-mat_doc,
year like bapi2017_gm_head_ret-doc_year.
*********************************************************************
*************Variable*********************************************
*********************************************************************
data : v_error_filename like rlgrap-filename.
data: goodsmvt_item like bapi2017_gm_item_create occurs 0 with header line,
return like bapiret2 occurs 0 with header line.
******************SELECTION SCREEN*********************************
selection-screen begin of block b1 with frame title text-001.
parameter: p_file like ibipparms-path obligatory.
selection-screen skip.
selection-screen:end of block b1.
*******************END OF SELECTION SCREEN***************************
*Intialization
initialization.
goodsmvt_code = '01'.
***********************************************************************
at selection-screen on value-request for p_file .
perform get_filename.
********************************************************************
************************************************************************
START-OF-SELECTION
************************************************************************
start-of-selection.
perform upload_file.
perform to_get_batch.
perform get_unique_po.
loop at i_po.
*append header details
perform append_header.
loop at i_po_gr where ebeln = i_po-ebeln.
*append items
perform append_items.
endloop.
PERFORM check_material_lock.
*call bapi for creating grn
perform call_bapi.
**display data
write : / i_po-ebeln, i_po-flag, i_po-message.
endloop.
*********************************************************************
end-of-selection
*********************************************************************
end-of-selection.
*******************************************************************
FORMS AND SUB-ROUTINES
*******************************************************************
************************************************************************
*& Form GET_FILENAME
************************************************************************
form get_filename.
call function 'F4_FILENAME'
exporting
program_name = syst-repid
dynpro_number = syst-dynnr
FIELD_NAME = ' '
importing
file_name = p_file
exceptions
others = 1.
if sy-subrc ne 0 .
write : / 'Enter File Name'.
endif.
endform. " GET_FILENAME
&----
*& Form UPLOAD_FILE
&----
form upload_file .
call function 'WS_UPLOAD'
exporting
CODEPAGE = ' '
filename = p_file
filetype = 'DAT'
HEADLEN = ' '
LINE_EXIT = ' '
TRUNCLEN = ' '
USER_FORM = ' '
USER_PROG = ' '
IMPORTING
FILELENGTH =
tables
data_tab = i_po_gr
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_table_width = 4
invalid_type = 5
no_batch = 6
unknown_error = 7
gui_refuse_filetransfer = 8
others = 9.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " UPLOAD_FILE
&----
*& Form get_unique_po
&----
form get_unique_po .
loop at i_po_gr.
i_po-ebeln = i_po_gr-ebeln.
collect i_po.
endloop.
endform. " get_unique_po
&----
*& Form append_header
&----
form append_header .
read table i_po_gr with key ebeln = i_po-ebeln.
clear goodsmvt_header.
refresh goodsmvt_item.
goodsmvt_header-header_txt = i_po_gr-ebeln.
goodsmvt_header-pstng_date = i_po_gr-post_date. "POSTING DATE
goodsmvt_header-doc_date = i_po_gr-doc_date. "DOC DATE
endform. " append_header
&----
*& Form append_items
&----
form append_items.
clear goodsmvt_item.
PERFORM toget_batch_no.
translate i_po_gr-matnr to upper case. "MODIFIED BY B.SATHEESH(UNISOFT) 20-09-07
translate i_po_gr-werks to upper case. "MODIFIED BY B.SATHEESH(UNISOFT) 20-09-07
translate i_po_gr-lgort to upper case. "MODIFIED BY B.SATHEESH(UNISOFT) 20-09-07
call function 'CONVERSION_EXIT_MATN1_INPUT'
exporting
input = i_po_gr-matnr
importing
output = i_po_gr-matnr
exceptions
length_error = 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.
goodsmvt_item-material = i_po_gr-matnr. "MATERIAL
goodsmvt_item-move_type = '101'. "GOODSMOVEMENT(GR)
goodsmvt_item-entry_qnt = i_po_gr-menge. "QUANTITY
goodsmvt_item-entry_uom = i_po_gr-meins. "UOM
goodsmvt_item-plant = i_po_gr-werks. "PLANT
goodsmvt_item-stge_loc = i_po_gr-lgort. "STORAGE LCATION
goodsmvt_item-po_number = i_po_gr-ebeln. "PURCHASE ORDER NO DELIV_ITEM_TO_SEARCH
goodsmvt_item-deliv_numb_to_search = i_po_gr-ebeln.
goodsmvt_item-po_item = i_po_gr-ebelp. "PURCHASE ORDER ITEM
goodsmvt_item-deliv_item_to_search = i_po_gr-ebelp.
goodsmvt_item-batch = i_po_gr-batchno.
goodsmvt_item-mvt_ind = 'B'. "GODS MVT INDICATOR
append goodsmvt_item.
CLEAR: v_lifnr.
endform. " append_items
&----
*& Form call_bapi
&----
text
----
--> p1 text
<-- p2 text
----
form call_bapi .
data: v_type(1).
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = goodsmvt_header
goodsmvt_code = goodsmvt_code
TESTRUN = ' '
importing
GOODSMVT_HEADRET =
materialdocument = materialdocument
matdocumentyear = year
tables
goodsmvt_item = goodsmvt_item
GOODSMVT_SERIALNUMBER =
return = return.
if not return[] is initial.
read table return with key type = 'E'.
v_type = 'N'.
if sy-subrc is initial.
concatenate return-id return-number return-message
into i_po-message separated by space.
endif.
else.
if materialdocument ne space or materialdocument ne 0.
v_type = 'Y'.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = '2'.
IMPORTING
RETURN = I_RETURN1.
concatenate 'Material Document Created No is' materialdocument year into i_po-message separated by space.
endif.
endif.
clear: goodsmvt_header,
materialdocument,
year,
goodsmvt_item,
return.
refresh: goodsmvt_item,
return.
move v_type to i_po-flag.
modify i_po.
clear v_type.
endform. " call_bapi
&----
*& Form check_material_lock
&----
form check_material_lock .
data : i_seqg3 like seqg3 occurs 0 with header line.
do 100 times.
call function 'ENQUEUE_READ'
exporting
gclient = sy-mandt
gname = 'MARC'
GARG = ' '
GUNAME = SY-UNAME
LOCAL = ' '
IMPORTING
NUMBER =
SUBRC =
tables
enq = i_seqg3
EXCEPTIONS
COMMUNICATION_FAILURE = 1
SYSTEM_FAILURE = 2
OTHERS = 3
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
if i_seqg3[] is initial.
CLEAR : return,
message.
exit.
else.
loop at i_seqg3.
loop at goodsmvt_item.
if i_seqg3-garg cs goodsmvt_item-material.
exit.
endif.
endloop.
endloop.
endif.
wait up to 1 seconds.
enddo.
endform. " check_material_lock
&----
*& Form to_get_batch
&----
text
----
--> p1 text
<-- p2 text
----
form to_get_batch .
data : it_gi_tmp like i_po_gr occurs 0 with header line,
l_clabs like mchb-clabs,
l_xchpf like mara-xchpf.
loop at i_po_gr.
translate i_po_gr-matnr to upper case. "MODIFIED BY B.SATHEESH(UNISOFT) 20-09-07
translate i_po_gr-werks to upper case. "MODIFIED BY B.SATHEESH(UNISOFT) 20-09-07
translate i_po_gr-lgort to upper case. "MODIFIED BY B.SATHEESH(UNISOFT) 20-09-07
it_gi_tmp = i_po_gr.
clear l_xchpf.
call function 'CONVERSION_EXIT_MATN1_INPUT'
exporting
input = i_po_gr-matnr
importing
output = i_po_gr-matnr
exceptions
length_error = 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.
select single xchpf from mara into l_xchpf where matnr = i_po_gr-matnr.
IF l_xchpf = 'X'.
select charg clabs from mchb into (v_charg, l_clabs) where matnr = i_po_gr-matnr and werks = i_po_gr-werks and lgort = i_po_gr-lgort.
if sy-subrc <> 0.
move : 'BEFORE SAP' to it_gi_tmp-batchno.
endif.
move : v_charg to it_gi_tmp-batchno.
append it_gi_tmp.
endselect.
ELSE.
APPEND it_gi_tmp.
ENDIF.
endloop.
refresh i_po_gr.
i_po_gr[] = it_gi_tmp[].
refresh it_gi_tmp.
endform. " to_get_batch
regards,
satheesh.
Message was edited by:
satheesh sath
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |