PO creation by using BAPI_PO_CREATE1
Hi gurus'
I have to create open po by using bapi BAPI_PO_CREATE1.
Po created properly as per our inputs but in created po created date has take current date.Why is not taken input created date.
can any one suggest me. why is happend and how to corrected throught bapi.
Best regards.
Pravin
Hi
Please go through the documentation in SE37 for the FM.. It is very clear on how you need to work on this BAPI. It is given with examples.
Regards,
Vishwa.
Similar Messages
-
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. -
Creation of invoicing plan while creating the PO using BAPI_PO_CREATE1
Hi, basically I'm creating a PO using BAPI_PO_CREATE1 and then creating Invoicing plan thru ME22 using BDC.
Could anyone please help me if there is any possibility of creation of invoicing plan while creating the PO itself using BAPI_PO_CREATE1.
thanks in advance.Hi,
Have you tried filling up the invoicing plan related tables of the bapi ?
*" INVPLANHEADER STRUCTURE BAPI_INVOICE_PLAN_HEADER OPTIONAL
*" INVPLANHEADERX STRUCTURE BAPI_INVOICE_PLAN_HEADERX OPTIONAL
*" INVPLANITEM STRUCTURE BAPI_INVOICE_PLAN_ITEM OPTIONAL
*" INVPLANITEMX STRUCTURE BAPI_INVOICE_PLAN_ITEMX OPTIONAL
Regards. -
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 -
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 -
Service PO creation Using BAPI_PO_CREATE1
Hi Friends,
Can any body tell me how to create a service PO based on the existing service Agreement by using BAPI_PO_CREATE1 with sample code.
Thanks,
KamleshHi Friends,
Can any body tell me how to create a service PO based on the existing service Agreement by using BAPI_PO_CREATE1 with sample code.
Thanks,
Kamlesh -
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. -
Service PO for Multiple Acct Assig is not created using BAPI_PO_CREATE1
Hi,
Im unable to create the Service po with multiple acct assiignment 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.
w_src-vrtkz = '2'. "Added
IF NOT w_src-vrtkz IS INITIAL.
w_poitem-distrib = w_src-vrtkz.
ENDIF.
Package No
IF w_src-srv_line_no EQ '2'.
w_poitem-pckg_no = 0000000001. "Assign dummy package no "w_src-packno. "Package no
ELSEIF w_src-srv_line_no EQ '3'.
w_poitem-pckg_no = 0000000004. "Assign dummy package 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'.
w_poitemx-pckg_no = 'X'.
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.
w_poschedule-SCHED_LINE = w_src-
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_poschedule-SCHED_LINE = 'X'.
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-quantity = w_src-menge. "added
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'.
w_poaccountx-cmmt_item = 'X'.
APPEND w_poaccountx TO i_poaccountx.
CLEAR w_poaccountx.
Extension for ZZSub
IF NOT w_src-zzsub IS INITIAL.
w_extensionin-structure = 'BAPI_TE_MEPOACCOUNTING'.
w_extensionin-valuepart1+0(5) = w_src-ebelp.
w_extensionin-valuepart1+5(2) = '01'.
w_extensionin-valuepart1+28(5) = w_src-zzsub.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
w_extensionin-structure = 'BAPI_TE_MEPOACCOUNTINGX'.
w_extensionin-valuepart1+0(5) = w_src-ebelp.
w_extensionin-valuepart1+5(2) = '01'.
w_extensionin-valuepart1+11(1) = 'X'.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
ENDIF.
Extension to add Expense Type only
IF NOT w_src-zzexptype IS INITIAL.
w_extensionin-structure = 'BAPI_TE_MEPOHEADER'.
w_extensionin-valuepart1+10(4) = w_src-zzexptype.
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.
ENDIF.
EXPORT i_extensionin[] TO MEMORY ID 'SUB'.
PO Services( One Line Iem)
IF w_src-srv_line_no EQ '2'.
w_poservices-pckg_no = 0000000001. "w_src-packno. "(assign package no as a dummy number)
w_poservices-line_no = 0000000001. "w_src-srv_line_no. "Line item
w_poservices-outl_ind = 'X'.
w_poservices-subpckg_no = 0000000003. "w_src-sub_packno. "(Dummy No.) "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
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
PO Services(Second Line Item )
w_poservices-pckg_no = 0000000003. "w_src-sub_packno. "(Dummy No.) "Sub package no
w_poservices-line_no = 0000000002.
w_poservices-ext_line = w_src-extrow. "External line
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-gr_price = w_src-brtwr. "GR Price
w_poservices-short_text = w_src-sh_text1. "Service Short Text
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 = w_src-zekkn. "'01'.
IF w_src-vproz IS INITIAL.
w_posrvacc-percentage = '100.0'.
ENDIF.
w_posrvacc-serial_no = '01'.
w_posrvacc-quantity = w_src-srqty. "Service Quantity
APPEND w_posrvacc TO i_posrvacc.
CLEAR w_posrvacc.
ELSEIF w_src-srv_line_no EQ '3'.
PO Services
if w_src-srv_line_no EQ '2'.
w_poservices-pckg_no = 0000000004. "(assign package no as a dummy number)
w_poservices-line_no = 0000000001. "Line item
w_poservices-outl_ind = 'X'.
w_poservices-subpckg_no = 0000000005. "(Dummy No.) "Sub package no
w_poservices-from_line = '1'.
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
w_poservices-pckg_no = 0000000005. "w_src-sub_packno. "(Dummy No.) "Sub package no
w_poservices-line_no = 0000000002.
w_poservices-ext_line = w_src-extrow. "External line
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-gr_price = w_src-brtwr. "GR Price
w_poservices-short_text = w_src-sh_text1. "Service Short Text
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
endif.
if w_src-srv_line_no EQ '3'.
w_poservices-pckg_no = 0000000005. "w_src-sub_packno. "(Dummy No.) "Sub package no
w_poservices-line_no = 0000000003.
w_poservices-ext_line = w_src-extrow. "External line
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-gr_price = w_src-brtwr. "GR Price
w_poservices-short_text = w_src-sh_text1. "Service Short Text
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
endif.
PO Service Access values
if w_src-srv_line_no EQ '2'.
w_posrvacc-pckg_no = 0000000005. "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_src-zekkn.
w_posrvacc-quantity = w_src-srqty. "Service Quantity
APPEND w_posrvacc TO i_posrvacc.
CLEAR w_posrvacc.
endif.
if w_src-srv_line_no EQ '3'.
w_posrvacc-pckg_no = 0000000005. "w_src-sub_packno. "Sub package no
w_posrvacc-line_no = 0000000003. "w_src-srv_line_no. "Line item
w_posrvacc-serno_line = '01'.
w_posrvacc-percentage = '100.0'.
w_posrvacc-serial_no = '02'. "w_src-zekkn. "'01'.
w_posrvacc-quantity = w_src-srqty. "Service Quantity
APPEND w_posrvacc TO i_posrvacc.
CLEAR w_posrvacc.
endif.
ENDIF.
ENDIF.
***Create a NEW PO
Call BAPI
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = w_poheader
poheaderx = w_poheaderx
TESTRUN = ' '
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.it is solved
-
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 -
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 -
Strange Behavior of program while using BAPI_PO_CREATE1
Hello SAP GURUs,
I've created an Upload Program using BAPI_PO_CREATE1 for Mass Service PO Creation.
When I execute the program and Specify the File for uploading, It Gives me errors as
E BAPI 1 No instance of object type PurchaseOrder has been created. External reference:
E MEPO 0 Purchase order still contains faulty items
E 6 436 In case of account assignment, please enter acc. assignment data for item
But when I come back to Selection Screen of the Program and specify the SAME FILE AGAIN and Execute,
The Program runs successfully and generates the PO number.
I have never seen such strange behavior in any BAPIs before.
Pls help..PERFORM refresh_tables.
PERFORM fill_tables.
END-OF-SELECTION.
Display the Summary as an ALV Grid Display
IF NOT ig_mymssg[] IS INITIAL.
PERFORM display_basic_list . "Grid Display
ELSE.
MESSAGE s000 WITH 'No data exists'(051).
STOP.
ENDIF.
*& Form refresh_tables
text
--> p1 text
<-- p2 text
FORM refresh_tables .
REFRESH: ig_fieldcat,
ig_mymssg,
poitem,
poitemx,
poaccount,
poaccountx,
poservices,
ig_return.
wt_itab, record, record2 .
ENDFORM. " refresh_tables
*& Form fill_tables
text
--> p1 text
<-- p2 text
FORM fill_tables .
record2[] = record[].
record3[] = record[].
DELETE ADJACENT DUPLICATES FROM record COMPARING id_no.
DELETE ADJACENT DUPLICATES FROM record2 COMPARING id_no po_item.
SELECT MAX( packno ) FROM esll INTO wrk_packno.
LOOP AT record.
CLEAR : poheader, poheaderx, wa_poitem, wa_poitemx, wa_poservices, wa_poaccount, wa_poaccountx, wa_poschedulex, wa_poschedule.
REFRESH: poitem, poitemx, poaccount, poaccountx, poservices, ig_return, posrvaccessvalues, poschedule, poschedulex.
PERFORM po_header.
LOOP AT record2 WHERE id_no = record-id_no.
wrk_packno = wrk_packno + 1.
PERFORM po_item.
PERFORM po_scheudle.
PERFORM acc_assignment.
PERFORM po_services.
ENDLOOP.
PERFORM create_po.
ENDLOOP.
ENDFORM. " fill_tables
*& Form display_basic_list
text
--> p1 text
<-- p2 text
FORM display_basic_list .
g_repid = sy-repid.
PERFORM f2000_fieldcat_init .
PERFORM display_alv_grid_1.
ENDFORM. " display_basic_list
*& Form f2000_fieldcat_init
text
--> p1 text
<-- p2 text
FORM f2000_fieldcat_init .
REFRESH ig_fieldcat.
PERFORM fill_fields_of_fieldcatalog USING 'IG_MYMSSG'
'STATUS'
c_x
'Status'
'10'.
PERFORM fill_fields_of_fieldcatalog USING 'IG_MYMSSG'
'RECORD'
c_x
'Record'
'20'.
PERFORM fill_fields_of_fieldcatalog USING 'IG_MYMSSG'
'ERRMSG'
'Message'
'100'.
ENDFORM. " f2000_fieldcat_init
*& Form display_alv_grid_1
text
--> p1 text
<-- p2 text
FORM display_alv_grid_1 .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_structure_name = 'IG_MYMSSG'
i_grid_title = 'LOG'
is_layout = wg_layout
it_fieldcat = ig_fieldcat[]
i_save = c_save
TABLES
t_outtab = ig_mymssg
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. " display_alv_grid_1
*& Form fill_fields_of_fieldcatalog
text
-->P_0626 text
-->P_0627 text
-->P_C_X text
-->P_0629 text
-->P_0630 text
FORM fill_fields_of_fieldcatalog USING p_tabname TYPE slis_tabname
p_field TYPE slis_fieldname
p_key TYPE c
p_name
len.
To fill in the fields of the table fieldcatalog depending on the field
CLEAR wg_fieldcat.
wg_fieldcat-fieldname = p_field. " The field name and the table
wg_fieldcat-tabname = p_tabname.. " name are the two minimum req
wg_fieldcat-key = p_key. " Specifies the column as a key
wg_fieldcat-seltext_l = p_name. " Column Header
wg_fieldcat-outputlen = len.
APPEND wg_fieldcat TO ig_fieldcat.
ENDFORM. " fill_fields_of_fieldcatalog
*& Form create_po
text
--> p1 text
<-- p2 text
FORM create_po .
CLEAR : wg_return.
REFRESH : ig_return.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = poheader
poheaderx = poheaderx
IMPORTING
exppurchaseorder = po_no
TABLES
return = ig_return
poitem = poitem
poitemx = poitemx
poschedule = poschedule
poschedulex = poschedulex
poaccount = poaccount
poaccountx = poaccountx
poservices = poservices
posrvaccessvalues = posrvaccessvalues.
SORT ig_return BY type.
READ TABLE ig_return INTO wg_return WITH KEY type = 'S'.
IF sy-subrc EQ 0.
CLEAR : wg_return.
REFRESH : ig_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
CLEAR wg_errmsg.
WRITE icon_green_light AS ICON TO wg_errmsg-status.
CONCATENATE record-id_no po_no INTO wg_errmsg-record SEPARATED BY '/'.
wg_errmsg-record = po_no.
wg_errmsg-errmsg = 'PO created'.
APPEND wg_errmsg TO ig_mymssg.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
READ TABLE ig_return INTO wg_return WITH KEY type = 'E' TRANSPORTING message.
CLEAR wg_errmsg.
WRITE icon_red_light AS ICON TO wg_errmsg-status.
wg_errmsg-record = record-id_no.
wg_errmsg-errmsg = wg_return-message.
APPEND wg_errmsg TO ig_mymssg.
ENDIF.
ENDFORM. " create_po
*& Form po_header
text
--> p1 text
<-- p2 text
FORM po_header .
poheader-comp_code = record-comp_code.
poheader-doc_type = record-doc_type.
poheader-vendor = record-vendor.
poheader-purch_org = 'SERV'.
poheader-pur_group = record-pur_group.
poheader-currency = 'INR'.
poheaderx-comp_code = 'X'.
poheaderx-doc_type = 'X'.
poheaderx-vendor = 'X'.
poheaderx-purch_org = 'X'.
poheaderx-pur_group = 'X'.
poheaderx-currency = 'X'.
ENDFORM. " po_header
*& Form po_item
text
--> p1 text
<-- p2 text
FORM po_item .
DATA : days TYPE num2.
DATA : final_dt TYPE datum.
DATA : is_ok TYPE boole_d.
DATA : msg_hndlr TYPE REF TO if_hrpa_message_handler.
days = 20.
CALL FUNCTION 'HR_ECM_ADD_PERIOD_TO_DATE'
EXPORTING
orig_date = sy-datum
num_days = days
signum = '+'
message_handler = msg_hndlr
IMPORTING
result_date = final_dt
is_ok = is_ok.
CLEAR: wa_poitem,wa_poitemx.
wa_poitem-po_item = record2-po_item.
wa_poitem-short_text = record2-short_text.
wa_poitem-plant = record2-plant.
wa_poitem-matl_group = 'S001'.
wa_poitem-tax_code = 'LA'.
wa_poitem-item_cat = item_cat.
wa_poitem-pckg_no = wrk_packno.
wa_poitem-acctasscat = acctasscat.
wa_poitem-gr_to_date = final_dt.
APPEND wa_poitem TO poitem.
wa_poitemx-po_item = record2-po_item.
wa_poitemx-po_itemx = 'X'.
wa_poitemx-short_text = 'X'.
wa_poitemx-plant = 'X'.
wa_poitemx-tax_code = 'X'.
wa_poitemx-item_cat = 'X'.
wa_poitemx-acctasscat = 'X'.
wa_poitemx-pckg_no = 'X'.
wa_poitemx-matl_group = 'X'.
wa_poitem-gr_to_date = 'X'.
APPEND wa_poitemx TO poitemx.
ENDFORM. " po_item
*& Form PO_SERVICES
text
--> p1 text
<-- p2 text
FORM po_services .
CLEAR: wa_poservices, wa_posrvaccessvalues.
wa_poservices-pckg_no = wrk_packno.
wa_poservices-line_no = '0000000001'.
wa_poservices-outl_ind = 'X'.
wa_poservices-subpckg_no = wa_poservices-pckg_no + 1.
wa_poservices-from_line = '000001'.
APPEND wa_poservices TO poservices.
CLEAR wa_poservices.
wrk_packno = wrk_packno + 1.
wa_poservices-pckg_no = wrk_packno.
wa_poservices-line_no = '0000000002'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = record2-service
IMPORTING
output = record2-service.
wa_poservices-ext_line = '0000000010'.
wa_poservices-service = record2-service.
wa_poservices-quantity = record2-quantity.
wa_poservices-gr_price = record2-gr_price.
wa_posrvaccessvalues-pckg_no = wrk_packno.
wa_posrvaccessvalues-line_no = '0000000002'.
wa_posrvaccessvalues-serial_no = '01'.
wa_posrvaccessvalues-serno_line = '01'.
wa_posrvaccessvalues-quantity = record2-quantity.
wa_posrvaccessvalues-net_value = record2-gr_price.
APPEND wa_poservices TO poservices.
APPEND wa_posrvaccessvalues TO posrvaccessvalues.
ENDFORM. " PO_SERVICES
*& Form ACC_ASSIGNMENT
text
--> p1 text
<-- p2 text
FORM acc_assignment .
DATA : tmp_gl LIKE bapimepoaccount-gl_account.
tmp_gl = '400265'.
CLEAR : wa_poaccount, wa_poaccountx.
wa_poaccount-po_item = record2-po_item.
wa_poaccount-serial_no = '01'.
wa_poaccount-co_area = '1000'.
wa_poaccount-quantity = record2-quantity.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = tmp_gl
IMPORTING
output = wa_poaccount-gl_account.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = record2-orderid
IMPORTING
output = wa_poaccount-orderid.
APPEND wa_poaccount TO poaccount.
wa_poaccountx-po_item = record2-po_item.
wa_poaccountx-serial_no = '01'.
wa_poaccountx-co_area = 'X'.
wa_poaccountx-quantity = 'X'.
wa_poaccountx-gl_account = 'X'.
wa_poaccountx-orderid = 'X'.
APPEND wa_poaccountx TO poaccountx.
ENDFORM. " ACC_ASSIGNMENT
*& Form PO_SCHEUDLE
text
--> p1 text
<-- p2 text
FORM po_scheudle .
CLEAR : wa_poschedule, wa_poschedulex.
wa_poschedule-po_item = record2-po_item.
wa_poschedule-sched_line = '0001'.
wa_poschedule-del_datcat_ext = 'D'.
wa_poschedule-delivery_date = sy-datum.
wa_poschedule-quantity = record2-quantity.
APPEND wa_poschedule TO poschedule.
wa_poschedulex-po_item = record2-po_item.
wa_poschedulex-sched_line = '0001'.
wa_poschedulex-po_itemx = 'X'.
wa_poschedulex-sched_linex = 'X'.
wa_poschedulex-del_datcat_ext = 'X'
wa_poschedulex-delivery_date = 'X'.
wa_poschedulex-quantity = 'X'.
APPEND wa_poschedulex TO poschedulex.
ENDFORM. " PO_SCHEUDLE -
Proble in Creating Multiple Item PO using BAPI_PO_CREATE1
Hi All..
I am creating PO using BAPI_PO_CREATE1. I have successfully created with single line item but when i tried to create with multiple line items it gives me error in partners(vendors) which i have used in table POPARTNER.
One more thing, I have created using BAPI with same partner roles with single line item but it gives me error in 2 or more line items.
So, Can Anybody help me in this..
Regards,
Meet Gohel
[email protected]Hi ,
U can use this code n check
*& Report ZPOBAPITRIAL
REPORT ZPOBAPITRIAL.
*DATA DECLARATION
CONSTANTS : C_X VALUE 'X'.
*Structures to hold PO header data
DATA : HEADER LIKE BAPIMEPOHEADER ,
HEADERX LIKE BAPIMEPOHEADERX .
*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.
data : w_header(40) value 'PO Header'.
DATA : it_item type standard table of BAPIMEPOITEM.
DATA : wa_item like BAPIMEPOITEM occurs 0 with header line.
DATA : it_itemx type standard table of BAPIMEPOITEMX.
DATA : wa_itemx like BAPIMEPOITEMX occurs 0 with header line.
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 '0103' ,
doctyp like HEADER-DOC_TYPE default 'NB' ,
item_int like header-item_intvl default '10' ,
cdate like HEADER-CREAT_DATE default sy-datum ,
vendor like HEADER-VENDOR default '0000500001',
pmnttrms like header-pmnttrms default '0007' ,
pur_org like HEADER-PURCH_ORG default '9000' ,
pur_grp like HEADER-PUR_GROUP default '401' ,
currency like header-currency default 'INR' .
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 '10',
material like ITEM-MATERIAL default '000000000300000014' ,
plant like ITEM-PLANT default '7640' ,
quantity like ITEM-QUANTITY default 10.
selection-screen end of block b2.
START-OF-SELECTION.
*DATA POPULATION
ws_langu = sy-langu. "Language variable
*POPULATE HEADER DATA FOR PO
HEADER-COMP_CODE = company .
HEADER-DOC_TYPE = doctyp .
*HEADER-CREAT_DATE = cdate .
header-item_intvl = item_int .
HEADER-VENDOR = vendor .
HEADER-LANGU = ws_langu .
header-pmnttrms = pmnttrms .
HEADER-PURCH_ORG = pur_org .
HEADER-PUR_GROUP = pur_grp .
header-currency = currency .
*POPULATE HEADER FLAG.
HEADERX-comp_code = c_x.
HEADERX-doc_type = c_x.
*HEADERX-creat_date = c_x.
headerx-item_intvl = c_x .
HEADERX-vendor = c_x.
HEADERX-langu = c_x.
headerx-pmnttrms = c_x .
HEADERX-purch_org = c_x.
HEADERX-pur_group = c_x.
*HEADERX-doc_date = c_x.
*POPULATE ITEM DATA.
wa_ITEM-PO_ITEM = item_num.
wa_ITEM-MATERIAL = material.
wa_ITEM-PLANT = plant.
wa_ITEM-QUANTITY = quantity.
append wa_item to it_item.
wa_ITEM-PO_ITEM = '20'.
wa_ITEM-MATERIAL = '000000000300000020'.
wa_ITEM-PLANT = plant.
wa_ITEM-QUANTITY = quantity.
append wa_item to it_item.
*APPEND ITEM.
*POPULATE ITEM FLAG TABLE
wa_ITEMX-PO_ITEM = item_num.
wa_itEMX-MATERIAL = C_X.
wa_ITEMX-PLANT = C_X .
wa_ITEMX-STGE_LOC = C_X .
wa_ITEMX-QUANTITY = C_X .
wa_ITEMX-TAX_CODE = C_X .
wa_ITEMX-ITEM_CAT = C_X .
wa_ITEMX-ACCTASSCAT = C_X .
append wa_itemx to it_itemx.
*APPEND ITEMX.
wa_ITEMX-PO_ITEM = '20'.
wa_itEMX-MATERIAL = C_X.
wa_ITEMX-PLANT = C_X .
wa_ITEMX-STGE_LOC = C_X .
wa_ITEMX-QUANTITY = C_X .
wa_ITEMX-TAX_CODE = C_X .
wa_ITEMX-ITEM_CAT = C_X .
wa_ITEMX-ACCTASSCAT = C_X .
append wa_itemx to it_itemx.
*BAPI CALL
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = HEADER
POHEADERX = HEADERX
POADDRVENDOR =
TESTRUN =
IMPORTING
EXPPURCHASEORDER =
EXPHEADER =
EXPPOEXPIMPHEADER =
TABLES
RETURN = RETURN
POITEM = it_ITEM
POITEMX = it_ITEMX.
*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: /001 return-type,
/001 return-message.
ENDLOOP.
award points if helpfull -
Creating po using bapi_po_create1
i am using bapi_po_create1 to create po's..po number and item(posnr) numbers are external numbers..so we have External order no range configured based on order type...
Do i need create external number ranges for posnr too..?
For some reason even if pass posnr = '9999', it's creating po's with '10','20'..etc.. is there a flag i need to set in BAPIMEPOITEM???
Thanks
Siva.Hi,
Check the sample code, and Observe the Bold Code. may be you missed that.
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.
<b>item-po_item = item_num.</b>
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
<b> itemx-po_item = item_num.
itemx-po_itemx = c_x.</b>
*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.
Check the Bold code.
Regards
vijay -
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. -
Creating Service PO using BAPI_PO_CREATE1
Hi gurus,
I am trying to create a PO with service lines using BAPI_PO_CREATE1 but am getting the following errror even though i have passed values to the structures POSERVICES POSRVACCESSVALUES and POACCOUNT along with item and header details:
Please maintain services or limits
Please suggest what are the basic details that need to be passed to the structures for creating a PO with service lines.Hi,
You need to use Package Number to link the services with the item. Check the tables like ESKN to know how the linking works with your existing data.
There are lot of posts related to this. Please do a search to get detailed answers. Thanks for your patience!!
Regards,
Yogesh
Maybe you are looking for
-
Change in Item category in Sales order
Hi, We have one requirement to change the quantity in the Billing document our requirement goes like this, Order was created with 10 Qty and PGI also done with 10qty, But physically customer receives 9 qty and Billing done with 10qty. Now customers w
-
Dear Experts , I need to do a third party service order . But in the system i can either use itemcategory D or S. Also I cannot define a new Item category Can anyone pls tell me how 2 do it ? regards anis
-
Hello. I have an iphone 3gs 8gb factory unlocked. Currently its running on ios 5.0.1 and I am trying to update it ios 5.1.1 but its not updating. The itunes downloads the ios 5.1.1and gives back unknown error(3194). Please help.
-
LMS 4.2 fails Device Package Update
Hallo, Device Package Update fails with this error: Error while downloading package information from Cisco.com for the selected products. See the d:/CSCOpx/log/psu.log file for details. PSU.log shows: ERROR [RemoteRepSync : downloadPsuHeadersAsXml]
-
I have an Airport Express hooked up to wirelessly extend the network of my Airport Extreme and also to act as a wireless bridge for my Mac Pro. My problem is that when I go in to add a device (blu-ray player, wii, etc.) two networks of the same name