Error in PO using BAPI_PO_CREATE1
Hi ,
I got a error in the po that in my template the netpr is 8.00 but in the output always displaying the amount 1.00 only in POITEM-NET_PRICE.even i change in the template different values but no change in the output.why like this and how to solve this.
Thanks,
Regards,
Rajendra.
Hi Eswar,
Below is the code,
tables: T100.
DATA : POHEADER LIKE BAPIMEPOHEADER ,
POHEADERX LIKE BAPIMEPOHEADERX,
POITEM LIKE BAPIMEPOITEM OCCURS 0 WITH HEADER LINE,
POITEMX LIKE BAPIMEPOITEMX OCCURS 0 WITH HEADER LINE,
POSCHEDULE LIKE BAPIMEPOSCHEDULE OCCURS 0 WITH HEADER LINE,
POSCHEDULEX LIKE BAPIMEPOSCHEDULX OCCURS 0 WITH HEADER LINE,
POACCOUNT LIKE BAPIMEPOACCOUNT OCCURS 0 WITH HEADER LINE,
POACCOUNTX LIKE BAPIMEPOACCOUNTX OCCURS 0 WITH HEADER LINE,
POCOND LIKE BAPIMEPOCOND OCCURS 0 WITH HEADER LINE,
POCONDX LIKE BAPIMEPOCONDX OCCURS 0 WITH HEADER LINE,
RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,
EXPPURCHASEORDER LIKE BAPIMEPOHEADER-PO_NUMBER.
POHEADER-COMP_CODE = '2006'.
DATA : BEGIN OF DATA_TAB OCCURS 0,
BSART(4) TYPE C,
LIFNR(10) TYPE C,
EKORG(4) TYPE C,
EKGRP(3) TYPE C,
EBELP(5) TYPE C,
MATNR(18) TYPE C,
MAKTX(40) TYPE C,
WERKS(4) TYPE C,
CHARG(10) TYPE C,
BEDNR(10) TYPE C,
PSTYP(1) TYPE C,
KNTTP(1) TYPE C,
ANLN1(12) TYPE C,
ANLN2(4) TYPE C,
AUFNR(12) TYPE C,
PS_PSP_PNR(8) TYPE C,
EINDT(8) TYPE C,
WAERS(5) TYPE C,
NETPR(11) TYPE C,
WKURS(9) TYPE C,
BEDAT(8) TYPE C,
SAKTO(10) TYPE C,
KOSTL(10) TYPE C,
MENGE(13) TYPE C,
MEINS(3) TYPE C,
KWERT(13) TYPE C,
KSCHL(4) TYPE C,
END OF DATA_TAB.
Data
DATA : wc_file type string,
wc_tabix like sy-tabix,
wc_fl(40) type c,
wc_tot(19) type n.
data: i_tab1 like alsmex_tabline occurs 0 with header line,
w_Data_tab like Data_tab occurs 0 with header line,
w_Data_tab like Data_tab,
w_totlines type i,
w_end_col type i.
DATA : C_X(1) TYPE c VALUE 'X'.
DATA : W_ERRSTAT(18) TYPE C.
DATA : W_ERRMSG(18) TYPE C.
DATA : I_EKKO LIKE EKKO OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF I_RETURN OCCURS 0.
DATA : EBELN LIKE EKKO-EBELN.
INCLUDE STRUCTURE DATA_TAB.
DATA : MESSAGE LIKE RETURN-MESSAGE.
DATA : END OF I_RETURN.
ALV
type-pools: slis.
data: txt_report like dokhl-object. "Reportname für Erläuterungsaufruf
data: gt_fieldcat type slis_t_fieldcat_alv,
gt_events type slis_t_event,
gt_sort type slis_t_sortinfo_alv,
gt_list_top_of_page type slis_t_listheader,
gs_layout type slis_layout_alv.
*Parameters
selection-screen begin of block mysel1 with frame.
parameters: pc_file like rlgrap-filename. " obligatory default 'C:'." default 'C:mat.xls'.
selection-screen end of block mysel1.
*AT SELECTION-SCREEN
at selection-screen on pc_file.
call function 'WS_QUERY'
exporting
query = 'FL'
filename = pc_file
importing
return = wc_fl.
condense wc_fl no-gaps.
if wc_fl eq space.
message e009 raising pc_file.
exit.
endif.
at selection-screen on value-request for pc_file.
wc_file = pc_file.
call function 'WS_FILENAME_GET'
exporting
mask = ' '
title = text-001
importing
filename = pc_file
exceptions
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
others = 5.
SELECTION-SCREEN
start-of-selection.
perform 1000_getfile.
perform 2000_process_bapi.
perform fieldcat_init using gt_fieldcat[].
perform layout_init using gs_layout.
perform comment_build using gt_list_top_of_page[].
perform eventtab_build using gt_events[].
PERFORM sort_build USING gt_sort[].
perform 3000_updation_log.
end-of-selection.
*& Form 1000_getfile
text
--> p1 text
<-- p2 text
FORM 1000_getfile .
*w_data_tab = data_tab.
Get the No of Rows in the file
CALL FUNCTION 'AA_FILE_UPLOAD_EXCEL'
EXPORTING
I_FILENAME = pc_file
I_TEST =
I_UCOMM =
I_MAXCOLS =
I_DELIMITER = ','
TABLES
ET_FILECONTENT = DATA_TAB
EXCEPTIONS
ERROR_ACCESSING_FILE = 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.
describe table Data_tab lines w_totlines.
w_end_col = 27.
w_totlines = 1.
Upload the data from file to Internal Table
refresh Data_tab.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = pc_file
i_begin_col = 1 " Starting col on each row from the upload excel file
i_begin_row = 4 " Starting row from the upload excel file
i_end_col = w_end_col " No. of columns in the upload excel file
i_end_row = w_totlines " Possible no. of rows in the upload excel file
tables
intern = i_tab1
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
endif.
sort i_tab1 by row col.
loop at i_tab1.
case i_tab1-col.
when 1.
clear w_Data_tab.
move i_tab1-value to w_Data_tab-bsart.
when 2.
move i_tab1-value to w_Data_tab-lifnr.
when 3.
move i_tab1-value to w_Data_tab-ekorg.
when 4.
move i_tab1-value to w_Data_tab-ekgrp.
when 5.
move i_tab1-value to w_Data_tab-ebelp.
when 6.
move i_tab1-value to w_Data_tab-matnr.
when 7.
move i_tab1-value to w_Data_tab-maktx.
when 8.
move i_tab1-value to w_Data_tab-werks.
when 9.
move i_tab1-value to w_Data_tab-charg.
when 10.
move i_tab1-value to w_Data_tab-bednr.
when 11.
move i_tab1-value to w_Data_tab-pstyp.
when 12.
move i_tab1-value to w_Data_tab-knttp.
when 13.
move i_tab1-value to w_Data_tab-anln1.
when 14.
move i_tab1-value to w_Data_tab-anln2.
when 15.
move i_tab1-value to w_Data_tab-aufnr.
when 16.
move i_tab1-value to w_Data_tab-ps_psp_pnr.
when 17.
move i_tab1-value to w_Data_tab-eindt.
when 18.
move i_tab1-value to w_Data_tab-waers.
when 19.
move i_tab1-value to w_Data_tab-netpr.
when 20.
move i_tab1-value to w_Data_tab-wkurs.
when 21.
move i_tab1-value to w_Data_tab-bedat.
when 22.
move i_tab1-value to w_Data_tab-sakto.
when 23.
move i_tab1-value to w_Data_tab-kostl.
when 24.
move i_tab1-value to w_Data_tab-menge.
when 25.
move i_tab1-value to w_Data_tab-meins.
when 26.
move i_tab1-value to w_Data_tab-kwert.
when 27.
move i_tab1-value to w_Data_tab-kschl.
endcase.
at end of row.
append w_Data_tab to Data_tab.
clear w_Data_tab.
endat.
endloop.
clear wc_tot.
describe table Data_tab lines wc_tot.
ENDFORM. " 1000_getfile
*& Form 2000_process_bapi
text
--> p1 text
<-- p2 text
FORM 2000_process_bapi .
LOOP AT DATA_TAB.
POHEADER-DOC_TYPE = DATA_TAB-BSART.
POHEADER-VENDOR = DATA_TAB-LIFNR.
POHEADER-PURCH_ORG = DATA_TAB-EKORG.
POHEADER-PUR_GROUP = DATA_TAB-EKGRP.
POHEADER-DOC_DATE = DATA_TAB-BEDAT.
POHEADER-EXCH_RATE = DATA_TAB-WKURS.
POHEADER-CURRENCY = DATA_TAB-WAERS.
APPEND POHEADER.
POHEADERX-DOC_TYPE = 'X'.
POHEADERX-VENDOR = 'X'.
POHEADERX-PURCH_ORG = 'X'.
POHEADERX-PUR_GROUP = 'X'.
POHEADERX-DOC_DATE = 'X'.
POHEADERX-EXCH_RATE = 'X'.
POHEADERX-CURRENCY = 'X'.
APPEND POHEADERX.
POITEM-PO_ITEM = DATA_TAB-EBELP.
POITEM-MATERIAL = DATA_TAB-MATNR.
POITEM-SHORT_TEXT = DATA_TAB-MAKTX.
POITEM-PLANT = DATA_TAB-WERKS.
POITEM-BATCH = DATA_TAB-CHARG.
POITEM-TRACKINGNO = DATA_TAB-BEDNR.
POITEM-ITEM_CAT = DATA_TAB-PSTYP.
POITEM-ACCTASSCAT = DATA_TAB-KNTTP.
POITEM-NET_PRICE = DATA_TAB-NETPR.
POITEM-QUANTITY = DATA_TAB-MENGE.
POITEM-PO_UNIT = DATA_TAB-MEINS.
APPEND POITEM.
POITEMX-PO_ITEM = DATA_TAB-EBELP.
POITEMX-PO_ITEM = 'X'.
POITEMX-MATERIAL = 'X'.
POITEMX-SHORT_TEXT = 'X'.
POITEMX-PLANT = 'X'.
POITEMX-BATCH = 'X'.
POITEMX-TRACKINGNO = 'X'.
POITEMX-ITEM_CAT = 'X'.
POITEMX-ACCTASSCAT = 'X'.
POITEMX-NET_PRICE = 'X'.
POITEMX-QUANTITY = 'X'.
POITEMX-PO_UNIT = 'X'.
APPEND POITEMX.
POACCOUNT-PO_ITEM = DATA_TAB-EBELP.
POACCOUNT-ASSET_NO = DATA_TAB-ANLN1.
POACCOUNT-SUB_NUMBER = DATA_TAB-ANLN2.
POACCOUNT-ORDERID = DATA_TAB-AUFNR.
POACCOUNT-WBS_ELEMENT = DATA_TAB-PS_PSP_PNR.
POACCOUNT-GL_ACCOUNT = DATA_TAB-SAKTO.
POACCOUNT-COSTCENTER = DATA_TAB-KOSTL.
POACCOUNT-QUANTITY = DATA_TAB-MENGE.
APPEND POACCOUNT.
POACCOUNTX-PO_ITEM = DATA_TAB-EBELP.
POACCOUNTX-ASSET_NO = 'X'.
POACCOUNTX-SUB_NUMBER = 'X'.
POACCOUNTX-ORDERID = 'X'.
POACCOUNTX-WBS_ELEMENT = 'X'.
POACCOUNTX-GL_ACCOUNT = 'X'.
POACCOUNTX-COSTCENTER = 'X'.
APPEND POACCOUNTX.
POCOND-ITM_NUMBER = DATA_TAB-EBELP.
POCOND-COND_VALUE = DATA_TAB-KWERT.
POCOND-CURRENCY = DATA_TAB-WAERS.
POCOND-COND_TYPE = DATA_TAB-KSCHL.
POCOND-CHANGE_ID = ' I '.
APPEND POCOND.
POCONDX-ITM_NUMBER = DATA_TAB-EBELP.
POCONDX-COND_VALUE = 'X'.
POCONDX-CURRENCY = 'X'.
POCONDx-COND_TYPE = 'X'.
POCONDx-CHANGE_ID = ' I '.
APPEND POCONDX.
POSCHEDULE-PO_ITEM = DATA_TAB-EBELP.
POSCHEDULE-DELIVERY_DATE = DATA_TAB-EINDT.
POSCHEDULE-QUANTITY = DATA_TAB-MENGE.
APPEND POSCHEDULE.
POSCHEDULEX-PO_ITEM = DATA_TAB-EBELP.
POSCHEDULEX-DELIVERY_DATE = 'X'.
POSCHEDULEx-QUANTITY = 'X'.
APPEND POSCHEDULEX.
ENDLOOP.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = POHEADER
POHEADERX = POHEADERX
IMPORTING
EXPPURCHASEORDER = EXPPURCHASEORDER
EXPHEADER =
EXPPOEXPIMPHEADER =
TABLES
RETURN = RETURN
POITEM = POITEM
POITEMX = POITEMX
POADDRDELIVERY =
POSCHEDULE = POSCHEDULE
POSCHEDULEX = POSCHEDULEX
POACCOUNT = POACCOUNT
POACCOUNTPROFITSEGMENT =
POACCOUNTX = POACCOUNTX
POCONDHEADER =
POCONDHEADERX =
POCOND = POCOND
POCONDX = POCONDX
POPARTNER =
IF SY-SUBRC = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = C_X
ENDIF.
data : w_ekko like ekko-ebeln.
LOOP AT DATA_TAB.
READ TABLE RETURN index 1.
MOVE-CORRESPONDING RETURN TO I_RETURN.
MOVE-CORRESPONDING DATA_TAB TO I_RETURN.
TO GET THE PO NUMBER *************
SELECT single EBELN FROM EKKO INTO w_EKKO
WHERE BSART EQ DATA_TAB-BSART
AND LIFNR EQ DATA_TAB-LIFNR
AND EKORG EQ DATA_TAB-EKORG
AND EKGRP EQ DATA_TAB-EKGRP.
MOVE w_EKKO TO I_RETURN-EBELN.
APPEND I_RETURN.
CLEAR I_RETURN.
ENDLOOP.
ENDFORM. " 2000_process_bapi
*& Form fieldcat_init
FORM fieldcat_init USING lt_fieldcat type slis_t_fieldcat_alv.
data: ls_fieldcat type slis_fieldcat_alv.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'EBELN'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-001.
ls_fieldcat-seltext_m = text-001.
ls_fieldcat-seltext_s = text-001.
ls_fieldcat-reptext_ddic = text-001.
ls_fieldcat-outputlen = '10'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'WERKS'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-002.
ls_fieldcat-seltext_m = text-002.
ls_fieldcat-seltext_s = text-002.
ls_fieldcat-reptext_ddic = text-002.
ls_fieldcat-outputlen = '4'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'KNTTP'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-003.
ls_fieldcat-seltext_m = text-003.
ls_fieldcat-seltext_s = text-003.
ls_fieldcat-reptext_ddic = text-003.
ls_fieldcat-outputlen = '4'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-004.
ls_fieldcat-seltext_m = text-004.
ls_fieldcat-seltext_s = text-004.
ls_fieldcat-reptext_ddic = text-004.
ls_fieldcat-outputlen = '18'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'MENGE'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-005.
ls_fieldcat-seltext_m = text-005.
ls_fieldcat-seltext_s = text-005.
ls_fieldcat-reptext_ddic = text-005.
ls_fieldcat-outputlen = '10'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'NETPR'.
ls_fieldcat-datatype = 'CURR'.
ls_fieldcat-seltext_l = text-006.
ls_fieldcat-seltext_m = text-006.
ls_fieldcat-seltext_s = text-006.
ls_fieldcat-reptext_ddic = text-006.
ls_fieldcat-outputlen = '11'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'MESSAGE'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-007.
ls_fieldcat-seltext_m = text-007.
ls_fieldcat-seltext_s = text-007.
ls_fieldcat-reptext_ddic = text-007.
ls_fieldcat-outputlen = '50'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ENDFORM. " fieldcat_init
*& Form layout_init
text
-->P_GS_LAYOUT text
FORM layout_init USING ls_layout type slis_layout_alv.
ls_layout-zebra = 'X'.
ENDFORM. " layout_init
*& Form comment_build
text
-->P_GT_LIST_TOP_OF_PAGE[] text
FORM comment_build USING Lt_top_of_page type slis_t_listheader.
field-symbols: .
data: ls_line type slis_listheader.
data: i_sel like textpool occurs 0 with header line.
read textpool sy-repid into i_sel language sy-langu.
delete i_sel where id ne 'S'.
LIST HEADING LINE: TYPE H
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = text-020.
append ls_line to lt_top_of_page.
clear ls_line.
ls_line-typ = 'S'.
ls_line-key = text-021.
append ls_line to lt_top_of_page.
Selection-screen
loop at i_sel.
assign (i_sel-key) to .
append ls_line to lt_top_of_page.
endloop.
ENDFORM. " comment_build
*& Form eventtab_build
text
-->P_GT_EVENTS[] text
FORM eventtab_build USING lt_events type slis_t_event.
data: ls_event type slis_alv_event.
move 'PF_STATUS_SET' to ls_event-name.
move 'Z2006RMMPOUPLOAD' to ls_event-form.
append ls_event to lt_events.
clear ls_event.
ENDFORM. "eventtab_build
FORM PF_STATUS_SET
form Z2006RMMPOUPLOAD using extab type slis_t_extab. "#EC CALLED
set pf-status 'Z2006RMMPOUPLOAD'. "EXCLUDING extab.
endform. "Z2006RMMPOUPLOAD
FORM TOP_OF_PAGE *
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
i_logo = 'MECOMB'
it_list_commentary = gt_list_top_of_page.
endform. "top_of_page
*& Form 3000_updation_log
FORM 3000_updation_log .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = 'Z2006RMMPOUPLOAD'
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = gs_layout
IT_FIELDCAT = gt_fieldcat[]
IT_EVENTS = gt_events[]
TABLES
T_OUTTAB = I_RETURN
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
ENDFORM. " 3000_updation_log
*& Form sort_build
FORM sort_build USING lt_sort type slis_t_sortinfo_alv.
data: ls_sort type slis_sortinfo_alv.
ls_sort-fieldname = 'EBELN'.
ls_sort-up = 'X'.
ls_sort-subtot = 'X'.
append ls_sort to lt_sort.
clear ls_sort.
ls_sort-fieldname = 'MATNR'.
ls_sort-up = 'X'.
append ls_sort to lt_sort.
clear ls_sort.
ENDFORM. " sort_build
Thanks,
Rajendra.
Similar Messages
-
Getting errors when iam using BAPI_PO_CREATE1 for Purchase Order creation
Hi sap Gurus,
I am getting Errors when iam using BAPI_PO_CREATE1 for Purchase Order creation that Material (144) does not exist but it is alreardy maintained in MM01.
I dont get how it is coming.and what are the mandatory fields in bapi BAPI_PO_CREATE1 in item level .that is too material only.
pls let me know .
thanks in advance.Hi,
Check the sample code..
report zpo_test .
*DATA DECLARATION
constants : c_x value 'X'.
*Structures to hold PO header data
data : header like bapimepoheader ,
headerx like bapimepoheaderx .
*Structures to hold PO account data
data : account like bapimepoaccount occurs 0 with header line ,
accountx like bapimepoaccountx occurs 0 with header line .
*Internal Tables to hold PO ITEM DATA
data : item like bapimepoitem occurs 0 with header line,
itemx like bapimepoitemx occurs 0 with header line,
*Internal table to hold messages from BAPI call
return like bapiret2 occurs 0 with header line,
*Internal table to hold messages from BAPI call
pocontractlimits like bapiesucc occurs 0 with header line.
data : w_header(40) value 'PO Header',
purchaseorder like bapimepoheader-po_number,
delivery_date like bapimeposchedule-delivery_date.
data : ws_langu like sy-langu.
*text-001 = 'PO Header' - define as text element
selection-screen begin of block b1 with frame title text-001.
parameters : company like header-comp_code default '122' ,
doctyp like header-doc_type default 'NB' ,
cdate like header-creat_date default sy-datum ,
vendor like header-vendor default '2000000012' ,
pur_org like header-purch_org default 'PU01' ,
pur_grp like header-pur_group default '005' .
*sociedad like HEADER-COMP_CODE default '122' ,
*vendedor like HEADER-SALES_PERS default 'sale person'.
selection-screen end of block b1.
selection-screen begin of block b2 with frame title text-002.
parameters : item_num like item-po_item default '00010',
material like item-material default '12000000' ,
tipo_imp like item-acctasscat default 'K' ,
*pos_doc like ITEM-ITEM_CAT default 'F' ,
shorttxt like item-short_text default 'PRUEBA BAPI' ,
grup_art like item-matl_group default '817230000' ,
plant like item-plant default '3001' ,
mpe like item-trackingno default '9999' ,
*contrato like ITEM-AGREEMENT default '4904000003' ,
*quantity like ITEM-QUANTITY default 1 .
po_unit like item-po_unit default 'EA'.
selection-screen end of block b2.
Par?mnetros de imputaci?n
selection-screen begin of block b3 with frame title text-004.
parameters : centro like account-costcenter default '1220813150',
cuenta like account-gl_account default '6631400' ,
num_pos like account-po_item default '10' ,
serial like account-serial_no default '01' ,
ind_imp like account-tax_code default 'I2' .
selection-screen end of block b3.
start-of-selection.
*DATA POPULATION
ws_langu = sy-langu. "Language variable
*POPULATE HEADER DATA FOR PO
*HEADER-COMP_CODE = sociedad .
header-doc_type = doctyp .
header-vendor = vendor .
header-creat_date = cdate .
header-created_by = 'TD17191' .
header-purch_org = pur_org .
header-pur_group = pur_grp .
header-comp_code = company .
header-langu = ws_langu .
*HEADER-SALES_PERS = vendedor .
*HEADER-CURRENCY = 'DOP' .
*HEADER-ITEM_INTVL = 10 .
*HEADER-PMNTTRMS = 'N30' .
*HEADER-EXCH_RATE = 1 .
*POPULATE HEADER FLAG.
headerx-comp_code = c_x.
headerx-doc_type = c_x.
headerx-vendor = c_x.
headerx-creat_date = c_x.
headerx-created_by = c_x.
headerx-purch_org = c_x.
headerx-pur_group = c_x.
headerx-langu = c_x.
*HEADERX-sales_pers = c_x.
*HEADERX-CURRENCY = c_x.
*HEADER-ITEM_INTVL = c_x.
*HEADER-PMNTTRMS = c_x.
*HEADER-EXCH_RATE = c_x.
*HEADER-EXCH_RATE = c_x.
*POPULATE ITEM DATA.
item-po_item = item_num.
item-quantity = '1'.
*ITEM-MATERIAL = material .
item-short_text = 'prueba bapi_po_create1'.
*ITEM-TAX_CODE = ''.
item-acctasscat = 'K' .
*ITEM-ITEM_CAT = 'D' .
item-matl_group = '817230000' .
item-plant = '3001' .
item-trackingno = '99999'.
item-preq_name = 'test'.
*ITEM-AGREEMENT = '' .
*ITEM-AGMT_ITEM = ''.
item-quantity = '1' .
item-po_unit = 'EA'.
*ITEM-ORDERPR_UN = 'EA'.
item-conv_num1 = '1'.
item-conv_den1 = '1'.
item-net_price = '1000000' .
item-price_unit = '1'.
item-gr_pr_time = '0'.
item-prnt_price = 'X'.
item-unlimited_dlv = 'X'.
item-gr_ind = 'X' .
item-ir_ind = 'X' .
item-gr_basediv = 'X'.
*ITEM-PCKG_NO = '' .
append item. clear item.
*POPULATE ITEM FLAG TABLE
itemx-po_item = item_num.
itemx-po_itemx = c_x.
*ITEMX-MATERIAL = C_X.
itemx-short_text = c_x.
itemx-quantity = c_x.
*ITEMX-TAX_CODE = C_X.
itemx-acctasscat = c_x.
*ITEMX-ITEM_CAT = c_x.
itemx-matl_group = c_x.
itemx-plant = c_x.
itemx-trackingno = c_x.
itemx-preq_name = c_x.
*ITEMX-AGREEMENT = C_X.
*ITEMX-AGMT_ITEM = c_x.
itemx-stge_loc = c_x.
itemx-quantity = c_x.
itemx-po_unit = c_x.
*ITEMX-ORDERPR_UN = C_X.
itemx-conv_num1 = c_x.
itemx-conv_den1 = c_x.
itemx-net_price = c_x.
itemx-price_unit = c_x.
itemx-gr_pr_time = c_x.
itemx-prnt_price = c_x.
itemx-unlimited_dlv = c_x.
itemx-gr_ind = c_x .
itemx-ir_ind = c_x .
itemx-gr_basediv = c_x .
append itemx. clear itemx.
*POPULATE ACCOUNT DATA.
account-po_item = item_num.
account-serial_no = serial .
account-creat_date = sy-datum .
account-costcenter = centro .
account-gl_account = cuenta .
account-gr_rcpt = 'tester'.
append account. clear account.
*POPULATE ACCOUNT FLAG TABLE.
accountx-po_item = item_num .
accountx-po_itemx = c_x .
accountx-serial_no = serial .
accountx-serial_nox = c_x .
accountx-creat_date = c_x .
accountx-costcenter = c_x .
accountx-gl_account = c_x .
account-gr_rcpt = c_x.
append accountx. clear accountx.
*BAPI CALL
call function 'DIALOG_SET_NO_DIALOG'.
call function 'BAPI_PO_CREATE1'
exporting
poheader = header
poheaderx = headerx
importing
exppurchaseorder = purchaseorder
tables
return = return
poitem = item
poitemx = itemx
poaccount = account
poaccountx = accountx.
*Confirm the document creation by calling database COMMIT
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'
IMPORTING
RETURN =
end-of-selection.
*Output the messages returned from BAPI call
loop at return.
write / return-message.
endloop.
Regards
Sudheer -
Error while Creating a PO using BAPI_PO_CREATE1
Hi Friends,
The following issue that I have observed and as explained below is one of the weirdest scenarios that I have seen while working with SAP. Hence, kindly help me with possible errors from my end. I am working on ECC 6.0.
Requirement: To automatically create a PO.
Option used: I have used a BAPI: u2018BAPI_PO_CREATE1u2019
Scenario: When I execute the BAPI u2018BAPI_PO_CREATE1u2019 directly in sequence with u2018BAPI_TRANSACTION_COMMITu2019, the PO gets created successfully. The data entered as input is:
POHEADER-COMP_CODE
POHEADER-DOC_TYPE
POHEADER-PMNTTRMS
POITEM-PO_ITEM
POITEM-QUANTITY
POITEM-TAX_CODE
POITEM-TAXJURCODE
POITEM-RFQ_NO
POITEM-RFQ_ITEM
POITEM-PREQ_NO
POITEM-PREQ_ITEM
POITEM-PREQ_NAME
POSCHEDULE-PO_ITEM
POSCHEDULE-SCHED_LINE
POSCHEDULE-QUANTITY
POSCHEDULE-PREQ_NO
POSCHEDULE-PREQ_ITEM
Problem: I need to pass data to the BAPI through code, so I called the BAPI u2018BAPI_PO_CREATE1u2019 and u2018BAPI_TRANSACTION_COMMITu2019 in a test function module as well as report. I passed the same data as mentioned above i.e. while creating the PO by passing data to the BAPI directly.
But the BAPI returns an error BAPI header data still faulty, enter plant, Pur. Org., Pur. Grp., etc.
I tried by passing all the available data for the header and then for the items, but finally, I still get an error that the item is from a different order account and just cannot create a PO.
The Test FM code is as shown below:
DATA : PYMNT_TERMS TYPE YOAF_SEC_MASTER-TER_PYMNT.
DATA : ITEM_NO(4) .
DATA : CURRENCY TYPE LFM1-WAERS.
DATA : POHEAD TYPE BAPIMEPOHEADER.
DATA : POHEADX TYPE BAPIMEPOHEADERX.
DATA : EXP_HEAD TYPE BAPIMEPOHEADER.
DATA : POITEM TYPE TABLE OF BAPIMEPOITEM WITH HEADER LINE.
DATA : POITEMX TYPE TABLE OF BAPIMEPOITEMX WITH HEADER LINE.
DATA : POSCHED TYPE TABLE OF BAPIMEPOSCHEDULE WITH HEADER LINE.
DATA : POSCHEDX TYPE TABLE OF BAPIMEPOSCHEDULX WITH HEADER LINE.
DATA : EX_PO_NUMBER TYPE BAPIMEPOHEADER-PO_NUMBER.
CONSTANTS : C_X VALUE 'X'.
POHEAD-COMP_CODE = 'P110'.
POHEAD-DOC_TYPE = DOC_TYPE.
POHEAD-PMNTTRMS = 'P10'.
POHEADX-COMP_CODE = C_X.
POHEADX-DOC_TYPE = C_X.
POHEADX-PMNTTRMS = C_X.
POITEM-PO_ITEM = '00001'.
POITEM-QUANTITY = '1.000'.
POITEM-TAX_CODE = 'D2'.
POITEM-TAXJURCODE = 'MH01'.
POITEM-RFQ_NO = '2300009491'.
POITEM-RFQ_ITEM = '00001'.
POITEM-PREQ_NO = '200003583'.
POITEM-PREQ_ITEM = '00001'.
POITEM-PREQ_NAME = 'SACHIN'.
APPEND POITEM.
POITEMX-PO_ITEM = '00001'.
POITEMX-PO_ITEMX = C_X.
POITEMX-QUANTITY = C_X .
POITEMX-TAX_CODE = C_X .
POITEMX-TAXJURCODE = C_X .
POITEM-RFQ_NO = C_X.
POITEM-RFQ_ITEM = C_X.
POITEM-PREQ_NO = C_X.
POITEM-PREQ_ITEM = C_X.
POITEMX-PREQ_NAME = C_X.
APPEND POITEMX.
POSCHED-PO_ITEM = '00001'.
POSCHED-SCHED_LINE = '0001'.
POSCHED-QUANTITY = '1.000'.
POSCHED-PREQ_NO = '1200003583'.
POSCHED-PREQ_ITEM = '00001'.
APPEND POSCHED.
POSCHEDX-PO_ITEM = '1'.
POSCHEDX-SCHED_LINE = '0001'.
POSCHEDX-PO_ITEMX = C_X.
POSCHEDX-SCHED_LINEX = C_X.
POSCHEDX-QUANTITY = C_X.
POSCHEDX-PREQ_NO = C_X.
POSCHEDX-PREQ_ITEM = C_X.
APPEND POSCHEDX.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = POHEAD
POHEADERX = POHEADX
IMPORTING
EXPPURCHASEORDER = EX_PO_NUMBER
EXPHEADER = EXP_HEAD
EXPPOEXPIMPHEADER =
TABLES
RETURN = RETURN_ERROR
POITEM = POITEM
POITEMX = POITEMX
POADDRDELIVERY =
POSCHEDULE = POSCHED
POSCHEDULEX = POSCHEDX
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = RETURN_ERROR.Hi,
As mentioned that this error was one of the wierdest SAP issues I have faced, it was due to the silliest copy paste errors on my behalf. I completely overlooked the POITEMX naming.
For 4 values of RFQ_NO, RFQ_ITEM, PREQ_NO, PREQ_ITEM, I didnt have the 'X' for POITEMX and kept on looking for errors for days.
BAPI_PO_CREATE1 works with min. possible inputs successfully.
Thanks to all! -
Error while creating a Service PO using BAPI_PO_CREATE1
Hi,
Im facing Error as "In case of account assignment, please enter acc. assignment data for item" while creating Service PO using BAPI_PO_CREATE1.
Header Data
w_poheader-comp_code = w_src-bukrs. "Company Code
w_poheader-doc_type = w_src-bsart. "Document type
w_poheader-delete_ind = w_src-vrtkz. "Deletion Indicator
CLEAR: lv_date.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = w_src-aedat
IMPORTING
date_internal = lv_date
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
w_poheader-creat_date = lv_date. "Creation Date
w_poheader-created_by = sy-uname. "Creator Name
w_poheader-vendor = w_src-lifnr. "Vendor
w_poheader-pmnttrms = w_src-zterm. "Payment Terms
w_poheader-purch_org = w_src-ekorg. "Purchase Organization
w_poheader-pur_group = w_src-ekgrp. "Purchase Group
w_poheader-ref_1 = w_src-ihrez. "OLD PO
w_poheaderx-comp_code = 'X'. "Company Code
w_poheaderx-doc_type = 'X'. "Document type
w_poheaderx-delete_ind = 'X'. "Deletion Indicator
w_poheaderx-creat_date = 'X'. "Creation Date
w_poheaderx-created_by = 'X'.
w_poheaderx-vendor = 'X'.
w_poheaderx-pmnttrms = 'X'. "Payment Terms
w_poheaderx-purch_org = 'X'. "Purchase Organization
w_poheaderx-pur_group = 'X'. "Purchase Group
w_poheaderx-ref_1 = 'X'.
Item Data
w_poitem-po_item = w_src-ebelp.
IF NOT w_src-elikz IS INITIAL.
w_poitem-delete_ind = w_src-elikz.
ENDIF.
IF NOT w_src-txz01 IS INITIAL.
w_poitem-short_text = w_src-txz01.
ENDIF.
IF NOT w_src-werks IS INITIAL.
w_poitem-plant = w_src-werks.
ENDIF.
Material group
IF NOT w_src-matkl IS INITIAL.
w_poitem-matl_group = w_src-matkl.
ENDIF.
Open or Partial Qty
IF w_src-opqty IS NOT INITIAL.
w_poitem-quantity = w_src-opqty.
ELSEIF NOT w_src-paqty IS INITIAL.
w_poitem-quantity = w_src-paqty.
ENDIF.
IF NOT w_src-meins IS INITIAL.
w_poitem-po_unit = w_src-meins. "Base Unit of Measure
ENDIF.
IF NOT w_src-netpr IS INITIAL.
w_poitem-net_price = w_src-netpr. "Net Price
ENDIF.
IF NOT w_src-mwskz IS INITIAL.
w_poitem-tax_code = w_src-mwskz.
ENDIF.
IF NOT w_src-pstyp IS INITIAL.
w_poitem-item_cat = w_src-pstyp.
ENDIF.
IF NOT w_src-knttp IS INITIAL.
w_poitem-acctasscat = w_src-knttp.
ENDIF.
IF NOT w_src-vrtkz IS INITIAL.
w_poitem-distrib = w_src-vrtkz.
ENDIF.
Package No
IF NOT w_src-packno IS INITIAL.
w_poitem-pckg_no = w_src-packno. "Package no
ENDIF.
IF w_poitem-delete_ind IS INITIAL AND
w_poitem-short_text IS INITIAL AND
w_poitem-plant IS INITIAL AND
w_poitem-matl_group IS INITIAL AND
w_poitem-quantity IS INITIAL AND
w_poitem-po_unit IS INITIAL AND
w_poitem-net_price IS INITIAL AND
w_poitem-tax_code IS INITIAL.
CLEAR lv_item.
ELSE.
APPEND w_poitem TO i_poitem.
CLEAR: w_poitem.
lv_item = 'X'.
ENDIF.
w_poitemx-po_item = w_src-ebelp.
w_poitemx-delete_ind = 'X'.
w_poitemx-short_text = 'X'.
w_poitemx-plant = 'X'.
w_poitemx-matl_group = 'X'.
w_poitemx-quantity = 'X'.
w_poitemx-po_unit = 'X'.
w_poitemx-net_price = 'X'.
w_poitemx-tax_code = 'X'.
w_poitemx-item_cat = 'X'.
w_poitemx-acctasscat = 'X'.
w_poitemx-distrib = 'X'.
IF NOT w_src-packno IS INITIAL.
w_poitemx-pckg_no = 'X'.
ENDIF.
IF lv_item = 'X'.
APPEND w_poitemx TO i_poitemx.
CLEAR: w_poitemx,
lv_item.
ENDIF.
PO Deliery Address
w_poaddrdelivery-po_item = w_src-ebelp.
IF NOT w_src-adrn2 IS INITIAL.
w_poaddrdelivery-addr_no = w_src-adrn2.
APPEND w_poaddrdelivery TO i_poaddrdelivery.
CLEAR w_poaddrdelivery.
ENDIF.
POschedule
w_poschedule-po_item = w_src-ebelp.
CLEAR: lv_date.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = w_src-eindt
IMPORTING
date_internal = lv_date
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
IF NOT lv_date IS INITIAL.
w_poschedule-del_datcat_ext = 'D'. "Delivery Date in Day Format
w_poschedule-delivery_date = lv_date.
w_poschedule-quantity = w_src-menge.
APPEND w_poschedule TO i_poschedule.
CLEAR w_poschedule.
lv_schd = 'X'.
ENDIF.
w_poschedulex-po_item = w_src-ebelp.
w_poschedulex-del_datcat_ext = 'X'.
w_poschedulex-delivery_date = 'X'.
w_poschedulex-quantity = 'X'.
IF lv_schd = 'X'.
APPEND w_poschedulex TO i_poschedulex.
CLEAR : w_poschedulex,
lv_schd.
ENDIF.
PO Account Assignment
w_poaccount-po_item = w_src-ebelp.
w_poaccount-serial_no = w_src-zekkn.
Distribution Indicator is 1
IF w_src-vrtkz EQ '1'.
w_poaccount-distr_perc = w_src-vproz.
IF NOT w_src-menge IS INITIAL.
CLEAR lv_menge.
lv_menge = w_src-menge.
ENDIF.
lv_acct_qty = lv_menge * w_src-vproz / 100.
Get Round value of Quanity
frac = FRAC( lv_acct_qty ).
IF frac EQ 0.
lv_acct_qty = FLOOR( lv_acct_qty ).
ELSE.
lv_acct_qty = CEIL( lv_acct_qty ).
ENDIF.
w_poaccount-quantity = lv_acct_qty.
ELSEIF w_src-vrtkz IS INITIAL.
w_poaccount-quantity = w_src-menge.
ENDIF.
w_poaccount-gl_account = w_src-saknr.
w_poaccount-costcenter = w_src-kostl.
w_poaccount-asset_no = w_src-anln1.
w_poaccount-wbs_element = w_src-wbs.
w_poaccount-network = w_src-nplnr.
w_poaccount-tax_code = w_src-mwskz.
w_poaccount-activity = w_src-vornr.
APPEND w_poaccount TO i_poaccount.
CLEAR w_poaccount.
w_poaccountx-po_item = w_src-ebelp.
w_poaccountx-serial_no = w_src-zekkn.
IF w_src-vrtkz EQ '1'.
w_poaccountx-distr_perc = 'X'.
ENDIF.
w_poaccountx-quantity = 'X'.
w_poaccountx-gl_account = 'X'.
w_poaccountx-costcenter = 'X'.
w_poaccountx-wbs_element = 'X'.
w_poaccountx-network = 'X'.
w_poaccountx-tax_code = 'X'.
w_poaccountx-activity = 'X'.
APPEND w_poaccountx TO i_poaccountx.
CLEAR w_poaccountx.
PO Services
w_poservices-pckg_no = w_src-packno. "Package no
w_poservices-line_no = w_src-srv_line_no. "Line item
w_poservices-ext_line = w_src-extrow. "External line
w_poservices-outl_level = 0.
w_poservices-outl_ind = 'X'.
w_poservices-subpckg_no = w_src-sub_packno. "Sub package no
w_poservices-quantity = w_src-srqty. "Service Quantity
w_poservices-base_uom = w_src-srmeins. "Service Basic unit of Measure
w_poservices-price_unit = '1'.
w_poservices-from_line = '1'.
w_poservices-gr_price = w_src-brtwr. "GR Price
w_poservices-short_text = w_src-sh_text1. "Service Short Text
w_poservices-matl_group = w_src-matkl. "Material Group
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
PO Service Access values
w_posrvacc-pckg_no = w_src-packno. "Package no
w_posrvacc-line_no = w_src-srv_line_no. "Line item
w_posrvacc-serno_line = w_src-zekkn. "'01'..
IF w_src-vproz IS INITIAL.
w_posrvacc-percentage = '100.0'.
ENDIF.
w_posrvacc-serial_no = w_src-zekkn. "'01'.
w_posrvacc-quantity = w_src-srqty. "Service Quantity
w_posrvacc-net_value = w_src-srqty. "Net value
APPEND w_posrvacc TO i_posrvacc.
CLEAR w_posrvacc.
ENDIF.
***Create a NEW PO
AT END OF ihrez.
Call BAPI
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = w_poheader
poheaderx = w_poheaderx
IMPORTING
exppurchaseorder = gv_ebeln
TABLES
return = i_return
poitem = i_poitem[]
poitemx = i_poitemx[]
poaddrdelivery = i_poaddrdelivery[]
poschedule = i_poschedule[]
poschedulex = i_poschedulex[]
poaccount = i_poaccount[]
poaccountx = i_poaccountx[]
poservices = i_poservices[]
posrvaccessvalues = i_posrvacc[]
extensionin = i_extensionin[].
Commit the Transaction
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
Regards,
Deepthi.1. If we get error as "In case of account assignment, please enter acc. assignment data for item" than First cehck whetaher u have authorization to Tcode ME23n or not. In my case, I din't had authorization to Me23n tcode.
2. If we get Error as "Please Mainatain Services or Limits". Please create a Service PO in the following Order.
*& Internal Table Declaration
DATA : i_intern TYPE STANDARD TABLE OF alsmex_tabline WITH HEADER LINE,
i_poitem TYPE STANDARD TABLE OF bapimepoitem,
i_poitemx TYPE STANDARD TABLE OF bapimepoitemx,
i_poaddrdelivery TYPE STANDARD TABLE OF bapimepoaddrdelivery,
i_poschedule TYPE STANDARD TABLE OF bapimeposchedule,
i_poschedulex TYPE STANDARD TABLE OF bapimeposchedulx,
i_poaccount TYPE STANDARD TABLE OF bapimepoaccount,
i_poaccountx TYPE STANDARD TABLE OF bapimepoaccountx,
i_poservices TYPE STANDARD TABLE OF bapiesllc,
i_posrvacc TYPE STANDARD TABLE OF bapiesklc,
i_extensionin TYPE STANDARD TABLE OF bapiparex,
i_return TYPE STANDARD TABLE OF bapiret2.
*& Work Area Declaration
DATA:
w_poheader TYPE bapimepoheader,
w_poheaderx TYPE bapimepoheaderx,
w_poitem TYPE bapimepoitem,
w_poitemx TYPE bapimepoitemx,
w_poaddrdelivery TYPE bapimepoaddrdelivery,
w_poschedule TYPE bapimeposchedule,
w_poschedulex TYPE bapimeposchedulx,
w_poaccount TYPE bapimepoaccount,
w_poaccountx TYPE bapimepoaccountx,
w_poservices TYPE bapiesllc,
w_posrvacc TYPE bapiesklc,
w_extensionin TYPE bapiparex,
w_return TYPE bapiret2.
START-OF-SELECTION.
Header Data
w_poheader-comp_code = '5791'. "Company Code
w_poheader-doc_type = 'Z0CM'. "Document type
w_poheader-creat_date = sy-datum. "lv_date. "Creation Date
w_poheader-created_by = sy-uname. "Creator Name
w_poheader-vendor = '0005012343'. "Vendor
w_poheader-pmnttrms = 'Z004'. "Payment Terms
w_poheader-purch_org = 'P000'. "Purchase Organization
w_poheader-pur_group = '001'. "Purchase Group
w_poheader-ref_1 = '004500007671'. "OLD PO
w_poheaderx-comp_code = 'X'. "Company Code
w_poheaderx-doc_type = 'X'. "Document type
w_poheaderx-creat_date = 'X'. "Creation Date
w_poheaderx-created_by = 'X'.
w_poheaderx-vendor = 'X'.
w_poheaderx-pmnttrms = 'X'. "Payment Terms
w_poheaderx-purch_org = 'X'. "Purchase Organization
w_poheaderx-pur_group = 'X'. "Purchase Group
w_poheaderx-ref_1 = 'X'.
Item Data
w_poitem-po_item = '000010'.
w_poitem-short_text = 'Z0CM - Default Appr. Test '.
w_poitem-plant = '5368'.
Trackign no
w_poitem-trackingno = ''.
Material group
w_poitem-matl_group = '119'.
w_poitem-po_unit = 'EA'. "Base Unit of Measure
w_poitem-net_price = '17500.00'. "Net Price
w_poitem-tax_code = 'I0'.
w_poitem-item_cat = '9'.
w_poitem-acctasscat = 'K'.
w_poitem-distrib = space.
Package must be given in item to create Service PO
w_poitem-pckg_no = 0000000001.
APPEND w_poitem TO i_poitem.
CLEAR: w_poitem.
w_poitemx-po_item = '000010'.
w_poitemx-delete_ind = 'X'.
w_poitemx-short_text = 'X'.
w_poitemx-plant = 'X'.
w_poitemx-trackingno = 'X'.
w_poitemx-matl_group = 'X'.
w_poitemx-quantity = 'X'.
w_poitemx-po_unit = 'X'.
w_poitemx-net_price = 'X'.
w_poitemx-tax_code = 'X'.
w_poitemx-item_cat = 'X'.
w_poitemx-acctasscat = 'X'.
w_poitemx-distrib = 'X'.
w_poitemx-pckg_no = 'X'.
APPEND w_poitemx TO i_poitemx.
CLEAR: w_poitemx.
PO Deliery Address
w_poaddrdelivery-po_item = '000010'.
w_poaddrdelivery-addr_no = '0000061208'.
APPEND w_poaddrdelivery TO i_poaddrdelivery.
CLEAR w_poaddrdelivery.
POschedule
w_poschedule-po_item = '000010'..
DATA : LV_DATE TYPE SY-DATUM,
lv_schd.
CLEAR: lv_date.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = '12/2/2009'
IMPORTING
date_internal = lv_date
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
IF NOT lv_date IS INITIAL.
w_poschedule-del_datcat_ext = 'D'. "Delivery Date in Day Format
w_poschedule-delivery_date = lv_date.
w_poschedule-quantity = '1.000'.
APPEND w_poschedule TO i_poschedule.
CLEAR w_poschedule.
lv_schd = 'X'.
ENDIF.
w_poschedulex-po_item = '000010'.
w_poschedulex-del_datcat_ext = 'X'.
w_poschedulex-delivery_date = 'X'.
w_poschedulex-quantity = 'X'.
IF lv_schd = 'X'.
APPEND w_poschedulex TO i_poschedulex.
CLEAR : w_poschedulex,
lv_schd.
ENDIF.
PO Account Assignment
w_poaccount-po_item = '000010'.
w_poaccount-serial_no = '01'.
w_poaccount-distr_perc = ''.
w_poaccount-quantity = '1.000'.
w_poaccount-gl_account = '0000603064'.
w_poaccount-costcenter = '0053680100'.
w_poaccount-asset_no = ''.
w_poaccount-wbs_element = ''.
w_poaccount-network = ''.
w_poaccount-tax_code = 'I0'.
w_poaccount-activity = ''.
APPEND w_poaccount TO i_poaccount.
CLEAR w_poaccount.
w_poaccountx-po_item = '000010'.
w_poaccountx-serial_no = '01'.
w_poaccountx-distr_perc = 'X'.
w_poaccountx-quantity = 'X'.
w_poaccountx-gl_account = 'X'.
w_poaccountx-costcenter = 'X'.
w_poaccountx-wbs_element = 'X'.
w_poaccountx-network = 'X'.
w_poaccountx-tax_code = 'X'.
w_poaccountx-activity = 'X'.
w_poaccountx-cmmt_item = 'X'.
APPEND w_poaccountx TO i_poaccountx.
CLEAR w_poaccountx.
Extension for ZZSub
w_extensionin-structure = 'BAPI_TE_MEPOACCOUNTING'.
w_extensionin-valuepart1+0(5) = '00010'..
w_extensionin-valuepart1+5(2) = '01'.
w_extensionin-valuepart1+28(5) = ''.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
w_extensionin-structure = 'BAPI_TE_MEPOACCOUNTINGX'.
w_extensionin-valuepart1+0(5) = '00010'.
w_extensionin-valuepart1+5(2) = '01'.
w_extensionin-valuepart1+11(1) = 'X'.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
Extension to add Expense Type only
w_extensionin-structure = 'BAPI_TE_MEPOHEADER'.
w_extensionin-valuepart1+10(4) = '0131'.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
w_extensionin-structure = 'BAPI_TE_MEPOHEADERX'.
w_extensionin-valuepart1+10(4) = 'X'.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
EXPORT i_extensionin[] TO MEMORY ID 'SUB'.
PO Services
PO Services( One Line Iem)
Assign the dummy no as Pacakage no
w_poservices-pckg_no = 0000000001. "(assign package no as a dummy number)
w_poservices-line_no = 0000000001. "Line item
w_poservices-outl_ind = 'X'.
Assign Dummy no as sub package no
w_poservices-subpckg_no = 0000000003. "(Dummy No.) "Sub package no
w_poservices-from_line = '1'.
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
PO Services(Second Line Item )
Assign the same sub package dummy no which is mentioned above
w_poservices-pckg_no = 0000000003. "(Dummy No.) "Sub package no
w_poservices-line_no = 0000000002.
w_poservices-ext_line = '0000000010'. "External line
w_poservices-quantity = '17500.0'. "Service Quantity
w_poservices-base_uom = 'EA'. "Service Basic unit of Measure
w_poservices-price_unit = '1'.
w_poservices-gr_price = '1'. "GR Price
w_poservices-short_text = 'Z0CM - Default Appr. T'. "Service Short Text
w_poservices-matl_group = '119'. "w_src-matkl. "Material Group
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
PO Service Access values
w_posrvacc-pckg_no = 0000000003. "w_src-sub_packno. "Sub package no
w_posrvacc-line_no = 0000000002. "w_src-srv_line_no. "Line item
w_posrvacc-serno_line = '01'.
w_posrvacc-percentage = '100.0'.
w_posrvacc-serial_no = '01'.
w_posrvacc-quantity = '17500.0'. "w_src-srqty. "Service Quantity
APPEND w_posrvacc TO i_posrvacc.
CLEAR w_posrvacc.
DATA : gv_ebeln TYPE ebeln.
Call BAPI
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = w_poheader
poheaderx = w_poheaderx
IMPORTING
exppurchaseorder = gv_ebeln
TABLES
return = i_return
poitem = i_poitem[]
poitemx = i_poitemx[]
poaddrdelivery = i_poaddrdelivery[]
poschedule = i_poschedule[]
poschedulex = i_poschedulex[]
poaccount = i_poaccount[]
poaccountx = i_poaccountx[]
poservices = i_poservices[]
posrvaccessvalues = i_posrvacc[]
extensionin = i_extensionin[].
Commit the Transaction
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
WRITE:/5 gv_ebeln COLOR 5.
SKIP 2.
DATA : lv_msg TYPE string.
LOOP AT i_return INTO w_return WHERE type = 'E'.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = w_return-id
lang = 'EN'
no = w_return-number
v1 = w_return-message_v1
v2 = w_return-message_v2
v3 = w_return-message_v3
v4 = w_return-message_v4
IMPORTING
msg = lv_msg
EXCEPTIONS
not_found = 1
OTHERS = 2.
WRITE:/10 lv_msg.
ENDLOOP. -
Error in : Purchase order Creation using BAPI_PO_CREATE1
Hell guys,
I am trying to create a PO using a BAPI - BAPI_PO_CREATE1
I want the new PO to have all the characteristics of an existing PO. whose PO # is stored in wa_order_split_create-docnr and for the new PO, i want the quantity from wa_order_split_create-qty_acptd and the delivery data to be wa_order_split_create-dly_date. But this process and code below gives a short dump in the std FM - MEPO_DOC_ITEM_GET . It raises an exception of failure. I am trying to create many new PO's in the loop below. If there is just one row, sometimes, it creates the PO even with the exception failure ( which is pretty weird).
Am i making any mistake while filling the header or item or schedule lines for the BAPI_PO_CREATE1 ? Any tips or clues why I am getting a dump ?
DATA: i_insert,
i_create_order,
i_cycle TYPE cycle,
i_qty_acpt TYPE dzmeng,
i_dly_date TYPE vbak-vdatu,
i_item TYPE roijnomiio .
DATA: i_order TYPE symsgv,
i_return TYPE swd_return .
DATA: i_vbak TYPE vbak,
i_vbap TYPE vbap,
i_ekko TYPE ekko,
i_ekpo TYPE ekpo,
i_bsoh TYPE bapisdhd1,
i_bsohx TYPE bapisdhd1x,
i_bpoh TYPE bapimepoheader,
i_bpohx TYPE bapimepoheaderx,
i_vbeln TYPE vbeln_va,
i_posnr TYPE posnr_va,
i_contr TYPE vbeln_va,
i_conit TYPE posnr_va,
i_ebeln TYPE ebeln,
i_ebelp TYPE ebelp,
i_pargr TYPE pargr,
i_thead TYPE thead,
i_line TYPE tline,
i_note TYPE txw_note,
i_new_vbeln TYPE vbeln_va,
i_new_ebeln TYPE ebeln,
i_wa_bsoi TYPE bapisditm,
i_wa_bsoix TYPE bapisditmx,
i_wa_bsop TYPE bapiparnr,
i_wa_bsos TYPE bapischdl,
i_wa_bsosx TYPE bapischdlx,
i_wa_vbpa TYPE vbpa,
i_wa_vbkd TYPE vbkd,
i_wa_bpoi TYPE bapimepoitem,
i_wa_bpoix TYPE bapimepoitemx,
i_wa_bpos TYPE bapimeposchedule,
i_wa_bposx TYPE bapimeposchedulx,
i_wa_bpop TYPE bapiekkop,
i_wa_ekpa TYPE ekpa,
i_message TYPE char72,
i_bapiretn TYPE bapiret2,
i_bapiret2 TYPE TABLE OF bapiret2 INITIAL SIZE 1,
i_vbpa TYPE TABLE OF vbpa INITIAL SIZE 1,
i_vbkd TYPE TABLE OF vbkd INITIAL SIZE 1,
i_ekpa TYPE TABLE OF ekpa INITIAL SIZE 1,
i_bsoi TYPE TABLE OF bapisditm INITIAL SIZE 1,
i_bsoix TYPE TABLE OF bapisditmx INITIAL SIZE 1,
i_bsos TYPE TABLE OF bapischdl INITIAL SIZE 1,
i_bsosx TYPE TABLE OF bapischdlx INITIAL SIZE 1,
i_bsop TYPE TABLE OF bapiparnr INITIAL SIZE 1,
i_bpoi TYPE TABLE OF bapimepoitem INITIAL SIZE 1,
i_bpoix TYPE TABLE OF bapimepoitemx INITIAL SIZE 1,
i_bpos TYPE TABLE OF bapimeposchedule INITIAL SIZE 1,
i_bposx TYPE TABLE OF bapimeposchedulx INITIAL SIZE 1,
i_bpop TYPE TABLE OF bapiekkop INITIAL SIZE 1,
i_text_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_line_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_txw_note TYPE TABLE OF txw_note INITIAL SIZE 1,
i_oij_el_doc_mot TYPE oij_el_doc_mot .
CONSTANTS: c_char_c VALUE 'C',
c_char_e VALUE 'E',
c_char_p VALUE 'P',
c_char_g VALUE 'G',
c_char_i VALUE 'I',
c_char_s VALUE 'S',
c_char_x VALUE 'X',
c_zsw(3) VALUE 'ZSW',
c_nomit_stat(4) VALUE 'ZDNY' .
DATA : lv_nomtk_split TYPE oij_nomtk.
DATA : i_order_split_create TYPE TABLE OF zsws_order_split.
DATA : wa_order_split_create TYPE zsws_order_split.
LOOP AT i_order_split_create INTO wa_order_split_create.
IF NOT i_create_order IS INITIAL .
CLEAR: i_create_order .
MOVE: wa_order_split_create-docnr TO i_ebeln,
wa_order_split_create-docitm TO i_ebelp .
CALL FUNCTION 'ME_EKKO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
IMPORTING
po_ekko = i_ekko
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
ENDIF .
* Fill PO Header
i_bpoh-comp_code = i_ekko-bukrs .
i_bpoh-doc_type = i_ekko-bsart .
i_bpoh-vendor = i_ekko-lifnr .
i_bpoh-langu = i_ekko-spras .
i_bpoh-pmnttrms = i_ekko-zterm .
i_bpoh-purch_org = i_ekko-ekorg .
i_bpoh-pur_group = i_ekko-ekgrp .
i_bpoh-currency = i_ekko-waers .
i_bpoh-agreement = i_ekko-konnr .
i_bpoh-incoterms1 = i_ekko-inco1 .
i_bpoh-incoterms2 = i_ekko-inco2 .
* Fill PO update indicator 'X'
i_bpohx-comp_code = c_char_x .
i_bpohx-doc_type = c_char_x .
i_bpohx-vendor = c_char_x .
i_bpohx-langu = c_char_x .
i_bpohx-pmnttrms = c_char_x .
i_bpohx-purch_org = c_char_x .
i_bpohx-pur_group = c_char_x .
i_bpohx-currency = c_char_x .
i_bpohx-agreement = c_char_x .
i_bpohx-incoterms1 = c_char_x .
i_bpohx-incoterms2 = c_char_x .
CALL FUNCTION 'ME_EKPO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
pi_ebelp = i_ebelp
IMPORTING
po_ekpo = i_ekpo
EXCEPTIONS
no_records_found = 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 .
* Fill PO Item
i_wa_bpoi-po_item = i_ekpo-ebelp .
i_wa_bpoi-material = i_ekpo-matnr .
i_wa_bpoi-plant = i_ekpo-werks .
i_wa_bpoi-stge_loc = i_ekpo-lgort .
i_wa_bpoi-quantity = wa_order_split_create-qty_acptd .
i_wa_bpoi-po_unit = i_ekpo-meins .
i_wa_bpoi-tax_code = i_ekpo-mwskz .
i_wa_bpoi-val_type = i_ekpo-bwtar .
i_wa_bpoi-item_cat = i_ekpo-pstyp .
i_wa_bpoi-acctasscat = i_ekpo-knttp .
i_wa_bpoi-agreement = i_ekpo-konnr .
i_wa_bpoi-agmt_item = i_ekpo-ktpnr .
APPEND i_wa_bpoi TO i_bpoi .
* Fill PO Item update indicator 'X'
i_wa_bpoix-po_item = i_ekpo-ebelp .
i_wa_bpoix-po_itemx = c_char_x .
i_wa_bpoix-material = c_char_x .
i_wa_bpoix-plant = c_char_x .
i_wa_bpoix-stge_loc = c_char_x .
i_wa_bpoix-quantity = c_char_x .
i_wa_bpoix-po_unit = c_char_x .
i_wa_bpoix-tax_code = c_char_x .
i_wa_bpoix-val_type = c_char_x .
i_wa_bpoix-item_cat = c_char_x .
i_wa_bpoix-acctasscat = c_char_x .
i_wa_bpoix-agreement = c_char_x .
i_wa_bpoix-agmt_item = c_char_x .
APPEND i_wa_bpoix TO i_bpoix .
* Fill PO Item Schedule
i_wa_bpos-po_item = i_ekpo-ebelp .
i_wa_bpos-sched_line = '0001' .
i_wa_bpos-delivery_date = wa_order_split_create-dly_date .
i_wa_bpos-quantity = wa_order_split_create-qty_acptd .
APPEND i_wa_bpos TO i_bpos .
* Fill PO Item schedule update indicator 'X'
i_wa_bposx-po_item = i_ekpo-ebelp .
i_wa_bposx-sched_line = '0001' .
i_wa_bposx-delivery_date = c_char_x .
i_wa_bposx-quantity = c_char_x .
APPEND i_wa_bposx TO i_bposx .
CLEAR: i_pargr .
SELECT SINGLE pargr
INTO i_pargr
FROM t161
WHERE bstyp = i_ekko-bstyp
AND bsart = i_ekko-bsart .
CLEAR i_ekpa[].
CALL FUNCTION 'MM_READ_PARTNERS'
EXPORTING
application = c_char_p
ebeln = i_ebeln
bstyp = i_ekko-bstyp
pargr = i_pargr
TABLES
x_ekpa = i_ekpa[].
LOOP AT i_ekpa INTO i_wa_ekpa .
i_wa_bpop-partnerdesc = i_wa_ekpa-parvw .
i_wa_bpop-langu = sy-langu .
IF NOT i_wa_ekpa-lifn2 IS INITIAL .
i_wa_bpop-buspartno = i_wa_ekpa-lifn2 .
ELSE .
i_wa_bpop-buspartno = i_wa_ekpa-parnr .
ENDIF .
APPEND i_wa_bpop TO i_bpop .
CLEAR: i_wa_ekpa, i_wa_bpop .
ENDLOOP .
CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = i_bpoh
poheaderx = i_bpohx
IMPORTING
exppurchaseorder = i_new_ebeln
TABLES
return = i_bapiret2
poitem = i_bpoi[]
poitemx = i_bpoix[]
poschedule = i_bpos[]
poschedulex = i_bposx[].
i_order = i_new_ebeln .
SHIFT i_order LEFT DELETING LEADING '0' .
i_return-errortype = c_char_i .
i_return-workarea = c_zsw .
i_return-message = '064' .
i_return-variable1 = i_order .
loop at i_bapiret2 into i_bapiretn where type ca 'EAX' .
append i_bapiretn to t_bapi_return .
endloop .
if t_bapi_return[] is initial .
i_create_order = c_char_x .
CALL FUNCTION 'SWD_POPUP_MESSAGE_SEND'
EXPORTING
act_return = i_return. "Popup with new PO no.
ENDCASE . " Docind
ENDIF .
ENDLOOP.Hi Shareen,
I think in the following parts of the code,
CALL FUNCTION 'MM_READ_PARTNERS'
EXPORTING
application = c_char_p
ebeln = i_ebeln
bstyp = i_ekko-bstyp
pargr = i_pargr
TABLES
x_ekpa = i_ekpa[].
Error in : Purchase order Creation using BAPI_PO_CREATE1
Posted: Mar 20, 2006 7:39 PM Reply E-mail this post
Hell guys,
I am trying to create a PO using a BAPI - BAPI_PO_CREATE1
I want the new PO to have all the characteristics of an existing PO. whose PO # is stored in wa_order_split_create-docnr and for the new PO, i want the quantity from wa_order_split_create-qty_acptd and the delivery data to be wa_order_split_create-dly_date. But this process and code below gives a short dump in the std FM - MEPO_DOC_ITEM_GET . It raises an exception of failure. I am trying to create many new PO's in the loop below. If there is just one row, sometimes, it creates the PO even with the exception failure ( which is pretty weird).
Am i making any mistake while filling the header or item or schedule lines for the BAPI_PO_CREATE1 ? Any tips or clues why I am getting a dump ?
DATA: i_insert,
i_create_order,
i_cycle TYPE cycle,
i_qty_acpt TYPE dzmeng,
i_dly_date TYPE vbak-vdatu,
i_item TYPE roijnomiio .
DATA: i_order TYPE symsgv,
i_return TYPE swd_return .
DATA: i_vbak TYPE vbak,
i_vbap TYPE vbap,
i_ekko TYPE ekko,
i_ekpo TYPE ekpo,
i_bsoh TYPE bapisdhd1,
i_bsohx TYPE bapisdhd1x,
i_bpoh TYPE bapimepoheader,
i_bpohx TYPE bapimepoheaderx,
i_vbeln TYPE vbeln_va,
i_posnr TYPE posnr_va,
i_contr TYPE vbeln_va,
i_conit TYPE posnr_va,
i_ebeln TYPE ebeln,
i_ebelp TYPE ebelp,
i_pargr TYPE pargr,
i_thead TYPE thead,
i_line TYPE tline,
i_note TYPE txw_note,
i_new_vbeln TYPE vbeln_va,
i_new_ebeln TYPE ebeln,
i_wa_bsoi TYPE bapisditm,
i_wa_bsoix TYPE bapisditmx,
i_wa_bsop TYPE bapiparnr,
i_wa_bsos TYPE bapischdl,
i_wa_bsosx TYPE bapischdlx,
i_wa_vbpa TYPE vbpa,
i_wa_vbkd TYPE vbkd,
i_wa_bpoi TYPE bapimepoitem,
i_wa_bpoix TYPE bapimepoitemx,
i_wa_bpos TYPE bapimeposchedule,
i_wa_bposx TYPE bapimeposchedulx,
i_wa_bpop TYPE bapiekkop,
i_wa_ekpa TYPE ekpa,
i_message TYPE char72,
i_bapiretn TYPE bapiret2,
i_bapiret2 TYPE TABLE OF bapiret2 INITIAL SIZE 1,
i_vbpa TYPE TABLE OF vbpa INITIAL SIZE 1,
i_vbkd TYPE TABLE OF vbkd INITIAL SIZE 1,
i_ekpa TYPE TABLE OF ekpa INITIAL SIZE 1,
i_bsoi TYPE TABLE OF bapisditm INITIAL SIZE 1,
i_bsoix TYPE TABLE OF bapisditmx INITIAL SIZE 1,
i_bsos TYPE TABLE OF bapischdl INITIAL SIZE 1,
i_bsosx TYPE TABLE OF bapischdlx INITIAL SIZE 1,
i_bsop TYPE TABLE OF bapiparnr INITIAL SIZE 1,
i_bpoi TYPE TABLE OF bapimepoitem INITIAL SIZE 1,
i_bpoix TYPE TABLE OF bapimepoitemx INITIAL SIZE 1,
i_bpos TYPE TABLE OF bapimeposchedule INITIAL SIZE 1,
i_bposx TYPE TABLE OF bapimeposchedulx INITIAL SIZE 1,
i_bpop TYPE TABLE OF bapiekkop INITIAL SIZE 1,
i_text_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_line_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_txw_note TYPE TABLE OF txw_note INITIAL SIZE 1,
i_oij_el_doc_mot TYPE oij_el_doc_mot .
CONSTANTS: c_char_c VALUE 'C',
c_char_e VALUE 'E',
c_char_p VALUE 'P',
c_char_g VALUE 'G',
c_char_i VALUE 'I',
c_char_s VALUE 'S',
c_char_x VALUE 'X',
c_zsw(3) VALUE 'ZSW',
c_nomit_stat(4) VALUE 'ZDNY' .
DATA : lv_nomtk_split TYPE oij_nomtk.
DATA : i_order_split_create TYPE TABLE OF zsws_order_split.
DATA : wa_order_split_create TYPE zsws_order_split.
LOOP AT i_order_split_create INTO wa_order_split_create.
IF NOT i_create_order IS INITIAL .
CLEAR: i_create_order .
MOVE: wa_order_split_create-docnr TO i_ebeln,
wa_order_split_create-docitm TO i_ebelp .
CALL FUNCTION 'ME_EKKO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
IMPORTING
po_ekko = i_ekko
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
ENDIF .
Fill PO Header
i_bpoh-comp_code = i_ekko-bukrs .
i_bpoh-doc_type = i_ekko-bsart .
i_bpoh-vendor = i_ekko-lifnr .
i_bpoh-langu = i_ekko-spras .
i_bpoh-pmnttrms = i_ekko-zterm .
i_bpoh-purch_org = i_ekko-ekorg .
i_bpoh-pur_group = i_ekko-ekgrp .
i_bpoh-currency = i_ekko-waers .
i_bpoh-agreement = i_ekko-konnr .
i_bpoh-incoterms1 = i_ekko-inco1 .
i_bpoh-incoterms2 = i_ekko-inco2 .
Fill PO update indicator 'X'
i_bpohx-comp_code = c_char_x .
i_bpohx-doc_type = c_char_x .
i_bpohx-vendor = c_char_x .
i_bpohx-langu = c_char_x .
i_bpohx-pmnttrms = c_char_x .
i_bpohx-purch_org = c_char_x .
i_bpohx-pur_group = c_char_x .
i_bpohx-currency = c_char_x .
i_bpohx-agreement = c_char_x .
i_bpohx-incoterms1 = c_char_x .
i_bpohx-incoterms2 = c_char_x .
CALL FUNCTION 'ME_EKPO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
pi_ebelp = i_ebelp
IMPORTING
po_ekpo = i_ekpo
EXCEPTIONS
no_records_found = 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 .
Fill PO Item
i_wa_bpoi-po_item = i_ekpo-ebelp .
i_wa_bpoi-material = i_ekpo-matnr .
i_wa_bpoi-plant = i_ekpo-werks .
i_wa_bpoi-stge_loc = i_ekpo-lgort .
i_wa_bpoi-quantity = wa_order_split_create-qty_acptd .
i_wa_bpoi-po_unit = i_ekpo-meins .
i_wa_bpoi-tax_code = i_ekpo-mwskz .
i_wa_bpoi-val_type = i_ekpo-bwtar .
i_wa_bpoi-item_cat = i_ekpo-pstyp .
i_wa_bpoi-acctasscat = i_ekpo-knttp .
i_wa_bpoi-agreement = i_ekpo-konnr .
i_wa_bpoi-agmt_item = i_ekpo-ktpnr .
APPEND i_wa_bpoi TO i_bpoi .
Fill PO Item update indicator 'X'
i_wa_bpoix-po_item = i_ekpo-ebelp .
i_wa_bpoix-po_itemx = c_char_x .
i_wa_bpoix-material = c_char_x .
i_wa_bpoix-plant = c_char_x .
i_wa_bpoix-stge_loc = c_char_x .
i_wa_bpoix-quantity = c_char_x .
i_wa_bpoix-po_unit = c_char_x .
i_wa_bpoix-tax_code = c_char_x .
i_wa_bpoix-val_type = c_char_x .
i_wa_bpoix-item_cat = c_char_x .
i_wa_bpoix-acctasscat = c_char_x .
i_wa_bpoix-agreement = c_char_x .
i_wa_bpoix-agmt_item = c_char_x .
APPEND i_wa_bpoix TO i_bpoix .
Fill PO Item Schedule
i_wa_bpos-po_item = i_ekpo-ebelp .
i_wa_bpos-sched_line = '0001' .
i_wa_bpos-delivery_date = wa_order_split_create-dly_date .
i_wa_bpos-quantity = wa_order_split_create-qty_acptd .
APPEND i_wa_bpos TO i_bpos .
Fill PO Item schedule update indicator 'X'
i_wa_bposx-po_item = i_ekpo-ebelp .
i_wa_bposx-sched_line = '0001' .
i_wa_bposx-delivery_date = c_char_x .
i_wa_bposx-quantity = c_char_x .
APPEND i_wa_bposx TO i_bposx .
CLEAR: i_pargr .
SELECT SINGLE pargr
INTO i_pargr
FROM t161
WHERE bstyp = i_ekko-bstyp
AND bsart = i_ekko-bsart .
CLEAR i_ekpa[].
CALL FUNCTION 'MM_READ_PARTNERS'
EXPORTING
application = c_char_p
ebeln = i_ebeln
bstyp = i_ekko-bstyp
pargr = i_pargr
TABLES
x_ekpa = <b>i_ekpa[].</b>
LOOP AT i_ekpa INTO i_wa_ekpa .
i_wa_bpop-partnerdesc = i_wa_ekpa-parvw .
i_wa_bpop-langu = sy-langu .
IF NOT i_wa_ekpa-lifn2 IS INITIAL .
i_wa_bpop-buspartno = i_wa_ekpa-lifn2 .
ELSE .
i_wa_bpop-buspartno = i_wa_ekpa-parnr .
ENDIF .
APPEND i_wa_bpop TO i_bpop .
CLEAR: i_wa_ekpa, i_wa_bpop .
ENDLOOP .
CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = i_bpoh
poheaderx = i_bpohx
IMPORTING
exppurchaseorder = i_new_ebeln
TABLES
return = i_bapiret2
<b> poitem = i_bpoi[]
poitemx = i_bpoix[]
poschedule = i_bpos[]
poschedulex = i_bposx[].</b>
it should be only i_bpoi, i_bpoix, i_bpos, i_bposx but not i_bpoi[], i_bpoix[], i_bpos[], i_bposx[].
CHange the code as follows:
DATA: i_insert,
i_create_order,
i_cycle TYPE cycle,
i_qty_acpt TYPE dzmeng,
i_dly_date TYPE vbak-vdatu,
i_item TYPE roijnomiio .
DATA: i_order TYPE symsgv,
i_return TYPE swd_return .
DATA: i_vbak TYPE vbak,
i_vbap TYPE vbap,
i_ekko TYPE ekko,
i_ekpo TYPE ekpo,
i_bsoh TYPE bapisdhd1,
i_bsohx TYPE bapisdhd1x,
i_bpoh TYPE bapimepoheader,
i_bpohx TYPE bapimepoheaderx,
i_vbeln TYPE vbeln_va,
i_posnr TYPE posnr_va,
i_contr TYPE vbeln_va,
i_conit TYPE posnr_va,
i_ebeln TYPE ebeln,
i_ebelp TYPE ebelp,
i_pargr TYPE pargr,
i_thead TYPE thead,
i_line TYPE tline,
i_note TYPE txw_note,
i_new_vbeln TYPE vbeln_va,
i_new_ebeln TYPE ebeln,
i_wa_bsoi TYPE bapisditm,
i_wa_bsoix TYPE bapisditmx,
i_wa_bsop TYPE bapiparnr,
i_wa_bsos TYPE bapischdl,
i_wa_bsosx TYPE bapischdlx,
i_wa_vbpa TYPE vbpa,
i_wa_vbkd TYPE vbkd,
i_wa_bpoi TYPE bapimepoitem,
i_wa_bpoix TYPE bapimepoitemx,
i_wa_bpos TYPE bapimeposchedule,
i_wa_bposx TYPE bapimeposchedulx,
i_wa_bpop TYPE bapiekkop,
i_wa_ekpa TYPE ekpa,
i_message TYPE char72,
i_bapiretn TYPE bapiret2,
i_bapiret2 TYPE TABLE OF bapiret2 INITIAL SIZE 1,
i_vbpa TYPE TABLE OF vbpa INITIAL SIZE 1,
i_vbkd TYPE TABLE OF vbkd INITIAL SIZE 1,
i_ekpa TYPE TABLE OF ekpa INITIAL SIZE 1,
i_bsoi TYPE TABLE OF bapisditm INITIAL SIZE 1,
i_bsoix TYPE TABLE OF bapisditmx INITIAL SIZE 1,
i_bsos TYPE TABLE OF bapischdl INITIAL SIZE 1,
i_bsosx TYPE TABLE OF bapischdlx INITIAL SIZE 1,
i_bsop TYPE TABLE OF bapiparnr INITIAL SIZE 1,
i_bpoi TYPE TABLE OF bapimepoitem INITIAL SIZE 1,
i_bpoix TYPE TABLE OF bapimepoitemx INITIAL SIZE 1,
i_bpos TYPE TABLE OF bapimeposchedule INITIAL SIZE 1,
i_bposx TYPE TABLE OF bapimeposchedulx INITIAL SIZE 1,
i_bpop TYPE TABLE OF bapiekkop INITIAL SIZE 1,
i_text_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_line_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_txw_note TYPE TABLE OF txw_note INITIAL SIZE 1,
i_oij_el_doc_mot TYPE oij_el_doc_mot .
CONSTANTS: c_char_c VALUE 'C',
c_char_e VALUE 'E',
c_char_p VALUE 'P',
c_char_g VALUE 'G',
c_char_i VALUE 'I',
c_char_s VALUE 'S',
c_char_x VALUE 'X',
c_zsw(3) VALUE 'ZSW',
c_nomit_stat(4) VALUE 'ZDNY' .
DATA : lv_nomtk_split TYPE oij_nomtk.
DATA : i_order_split_create TYPE TABLE OF zsws_order_split.
DATA : wa_order_split_create TYPE zsws_order_split.
LOOP AT i_order_split_create INTO wa_order_split_create.
IF NOT i_create_order IS INITIAL .
CLEAR: i_create_order .
MOVE: wa_order_split_create-docnr TO i_ebeln,
wa_order_split_create-docitm TO i_ebelp .
CALL FUNCTION 'ME_EKKO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
IMPORTING
po_ekko = i_ekko
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
ENDIF .
Fill PO Header
i_bpoh-comp_code = i_ekko-bukrs .
i_bpoh-doc_type = i_ekko-bsart .
i_bpoh-vendor = i_ekko-lifnr .
i_bpoh-langu = i_ekko-spras .
i_bpoh-pmnttrms = i_ekko-zterm .
i_bpoh-purch_org = i_ekko-ekorg .
i_bpoh-pur_group = i_ekko-ekgrp .
i_bpoh-currency = i_ekko-waers .
i_bpoh-agreement = i_ekko-konnr .
i_bpoh-incoterms1 = i_ekko-inco1 .
i_bpoh-incoterms2 = i_ekko-inco2 .
Fill PO update indicator 'X'
i_bpohx-comp_code = c_char_x .
i_bpohx-doc_type = c_char_x .
i_bpohx-vendor = c_char_x .
i_bpohx-langu = c_char_x .
i_bpohx-pmnttrms = c_char_x .
i_bpohx-purch_org = c_char_x .
i_bpohx-pur_group = c_char_x .
i_bpohx-currency = c_char_x .
i_bpohx-agreement = c_char_x .
i_bpohx-incoterms1 = c_char_x .
i_bpohx-incoterms2 = c_char_x .
CALL FUNCTION 'ME_EKPO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
pi_ebelp = i_ebelp
IMPORTING
po_ekpo = i_ekpo
EXCEPTIONS
no_records_found = 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 .
Fill PO Item
i_wa_bpoi-po_item = i_ekpo-ebelp .
i_wa_bpoi-material = i_ekpo-matnr .
i_wa_bpoi-plant = i_ekpo-werks .
i_wa_bpoi-stge_loc = i_ekpo-lgort .
i_wa_bpoi-quantity = wa_order_split_create-qty_acptd .
i_wa_bpoi-po_unit = i_ekpo-meins .
i_wa_bpoi-tax_code = i_ekpo-mwskz .
i_wa_bpoi-val_type = i_ekpo-bwtar .
i_wa_bpoi-item_cat = i_ekpo-pstyp .
i_wa_bpoi-acctasscat = i_ekpo-knttp .
i_wa_bpoi-agreement = i_ekpo-konnr .
i_wa_bpoi-agmt_item = i_ekpo-ktpnr .
APPEND i_wa_bpoi TO i_bpoi .
Fill PO Item update indicator 'X'
i_wa_bpoix-po_item = i_ekpo-ebelp .
i_wa_bpoix-po_itemx = c_char_x .
i_wa_bpoix-material = c_char_x .
i_wa_bpoix-plant = c_char_x .
i_wa_bpoix-stge_loc = c_char_x .
i_wa_bpoix-quantity = c_char_x .
i_wa_bpoix-po_unit = c_char_x .
i_wa_bpoix-tax_code = c_char_x .
i_wa_bpoix-val_type = c_char_x .
i_wa_bpoix-item_cat = c_char_x .
i_wa_bpoix-acctasscat = c_char_x .
i_wa_bpoix-agreement = c_char_x .
i_wa_bpoix-agmt_item = c_char_x .
APPEND i_wa_bpoix TO i_bpoix .
Fill PO Item Schedule
i_wa_bpos-po_item = i_ekpo-ebelp .
i_wa_bpos-sched_line = '0001' .
i_wa_bpos-delivery_date = wa_order_split_create-dly_date .
i_wa_bpos-quantity = wa_order_split_create-qty_acptd .
APPEND i_wa_bpos TO i_bpos .
Fill PO Item schedule update indicator 'X'
i_wa_bposx-po_item = i_ekpo-ebelp .
i_wa_bposx-sched_line = '0001' .
i_wa_bposx-delivery_date = c_char_x .
i_wa_bposx-quantity = c_char_x .
APPEND i_wa_bposx TO i_bposx .
CLEAR: i_pargr .
SELECT SINGLE pargr
INTO i_pargr
FROM t161
WHERE bstyp = i_ekko-bstyp
AND bsart = i_ekko-bsart .
CLEAR i_ekpa[].
CALL FUNCTION 'MM_READ_PARTNERS'
EXPORTING
application = c_char_p
ebeln = i_ebeln
bstyp = i_ekko-bstyp
pargr = i_pargr
TABLES
x_ekpa = i_ekpa.
LOOP AT i_ekpa INTO i_wa_ekpa .
i_wa_bpop-partnerdesc = i_wa_ekpa-parvw .
i_wa_bpop-langu = sy-langu .
IF NOT i_wa_ekpa-lifn2 IS INITIAL .
i_wa_bpop-buspartno = i_wa_ekpa-lifn2 .
ELSE .
i_wa_bpop-buspartno = i_wa_ekpa-parnr .
ENDIF .
APPEND i_wa_bpop TO i_bpop .
CLEAR: i_wa_ekpa, i_wa_bpop .
ENDLOOP .
CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = i_bpoh
poheaderx = i_bpohx
IMPORTING
exppurchaseorder = i_new_ebeln
TABLES
return = i_bapiret2
poitem = i_bpoi
poitemx = i_bpoix
poschedule = i_bpos
poschedulex = i_bposx.
i_order = i_new_ebeln .
SHIFT i_order LEFT DELETING LEADING '0' .
i_return-errortype = c_char_i .
i_return-workarea = c_zsw .
i_return-message = '064' .
i_return-variable1 = i_order .
loop at i_bapiret2 into i_bapiretn where type ca 'EAX' .
append i_bapiretn to t_bapi_return .
endloop .
if t_bapi_return[] is initial .
i_create_order = c_char_x .
CALL FUNCTION 'SWD_POPUP_MESSAGE_SEND'
EXPORTING
act_return = i_return. "Popup with new PO no.
ENDCASE . " Docind
ENDIF .
ENDLOOP. -
Error using BAPI_PO_CREATE1 for creating PO with services
Hi,
I'm getting an error saying 'EnTER account assignment data for item' when I use BAPI_PO_CREATE1 and try to create POs with Service Items. I have filled all the required details, even then the system throws up this error message. Thanks for any help.
Regards,
Vijaywhat have you passed to the table POACCOUNT? and POACCOUNTX?
Regards,
Ravi -
Error: Internal Prising Error while using BAPI_PO_CREATE1
Hi Experts,
I am creating PO from Contract (VA41/VA42) using BAPI_PO_CREATE1 in user exit MV45AFZZ - USEREXIT_SAVE_DOCUMENT_PREPARE.
BAPI is returning the PO number and after coming out from BAPI. I am getting an popup message STOP - Internal Prising Error.
Even though bapi returned the PO number there is no PO exists with that number.
Please provide you valuable inputs.
Thanks & RegardsHi Experts,
I am creating PO from Contract (VA41/VA42) using BAPI_PO_CREATE1 in user exit MV45AFZZ - USEREXIT_SAVE_DOCUMENT_PREPARE.
BAPI is returning the PO number and after coming out from BAPI. I am getting an popup message STOP - Internal Prising Error.
Even though bapi returned the PO number there is no PO exists with that number.
Please provide you valuable inputs.
Thanks & Regards -
Getting errors when iam using bapi ' BAPI_PO_CREATE1'
Hi Sap Gurus,
I need small info over bapi BAPI_PO_CREATE1.
While creating Purchase orders using BAPI_PO_CREATE1 it is not allowing me to enter partner function details .I am getting below errors.
i.e
1) it is not allowing to update partner function details.and iam not getting what excact bapi structure for partner function details.here i found 'BAPIEKKOP' in tables option.but these fields are not matching with ME21N screen partner function fields . I want to update PARTNER FUNTCION, PARTNER NAME, DEFALT PARTNER.in bapi structure BAPIEKKOP there is no DEFAULT PARTNER instead of this there is DELETION INDICATOR.
Pls let me know the exact bapi structure and fields in BAPI.
2). I am getting the below error when iam posting the Pur.Order
i.e Item 10 Acct Assgt 1
Account 460600 does not exist in chart of accounts CANO.
what does it means? Evenif that Account is existed in chart of account CANO and Even i posted that PO, it showing like above.and iam getting all field in PO like CO area,COST center and G/L account for Account Assingment group 'K' .
I could not understand why it is giving such type of errors.
Pls let me know the anwsers for above errors .
thanks in advance.Hi Sap Gurus,
I need small info over bapi BAPI_PO_CREATE1.
While creating Purchase orders using BAPI_PO_CREATE1 it is not allowing me to enter partner function details .I am getting below errors.
i.e
1) it is not allowing to update partner function details.and iam not getting what excact bapi structure for partner function details.here i found 'BAPIEKKOP' in tables option.but these fields are not matching with ME21N screen partner function fields . I want to update PARTNER FUNTCION, PARTNER NAME, DEFALT PARTNER.in bapi structure BAPIEKKOP there is no DEFAULT PARTNER instead of this there is DELETION INDICATOR.
Pls let me know the exact bapi structure and fields in BAPI.
2). I am getting the below error when iam posting the Pur.Order
i.e Item 10 Acct Assgt 1
Account 460600 does not exist in chart of accounts CANO.
what does it means? Evenif that Account is existed in chart of account CANO and Even i posted that PO, it showing like above.and iam getting all field in PO like CO area,COST center and G/L account for Account Assingment group 'K' .
I could not understand why it is giving such type of errors.
Pls let me know the anwsers for above errors .
thanks in advance. -
Short dump while using BAPI_PO_CREATE1
Hi all,
I am facing this short dump while executing my program that uses BAPI_PO_CREATE1.
The error is 'Exception condition "failure" raised'.
The trigger location of runtime error is
Program : CL_HANDLE_MANAGER_MM====================CP
Include: CL_HANDLE_MANAGER_MM=====================CM005
Module name: GET
Source code:
Method GET.
If my_manager is initial.
Call method get_manager.
endif.
call method my_manager-> search EXporting im_id = im_id
Importing ex_handle = ex_handle
Exceptions failure = 01.
If sy-subrc <>0.
raise failure.
endif.
I am a beginner in ABAP. Plz help.Hi ,
I faced the similar situation once , in my case when i passed the Delivery indicator value in the Item Table as well as Itemx Table , i was facing this error .
what i suggest you is to pass it at the Item table only , not at the itemx Table.
it worked for me .
try this and reply for the same. -
Hi,
Hi i created upload prog for PO using BAPI_PO_CREATE1.I got the below error.so what will be problem whether the error is in the code are in the template.pls solve my issue.
the error is as below.
Creation of PO using Enjoy BAPI unsuccessful
Thanks,
Rajendra.Hi Eswar,
Below is the code,
tables: T100.
DATA : POHEADER LIKE BAPIMEPOHEADER OCCURS 0 WITH HEADER LINE,
POHEADERX LIKE BAPIMEPOHEADERX OCCURS 0 WITH HEADER LINE,
POITEM LIKE BAPIMEPOITEM OCCURS 0 WITH HEADER LINE,
POITEMX LIKE BAPIMEPOITEMX OCCURS 0 WITH HEADER LINE,
POSCHEDULE LIKE BAPIMEPOSCHEDULE OCCURS 0 WITH HEADER LINE,
POSCHEDULEX LIKE BAPIMEPOSCHEDULX OCCURS 0 WITH HEADER LINE,
POACCOUNT LIKE BAPIMEPOACCOUNT OCCURS 0 WITH HEADER LINE,
POACCOUNTX LIKE BAPIMEPOACCOUNTX OCCURS 0 WITH HEADER LINE,
POCOND LIKE BAPIMEPOCOND OCCURS 0 WITH HEADER LINE,
POCONDX LIKE BAPIMEPOCONDX OCCURS 0 WITH HEADER LINE,
RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,
EXPPURCHASEORDER LIKE BAPIMEPOHEADER-PO_NUMBER.
POHEADER-COMP_CODE = '2006'.
DATA : BEGIN OF DATA_TAB OCCURS 0,
BSART(40) TYPE C,
LIFNR(10) TYPE C,
EKORG(4) TYPE C,
EKGRP(3) TYPE C,
EBELP(5) TYPE C,
MATNR(18) TYPE C,
MAKTX(40) TYPE C,
WERKS(4) TYPE C,
CHARG(10) TYPE C,
BEDNR(10) TYPE C,
PSTYP(1) TYPE C,
KNTTP(1) TYPE C,
ANLN1(12) TYPE C,
ANLN2(4) TYPE C,
AUFNR(12) TYPE C,
PS_PSP_PNR(8) TYPE C,
EINDT(8) TYPE C,
WAERS(5) TYPE C,
NETPR(11) TYPE C,
WKURS(9) TYPE C,
BEDAT(8) TYPE C,
SAKTO(10) TYPE C,
KOSTL(10) TYPE C,
MENGE(13) TYPE C,
MEINS(3) TYPE C,
END OF DATA_TAB.
*DATA : BEGIN OF DATA_TAB OCCURS 0,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
EKORG LIKE EKKO-EKORG,
EKGRP LIKE EKKO-EKGRP,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
MAKTX LIKE MAKT-MAKTX,
WERKS LIKE EKPO-WERKS,
CHARG LIKE MCH1-CHARG,
BEDNR LIKE EKPO-BEDNR,
PSTYP LIKE EKPO-PSTYP,
KNTTP LIKE EKPO-KNTTP,
ANLN1 LIKE EKKN-ANLN1,
ANLN2 LIKE EKKN-ANLN2,
AUFNR LIKE EKKN-AUFNR,
PS_PSP_PNR LIKE EKKN-PS_PSP_PNR,
EINDT LIKE EKET-EINDT,
WAERS LIKE EKKO-WAERS,
NETPR LIKE EKPO-NETPR,
WKURS LIKE EKKO-WKURS,
BEDAT LIKE EKKO-BEDAT,
SAKTO LIKE EKKN-SAKTO,
KOSTL LIKE EKKN-KOSTL,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
END OF DATA_TAB.
Data
DATA : wc_file type string,
wc_tabix like sy-tabix,
wc_fl(40) type c,
wc_tot(19) type n.
data: i_tab1 like alsmex_tabline occurs 0 with header line,
w_Data_tab like Data_tab occurs 0 with header line,
w_Data_tab like Data_tab,
w_totlines type i,
w_end_col type i.
DATA : C_X(1) TYPE c VALUE 'X'.
DATA : W_ERRSTAT(18) TYPE C.
DATA : W_ERRMSG(18) TYPE C.
DATA : I_EKKO LIKE EKKO OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF I_RETURN OCCURS 0.
INCLUDE STRUCTURE DATA_TAB.
DATA : EBELN LIKE I_EKKO-EBELN.
DATA : MESSAGE LIKE RETURN-MESSAGE.
DATA : END OF I_RETURN.
ALV
type-pools: slis.
data: txt_report like dokhl-object. "Reportname für Erläuterungsaufruf
data: gt_fieldcat type slis_t_fieldcat_alv,
gt_events type slis_t_event,
gt_sort type slis_t_sortinfo_alv,
gt_list_top_of_page type slis_t_listheader,
gs_layout type slis_layout_alv.
*Parameters
selection-screen begin of block mysel1 with frame.
parameters: pc_file like rlgrap-filename. " obligatory default 'C:'." default 'C:mat.xls'.
selection-screen end of block mysel1.
*AT SELECTION-SCREEN
at selection-screen on pc_file.
call function 'WS_QUERY'
exporting
query = 'FL'
filename = pc_file
importing
return = wc_fl.
condense wc_fl no-gaps.
if wc_fl eq space.
message e009 raising pc_file.
exit.
endif.
at selection-screen on value-request for pc_file.
wc_file = pc_file.
call function 'WS_FILENAME_GET'
exporting
mask = ' '
title = text-001
importing
filename = pc_file
exceptions
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
others = 5.
SELECTION-SCREEN
start-of-selection.
perform 1000_getfile.
perform 2000_process_bapi.
perform fieldcat_init using gt_fieldcat[].
perform layout_init using gs_layout.
perform comment_build using gt_list_top_of_page[].
perform eventtab_build using gt_events[].
PERFORM sort_build USING gt_sort[].
perform 3000_updation_log.
end-of-selection.
*& Form 1000_getfile
text
--> p1 text
<-- p2 text
FORM 1000_getfile .
*w_data_tab = data_tab.
Get the No of Rows in the file
CALL FUNCTION 'AA_FILE_UPLOAD_EXCEL'
EXPORTING
I_FILENAME = pc_file
I_TEST =
I_UCOMM =
I_MAXCOLS =
I_DELIMITER = ','
TABLES
ET_FILECONTENT = DATA_TAB
EXCEPTIONS
ERROR_ACCESSING_FILE = 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.
call function 'FAA_FILE_UPLOAD_EXCEL'
exporting
i_filename = pc_file
i_delimiter = ','
tables
et_filecontent = DATA_TAB
exceptions
error_accessing_file = 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.
describe table Data_tab lines w_totlines.
w_end_col = 25.
w_totlines = 1.
Upload the data from file to Internal Table
refresh Data_tab.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = pc_file
i_begin_col = 1 " Starting col on each row from the upload excel file
i_begin_row = 4 " Starting row from the upload excel file
i_end_col = w_end_col " No. of columns in the upload excel file
i_end_row = w_totlines " Possible no. of rows in the upload excel file
tables
intern = i_tab1
exceptions
inconsistent_parameters = 1
upload_ole = 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.
sort i_tab1 by row col.
loop at i_tab1.
case i_tab1-col.
when 1.
clear w_Data_tab.
move i_tab1-value to w_Data_tab-bsart.
when 2.
move i_tab1-value to w_Data_tab-lifnr.
when 3.
move i_tab1-value to w_Data_tab-ekorg.
when 4.
move i_tab1-value to w_Data_tab-ekgrp.
when 5.
move i_tab1-value to w_Data_tab-ebelp.
when 6.
move i_tab1-value to w_Data_tab-matnr.
when 7.
move i_tab1-value to w_Data_tab-maktx.
when 8.
move i_tab1-value to w_Data_tab-werks.
when 9.
move i_tab1-value to w_Data_tab-charg.
when 10.
move i_tab1-value to w_Data_tab-bednr.
when 11.
move i_tab1-value to w_Data_tab-pstyp.
when 12.
move i_tab1-value to w_Data_tab-knttp.
when 13.
move i_tab1-value to w_Data_tab-anln1.
when 14.
move i_tab1-value to w_Data_tab-anln2.
when 15.
move i_tab1-value to w_Data_tab-aufnr.
when 16.
move i_tab1-value to w_Data_tab-ps_psp_pnr.
when 17.
move i_tab1-value to w_Data_tab-eindt.
when 18.
move i_tab1-value to w_Data_tab-waers.
when 19.
move i_tab1-value to w_Data_tab-netpr.
when 20.
move i_tab1-value to w_Data_tab-wkurs.
when 21.
move i_tab1-value to w_Data_tab-bedat.
when 22.
move i_tab1-value to w_Data_tab-sakto.
when 23.
move i_tab1-value to w_Data_tab-kostl.
when 24.
move i_tab1-value to w_Data_tab-menge.
when 25.
move i_tab1-value to w_Data_tab-meins.
endcase.
at end of row.
append w_Data_tab to Data_tab.
clear w_Data_tab.
endat.
endloop.
clear wc_tot.
describe table Data_tab lines wc_tot.
ENDFORM. " 1000_getfile
*& Form 2000_process_bapi
text
--> p1 text
<-- p2 text
FORM 2000_process_bapi .
LOOP AT DATA_TAB.
POHEADER-DOC_TYPE = DATA_TAB-BSART.
POHEADER-VENDOR = DATA_TAB-LIFNR.
POHEADER-PURCH_ORG = DATA_TAB-EKORG.
POHEADER-PUR_GROUP = DATA_TAB-EKGRP.
POHEADER-DOC_DATE = DATA_TAB-BEDAT.
APPEND POHEADER.
POHEADERX-DOC_TYPE = 'X'.
POHEADERX-VENDOR = 'X'.
POHEADERX-PURCH_ORG = 'X'.
POHEADERX-PUR_GROUP = 'X'.
POHEADERX-DOC_DATE = 'X'.
APPEND POHEADERX.
POITEM-PO_ITEM = DATA_TAB-EBELP.
POITEM-MATERIAL = DATA_TAB-MATNR.
POITEM-SHORT_TEXT = DATA_TAB-MAKTX.
POITEM-PLANT = DATA_TAB-WERKS.
POITEM-BATCH = DATA_TAB-CHARG.
POITEM-TRACKINGNO = DATA_TAB-BEDNR.
POITEM-ITEM_CAT = DATA_TAB-PSTYP.
POITEM-ACCTASSCAT = DATA_TAB-KNTTP.
POITEM-NET_PRICE = DATA_TAB-NETPR.
POITEM-QUANTITY = DATA_TAB-MENGE.
POITEM-PO_UNIT = DATA_TAB-MEINS.
APPEND POITEM.
POITEMX-PO_ITEM = 'X'.
POITEMX-MATERIAL = 'X'.
POITEMX-SHORT_TEXT = 'X'.
POITEMX-PLANT = 'X'.
POITEMX-BATCH = 'X'.
POITEMX-TRACKINGNO = 'X'.
POITEMX-ITEM_CAT = 'X'.
POITEMX-ACCTASSCAT = 'X'.
POITEMX-NET_PRICE = 'X'.
POITEMX-QUANTITY = 'X'.
POITEMX-PO_UNIT = 'X'.
APPEND POITEMX.
POACCOUNT-ASSET_NO = DATA_TAB-ANLN1.
POACCOUNT-SUB_NUMBER = DATA_TAB-ANLN2.
POACCOUNT-ORDERID = DATA_TAB-AUFNR.
POACCOUNT-WBS_ELEMENT = DATA_TAB-PS_PSP_PNR.
POACCOUNT-GL_ACCOUNT = DATA_TAB-SAKTO.
POACCOUNT-COSTCENTER = DATA_TAB-KOSTL.
APPEND POACCOUNT.
POACCOUNTX-ASSET_NO = 'X'.
POACCOUNTX-SUB_NUMBER = 'X'.
POACCOUNTX-ORDERID = 'X'.
POACCOUNTX-WBS_ELEMENT = 'X'.
POACCOUNTX-GL_ACCOUNT = 'X'.
POACCOUNTX-COSTCENTER = 'X'.
APPEND POACCOUNTX.
POCOND-CURRENCY = DATA_TAB-WAERS.
POCOND-CONEXCHRAT = DATA_TAB-WKURS.
APPEND POCOND.
POCONDX-CURRENCY = 'X'.
POCONDX-CONEXCHRAT = 'X'.
APPEND POCONDX.
POSCHEDULE-PO_ITEM = DATA_TAB-EBELP.
POSCHEDULE-DELIVERY_DATE = DATA_TAB-EINDT.
APPEND POSCHEDULE.
POSCHEDULEX-PO_ITEM = 'X'.
POSCHEDULEX-DELIVERY_DATE = 'X'.
APPEND POSCHEDULEX.
ENDLOOP.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = POHEADER
POHEADERX = POHEADERX
POADDRVENDOR =
TESTRUN =
MEMORY_UNCOMPLETE =
MEMORY_COMPLETE =
POEXPIMPHEADER =
POEXPIMPHEADERX =
VERSIONS =
NO_MESSAGING =
NO_MESSAGE_REQ =
NO_AUTHORITY =
NO_PRICE_FROM_PO =
IMPORTING
EXPPURCHASEORDER = EXPPURCHASEORDER
EXPHEADER =
EXPPOEXPIMPHEADER =
TABLES
RETURN = RETURN
POITEM = POITEM
POITEMX = POITEMX
POADDRDELIVERY =
POSCHEDULE = POSCHEDULE
POSCHEDULEX = POSCHEDULEX
POACCOUNT = POACCOUNT
POACCOUNTPROFITSEGMENT =
POACCOUNTX = POACCOUNTX
POCONDHEADER =
POCONDHEADERX =
POCOND = POCOND
POCONDX = 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 = C_X
IMPORTING
RETURN =
ENDIF.
LOOP AT DATA_TAB.
READ TABLE RETURN WITH KEY MESSAGE = RETURN-MESSAGE.
MOVE-CORRESPONDING RETURN TO I_RETURN.
MOVE-CORRESPONDING DATA_TAB TO I_RETURN.
APPEND I_RETURN.
CLEAR I_RETURN.
ENDLOOP.
TO GET THE PO NUMBER *************
SELECT EBELN BSART FROM EKKO INTO TABLE I_EKKO
WHERE BSART EQ DATA_TAB-BSART
AND LIFNR EQ DATA_TAB-LIFNR
AND EKORG EQ DATA_TAB-EKORG
AND EKGRP EQ DATA_TAB-EKGRP.
LOOP AT I_EKKO.
MOVE I_EKKO-EBELN TO I_RETURN-EBELN.
APPEND I_RETURN.
CLEAR I_RETURN.
ENDLOOP.
*ALM_ME_MAP_RETURN_MESSAGE
IF RETURN IS INITIAL.
W_ERRSTAT = 'PASS'.
ELSE.
W_ERRSTAT = 'FAIL'.
LOOP AT RETURN.
W_ERRMSG = RETURN-MESSAGE.
ENDLOOP.
ENDIF.
WAIT UP TO 2 SECONDS.
ENDIF.
LOOP AT RETURN.
WRITE : / RETURN-TYPE, RETURN-ID, RETURN-NUMBER, RETURN-MESSAGE,
RETURN-LOG_NO, RETURN-LOG_MSG_NO, RETURN-MESSAGE_V1,
RETURN-MESSAGE_V2, RETURN-MESSAGE_V3, RETURN-MESSAGE_V4,
RETURN-PARAMETER, RETURN-ROW, RETURN-FIELD, RETURN-SYSTEM.
ENDLOOP.
ENDFORM. " 2000_process_bapi
*& Form fieldcat_init
text
-->P_GT_FIELDCAT[] text
FORM fieldcat_init USING lt_fieldcat type slis_t_fieldcat_alv.
data: ls_fieldcat type slis_fieldcat_alv.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'EBELN'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-001.
ls_fieldcat-seltext_m = text-001.
ls_fieldcat-seltext_s = text-001.
ls_fieldcat-reptext_ddic = text-001.
ls_fieldcat-outputlen = '10'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'WERKS'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-002.
ls_fieldcat-seltext_m = text-002.
ls_fieldcat-seltext_s = text-002.
ls_fieldcat-reptext_ddic = text-002.
ls_fieldcat-outputlen = '4'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'KNTTP'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-003.
ls_fieldcat-seltext_m = text-003.
ls_fieldcat-seltext_s = text-003.
ls_fieldcat-reptext_ddic = text-003.
ls_fieldcat-outputlen = '4'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-004.
ls_fieldcat-seltext_m = text-004.
ls_fieldcat-seltext_s = text-004.
ls_fieldcat-reptext_ddic = text-004.
ls_fieldcat-outputlen = '18'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'MENGE'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-005.
ls_fieldcat-seltext_m = text-005.
ls_fieldcat-seltext_s = text-005.
ls_fieldcat-reptext_ddic = text-005.
ls_fieldcat-outputlen = '10'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'NETPR'.
ls_fieldcat-datatype = 'CURR'.
ls_fieldcat-seltext_l = text-006.
ls_fieldcat-seltext_m = text-006.
ls_fieldcat-seltext_s = text-006.
ls_fieldcat-reptext_ddic = text-006.
ls_fieldcat-outputlen = '11'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'MESSAGE'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-007.
ls_fieldcat-seltext_m = text-007.
ls_fieldcat-seltext_s = text-007.
ls_fieldcat-reptext_ddic = text-007.
ls_fieldcat-outputlen = '50'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ENDFORM. " fieldcat_init
*& Form layout_init
text
-->P_GS_LAYOUT text
FORM layout_init USING ls_layout type slis_layout_alv.
ls_layout-zebra = 'X'.
ENDFORM. " layout_init
*& Form comment_build
text
-->P_GT_LIST_TOP_OF_PAGE[] text
FORM comment_build USING Lt_top_of_page type slis_t_listheader.
field-symbols: .
data: ls_line type slis_listheader.
data: i_sel like textpool occurs 0 with header line.
read textpool sy-repid into i_sel language sy-langu.
delete i_sel where id ne 'S'.
LIST HEADING LINE: TYPE H
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = text-020.
append ls_line to lt_top_of_page.
clear ls_line.
ls_line-typ = 'S'.
ls_line-key = text-021.
append ls_line to lt_top_of_page.
Selection-screen
loop at i_sel.
assign (i_sel-key) to .
append ls_line to lt_top_of_page.
endloop.
ENDFORM. " comment_build
*& Form eventtab_build
text
-->P_GT_EVENTS[] text
FORM eventtab_build USING lt_events type slis_t_event.
data: ls_event type slis_alv_event.
move 'PF_STATUS_SET' to ls_event-name.
move 'Z2006RMMPOUPLOAD' to ls_event-form.
append ls_event to lt_events.
clear ls_event.
ENDFORM. "eventtab_build
FORM PF_STATUS_SET
form Z2006RMMPOUPLOAD using extab type slis_t_extab. "#EC CALLED
set pf-status 'Z2006RMMPOUPLOAD'. "EXCLUDING extab.
endform. "Z2006RMMPOUPLOAD
FORM TOP_OF_PAGE *
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
i_logo = 'MECOMB'
it_list_commentary = gt_list_top_of_page.
endform. "top_of_page
*& Form 3000_updation_log
text
--> p1 text
<-- p2 text
FORM 3000_updation_log .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = 'Z2006RMMPOUPLOAD'
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = gs_layout
IT_FIELDCAT = gt_fieldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = gt_events[]
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = I_RETURN
EXCEPTIONS
PROGRAM_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.
ENDFORM. " 3000_updation_log
*& Form sort_build
text
-->P_GT_SORT[] text
FORM sort_build USING lt_sort type slis_t_sortinfo_alv.
data: ls_sort type slis_sortinfo_alv.
ls_sort-fieldname = 'EBELN'.
ls_sort-up = 'X'.
ls_sort-subtot = 'X'.
append ls_sort to lt_sort.
clear ls_sort.
ls_sort-fieldname = 'MATNR'.
ls_sort-up = 'X'.
append ls_sort to lt_sort.
clear ls_sort.
ENDFORM. " sort_build
Thanks,
Regards,
Rajendra -
Creation of PO using BAPI_PO_CREATE1 without info record
Hi,
I am making a progrma to create the PO using BAPI_PO_CREATE1 but for the materials for which info record is create din the system it is creating the PO properly but for the materials for which info record is no there even I am giving the Price and tax cod ein th eBAPI item table system is not creating th PO, so is info record mandatory for this.
regards,
zafarHi,
I have use the BAPI as per given note ref. I am taking the PO price from Info record for this I am not giving the item price in the BAPI items, but I want that the header discount should from the user input, but when I ma giving the header discount codnition system is giving error PO header fault, but along with this If i given the items value to in the net price then it is creating the PO, so is it possible to get the items value from the info record and header codnition discount value from user input, we dont want to maintain discount at info record.
regards,
zafar -
PO Upload using BAPI_PO_CREATE1
Hello All,
I m developing PO upload program using BAPI_PO_CREATE1.
It gives me massages like this:
Error transferring ExtensionIn data for enhancement CI_EKPODB.
PO held under the number 4800000109.
But no PO exists. Include CI_EKPODB contains one Quan and four Char fields.
Please tell me how to resolve this issue.
Regards
NadeemHi
check this code
Program : ZGMIMM_ME21.
Transaction Code :
Description : BDC for Purchase order
report zgmimm_me21 no standard page heading line-size 255.
tables: t100.
type-pools: truxs.
types: begin of i_upload,
lifnr like ekko-lifnr, "Vendor Number
bukrs like ekko-bukrs, "Order type
bedat like ekko-bedat, "Purchase Order Date
ekorg like ekko-ekorg, "Purchasing organization
ausnr like ekko-ausnr, "Purchase order
ekgrp like ekko-ekgrp, "Purchasing group
eddat like ekko-bedat, "Delivery date
werks like ekpo-werks, "Plant
lgort like ekpo-lgort, "Storage location
zterm like ekko-zterm, "Payment terms
ematn like ekpo-ematn, "Material
menge like ekpo-menge, "PO Quantity
lewed like ekpo-lewed, "Latest GR Date
end of i_upload.
data: begin of i_input occurs 0,
pbg(10) type c,
bldat(07) type c, "001
BLDAT like BKPF-BUDAT,
hkont(10) type c,
kostl(10) type c,
wrbtr(11) type c,
dbcrflag(01) type c,
sgtxt(32) type c,
end of i_input.
data: v_counter(2) type n.
data: v_mod type i.
data: v_ebelp like ekpo-ebelp.
data: v_fname(132) type c.
data: v_fname1(132) type c.
data: v_tabix like sy-tabix.
data : ws_text(200) type c.
data : wa_mag(1).
data: begin of int_msg occurs 0,
cnt type i,
massage(1) type c,
text(200) type c,
end of int_msg.
data : begin of i_final occurs 0,
lifnr like ekko-lifnr, "Vendor Number
bukrs like ekko-bukrs, "Order type
bedat(10),
ekorg like ekko-ekorg, "Purchasing organization
ausnr like ekko-ausnr, "Purchase order
ekgrp like ekko-ekgrp, "Purchasing group
eddat(10),
werks like ekpo-werks, "Plant
lgort like ekpo-lgort, "Storage location
zterm like ekko-zterm, "Payment terms
ematn like ekpo-ematn, "Material
menge type char15, "PO Quantity
lewed(10),
***+EDS
TAX_CODE type mwskz,
GR_BASEDIV,
end of i_final.
data: it_datatab type standard table of i_upload,
wa_datatab type i_upload.
data: it_raw type truxs_t_text_data.
data: begin of bdcdata occurs 0.
include structure bdcdata.
data: end of bdcdata.
data: begin of messtab occurs 0.
include structure bdcmsgcoll.
data: end of messtab.
data: begin of t_input occurs 0.
include structure i_input.
data: end of t_input.
data: begin of i_local_output occurs 0,
text(2800) type c,
end of i_local_output.
data: begin of i_error occurs 0.
include structure i_input.
data: text(50) type c.
data: end of i_error.
data : _datum1(10).
data : t_datum1(10).
data: msgno like sy-msgno,
msgid like sy-msgid,
msgty like sy-msgty,
message like message.
*Data : TEXT(50) Type c value 'File Shoud be in Excel Format'.
data: wa_head type bapimepoheader,
wa_headx type bapimepoheaderx,
i_return type bapiret2 occurs 0 with header line,
i_item type bapimepoitem occurs 0 with header line,
i_itemx type bapimepoitemx occurs 0 with header line,
i_sch type bapimeposchedule occurs 0 with header line,
i_schx type bapimeposchedulx occurs 0 with header line.
SELECTION SCREEN
parameters: p_file type rlgrap-filename obligatory modif id app.
Write : /3 Text.
START OF SELECTION
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.
perform data_from_excel_to_sap.
perform pass_data_to_final_int_tab.
perform fill_bdc_data.
perform fill_bapi_parameters.
perform call_po_create_bapi.
*& Form DATA_FROM_EXCEL_TO
text
--> p1 text
<-- p2 text
form data_from_excel_to_sap.
call function 'TEXT_CONVERT_XLS_TO_SAP'
exporting
I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
tables
i_tab_converted_data = it_datatab[] "ACTUAL DATA
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.
endform. " DATA_FROM_EXCEL_TO
*& Form PASS_DATA_TO_FINAL_INTERNAL_TA
text
--> p1 text
<-- p2 text
form pass_data_to_final_int_tab.
loop at it_datatab into wa_datatab.
move wa_datatab-lifnr to i_final-lifnr. "Vendor Number
move wa_datatab-bukrs to i_final-bukrs. "Order type
move wa_datatab-bedat to i_final-bedat. "Purchase Order Date
concatenate i_final-bedat6(2) '.' i_final-bedat4(2) '.20'
i_final-bedat+2(2) into _datum1.
i_final-bedat = _datum1.
move wa_datatab-ekorg to i_final-ekorg. "Purchasing organization
move wa_datatab-ausnr to i_final-ausnr. "Purchase order
move wa_datatab-ekgrp to i_final-ekgrp. "Purchasing group
move wa_datatab-eddat to i_final-eddat. "Delivery date
concatenate i_final-eddat6(2) '.' i_final-eddat4(2) '.20'
i_final-eddat+2(2) into _datum1.
i_final-eddat = _datum1.
move wa_datatab-werks to i_final-werks. "Plant
move wa_datatab-lgort to i_final-lgort. "Storage location
move wa_datatab-zterm to i_final-zterm. "Payment terms
move wa_datatab-ematn to i_final-ematn. "Material
move wa_datatab-menge to i_final-menge. "PO Quantity
move wa_datatab-lewed to i_final-lewed. "Latest GR Date
***Value Hard coaded considering this Program is only for Import.
I_FINAL-TAX_CODE = 'V0'.
I_FINAL-GR_BASEDIV = ' '.
concatenate i_final-lewed6(2) '.' i_final-lewed4(2) '.20'
i_final-lewed+2(2) into _datum1.
i_final-lewed = _datum1.
append i_final.
endloop.
endform. " PASS_DATA_TO_FINAL_INTERNAL_TA
*& Form FILL_BDC_DATA
text
--> p1 text
<-- p2 text
form fill_bdc_data.
read table i_final index 1.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0100',
' ' 'BDC_CURSOR' 'RM06E-MATKL',
' ' 'BDC_OKCODE' '=KOPF',
' ' 'EKKO-LIFNR' i_final-lifnr,
' ' 'RM06E-BSART' i_final-bukrs,
' ' 'RM06E-BEDAT' i_final-bedat,
' ' 'RM06E-BSTNR' i_final-ausnr,
' ' 'EKKO-EKORG' i_final-ekorg,
' ' 'EKKO-EKGRP' i_final-ekgrp,
' ' 'RM06E-EEIND' i_final-eddat,
' ' 'RM06E-LPEIN' 'T',
' ' 'RM06E-WERKS' i_final-werks,
' ' 'RM06E-LGORT' i_final-lgort.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0101',
' ' 'BDC_OKCODE' '=AB',
' ' 'EKKO-ZTERM' i_final-zterm.
move: '01' to v_counter.
loop at i_final.
move: sy-tabix to v_tabix.
concatenate 'EKPO-EMATN(' v_counter ')' into v_fname.
concatenate 'EKPO-MENGE(' v_counter ')' into v_fname1.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0120',
' ' 'BDC_OKCODE' '=DETZ',
' ' 'RM06E-EBELP' '5',
' ' v_fname i_final-ematn,
' ' v_fname1 i_final-menge.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0112',
' ' 'BDC_CURSOR' 'EKPO-LEWED',
' ' 'BDC_OKCODE' '/00',
' ' 'EKPO-LEWED' i_final-lewed,
' ' 'EKPO-PRDAT' i_final-bedat.
' ' 'EKPO-IPRKZ' 'D'.
v_mod = v_counter mod 5.
if v_mod eq 0.
clear v_ebelp.
move: v_tabix to v_ebelp.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0120',
' ' 'BDC_OKCODE' '/00',
' ' 'RM06E-EBELP' v_ebelp.
v_counter = '02'.
else.
v_counter = v_counter + 1.
endif.
endloop.
loop at i_final.
clear: v_fname.
v_counter = sy-tabix.
v_ebelp = sy-tabix.
concatenate 'RM06E-TCSELFLAG(' '01' ')' into v_fname.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0120',
' ' 'RM06E-EBELP' v_ebelp,
' ' 'BDC_OKCODE' '/00'.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0120',
' ' 'BDC_CURSOR' 'RM06E-BSTPO(01)',
' ' 'BDC_OKCODE' '=DETZ',
' ' 'RM06E-EBELP' v_ebelp,
' ' v_fname 'X'.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0112',
' ' 'BDC_CURSOR' 'EKPO-LEWED',
' ' 'BDC_OKCODE' '/00',
' ' 'EKPO-PLIFZ' '91',
' ' 'EKPO-GEWEI' 'KG',
' ' 'EKPO-PRDAT' i_final-bedat,
' ' 'EKPO-IPRKZ' 'D',
' ' 'EKPO-LEWED' i_final-lewed.
endloop.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0120',
' ' 'BDC_CURSOR' 'RM06E-BSTPO(10)',
' ' 'BDC_OKCODE' '=BU',
' ' 'RM06E-EBELP' '1'.
perform f0510_bdcdata using :
'X' 'SAPLSPO1' '0300',
' ' 'BDC_OKCODE' '=YES'.
call transaction 'ME21' using bdcdata messages into messtab
mode 'A' update 'S'.
perform f000_process_errors.
clear: bdcdata, messtab.
refresh: bdcdata, messtab.
loop at int_msg.
write:/ int_msg-text.
endloop.
endform. " FILL_BDC_DATA
*& Form F0510_BDCDATA
text
-->dynbegin text
-->name text
-->value text
form f0510_bdcdata using value(dynbegin)
value(name)
value(value).
if dynbegin = 'X'.
clear bdcdata.
move: name to bdcdata-program,
value to bdcdata-dynpro,
'X' to bdcdata-dynbegin.
append bdcdata.
else.
clear bdcdata.
move: name to bdcdata-fnam,
value to bdcdata-fval.
append bdcdata.
endif.
endform. " F0510_BDCDATA
*& Form F000_PROCESS_ERRORS
text
--> p1 text
<-- p2 text
form f000_process_errors.
loop at messtab.
clear t100.
select single * from t100 where sprsl = messtab-msgspra
and arbgb = messtab-msgid
and msgnr = messtab-msgnr.
ws_text = t100-text.
wa_mag = messtab-msgtyp.
if ws_text cs '&1'.
replace '&1' with messtab-msgv1 into ws_text.
replace '&2' with messtab-msgv2 into ws_text.
replace '&3' with messtab-msgv3 into ws_text.
replace '&4' with messtab-msgv4 into ws_text.
else.
replace '&' with messtab-msgv1 into ws_text.
replace '&' with messtab-msgv2 into ws_text.
replace '&' with messtab-msgv3 into ws_text.
replace '&' with messtab-msgv4 into ws_text.
endif.
condense ws_text.
move ws_text to int_msg-text.
move wa_mag to int_msg-massage.
append int_msg.
endloop.
delete int_msg where massage = 'W'.
endform. " F000_PROCESS_ERRORS
*& Form fill_bapi_parameters
Subroutine to fill BAPI Parameters
form fill_bapi_parameters.
clear: wa_head, wa_headx, i_return, i_item, i_itemx, i_sch, i_schx.
perform fill_bapi_header.
perform fill_bapi_items.
endform. " fill_bapi_parameters
*& Form fill_bapi_header
Subroutine to fill the bapi header
form fill_bapi_header.
read table i_final index 1.
check sy-subrc eq 0.
move: i_final-ausnr to wa_head-po_number,
i_final-bukrs to wa_head-doc_type,
i_final-zterm to wa_head-pmnttrms,
i_final-ekorg to wa_head-purch_org,
i_final-ekgrp to wa_head-pur_group,
'FOB' to wa_head-incoterms1,
'Free On Board' to wa_head-incoterms2.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = i_final-lifnr
importing
output = i_final-lifnr.
move: i_final-lifnr to wa_head-vendor.
concatenate i_final-bedat+6(4)
i_final-bedat+3(2)
i_final-bedat(2) into wa_head-doc_date.
move: 'X' to wa_headx-po_number,
'X' to wa_headx-doc_type,
'X' to wa_headx-vendor,
'X' to wa_headx-pmnttrms,
'X' to wa_headx-purch_org,
'X' to wa_headx-pur_group,
'X' to wa_headx-doc_date,
'X' to wa_headx-incoterms1,
'X' to wa_headx-incoterms2.
endform. " fill_bapi_header
*& Form fill_bapi_items
Subroutine to fill the bapi items
form fill_bapi_items.
loop at i_final.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = i_final-ematn
importing
output = i_final-ematn.
move: sy-tabix to i_item-po_item,
i_final-ematn to i_item-material,
i_final-werks to i_item-plant,
i_final-lgort to i_item-stge_loc,
i_final-menge to i_item-quantity.
I_ITEM-TAX_CODE = I_FINAL-TAX_CODE.
I_ITEM-GR_BASEDIV = I_FINAL-GR_BASEDIV.
concatenate i_final-lewed+6(4)
i_final-lewed+3(2)
i_final-lewed(2) into i_item-gr_to_date.
move: sy-tabix to i_itemx-po_item,
'X' to i_itemx-po_itemx,
'X' to i_itemx-material,
'X' to i_itemx-plant,
'X' to i_itemx-stge_loc,
'X' to i_itemx-quantity,
'X' to i_itemx-gr_to_date.
**EDS
move: 'X' TO i_itemx-TAX_CODE ,
'X' TO i_itemx-GR_BASEDIV.
append: i_item, i_itemx.
move: sy-tabix to i_sch-po_item,
'0001' to i_sch-sched_line,
'D' to i_sch-del_datcat_ext.
i_final-menge to i_sch-quantity.
concatenate i_final-eddat(2)
i_final-eddat+3(2)
i_final-eddat+6(4) into i_sch-delivery_date.
move: sy-tabix to i_schx-po_item,
'0001' to i_schx-sched_line,
'X' to i_schx-po_itemx,
'X' to i_schx-sched_linex,
'X' to i_schx-quantity,
'X' to i_schx-delivery_date,
'X' to i_schx-del_datcat_ext.
append: i_sch, i_schx.
endloop.
endform. " fill_bapi_items
*& Form call_po_create_bapi
Subroutine to call PO CREATE BAPI
form call_po_create_bapi.
call function 'BAPI_PO_CREATE1'
exporting
poheader = wa_head
poheaderx = wa_headx
tables
return = i_return
poitem = i_item
poitemx = i_itemx
poschedule = i_sch
poschedulex = i_schx.
read table i_return with key type = 'S'
id = '06'
number = '017'.
if sy-subrc eq 0.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
write:/ i_return-message.
else.
delete i_return where type = 'S'.
delete i_return where type = 'I'.
delete i_return where type = 'W'.
write:/ 'Following Errors occured in PO Creation:'.
skip.
loop at i_return.
write:/ i_return-message.
endloop.
endif.
endform. " call_po_create_bapi
thanks
sitaram -
Using BAPI_PO_CREATE1 : Linking service, and account assignment
Hello,
I have trouble when using BAPI_PO_CREATE1. When creating PO using BAPI_PO_CREATE1, I need to input service for each po item and the service itself need to have account assignment. I simplify the code below.
**PO item
t_poitem-po_item = '10'. "for item 10
t_poitem-PCKG_NO = '20'. "link with service
t_poitemx-po_item = 'X'.
t_poitemx-PCKG_NO = 'X'.
**Account Assignment
t_poaccount-po_item = '10'. "link with PO Item
t_poaccount-SERIAL_NO = '01'.
t_poaccount-DISTR_PERC = 1.
t_poaccountx-po_item = '10'.
t_poaccountx-SERIAL_NO = '01'.
t_poaccountx-po_itemx = 'X'.
t_poaccountx-SERIAL_NOx = 'X'.
t_poaccountx-DISTR_PERC = 'X'.
**PO Services
**1st row
t_poservices-PCKG_NO = '20'.
t_poservices-LINE_NO = '0000000001'.
t_poservices-SUBPCKG_NO = '21'.
APPEND t_poservices.
clear t_poservices.
**2nd row
t_poservices-PCKG_NO = '21'.
t_poservices-LINE_NO = '0000000002'.
t_poservices-EXT_LINE = '0000000010'.
**fill account assignment for services
t_POSRVACCESSVALUES-pckg_no = '21'.
t_POSRVACCESSVALUES-LINE_NO = '0000000002'.
T_POSRVACCESSVALUES-SERNO_LINE = '01'.
t_POSRVACCESSVALUES-SERIAL_NO = '01'. "acct. assign. link
t_POSRVACCESSVALUES-PERCENTAGE = '100'.
Every time i execute BAPI_PO_CREATE1 using entry similar like above, i always found error message in t_return like this:
No account assignment exists for service line 0000000010
I feel sure that i have fill every field needed to link services and account assignment which is using serial_no, but somehow it does not link correctly. Can anyone advise me if there is some thing missing or incorrect with my ABAP code above? Thank you in advance for your help. For sure, first helpful answer will receive my rewards point.
Regards,
AbrahamThank you for the code. Actually i have fill the required field as you told but i did not put it in my code here to focus the problem on service and account assignment. After checking out your code, i found that the different between your code and mine is in services table.
<u><b>your code :</b></u>
<b>POSERVICES:structure</b>
PCKG_NO : 0000000001
LINE_NO :0000000001
SUBPCKG_NO : 0000000002
SERVICE :3000000000017
QUANTITY :5
BASE_UOM :AU
GR_PRICE :20000
<b>POSRVACCESSVALUES: structure name</b>
PCKG_NO :0000000002
LINE_NO :0000000002
<u><b>my code are:</b></u>
<b>POSERVICES:structure</b>
PCKG_NO : 0000000001
LINE_NO :0000000001
SUBPCKG_NO : 0000000002
PCKG_NO : 0000000002
LINE_NO :0000000002
SERVICE :3000000000017
QUANTITY :5
BASE_UOM :AU
GR_PRICE :20000
<b>POSRVACCESSVALUES: structure name</b>
PCKG_NO :0000000002
LINE_NO :0000000002
SERIAL_NO :0000000001
The other difference are in account assignment table, you didn't fill SERIAL_NO field.
my code will be like below:
<b>POACCOUNT: structure name</b>
PO_ITEM :10
SERIAL_NO : 0000000001
If using your version, the error message will be:
<i>In case of account assignment, please enter acc. assignment data for item</i>
If using my version, the error message will be:
<i>No account assignment exists for service line 0000000010</i>
Please advise what was wrong with my code. Thank you.
Regards,
Abraham -
Problem in conditions pricing updation using BAPI_PO_CREATE1
hi,
I am creating PO using BAPI_PO_CREATE1 however when i am passing the data to the bapi for conditions at item level the price value is not changing and throwing error as ( NET PRICE FOR ITEM 00010 adopted from last document ) so for all the items its throwing the same information and when i am chekin the PO the value is not the changing. and while creating the PO manually also the net price is coming automatically and we need to backspace the value and re enter the new value. So wht should i do in order to input the data into the PO.
Thanks in advanceThanks
-
Net Price showing zero while using BAPI_PO_CREATE1 for me21n
Dear All,
I am using BAPI_PO_CREATE1 for ME21N. The problem is, after execution of the program the error msg it shows-
No instance of object type PurchaseOrder has been created. External reference:
Purchase order still contains faulty items
Net price must be greater than 0
The values are coming from excel file.
Please tell me where I am doing wrong.
With regards,
Rosaline.Hi,
Symptom
You create a purchase order with BAPI_PO_CREATE1 or you add an item to an existing purchase order with BAPI_PO_CHANGE. You assign a value in field POITEM-NET_PRICE. However, this value is not transferred. If it was not possible for you to determine any conditions, the system generated the error message 06218 'Net price must be greater than 0'.
Other terms
BAPI_PO_CREATE1, BAPI_PO_CHANGE, price, net price, gross price, conditions, price determination, condition type, 06218, EKPO-NETPR, NETPR, POITEM-NET_PRICE, NET_PRICE, PO_PRICE, BAPI_PO_PRICE, BUS2012, PurchaseOrder.CreateFromData1, CreateFromData1, PurchaeOrder.Change
Reason and Prerequisites
This function has not been available up to now. You could also assign conditions via the condition tables.
Read also Notes 399791, 428621, 529287, 578253 and 539950 for this.
Solution
The present note adds field PO_PRICE to table POITEM. PO_PRICE can have the values ' ', '1' or '2' with the following meaning:
PO_PRICE = ' ': The price determination is carried out as before.
PO_PRICE = '1': The value assigned in field NET_PRICE is transferred as a gross price, that is it is set in the condition type that is defined as a base price in the calculation schema. All other condition types remain unchanged. No conditions are copied from the last document.
PO_PRICE = '2': The value assigned in field NET_PRICE is transferred as a net price, that is it is set in the condition type that is defined as base price in the calculation scheme. All other condition types are deleted.
Note the following
The following restrictions apply to field PO_PRICE:
If you assign conditions via the BAPI interface, these are always transferred. This is carried out independently of the value that you assign in field PO_PRICE.
If you add a new item to a purchase order with BAPI_PO_CHANGE, it does not suffice to fill field POITEM-NET_PRICE on item level. The corresponding currency must be specified explicitly on header level.
You can only use field PO_PRICE during the creation of a purchase order item. If you want to change the price of an already existing item, you can only do this via the conditions.
If you fill field POITEM-PO_PRICE, you must enter an 'X' in POITEMX-PO_PRICE so that the value is transferred.
Correction
The correction is made available via R/3 support package. If you want to implement the note manually, proceed as follows:
1. Make sure that your system contains Notes 494759, 552189 and 578253.
2. Create data type BAPI_PO_PRICE with the following attributes:
Short text:
Price transfer indicator: 1 = gross, 2 = net
Package: ME
Domain: BPUEB
3. Extend structure BAPIMEPOITEM (directly after NO_ROUNDING):
Component: PO_PRICE
Component type: BAPI_PO_PRICE
4. Extend structure BAPIMEPOITEMX (directly after NO_ROUNDING):
Component: PO_PRICE
Component type: BAPIUPDATE
5. Extend structure MEPOITEM_DATA (directly after NO_ROUNDING):
Component: PO_PRICE
Component type: BAPI_PO_PRICE
6. Extend structure MEPOITEM_DATAX (directly after NO_ROUNDING):
Component: PO_PRICE
Component type: BAPIUPDATE
7. Implement the correction instructions in your system.
regards,
Ravi
Edited by: Parupelly on Dec 14, 2011 1:30 PM
Maybe you are looking for
-
Mac is very slow after upgrading to 10.8.3
my mac with 2.4 ghz i5 and 4gb RAm is very slow after upgrading to OS X 10.8.3 any suggestions would be appreciated...
-
User validity date is not refelcting in Childsystem
Hi Experts, I have changed the validity of a user in CuA system . But the validity is not reflecting in child system. on checking SCUL I found the error as " User type 75 is not actiive". I didnot find any issues in distributing roles and profiles
-
IOS 6.1 will not sync with macbook pro ical
I can not get iCal from my macbook pro 10.7.5 to sync with ical on my ipad 6.1. any suggestions?
-
Defining onRelease in a loop.
So I'm building a dynamic menu where the button actions change for each item that is listed. Now I think I could do this while writing classes, but I'm rushing to get it done, I'd rather just script functions for it. However, when I run a for loop, i
-
Have succesfully captured my signature as a stamp in Acrobat 6 Pro. Regrettably, I can select my stamp/signature but cannot place it in the document. Instead, I find the words "The Paste" in its place. I made these attempts with edit-> paste or right