2008 May 22 2:03 PM
hi mates,
im using bapi_goodsmvt_create in my prog. for transfer posting(mb1b). the following error msg is displayed wen i run my prog.
Qty and / or "delivery completed" ind. or final issue ind. are missing
wat is that im missing here?
regards
mano
2008 May 22 2:09 PM
2008 May 22 2:09 PM
The quantity or one (or two) of your indicators are missing.
delivery completed" indicator
final issue indicator.
These are (probably) fields in the one of your BAPI interface parameters.
2008 May 22 2:23 PM
HI Manoj,
see the following code
&----
*& Report Zchaitu_po_update
*&
&----
*&
*&
&----
REPORT zchaitu_po_update.
TABLES: lfa1,
ekko,
ekpo.
TYPES: BEGIN OF ty_lfa1,
zterm TYPE lfb1-zterm,
adrnr TYPE lfa1-adrnr,
pstlz TYPE lfa1-pstlz,
otr01 TYPE lfa1-ort01,
land1 TYPE lfa1-land1,
telf1 TYPE lfa1-telf1,
telfx TYPE lfa1-telfx,
stcd1 TYPE lfa1-stcd1,
name1 TYPE lfa1-name1,
inco1 TYPE ekpo-inco1,
txjcd TYPE ekpo-txjcd,
END OF ty_lfa1.
TYPES: BEGIN OF ty_ekko_ekpo,
ebeln TYPE ekko-ebeln,
ebelp TYPE ekpo-ebelp,
END OF ty_ekko_ekpo.
*TYPES: BEGIN OF TY_REC,
DOC_TYPE TYPE BAPIMEPOHEADER-DOC_TYPE, "BSART
VENDOR TYPE BAPIMEPOHEADER-VENDOR, "LIFNR
PURCH_ORG TYPE BAPIMEPOHEADER-PURCH_ORG, "EKORG
PO_NUMBER TYPE BAPIMEPOHEADER-PO_NUMBER, "EBELN
PUR_GROUP TYPE BAPIMEPOHEADER-PUR_GROUP, "EKGRP
COMP_CODE TYPE BAPIMEPOHEADER-COMP_CODE, "BUKRS
PO_ITEM TYPE BAPIMEPOITEM-PO_ITEM, "EBELP
ACCTASSCAT TYPE BAPIMEPOITEM-ACCTASSCAT, "KNTTP
MATERIAL TYPE BAPIMEPOITEM-MATERIAL, "MATNR
QUANTITY TYPE BAPIMEPOITEM-QUANTITY, "MENGE
PO_UNIT TYPE BAPIMEPOITEM-PO_UNIT, "MEINS
NET_PRICE TYPE BAPIMEPOITEM-NET_PRICE, "NETPR
SHORT_TEXT TYPE BAPIMEPOITEM-SHORT_TEXT, "TXZ01
GL_ACCOUNT TYPE BAPIMEPOACCOUNT-GL_ACCOUNT, "SAKTO
COSTCENTER TYPE BAPIMEPOACCOUNT-COSTCENTER, "KOSTL
DELIVERY_DATE TYPE BAPIMEPOSCHEDULE-DELIVERY_DATE, "EINDT
PLANT TYPE BAPIMEPOITEM-PLANT, "WERKS
INT_OBJ_NO TYPE BAPIMEPOITEM-INT_OBJ_NO, "EAN11
REF_1 TYPE BAPIMEPOHEADER-REF_1, "IHREZ
BWART TYPE BAPI2017_GM_ITEM_CREATE-MOVE_TYPE, "BWART
END OF TY_REC.
TYPES: BEGIN OF ty_rec,
doc_type TYPE bapiekkoc-doc_type, "BSART
vendor TYPE bapiekkoc-vendor, "LIFNR
purch_org TYPE bapiekkoc-purch_org, "EKORG
po_number TYPE bapiekkoc-po_number, "EBELN
pur_group TYPE bapiekkoc-pur_group, "EKGRP
co_code TYPE bapiekkoc-co_code, "BUKRS
po_item TYPE bapiekpoc-po_item, "EBELP
acctasscat TYPE bapiekpoc-acctasscat, "KNTTP
material TYPE bapiekpoc-material, "MATNR
disp_quan TYPE bapiekpoc-disp_quan, "MENGE
unit TYPE bapiekpoc-unit, "MEINS
net_price TYPE bapiekpoc-net_price, "NETPR
short_text TYPE bapiekpoc-short_text, "TXZ01
g_l_acct TYPE bapiekkn-g_l_acct, "SAKTO
cost_ctr TYPE bapiekkn-cost_ctr, "KOSTL
deliv_date TYPE bapieket-deliv_date, "EINDT
plant TYPE bapiekpoc-plant, "WERKS
INT_OBJ_NO TYPE BAPIEKPOC-INT_OBJ_NO, "EAN11
ref_1 TYPE bapiekkoa-ref_1, "IHREZ
bwart TYPE bapi2017_gm_item_create-move_type, "BWART
END OF ty_rec.
*TYPES:
DATA: it_bapiekkoc TYPE TABLE OF bapiekkoc,
w_bapiekkoc TYPE bapiekkoc.
DATA: it_bapiekpoc TYPE TABLE OF bapiekpoc,
w_bapiekpoc TYPE bapiekpoc.
DATA: it_bapiekkn TYPE TABLE OF bapiekkn,
w_bapiekkn TYPE bapiekkn.
DATA: it_bapieket TYPE TABLE OF bapieket,
w_bapieket TYPE bapieket.
DATA: it_bapireturn TYPE TABLE OF bapireturn,
w_bapireturn TYPE bapireturn.
DATA: it_bapiekkoa TYPE TABLE OF bapiekkoa,
w_bapiekkoa TYPE bapiekkoa.
DATA: p1_file TYPE string,
w_purchaseorder TYPE bapimepoheader-po_number.
DATA: it_lfa1 TYPE TABLE OF ty_lfa1.
DATA: it_ekko_ekpo TYPE TABLE OF ty_ekko_ekpo,
w_ekko_ekpo TYPE ty_ekko_ekpo.
DATA: it_rec TYPE ty_rec OCCURS 0 WITH HEADER LINE,
w_rec TYPE ty_rec,
it_error TYPE TABLE OF ty_rec,
w_error TYPE ty_rec.
DATA: it_bapimepoheader TYPE TABLE OF bapimepoheader, "PO HEADER DATA
w_bapimepoheader TYPE bapimepoheader.
DATA: it_bapimepoheaderx TYPE TABLE OF bapimepoheaderx, "Header Data (Change Toolbar)
w_bapimepoheaderx TYPE bapimepoheaderx.
DATA: it_bapimepoaddrvendor TYPE TABLE OF bapimepoaddrvendor, "ADDRESS OF VENDOR
w_bapimepoaddrvendor TYPE bapimepoaddrvendor.
DATA: it_bapimepoitem TYPE TABLE OF bapimepoitem, "Item Data
w_bapimepoitem TYPE bapimepoitem.
DATA: it_bapiret2 TYPE TABLE OF bapiret2, "RETURN PARAMETER
w_bapiret2 TYPE bapiret2.
DATA: it_bapimepoaccount TYPE TABLE OF bapimepoaccount, "Account Assignment Fields
w_bapimepoaccount TYPE bapimepoaccount.
DATA: it_bapimeposchedule TYPE TABLE OF bapimeposchedule, "Delivery Schedule
w_bapimeposchedule TYPE bapimeposchedule.
DATA: w_gm_head TYPE bapi2017_gm_head_01,
i_gm_item TYPE TABLE OF bapi2017_gm_item_create,
w_gm_item TYPE bapi2017_gm_item_create,
i_return TYPE TABLE OF bapiret2.
DATA: c_mvind(1) TYPE c.
DATA: v_matdoc TYPE bapi2017_gm_head_ret-mat_doc.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_file TYPE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
F4 Functionality for data file to upload
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM f4_file USING p_file.
START-OF-SELECTION.
PERFORM upload_file USING p_file.
SELECT aadrnr apstl2
aort01 aland1
atelf1 atelfx
astcd1 aname1
binco1 btxjcd
INTO TABLE it_lfa1
FROM lfa1 AS a
INNER JOIN ekpo AS b
ON alifnr = bemlif.
*SELECT ADRNR PSTL2
OTR01 LAND1
TELF1 TELFX
STCD1 NAME1
BINCO1 BTXJCD
INTO TABLE IT_LFA1
FROM LFA1 .
*
loop at it_lfa1.
read table it_ekpo withe key lifnr = it_ekpo-emlif.
read table it_lfb1 with key lifnr = it_lfb1-lifnr.
endloop.
SELECT aebeln bebelp
INTO TABLE it_ekko_ekpo
FROM ekko AS a
INNER JOIN ekpo AS b
ON aebeln = bebeln
FOR ALL ENTRIES IN it_rec
WHERE a~ebeln = it_rec-po_number AND
b~ebelp = it_rec-po_item.
SELECT EBELN
FROM EKKO
INTO TABLE IT-EKKO
WHERE EBELN = W_REC-PO_NUMBER.
LOOP AT it_rec INTO w_rec.
READ TABLE it_ekko_ekpo INTO w_ekko_ekpo WITH KEY ebeln = w_rec-po_number
ebelp = w_rec-po_item.
IF sy-subrc = 0.
PERFORM update_po.
ELSE.
CLEAR w_ekko_ekpo.
READ TABLE it_ekko_ekpo INTO w_ekko_ekpo WITH KEY ebeln = w_rec-po_number.
IF sy-subrc = 0.
PERFORM update_po.
ELSE.
PERFORM create_po.
ENDIF.
ENDIF.
ENDLOOP.
&----
*& Form UPDATE_PO
&----
text
----
FORM update_po.
W_BAPIMEPOHEADER-DOC_TYPE = W_REC-DOC_TYPE.
W_BAPIMEPOHEADER-VENDOR = W_REC-VENDOR.
W_BAPIMEPOHEADER-PURCH_ORG = W_REC-PURCH_ORG.
W_BAPIMEPOHEADER-PO_NUMBER = W_REC-PO_NUMBER.
W_BAPIMEPOHEADER-PUR_GROUP = W_REC-PUR_GROUP.
W_BAPIMEPOHEADER-COMP_CODE = W_REC-COMP_CODE.
W_BAPIMEPOHEADER-REF_1 = W_REC-REF_1.
APPEND W_BAPIMEPOHEADER TO IT_BAPIMEPOHEADER.
*
W_BAPIMEPOITEM-PO_ITEM = W_REC-PO_ITEM.
W_BAPIMEPOITEM-ACCTASSCAT = W_REC-ACCTASSCAT.
W_BAPIMEPOITEM-MATERIAL = W_REC-MATERIAL.
W_BAPIMEPOITEM-QUANTITY = W_REC-QUANTITY.
W_BAPIMEPOITEM-PO_UNIT = W_REC-PO_UNIT.
W_BAPIMEPOITEM-NET_PRICE = W_REC-NET_PRICE.
W_BAPIMEPOITEM-SHORT_TEXT = W_REC-SHORT_TEXT.
W_BAPIMEPOITEM-PLANT = W_REC-PLANT.
W_BAPIMEPOITEM-INT_OBJ_NO = W_REC-INT_OBJ_NO.
APPEND W_BAPIMEPOITEM TO IT_BAPIMEPOITEM.
*
W_BAPIMEPOACCOUNT-GL_ACCOUNT = W_REC-GL_ACCOUNT.
W_BAPIMEPOACCOUNT-COSTCENTER = W_REC-COSTCENTER.
APPEND W_BAPIMEPOACCOUNT TO IT_BAPIMEPOACCOUNT.
*
W_BAPIMEPOSCHEDULE-DELIVERY_DATE = W_REC-DELIVERY_DATE.
APPEND W_BAPIMEPOSCHEDULE TO IT_BAPIMEPOSCHEDULE.
w_bapiekkoc-doc_type = w_rec-doc_type.
w_bapiekkoc-vendor = w_rec-vendor.
w_bapiekkoc-purch_org = w_rec-purch_org.
w_bapiekkoc-po_number = w_rec-po_number.
w_bapiekkoc-pur_group = w_rec-pur_group.
w_bapiekkoc-co_code = w_rec-co_code.
W_BAPIEKKOC-REF_1 = W_REC-REF_1.
APPEND w_bapiekkoc TO it_bapiekkoc.
w_bapiekpoc-po_item = w_rec-po_item.
w_bapiekpoc-acctasscat = w_rec-acctasscat.
w_bapiekpoc-material = w_rec-material.
w_bapiekpoc-disp_quan = w_rec-disp_quan.
w_bapiekpoc-unit = w_rec-unit.
w_bapiekpoc-net_price = w_rec-net_price.
w_bapiekpoc-short_text = w_rec-short_text.
w_bapiekpoc-plant = w_rec-plant.
W_BAPIEKPOC-INT_OBJ_NO = W_REC-INT_OBJ_NO.
APPEND w_bapiekpoc TO it_bapiekpoc.
w_bapiekkn-g_l_acct = w_rec-g_l_acct.
w_bapiekkn-cost_ctr = w_rec-cost_ctr.
APPEND w_bapiekkn TO it_bapiekkn.
w_bapieket-deliv_date = w_rec-deliv_date.
APPEND w_bapieket TO it_bapieket.
w_bapiekkoa-ref_1 = w_rec-ref_1.
APPEND w_bapiekkoa TO it_bapiekkoa.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = w_purchaseorder
POHEADER =
POHEADERX =
POADDRVENDOR =
TESTRUN =
MEMORY_UNCOMPLETE =
MEMORY_COMPLETE =
POEXPIMPHEADER =
POEXPIMPHEADERX =
VERSIONS =
NO_MESSAGING =
NO_MESSAGE_REQ =
NO_AUTHORITY =
NO_PRICE_FROM_PO =
IMPORTING
EXPHEADER =
EXPPOEXPIMPHEADER =
TABLES
RETURN =
POITEM =
POITEMX =
POADDRDELIVERY =
POSCHEDULE =
POSCHEDULEX =
POACCOUNT =
POACCOUNTPROFITSEGMENT =
POACCOUNTX =
POCONDHEADER =
POCONDHEADERX =
POCOND =
POCONDX =
POLIMITS =
POCONTRACTLIMITS =
POSERVICES =
POSRVACCESSVALUES =
POSERVICESTEXT =
EXTENSIONIN =
EXTENSIONOUT =
POEXPIMPITEM =
POEXPIMPITEMX =
POTEXTHEADER =
POTEXTITEM =
ALLVERSIONS =
POPARTNER =
.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
PERFORM create_gr.
ELSE.
READ TABLE it_bapiret2 TRANSPORTING NO FIELDS WITH KEY type = 'E'.
IF sy-subrc = 0.
APPEND w_rec TO it_error.
CLEAR w_rec.
ENDIF.
ENDIF.
w_gm_item-material = w_rec-material.
*
w_gm_item-plant = w_rec-plant.
*
w_gm_item-move_type = w_rec-bwart.
*
w_gm_item-mvt_ind = c_mvind.
*
w_gm_item-entry_qnt = w_rec-disp_quan.
*
w_gm_item-entry_uom = w_rec-unit.
*
W_GM_ITEM-SCHED_LINE = W_GRTAB-SCHED_LINE. """"""""""""""""ON 07/12/2007
*
w_gm_item-po_number = w_rec-po_number.
*
w_gm_item-po_item = w_rec-po_item.
*
APPEND w_gm_item TO i_gm_item.
*
*
*
w_gm_head-pstng_date = sy-datum.
*
w_gm_head-doc_date = sy-datum.
*
w_gm_head-ref_doc_no = w_rec-po_number.
*
*
*
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = w_gm_head
goodsmvt_code = '01' "C_GMCODE
IMPORTING
materialdocument = v_matdoc
TABLES
goodsmvt_item = i_gm_item
return = i_return.
ENDFORM. "UPDATE_PO
&----
*& Form F4_FILE
&----
text
----
-->P_P_FLTFIL text
----
*FORM F4_FILE USING P_P_FLTFIL.
FORM f4_file USING file TYPE rlgrap-filename.
Function Module to Prompt the user for File-Selection
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = file.
ENDFORM. "REQUEST_FILE
*ENDFORM. " F4_FILE
&----
*& Form UPLOAD_FILE
&----
text
----
-->P_P_FILE text
----
FORM upload_file USING p_p_file.
p1_file = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p1_file
FILETYPE = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER
TABLES
data_tab = it_rec
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SORT it_rec BY po_number po_item.
ENDFORM. " UPLOAD_FILE
&----
*& Form CREATE_PO
&----
text
----
--> p1 text
<-- p2 text
----
FORM create_po .
w_bapiekkoc-doc_type = w_rec-doc_type.
w_bapiekkoc-vendor = w_rec-vendor.
w_bapiekkoc-purch_org = w_rec-purch_org.
w_bapiekkoc-po_number = w_rec-po_number.
w_bapiekkoc-pur_group = w_rec-pur_group.
w_bapiekkoc-co_code = w_rec-co_code.
W_BAPIEKKOC-REF_1 = W_REC-REF_1.
APPEND w_bapiekkoc TO it_bapiekkoc.
w_bapiekpoc-po_item = w_rec-po_item.
w_bapiekpoc-acctasscat = w_rec-acctasscat.
w_bapiekpoc-material = w_rec-material.
w_bapiekpoc-disp_quan = w_rec-disp_quan.
w_bapiekpoc-unit = w_rec-unit.
w_bapiekpoc-net_price = w_rec-net_price.
w_bapiekpoc-short_text = w_rec-short_text.
w_bapiekpoc-plant = w_rec-plant.
W_BAPIEKPOC-INT_OBJ_NO = W_REC-INT_OBJ_NO.
APPEND w_bapiekpoc TO it_bapiekpoc.
w_bapiekkn-g_l_acct = w_rec-g_l_acct.
w_bapiekkn-cost_ctr = w_rec-cost_ctr.
APPEND w_bapiekkn TO it_bapiekkn.
w_bapieket-deliv_date = w_rec-deliv_date.
APPEND w_bapieket TO it_bapieket.
w_bapiekkoa-ref_1 = w_rec-ref_1.
APPEND w_bapiekkoa TO it_bapiekkoa.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = w_bapimepoheader
POHEADERX =
POADDRVENDOR =
TESTRUN =
MEMORY_UNCOMPLETE =
MEMORY_COMPLETE =
POEXPIMPHEADER =
POEXPIMPHEADERX =
VERSIONS =
NO_MESSAGING =
NO_MESSAGE_REQ =
NO_AUTHORITY =
NO_PRICE_FROM_PO =
IMPORTING
EXPPURCHASEORDER =
EXPHEADER =
EXPPOEXPIMPHEADER =
TABLES
return = it_bapiret2
poitem = it_bapimepoitem
POITEMX =
POADDRDELIVERY =
poschedule = it_bapimeposchedule
POSCHEDULEX =
poaccount = it_bapimepoaccount
POACCOUNTPROFITSEGMENT =
POACCOUNTX =
POCONDHEADER =
POCONDHEADERX =
POCOND =
POCONDX =
POLIMITS =
POCONTRACTLIMITS =
POSERVICES =
POSRVACCESSVALUES =
POSERVICESTEXT =
EXTENSIONIN =
EXTENSIONOUT =
POEXPIMPITEM =
POEXPIMPITEMX =
POTEXTHEADER =
POTEXTITEM =
ALLVERSIONS =
POPARTNER =
.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
.
PERFORM create_gr.
ELSE.
READ TABLE it_bapiret2 TRANSPORTING NO FIELDS WITH KEY type = 'E'.
IF sy-subrc = 0.
APPEND w_rec TO it_error.
CLEAR w_rec.
ENDIF.
ENDIF.
ENDFORM. " CREATE_PO
&----
*& Form CREATE_GR
&----
text
----
--> p1 text
<-- p2 text
----
FORM create_gr .
CHECK RETURN IS INITIAL.
WAIT UP TO 4 SECONDS.
*-- Goods movement create
w_gm_item-material = w_rec-material.
w_gm_item-plant = w_rec-plant.
w_gm_item-move_type = w_rec-bwart.
w_gm_item-mvt_ind = c_mvind.
w_gm_item-entry_qnt = w_rec-disp_quan.
w_gm_item-entry_uom = w_rec-unit.
W_GM_ITEM-SCHED_LINE = W_GRTAB-SCHED_LINE. """"""""""""""""ON 07/12/2007
w_gm_item-po_number = w_rec-po_number.
w_gm_item-po_item = w_rec-po_item.
APPEND w_gm_item TO i_gm_item.
w_gm_head-pstng_date = sy-datum.
w_gm_head-doc_date = sy-datum.
w_gm_head-ref_doc_no = w_rec-po_number.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = w_gm_head
goodsmvt_code = '01' "C_GMCODE
IMPORTING
materialdocument = v_matdoc
TABLES
goodsmvt_item = i_gm_item
return = i_return.
READ TABLE I_RETURN TRANSPORTING NO FIELDS WITH KEY TYPE = 'E'.
*
IF SY-SUBRC NE 0.
*
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
*
LOOP AT GR_SUB_TAB INTO W_GRSUB WHERE EBELN = W_GRTAB-EBELN.
*
INSERT INTO ZSUBMATNR VALUES W_GRSUB.
*
ENDLOOP.
*
ELSE.
*
APPEND LINES OF I_RETURN TO RETURN.
*
ENDIF.
CLEAR i_gm_item. """"""""""""""""""""
.
ENDFORM. " CREATE_GR
reward points if helpful.