2008 Nov 29 11:24 AM
hi,
i am working on BAPIS for the first time and using BAPI_PO_CREATE1 for uploading data for open PO.but nothing is getting uploaded and message that is returning from BAPI is:
Check item number 0 in table POITEMX
Check item number 0 in table POSCHEDULEX
Check item number 0 in table POACCOUNTX
Currency key is unknown
No instance of object type PurchaseOrder has been created. External reference:
what can be the reason.
hi,
i am working on BAPIS for the first time and using BAPI_PO_CREATE1 for uploading data for open PO.but nothing is getting uploaded and message that is returning from BAPI is:
Check item number 0 in table POITEMX
Check item number 0 in table POSCHEDULEX
Check item number 0 in table POACCOUNTX
Currency key is unknown
No instance of object type PurchaseOrder has been created. External reference:
what can be the reason.
2008 Nov 29 11:35 AM
2008 Nov 29 11:43 AM
hi,
what should i check in this include...is this include is called internally by the bapi BAPI_PO_CREATE1.
2008 Nov 29 12:42 PM
Hi
First, I would suggest you to go through the documentation of the BAPI in SE37. Then, type the BAPI name in SCN search, you will get surplus results some of which may be sample code also. Go through them.
After, all this you will get a fair idea on how to work on BAPI's.
Vishwa.
2008 Nov 29 12:48 PM
hi vishwa,
i had gone throu the documentation done the coding and when i faced the issues then only i posted..
i had transfer the data to the tables which r of my concerned POHEADER,POITEM,POACCOUNT,POSCHEDULE and passed it to the BAPI.
i had also declared the POHEADERX,POITEMX AND POSCHEDULEX as my data is chenge relevant.then also the BAPI is not working.
2008 Nov 29 2:59 PM
2008 Nov 29 3:52 PM
>
> hi,
>
> i am working on BAPIS for the first time and using BAPI_PO_CREATE1 for uploading data for open PO.but nothing is getting uploaded and message that is returning from BAPI is:
> Check item number 0 in table POITEMX
> Check item number 0 in table POSCHEDULEX
> Check item number 0 in table POACCOUNTX
> Currency key is unknown
> No instance of object type PurchaseOrder has been created. External reference:
>
> what can be the reason.
I think you are not passing X to some values in the tables. If you see, the error is not with the data, but with the check structures. I think the item field in all the three structures, you are not passing X to them. Just check all the three structures in the program first.
Vishwa.
2008 Nov 30 4:38 AM
Hi Manikant
I think in your case since it is an open PO you should use the BAPI_PO_CHANGE.
po_number = i_ekkn-ebeln.
*Changing the Quantity at item level
i_poitem-po_item = i_ekkn-ebelp.
i_poitemx-po_item = i_ekkn-ebelp.
i_poitem-quantity = g_po_chg_qty.
i_poitemx-quantity = 'X'.
APPEND: i_poitem, i_poitemx.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = po_number
TABLES
return = i_return
poitem = i_poitem
poitemx = i_poitemx.
also use BAPI_Transaction_Commit to commit the transaction.
Hope it is helpful.
Regards
Neha
2008 Dec 01 6:45 AM
hi,
i am not changing the PO.but actually i am uploading open PO from old sap system to new sap system.
but i want the PO no. not to be automatically generated but PO no. is to be externally provided in the flat file.is this possible bcoz when i am executing BAPI_PO_CREATE1 its throeing error that :
No instance of object type PurchaseOrder has been created. External reference:
2008 Dec 01 6:58 AM
Hi,
Have you passed value X for all X bar fields?
Please check Value X for all the X bar control structures which will be mentioned as below.
Parameter: POHEADERX
COMP_CODE = X
DOC_TYPE = X
ITEM_INTVL = X
VENDOR = X
PMNTTRMS = X
PURCH_ORG = X
PUR_GROUP = X
Parameter: POITEMX
PO_ITEM = 00001
MATERIAL = X
PLANT = X
STGE_LOC = X
QUANTITY = X
TAX_CODE = X
ITEM_CAT = X
ACCTASSCAT = X
Parameter: POSCHEDULEX
PO_ITEM = 00001
SCHED_LINE = 0001
PO_ITEMX = X
SCHED_LINEX = X
DELIVERY_DATE = X
QUANTITY = X
PO_ITEM = 00001
SCHED_LINE = 0002
PO_ITEMX = X
SCHED_LINEX = X
DELIVERY_DATE = X
QUANTITY = X
PO_ITEM = 00001
SCHED_LINE = 0003
PO_ITEMX = X
SCHED_LINEX = X
DELIVERY_DATE = X
QUANTITY = X
Parameter: POACCOUNTX
PO_ITEM = 00001
SERIAL_NO = 01
QUANTITY = X
GL_ACCOUNT = X
COSTCENTER = X
CO_AREA = X
Thanks and Best Regards,
Deepa Kulkarni
2008 Dec 01 7:01 AM
Here i'm sending one example with 'BAPI_PO_CREATE1'. Observe what the Parameters we need to pass as Mandatory.
It will help U.
REPORT ZBAPI_PO_UPLOAD_BS.
Tables Declaration
TABLES: ZMM_SOLOMON_PO, EKKO, LFM1.
Constant Declaration
DATA: L_BSART LIKE MEPO_TOPLINE-BSART VALUE 'NB'.
DATA: L_BSART1 LIKE MEPO_TOPLINE-BSART VALUE 'ZNB'.
CONSTANTS: C_EKORG LIKE MEPO1222-EKORG VALUE 'POMR',
C_EKGRP LIKE MEPO1222-EKGRP VALUE 'PG1',
C_BUKRS LIKE EKKO-BUKRS VALUE 'SBPL'.
Variable Declaration
DATA: A TYPE C VALUE '/'.
data : gfile(150).
data : hfile(150).
data : ifile(150).
DATA: g_file(200).
DATA: h_file(200).
data: i_file(200).
*DATA: COUNT LIKE SY-INDEX.
DATA: date(8), date1(6).
date = sy-datum.
concatenate date6(2) date4(2) date+0(4) into date.
date1 = date+2(6).
data: name(32).
DATA : S_MSG1(300).
DATA : V_MSG1 LIKE S_MSG1 OCCURS 0 WITH HEADER LINE.
DATA : I_MSG1 LIKE V_MSG1 OCCURS 0 WITH HEADER LINE.
DATA : I_MSG2 LIKE V_MSG1 OCCURS 0 WITH HEADER LINE.
DATA: COUNT LIKE SY-TABIX.
DATA: G_FLAG(1).
constants : c_x value 'X'.
Internal table Declaration
DATA: BEGIN OF i_tab OCCURS 0,
VERKF LIKE EKKO-VERKF,
VERKF1 LIKE EKKO-VERKF,
LIFNR LIKE EKKO-LIFNR,
WERKS LIKE EKPO-WERKS,
EBELP1 like ekpo-ebelp,
MATNR LIKE EKPO-MATNR,
IDNLF LIKE EKPO-IDNLF,
MENGE(16),
BPRME LIKE EKPO-BPRME,
LEWED LIKE EKPO-LEWED,
NETPR(13),
CURRKEY(5),
EBELN LIKE EORD-EBELN,
EBELP LIKE EORD-EBELN,
VERKF2 LIKE EKKO-VERKF,
KALSK LIKE LFM1-KALSK,
BSART LIKE MEPO_TOPLINE-BSART,
LIFNR1 LIKE EKKO-LIFNR,
FLAG(1),
PSTYP like ekpo-PSTYP,
END OF i_tab.
data: begin of it_usr occurs 0,
tx_id like ZMMINT_USR-tx_id,
werks like ZMMINT_USR-werks,
uname like ZMMINT_USR-uname,
end of it_usr.
constants: c_plant like zmmint_usr-werks value 'OMR'.
DATA: ETAB LIKE I_TAB OCCURS 0 WITH HEADER LINE.
DATA: I_TAB2 LIKE I_TAB OCCURS 0 WITH HEADER LINE.
DATA: I_TAB3 LIKE I_TAB OCCURS 0 WITH HEADER LINE.
DATA: I_OUT LIKE I_TAB OCCURS 0 WITH HEADER LINE.
DATA: ETAB1 LIKE I_TAB OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF i_tab1 OCCURS 0,
MATNR LIKE EORD-MATNR,
WERKS LIKE EORD-WERKS,
LIFNR LIKE EORD-LIFNR,
EBELN LIKE EORD-EBELN,
EBELP LIKE EORD-EBELP,
END OF i_tab1.
DATA: BEGIN OF i_lfm1 OCCURS 0,
KALSK LIKE LFM1-KALSK,
END OF i_lfm1.
DATA: BEGIN OF i_ekko OCCURS 0,
BSART LIKE EKKO-BSART,
END OF i_ekko.
DATA: BEGIN OF I_ZMM_SOLOMON_PO OCCURS 0,
SOLOMON_PO LIKE ZMM_SOLOMON_PO-SOLOMON_PO,
SOLOMON_DATE LIKE ZMM_SOLOMON_PO-SOLOMON_DATE,
FLAG LIKE ZMM_SOLOMON_PO-FLAG,
END OF I_ZMM_SOLOMON_PO.
Data Declaration for BAPI *****************
data: begin of pohead occurs 10.
include structure BAPIMEPOHEADER.
data: end of pohead.
data: begin of poheadx occurs 10.
include structure BAPIMEPOHEADERX.
data: end of poheadx.
*EXPPURCHASEORDER
data: BEGIN OF ponum.
include structure BAPIMEPOHEADER.
data: end of ponum.
data: begin of poitem occurs 100.
include structure BAPIMEPOITEM.
data: end of poitem.
data: begin of poitemx occurs 100.
include structure BAPIMEPOITEMX.
data: end of poitemx.
data: begin of poitemsch occurs 100.
include structure BAPIMEPOSCHEDULE.
data: end of poitemsch.
data: begin of poitemschx occurs 100.
include structure BAPIMEPOSCHEDULX.
data: end of poitemschx.
data: begin of errmsg occurs 10.
include structure bapiret2.
data: end of errmsg.
data : errflag.
START-OF-SELECTION.
if sy-host = 'sanyobplsap' or sy-host = 'SANYOBPLSAP'.
gfile = 'D:\SAP_INT\INBOUND\INBOX'.
ifile = 'D:\SAP_INT\INBOUND\LOG'.
hfile = 'D:\SAP_INT\INBOUND\OUTBOX'.
ENDIF.
if sy-host = 'sapqm' or sy-host = 'SAPQM'.
gfile = 'E:\SAP_INT\INBOUND\INBOX'.
ifile = 'E:\SAP_INT\INBOUND\LOG'.
hfile = 'E:\SAP_INT\INBOUND\OUTBOX'.
ENDIF.
if sy-host = 'sapgrp' or sy-host = 'SAPGRP'.
gfile = 'S:\SAP_INT\INBOUND\INBOX'.
ifile = 'S:\SAP_INT\INBOUND\LOG'.
hfile = 'S:\SAP_INT\INBOUND\OUTBOX'.
ENDIF.
PERFORM UPLOAD_DATA.
PERFORM SUB_SEND_MAIL.
&----
*& Form UPLOAD_DATA
&----
text
----
--> p1 text
<-- p2 text
----
FORM UPLOAD_DATA .
data: p_fdir(200) type c .
p_fdir = gfile.
data: begin of it_filedir occurs 10.
include structure salfldir.
data: end of it_filedir.
Get Current Directory Listing for OUT Dir
call function 'RZL_READ_DIR_LOCAL'
EXPORTING
name = p_fdir
TABLES
file_tbl = it_filedir.
data: it_filedir1 like it_filedir occurs 0 with header line.
loop at it_filedir.
if it_filedir-name(4) = 'CPOR' or it_filedir-name(4) = 'cpor'.
move it_filedir-name to it_filedir1-name.
append it_filedir1.
endif.
endloop.
IF IT_FILEDIR1[] IS INITIAL.
WRITE:/ 'FILE NOT FOUND'.
STOP.
ENDIF.
REFRESH I_MSG1.
CLEAR I_MSG1.
loop at it_filedir1.
REFRESH I_TAB.
REFRESH I_TAB2.
REFRESH I_TAB1.
REFRESH I_OUT.
data: g_file(100) type c .
name = it_filedir1-name.
concatenate: gfile '\' name into g_file.
data : i_tab1(200).
OPEN DATASET g_file FOR INPUT IN TEXT MODE
ENCODING DEFAULT
IGNORING CONVERSION ERRORS.
IF SY-SUBRC EQ 0.
DO.
READ DATASET g_file INTO i_tab1.
if sy-subrc = 0.
split i_tab1 at ',' into i_tab-verkf i_tab-verkf1 i_tab-lifnr
i_tab-ebelp1 i_tab-werks i_tab-matnr i_tab-idnlf
i_tab-menge i_tab-bprme i_tab-lewed i_tab-netpr
i_tab-CURRKEY i_tab-PSTYP.
else.
exit.
endif.
APPEND i_tab.
clear i_tab.
ENDDO.
ENDIF.
*************** end error testing*******************
CLOSE DATASET g_file.
PERFORM GET_OUTLINE_AGREEMENT.
LOOP AT I_TAB.
MOVE: I_TAB-VERKF TO ZMM_SOLOMON_PO-SOLOMON_PO,
I_TAB-VERKF1 TO ZMM_SOLOMON_PO-SOLOMON_DATE.
insert ZMM_SOLOMON_PO.
if sy-subrc eq 0.
commit work.
else.
rollback work.
endif.
ENDLOOP.
MOVE I_TAB[] TO I_OUT[].
MOVE I_TAB[] TO I_TAB3[].
SORT I_TAB BY VERKF.
DELETE ADJACENT DUPLICATES FROM I_TAB COMPARING VERKF.
CLEAR COUNT.
loop at i_tab.
COUNT = SY-TABIX.
select SINGLE *
from ZMM_SOLOMON_PO WHERE SOLOMON_PO = I_TAB-VERKF AND
SOLOMON_DATE = I_TAB-VERKF1.
IF SY-SUBRC = 0.
I_TAB-FLAG = 'C'.
MODIFY I_TAB INDEX COUNT.
concatenate 'File Name : ' name into i_msg1.
append i_msg1.
concatenate 'File Name : ' name into i_msg2.
append i_msg2.
CONCATENATE 'ERROR : PO ' I_TAB-VERKF
' WAS ALREADY UPLOADED' INTO I_MSG1.
APPEND I_MSG1.
CONCATENATE 'ERROR : PO ' I_TAB-VERKF
' WAS ALREADY UPLOADED' INTO I_MSG2.
APPEND I_MSG2.
CLEAR I_TAB-FLAG.
CONTINUE.
ELSE.
refresh pohead.
refresh poheadx.
clear pohead.
refresh poitem.
refresh poitemX.
pohead-DOC_TYPE = i_tab-bsart.
pohead-VENDOR = i_tab-lifnr.
pohead-PURCH_ORG = c_ekorg.
pohead-CREAT_DATE = i_tab-verkf1.
pohead-PUR_GROUP = c_ekgrp.
pohead-COMP_CODE = c_bukrs.
pohead-SALES_PERS = I_TAB-VERKF2.
pohead-doc_date = sy-datum.
pohead-langu = sy-langu.
IF I_TAB-CURRKEY = 'USD'.
pohead-CURRENCY = 'USDN'.
ELSE.
pohead-CURRENCY = I_TAB-CURRKEY.
ENDIF.
pohead-ITEM_INTVL = ''.
append pohead.
poheadx-DOC_TYPE = c_x.
poheadx-VENDOR = c_x.
poheadx-PURCH_ORG = c_x.
poheadx-PUR_GROUP = c_x.
poheadx-COMP_CODE = c_x.
poheadx-SALES_PERS = c_x.
poheadx-ITEM_INTVL = c_x.
poheadx-doc_date = c_x.
poheadx-CURRENCY = c_x.
poheadx-langu = c_x.
append poheadx.
refresh poitem.
clear poitem.
refresh poitemsch.
refresh poitemschx.
clear poitemsch.
clear poitemschx.
sort i_tab3 by verkf ebelp1.
loop at i_tab3 WHERE VERKF = I_TAB-VERKF.
clear poitem.
poitem-PO_ITEM = i_tab3-ebelp1.
poitem-MATERIAL = i_tab3-MATNR.
poitem-QUANTITY = i_tab3-MENGE.
poitem-PO_UNIT = i_tab3-BPRME.
poitem-NET_PRICE = i_tab3-NETPR.
IF I_TAB3-CURRKEY = 'USD'.
multiply poitem-NET_PRICE by 1000.
ENDIF.
poitem-NO_ROUNDING = 'X'.
poitem-PLANT = i_tab3-WERKS.
poitem-INFO_UPD = ''.
if i_tab3-PSTYP <> ''.
poitem-item_cat = i_tab3-PSTYP.
endif.
poitem-GR_TO_DATE = i_tab3-LEWED.
poitem-tax_code = c_x.
poitem-item_cat = c_x.
POITEM-ACCTASSCAT = c_x.
poitem-AGREEMENT = i_tab3-ebeln.
poitem-AGMT_ITEM = i_tab3-ebelp1.
poitem-VEND_MAT = i_tab3-IDNLF.
append poitem.
clear poitemx.
poitemx-PO_ITEM = i_tab3-ebelp1.
poitemx-MATERIAL = c_x.
poitemx-QUANTITY = c_x.
poitemx-PO_UNIT = c_x.
poitemx-NET_PRICE = c_x.
poitemx-NO_ROUNDING = c_x.
poitemx-PLANT = c_x.
poitemx-GR_TO_DATE = c_x.
poitemx-INFO_UPD = c_x.
poitemx-tax_code = c_x.
poitemx-item_cat = c_x.
POITEMx-ACCTASSCAT = c_x.
poitemx-AGREEMENT = 'X'.
poitemx-AGMT_ITEM = 'X'.
poitemx-VEND_MAT = c_x.
append poitemx.
poitemsch-PO_ITEM = i_tab3-ebelp1.
poitemsch-SCHED_LINE = '0001'.
poitemsch-DELIVERY_DATE = i_tab3-LEWED.
poitemsch-QUANTITY = i_tab3-MENGE.
append poitemsch.
poitemschx-PO_ITEM = i_tab3-ebelp1.
poitemschx-SCHED_LINE = '0001'.
poitemschx-PO_ITEMX = C_X.
poitemschx-DELIVERY_DATE = c_x.
poitemschx-QUANTITY = C_X.
append poitemschx.
endloop.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = pohead
POHEADERX = poheadx
POADDRVENDOR =
TESTRUN =
MEMORY_UNCOMPLETE =
MEMORY_COMPLETE =
POEXPIMPHEADER =
POEXPIMPHEADERX =
VERSIONS =
NO_MESSAGING =
NO_MESSAGE_REQ =
NO_AUTHORITY =
NO_PRICE_FROM_PO =
IMPORTING
EXPPURCHASEORDER =
EXPHEADER = ponum
EXPPOEXPIMPHEADER =
TABLES
RETURN = errmsg
POITEM = poitem
POITEMX = poitemx
POADDRDELIVERY =
POSCHEDULE = poitemsch
POSCHEDULEX = poitemschx
POACCOUNT =
POACCOUNTPROFITSEGMENT =
POACCOUNTX =
POCONDHEADER =
POCONDHEADERX =
POCOND =
POCONDX =
POLIMITS =
POCONTRACTLIMITS =
POSERVICES =
POSRVACCESSVALUES =
POSERVICESTEXT =
EXTENSIONIN =
EXTENSIONOUT =
POEXPIMPITEM =
POEXPIMPITEMX =
POTEXTHEADER =
POTEXTITEM =
ALLVERSIONS =
POPARTNER =
.
clear errflag.
loop at errmsg.
if sy-tabix = 1.
concatenate 'File Name : ' name into i_msg1.
append i_msg1.
concatenate 'Sol PO : ' I_TAB-VERKF ' '
I_TAB-VERKF1 into i_msg1.
append i_msg1.
concatenate 'File Name : ' name into i_msg1.
append i_msg2.
concatenate 'Sol PO : ' I_TAB-VERKF ' '
I_TAB-VERKF1 into i_msg2.
append i_msg2.
endif.
if errmsg-type eq 'E'.
write:/'Error in function', errmsg-message.
errflag = 'X'.
else.
write:/ errmsg-message.
endif.
MOVE : ERRMSG-MESSAGE TO I_MSG1.
APPEND I_MSG1.
MOVE : ERRMSG-MESSAGE TO I_MSG2.
APPEND I_MSG2.
endloop.
if errflag is initial.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN =
.
commit work and wait.
if sy-subrc ne 0.
write:/ 'Error in updating'.
exit.
else.
concatenate 'File Name : ' name into i_msg1.
append i_msg1.
concatenate 'Sol PO : ' I_TAB-VERKF ' '
I_TAB-VERKF1 into i_msg1.
append i_msg1.
concatenate 'File Name : ' name into i_msg2.
append i_msg2.
concatenate 'Sol PO : ' I_TAB-VERKF ' '
I_TAB-VERKF1 into i_msg2.
append i_msg1.
write:/ ponum-PO_NUMBER, ponum-comp_code.
ZMM_SOLOMON_PO-SOLOMON_PO = I_TAB-VERKF.
ZMM_SOLOMON_PO-SOLOMON_DATE = I_TAB-VERKF1.
INSERT ZMM_SOLOMON_PO.
COMMIT WORK AND WAIT.
I_TAB-FLAG = 'C'.
MODIFY I_TAB INDEX COUNT.
CONCATENATE ponum-PO_NUMBER ' ' ponum-comp_code
'UPLOADED SUCESSFULLY' INTO I_MSG1.
APPEND I_MSG1.
CONCATENATE ponum-PO_NUMBER ' ' ponum-comp_code
'UPLOADED SUCESSFULLY' INTO I_MSG2.
APPEND I_MSG2.
endif.
endif.
ENDIF.
WAIT UP TO 10 SECONDS.
endloop.
CLEAR G_FLAG.
LOOP AT I_TAB WHERE FLAG <> 'C'.
G_FLAG = 'X'.
ENDLOOP.
IF G_FLAG IS INITIAL.
CLEAR G_FLAG.
concatenate: hfile '\' date1 '\' name into h_file.
OPEN DATASET h_file FOR OUTPUT IN TEXT MODE
ENCODING DEFAULT
IGNORING CONVERSION ERRORS.
IF SY-SUBRC EQ 0.
LOOP AT I_OUT.
CONCATENATE I_OUT-VERKF ',' I_OUT-VERKF1 ',' I_OUT-LIFNR ','
I_OUT-EBELP1 ',' I_OUT-WERKS ',' I_OUT-MATNR ','
I_OUT-IDNLF ',' I_OUT-MENGE ',' I_OUT-BPRME ','
I_OUT-LEWED ',' I_OUT-NETPR ',' I_OUT-CURRKEY
',' I_OUT-PSTYP
INTO I_TAB2.
TRANSFER i_tab2 TO h_file.
ENDLOOP.
DELETE DATASET g_file.
ENDIF.
CLOSE DATASET h_file.
ENDIF.
Begin of log creation
concatenate: ifile '\' date1 '\' name into i_file.
IF NOT I_MSG2[] IS INITIAL.
OPEN DATASET i_file FOR OUTPUT IN TEXT MODE
ENCODING DEFAULT
IGNORING CONVERSION ERRORS.
IF SY-SUBRC EQ 0.
LOOP AT I_MSG2.
TRANSFER I_MSG2 TO i_file.
ENDLOOP.
ENDIF.
REFRESH I_MSG2.
CLEAR I_MSG2.
CLOSE DATASET I_file.
ENDIF.
****End of log creation
endloop.
ENDFORM. " UPLOAD_DATA
&----
*& Form GET_OUTLINE_AGREEMENT
&----
text
----
--> p1 text
<-- p2 text
----
FORM GET_OUTLINE_AGREEMENT .
DATA: L_TABIX LIKE SY-TABIX.
DATA: L_LIFNR LIKE EKKO-LIFNR.
DATA : L_EBELP like ekpo-ebelp.
LOOP AT I_TAB.
L_TABIX = SY-TABIX.
CONCATENATE I_TAB-VERKF I_TAB-VERKF1 INTO I_TAB-VERKF2
SEPARATED BY '#'.
MODIFY I_TAB INDEX L_TABIX.
clear i_tab.
ENDLOOP.
LOOP AT I_TAB.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = I_TAB-LIFNR
IMPORTING
OUTPUT = L_LIFNR.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = I_TAB-EBELP1
IMPORTING
OUTPUT = L_EBELP.
I_TAB-LIFNR = L_LIFNR.
I_TAB-EBELP1 = L_EBELP.
SELECT SINGLE *
FROM LFM1
WHERE LIFNR EQ L_LIFNR AND
EKORG = C_EKORG.
IF SY-SUBRC EQ 0.
IF LFM1-KALSK EQ 'ZD'.
L_BSART = 'NB'.
MOVE L_BSART TO I_TAB-BSART.
MODIFY I_TAB. " INDEX 1.
clear i_tab.
ELSEIF LFM1-KALSK EQ 'ZI'.
L_BSART1 = 'ZNB'.
MOVE L_BSART1 TO I_TAB-BSART.
MODIFY I_TAB.
clear i_tab.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " GET_OUTLINE_AGREEMENT
&----
*& Form CHECK_ENTRIES_ZMM_SOLOMON_PO
&----
text
----
--> p1 text
<-- p2 text
----
*FORM CHECK_ENTRIES_ZMM_SOLOMON_PO .
select SOLOMON_PO
SOLOMON_DATE
FLAG
from ZMM_SOLOMON_PO
into table I_ZMM_SOLOMON_PO.
if I_TAB[] is NOT initial.
loop at i_TAB.
count = sy-tabix.
read table I_ZMM_SOLOMON_PO with key SOLOMON_PO = I_TAB-VERKF.
IF SY-SUBRC = 0.
delete i_TAB index count.
CONCATENATE 'PO : ' I_TAB-VERKF
' WAS ALREADY CREATED' INTO I_MSG1.
APPEND I_MSG1.
CLEAR I_TAB.
endif.
endloop.
endif.
*ENDFORM. " CHECK_ENTRIES_ZMM_SOLOMON_PO
&----
*& Form SUB_SEND_MAIL
&----
text
----
--> p1 text
<-- p2 text
----
FORM SUB_SEND_MAIL .
DATA: BEGIN OF EMAIL_DATA.
INCLUDE STRUCTURE SODOCCHGI1.
DATA: END OF EMAIL_DATA.
DATA: BEGIN OF EMAIL_SEND OCCURS 10.
INCLUDE STRUCTURE SOMLRECI1.
DATA: END OF EMAIL_SEND.
if not i_msg1[] is initial.
select * from zmmint_usr into corresponding fields of table it_usr
where werks = c_plant and tx_id = 'CPOR'.
if sy-subrc = 0.
loop at it_usr.
EMAIL_DATA-OBJ_NAME = 'MESSAGE'.
EMAIL_DATA-OBJ_DESCR = 'PURCHASE ORDER CREATION'.
EMAIL_DATA-OBJ_LANGU = 'E'.
EMAIL_DATA-SENSITIVTY = 'P'.
EMAIL_DATA-OBJ_PRIO = '1'.
EMAIL_DATA-NO_CHANGE = 'X'.
EMAIL_DATA-PRIORITY = '1'.
EMAIL_SEND-RECEIVER = it_usr-uname.
EMAIL_SEND-REC_TYPE = 'B'.
EMAIL_SEND-EXPRESS = 'X'.
EMAIL_SEND-REC_ID = sy-uname.
APPEND EMAIL_SEND.
endloop.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = EMAIL_DATA
DOCUMENT_TYPE = 'RAW'
PUT_IN_OUTBOX = 'X'
TABLES
OBJECT_CONTENT = I_MSG1
RECEIVERS = EMAIL_SEND.
endif.
endif.
ENDFORM. " SUB_SEND_MAIL
Regards
M.P. Reddy
2008 Dec 01 7:18 AM
Hi Mani,
you need to put an 'X' for each of the fields you have used in POITEM in POITEMX and same way for others..
You can test the BAPI first in SE37 then you can code for the same...
check my post in wiki for the same... and let me know in case som error.
https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/function%252bmodule%252btest%252bsequence
Sachin
2008 Dec 01 7:25 AM
see the following example:-
&----
*& Report YBAPI_PO_CREATE1
*&
&----
*&
*&
&----
REPORT YBAPI_PO_CREATE1.
data:
header like BAPIMEPOHEADER,
headerx like BAPIMEPOHEADERX,
it_item like standard table of BAPIMEPOITEM,
it_itemx like standard table of BAPIMEPOITEMX,
return like standard table of BAPIRET2,
wa_item like BAPIMEPOITEM,
wa_itemx like BAPIMEPOITEMX,
p_int type i,
p_matnr like mara-matnr,
p_pono like ekko-ebeln.
constants:
c_x type c value 'X'.
header-comp_code = '3000'.
header-doc_type = 'DP25'.
header-creat_date = sy-datum.
header-item_intvl = '10'.
header-vendor = 'ARAMI-00'.
header-langu = sy-langu.
header-pmnttrms = '0001'.
header-purch_org = '3000'.
header-pur_group = '010'.
header-currency = 'USD'.
headerx-comp_code = c_x.
headerx-doc_type = c_x.
headerx-creat_date = c_x.
headerx-item_intvl = c_x .
headerx-vendor = c_x.
headerx-langu = c_x.
headerx-pmnttrms = c_x .
headerx-purch_org = c_x.
headerx-pur_group = c_x.
*LOOP AT it_final2 INTO wa_final2.
p_int = p_int + 10.
wa_item-po_item = p_int.
p_matnr = 'T-SRM01'.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = p_matnr
IMPORTING
output = p_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.
wa_item-material = p_matnr.
wa_item-plant = '3200'.
wa_item-quantity = 100.
wa_item-conf_ctrl = 'Z01'.
wa_item-ACKN_REQD = 'X'.
WA_ITEM-ERS = ''.
APPEND wa_item TO it_item.
wa_itemx-po_item = p_int.
wa_itemx-material = c_x.
wa_itemx-plant = c_x .
wa_itemx-stge_loc = c_x .
wa_itemx-quantity = c_x .
wa_itemx-item_cat = c_x .
wa_itemx-acctasscat = c_x .
wa_itemx-conf_ctrl = 'X'.
wa_itemx-ACKN_REQD = 'X'.
WA_ITEMX-ERS = 'X'.
APPEND wa_itemx TO it_itemx.
*ENDLOOP.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = header
poheaderx = headerx
IMPORTING
exppurchaseorder = p_pono
TABLES
return = return
poitem = it_item
poitemx = it_itemx.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
.
write:/ p_pono.
<removed_by_moderator>
Edited by: Julius Bussche on Dec 1, 2008 8:31 AM
2008 Dec 01 7:51 AM
hi,
now the BAPI is working fine for a simple PO upload.
but i am facing one problem:-when in the flat file the plant,material,document type are in lower case then BAPI throws an error message that enter valid input or data doesn't exists.
but when the file consists of all the above data in upper case then no error message.
why so.
2008 Dec 01 8:06 AM
Hi
When you are working with BAPI, we should be careful that you pass the values exactly same as it is stored in database including uppercase. So, it will take only when it is in uppercase as that is how it is stored in the table and even with numbers. For example, the vendor number is 2000, you should give the number as 0000020000, that is because the field length in the table is 10.
Vishwa.
2008 Dec 01 9:24 AM
hi,
can i use BAPI_PO_CREATE1 for creating service PO.
when i am trying to create a service PO then i am maintaining data-service no. in the table:
POSERVICES LIKE BAPIESLLC
but when i am executing the BAPI its giving error that i have to maintain a serial no. in:
POSRVACCESSVALUES LIKE BAPIESKLC
so i maintained serial no.,quantity,net value in POSRVACCESSVALUES.
and that serial no. field will link to the POACCOUNT structure,so i have mantained serial no in POACCOUNT also.
but now i am getting error i.e:
E SE 029 Please maintain services or limits 000000 POITEM 1
what can be the reson.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |