BAPI_PO_CREATE1 error
Hi all,
While creating po through bapi_po_create1 i am getting error In MM ChapterID is not created for 00010.But since this is non-exciseable item i guess chapter ID is not maintained.So please tell me solution to avoid this error in bapi.
Regards.
Akanksha.
I ran a search on the function module name here on SDN, got a couple hits. Here are some links to ones that may help you out.
BAPI_PO_CREATE1 FAILURE exception raised
An example program.
BAPI_PO_CREATE1 example
May not hurt to check OSS, see if there is anything relevant.
Regards,
Rich Heilman
Similar Messages
-
Service purchase order bapi_po_create1 error: maintain services or limits
I am trying to create service Purchase Order.
I am getting error: 'Purchase order still contains faulty items, Please maintain services or limits'.
Struggling to solve this. Can anybody shed some light on this to solve.
I would appreciate your any help.
thanks.
The following is the code I am working.
REPORT ZAUTO_PO_CREATE1 .
constants: c_x value 'X'.
DATA: i_poitem TYPE STANDARD TABLE OF bapimepoitem,
i_poitemx TYPE STANDARD TABLE OF bapimepoitemx,
i_poitem_sch TYPE STANDARD TABLE OF bapimeposchedule,
i_poitem_schx TYPE STANDARD TABLE OF bapimeposchedulx,
i_acct_*** TYPE STANDARD TABLE OF bapimepoaccount,
i_polimits type standard table of BAPIESUHC,
i_acct_assx TYPE STANDARD TABLE OF bapimepoaccountx,
i_services TYPE STANDARD TABLE OF bapiesllc ,
i_srvacc TYPE STANDARD TABLE OF bapiesklc,
i_return TYPE STANDARD TABLE OF bapiret2,
wa_header TYPE bapimepoheader,
wa_headerx TYPE bapimepoheaderx,
wa_poitem TYPE bapimepoitem,
wa_poitemx TYPE bapimepoitemx,
wa_poitem_sch TYPE bapimeposchedule,
wa_poitem_schx TYPE bapimeposchedulx,
wa_acct_*** TYPE bapimepoaccount,
wa_acct_assx TYPE bapimepoaccountx,
wa_services TYPE bapiesllc,
wa_srvacc TYPE bapiesklc,
wa_return TYPE bapiret2,
wa_BAPIESUHC type BAPIESUHC,
ws_po TYPE bapimepoheader-po_number.
data: wa_it_xlikp like line of it_xlikp.
loop at it_xlikp into wa_it_xlikp.
endloop.
data: wa_it_xlips like line of it_xlips.
loop at it_xlips into wa_it_xlips.
endloop.
data: wa_it_xvbpa like line of it_xvbpa.
loop at it_xvbpa into wa_it_xvbpa.
if wa_it_xvbpa-parvw = 'SP'.
wa_header-vendor = wa_it_xvbpa-lifnr.
endif.
endloop.
*data: it_komp type table of komp,
wa_it_komp like line of it_komp.
loop at it_komp into wa_it_komp.
endloop.
service PO is only for YLF delivery type.
if wa_it_xlikp-lfart ne 'YLF'.
exit.
endif.
shipping conditions.
*case wa_it_xlikp-vsbed.
*when '3P' or 'CP'.
*exit.
*endcase.
wa_header-doc_type = 'YB'.
wa_header-creat_date = sy-datum.
wa_header-created_by = sy-uname.
wa_header-vendor = '0005000000'.
wa_header-comp_code = 'OB01'.
wa_header-purch_org = 'OB01'.
wa_header-pur_group = 'OB9'.
wa_header-CURRENCY = 'USD'.
wa_header-vper_start = '20061118'.
wa_header-vper_end = '20061126'.
wa_header-ref_1 = 1.
wa_header-incoterms1 = 'AOS'.
wa_header-incoterms2 = ''.
wa_header-our_ref = 'N'.
wa_headerx-comp_code = c_x.
wa_headerx-doc_type = c_x.
wa_headerx-creat_date = c_x.
wa_headerx-created_by = c_x.
wa_headerx-vendor = c_x.
wa_headerx-purch_org = c_x.
wa_headerx-pur_group = c_x.
wa_headerx-vper_start = c_x.
wa_headerx-vper_end = c_x.
wa_headerx-ref_1 = c_x.
wa_headerx-incoterms1 = c_x.
wa_headerx-incoterms2 = c_x.
wa_headerx-our_ref = c_x.
wa_poitem-po_item = '00010'.
wa_poitem-short_text = 'Automatic generation - Freight'.
wa_poitem-plant = '0089'.
wa_poitem-quantity = '1'.
*wa_poitem-MATERIAL = '10'.
wa_poitem-NET_PRICE = '23.00'.
wa_poitem-po_unit = 'ACT'.
wa_poitem-item_cat = 'D'.
wa_poitem-acctasscat = 'K'.
*wa_poitem-matl_group = 'S1'.
*wa_poitem-pckg_no = '10'.
APPEND wa_poitem TO i_poitem .
wa_poitemx-po_item = '00010'.
*wa_poitemx-po_itemx = c_x.
wa_poitemx-short_text = c_x.
wa_poitemx-plant = c_x.
wa_poitemx-quantity = c_x.
wa_poitemx-net_price = c_x.
wa_poitemx-po_unit = c_x.
wa_poitemx-tax_code = c_x.
wa_poitemx-item_cat = c_x.
wa_poitemx-acctasscat = c_x.
wa_poitemx-matl_group = c_x.
wa_poitemx-pckg_no = c_x.
APPEND wa_poitemx TO i_poitemx.
wa_poitem_sch-po_item = wa_poitem-po_item .
**wa_poitem_sch-delivery_date = ''.
APPEND wa_poitem_sch TO i_poitem_sch.
wa_poitem_schx-po_item = wa_poitem-po_item.
wa_poitem_schx-po_itemx = c_x.
wa_poitem_schx-delivery_date = c_x.
APPEND wa_poitem_schx TO i_poitem_schx.
wa_acct_***-po_item = wa_poitem-po_item.
wa_acct_***-serial_no = 01.
wa_acct_***-gl_account = '5210'.
wa_acct_***-co_area = 'OB01'.
wa_acct_***-costcenter = '36089'.
wa_acct_***-funds_ctr = 'DUMMY'.
APPEND wa_acct_*** TO i_acct_***.
wa_acct_assx-po_item = wa_poitem-po_item.
wa_acct_assx-serial_no = 01.
wa_acct_assx-po_itemx = c_x.
wa_acct_assx-serial_nox = c_x.
wa_acct_assx-gl_account = c_x.
wa_acct_assx-co_area = c_x.
wa_acct_assx-costcenter = c_x.
wa_acct_***-funds_ctr = c_x.
APPEND wa_acct_assx TO i_acct_assx.
*services/ limits
*wa_BAPIESUHC-limit = '3000.00'.
wa_BAPIESUHC-EXP_VALUE = '300.00'.
wa_BAPIESUHC-no_limit = 'X'.
*wa_BAPIESUHC-NO_FRLIMIT = 'X'.
append wa_bapiesuhc to i_polimits.
wa_services-pckg_no = '20'.
wa_services-line_no = '2'.
wa_services-service = '0005000000'.
wa_services-subpckg_no = '10'.
wa_services-quantity = '100'.
wa_services-gr_price = '100'.
wa_services-userf1_txt = 'TEXT'.
wa_services-from_line = '1'.
wa_services-to_line = '2'.
APPEND wa_services TO i_services.
wa_srvacc-pckg_no = '20'.
wa_srvacc-line_no = '1'.
wa_srvacc-serno_line = '02'.
wa_srvacc-serial_no = '02'.
wa_srvacc-percentage = '100'.
APPEND wa_srvacc TO i_srvacc.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = wa_header
poheaderx = wa_headerx
POADDRVENDOR =
TESTRUN =
MEMORY_UNCOMPLETE =
MEMORY_COMPLETE =
POEXPIMPHEADER =
POEXPIMPHEADERX =
VERSIONS =
NO_MESSAGING =
NO_MESSAGE_REQ =
no_authority = c_x
no_price_from_po = c_x
IMPORTING
exppurchaseorder = ws_po
EXPHEADER =
EXPPOEXPIMPHEADER =
TABLES
return = i_return
poitem = i_poitem
poitemx = i_poitemx
POADDRDELIVERY =
poschedule = i_poitem_sch
poschedulex = i_poitem_schx
poaccount = i_acct_***
*POACCOUNTPROFITSEGMENT =
poaccountx = i_acct_assx
POCONDHEADER =
POCONDHEADERX =
POCOND =
POCONDX =
POLIMITS = i_polimits
POCONTRACTLIMITS =
poservices = i_services
posrvaccessvalues = i_srvacc
POSERVICESTEXT =
EXTENSIONIN =
EXTENSIONOUT =
POEXPIMPITEM =
POEXPIMPITEMX =
POTEXTHEADER =
POTEXTITEM =
ALLVERSIONS =
POPARTNER =
***confirms the document creation by database commit.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN =
LOOP AT i_return INTO wa_return.
WRITE wa_return-message.
ENDLOOP.Fill this tables:
GT_POSRVACCESSVALUES TYPE STANDARD TABLE OF BAPIESKLC,
GT_POCONTRACTLIMITS TYPE STANDARD TABLE OF BAPIESUCC,
Glauco -
Bapi_po_create1 error--service PO
We are upgradeing to ECC6 and we have a program that is currently working in our old system using bapi_po_create1 to create service PO's.
We are getting an account assignment error in the ECC6system, "In case of account assignment, please enter acc. assignment data for item"
Entering manually works but I can't find out what has changed to correct the bapi.
Any ideas or does someone have an example of a service entry.
Thanks
JulieHi Julie,
please check the following:
The package number should be set according to FAQ note 499626,
question 8.
POITEMX: if there are also fields filled with an X, which were NOT
filled in the POITEM structure, please remove those X entries.
If a field in POITEMX is marked 'X', it means that the corresponding
field in POITEM has a value.
Similar is the case for POACCOUNT and POACCOUNTX.
Please check the FAQ note 420332 about how to fill the data structure correctly for service POs. In most of the cases the error message 06 436 disappeared after the data structures were set up correctly.
Please check / and if needed implement also the note 1236355
Regards,
Edit -
BAPI_PO_CREATE1 Error related to Fiscal year variant
Hi,
I am working on open PO tranfer program.
initialy i have created one PO from ME21n tcode, and its worked out fine
now using same data when i creating PO using BAPI -> BAPI_PO_CREATE1 then i am getting following error
E No instance of object type PurchaseOrder has been created. External reference:
E Purchase order still contains faulty items
W Purchase order date is in the past
I Order unit ****** cannot be used
I Date / / period is not valid
E For the Z6 fiscal year variant, no period is defined for / /
I Net price for item 00010 adopted from last document
Wondering why error "For the Z6 fiscal year variant, no period is defined for / / " not triggered in ME21n ?
From excel i am passing below item data:
1. wa_data-ebelp
2. wa_data-ematn
3. wa_data-menge
4. wa_data-meins
5. wa_data-netpr
Please look into below code...
LOOP AT it_data INTO wa_data WHERE ebeln = wa_header-ebeln.
* PO Item data
wa_poitem-po_item = wa_data-ebelp.
wa_poitem-short_text = wa_data-txz01.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = wa_data-ematn
IMPORTING
OUTPUT = wa_poitem-material
* EXCEPTIONS
* LENGTH_ERROR = 1
* OTHERS = 2
wa_poitem-plant = 'U001'.
wa_poitem-stge_loc = 'M001'.
wa_poitem-quantity = wa_data-menge.
wa_poitem-po_unit = wa_data-meins. "001
wa_poitem-net_price = wa_data-netpr. "001
wa_poitem-price_unit = wa_data-peinh. "001
wa_poitem-prnt_price = c_x.
wa_poitem-order_reason = 'PB'.
wa_poitem-vend_mat = wa_data-idnlf. "Vend Mat num
wa_poitem-period_ind_expiration_date = 'D'.
APPEND wa_poitem TO it_poitem.
wa_poitemx-po_item = wa_data-ebelp.
wa_poitemx-short_text = c_x.
wa_poitemx-material = c_x.
wa_poitemx-plant = c_x.
wa_poitemx-stge_loc = c_x.
wa_poitemx-quantity = c_x.
wa_poitemx-po_unit = c_x. "001
wa_poitemx-net_price = c_x. "001
wa_poitemx-price_unit = c_x. "001
wa_poitemx-prnt_price = c_x.
wa_poitemx-order_reason = c_x.
wa_poitemx-vend_mat = c_x.
wa_poitemx-period_ind_expiration_date = c_x.
APPEND wa_poitemx TO it_poitemx.
* PO Delivery schedule data
wa_poschedule-po_item = wa_data-ebelp.
wa_poschedule-delivery_date = wa_data-eindt.
APPEND wa_poschedule TO it_poschedule.
wa_poschedulex-po_item = wa_data-ebelp.
wa_poschedulex-delivery_date = c_x.
APPEND wa_poschedulex TO it_poschedulex.
ENDLOOP.
Please suggest what went wrong?here is the sample code
this my sample code to create PO with BAPI,
DATA : lwa_bapimepoheader TYPE bapimepoheader
,lwa_bapimepoheaderx TYPE bapimepoheaderx
,li_bapimepoitem TYPE STANDARD TABLE OF bapimepoitem
,lwa_bapimepoitem TYPE bapimepoitem
,li_bapimepoitemx TYPE STANDARD TABLE OF bapimepoitemx
,lwa_bapimepoitemx TYPE bapimepoitemx
,li_conditions TYPE STANDARD TABLE OF komv
,li_return TYPE STANDARD TABLE OF bapiret2
, n TYPE c
PARAMETERS: p1 TYPE c AS CHECKBOX.
IF p1 = 'X'.
lwa_bapimepoheader-doc_type = 'NB'.
lwa_bapimepoheader-purch_org = 'NA00'.
lwa_bapimepoheader-pur_group = 'C02'.
lwa_bapimepoheaderx-doc_type = 'X'.
lwa_bapimepoheaderx-purch_org = 'X'.
lwa_bapimepoheaderx-pur_group = 'X'.
lwa_bapimepoitem-po_item = '10'.
lwa_bapimepoitem-material = '000000000000020111'.
lwa_bapimepoitem-plant = 'CA01'.
lwa_bapimepoitem-vend_mat = '1000'.
lwa_bapimepoitem-quantity = '10'.
lwa_bapimepoitem-orderpr_un = 'M'.
lwa_bapimepoitem-no_more_gr = 'K'.
lwa_bapimepoitem-agreement = '4600000095'.
lwa_bapimepoitem-agmt_item = '10'.
lwa_bapimepoitem-pricedate = 'X'.
lwa_bapimepoitem-price_date = '20071030'.
lwa_bapimepoitem-no_rounding = 'X'.
APPEND lwa_bapimepoitem TO li_bapimepoitem.
lwa_bapimepoitemx-po_item = '10'.
lwa_bapimepoitemx-po_itemx = 'X'.
lwa_bapimepoitemx-po_itemx = 'X'.
lwa_bapimepoitemx-material = 'X'.
lwa_bapimepoitemx-plant = 'X'.
lwa_bapimepoitemx-quantity = 'X'.
lwa_bapimepoitemx-po_unit = 'X'.
lwa_bapimepoitemx-orderpr_un = 'X'.
lwa_bapimepoitemx-acctasscat = 'X'.
lwa_bapimepoitemx-agreement = 'X'.
lwa_bapimepoitemx-agmt_item = 'X'.
lwa_bapimepoitemx-pricedate = 'X'.
lwa_bapimepoitemx-price_date = 'X'.
lwa_bapimepoitemx-preq_no = 'X'.
lwa_bapimepoitemx-preq_item = 'X'.
lwa_bapimepoitemx-no_rounding = 'X'.
APPEND lwa_bapimepoitemx TO li_bapimepoitemx.
DATA: lo_msg_handler TYPE REF TO cl_message_handler_mm.
CALL METHOD cl_message_handler_mm=>get_handler
IMPORTING
ex_handler = lo_msg_handler.
lo_msg_handler->remove_all( ).
lo_msg_handler->cleanup( ).
CALL FUNCTION 'BAPI_PO_CREATE1' "in background task
EXPORTING
poheader = lwa_bapimepoheader
poheaderx = lwa_bapimepoheaderx
testrun = 'X'
NO_MESSAGING = c_x
NO_MESSAGE_REQ = c_x
no_authority = 'X'
IMPORTING
expheader = lwa_bapimepoheader
TABLES
return = li_return
poitem = li_bapimepoitem
poitemx = li_bapimepoitemx
conditions = li_conditions.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'. -
Hi ,
I m using BAPI_PO_CREATE1 for standard PO creation in UI /Module Pool programming., wherein I fill in all details aliongwith item details except for PO Number and try to save it.
But on debugging the part after saving it ,following errors are observed as entries in Return table parameter of BAPI_PO_CREATE1 :
Errors seen :
1 Please enter items first
2 No instance of object type PurchaseOrder has been created.
3 PO header data still faulty
Please suggest the way out as how to eliminate these errors.
Regards,
Abhishek
Edited by: Abhishek Sawant on Jan 29, 2008 9:53 AM
Edited by: Abhishek Sawant on Jan 29, 2008 10:32 AMHai.
check the code.
REPORT zpo_bapi_purchord_tej.
DATA DECLARATIONS *
TYPE-POOLS slis.
TYPES: BEGIN OF ty_table,
v_legacy(8),
vendor TYPE bapimepoheader-vendor,
purch_org TYPE bapimepoheader-purch_org,
pur_group TYPE bapimepoheader-pur_group,
material TYPE bapimepoitem-material,
quantity(13),
delivery_date TYPE bapimeposchedule-delivery_date,
net_price(23),
plant TYPE bapimepoitem-plant,
END OF ty_table.
TYPES: BEGIN OF ty_alv,
v_legs(8),
success(10),
v_legf(8),
END OF ty_alv.
TYPES: BEGIN OF ty_alv1,
v_legf1(8),
v_msg(500),
END OF ty_alv1.
*-----Work area declarations.
DATA: x_table TYPE ty_table,
x_header TYPE bapimepoheader,
x_headerx TYPE bapimepoheaderx,
x_item TYPE bapimepoitem,
x_itemx TYPE bapimepoitemx,
x_sched TYPE bapimeposchedule,
x_schedx TYPE bapimeposchedulx,
x_commatable(255),
x_alv TYPE ty_alv,
x_alv1 TYPE ty_alv1,
x_alv2 TYPE ty_alv1.
*-----Internal table declarations.
DATA: it_table TYPE TABLE OF ty_table,
it_commatable LIKE TABLE OF x_commatable,
it_item TYPE TABLE OF bapimepoitem,
it_itemx TYPE TABLE OF bapimepoitemx,
it_sched TYPE TABLE OF bapimeposchedule,
it_schedx TYPE TABLE OF bapimeposchedulx,
it_alv TYPE TABLE OF ty_alv,
it_alv1 TYPE TABLE OF ty_alv1,
it_alv2 TYPE TABLE OF ty_alv1.
DATA: po_number TYPE bapimepoheader-po_number,
x_return TYPE bapiret2,
it_return TYPE TABLE OF bapiret2,
v_file TYPE string,
v_temp(8),
v_succsount TYPE i VALUE 0,
v_failcount TYPE i VALUE 0,
v_total TYPE i.
DATA: v_temp1(5) TYPE n VALUE 0.
DATA: x_event TYPE slis_t_event,
x_fieldcat TYPE slis_t_fieldcat_alv,
x_list_header TYPE slis_t_listheader,
x_event1 LIKE LINE OF x_event,
x_layout1 TYPE slis_layout_alv,
x_variant1 TYPE disvariant,
x_repid2 LIKE sy-repid.
DATA : it_fieldcat TYPE TABLE OF slis_t_fieldcat_alv.
SELECTION-SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK v_b1 WITH FRAME.
*-----To fetch the flat file.
PARAMETERS: p_file TYPE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK v_b1.
AT SELECTION-SCREEN *
AT SELECTION-SCREEN.
IF p_file IS INITIAL.
MESSAGE text-001 TYPE 'E'.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
*-----To use F4 help to find file path.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file.
v_file = p_file.
START-OF-SELECTION *
START-OF-SELECTION.
PERFORM gui_upload.
LOOP AT it_table INTO x_table.
PERFORM header_details.
v_temp = x_table-v_legacy.
LOOP AT it_table INTO x_table WHERE v_legacy = v_temp.
PERFORM lineitem.
PERFORM schedule.
ENDLOOP.
DELETE it_table WHERE v_legacy = v_temp.
PERFORM bapicall.
MOVE po_number TO x_alv-success.
APPEND x_alv TO it_alv.
CLEAR x_alv.
*-----To clear the item details in internal table after the operation for a header.
REFRESH: it_item,
it_itemx,
it_sched,
it_schedx.
CLEAR: v_temp1.
ENDLOOP.
v_total = v_succsount + v_failcount.
PERFORM display_alv.
FORM GUI_UPLOAD *
FORM gui_upload .
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_file
filetype = 'ASC'
TABLES
data_tab = it_commatable
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17
IF sy-subrc = 0.
*-----To fetch the comma seperated flat file into an internal table.
LOOP AT it_commatable INTO x_commatable.
IF x_commatable IS NOT INITIAL.
SPLIT x_commatable AT ',' INTO
x_table-v_legacy
x_table-vendor
x_table-purch_org
x_table-pur_group
x_table-material
x_table-quantity
x_table-delivery_date
x_table-net_price
x_table-plant.
APPEND x_table TO it_table.
ENDIF.
CLEAR x_table.
ENDLOOP.
ENDIF.
ENDFORM. " gui_upload
FORM HEADER_DETAILS *
FORM header_details .
MOVE 'NB' TO x_header-doc_type.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = x_table-vendor
IMPORTING
output = x_table-vendor
MOVE x_table-vendor TO x_header-vendor.
MOVE x_table-purch_org TO x_header-purch_org.
MOVE x_table-pur_group TO x_header-pur_group.
x_headerx-doc_type = 'X'.
x_headerx-vendor = 'X'.
x_headerx-purch_org = 'X'.
x_headerx-pur_group = 'X'.
ENDFORM. " header_details
FORM LINEITEM *
FORM lineitem .
v_temp1 = v_temp1 + 10.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_temp1
IMPORTING
output = v_temp1.
MOVE v_temp1 TO x_item-po_item.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = x_table-material
IMPORTING
output = x_table-material.
MOVE x_table-material TO x_item-material.
MOVE x_table-quantity TO x_item-quantity.
MOVE x_table-net_price TO x_item-net_price.
MOVE x_table-plant TO x_item-plant.
x_itemx-po_item = v_temp1.
x_itemx-material = 'X'.
x_itemx-quantity = 'X'.
x_itemx-net_price = 'X'.
x_itemx-plant = 'X'.
APPEND x_item TO it_item.
APPEND x_itemx TO it_itemx.
CLEAR: x_item, x_itemx.
ENDFORM. " lineitem1
FORM SCHEDULE *
FORM schedule .
MOVE x_table-delivery_date TO x_sched-delivery_date.
MOVE v_temp1 TO x_sched-po_item.
x_schedx-delivery_date = 'X'.
x_schedx-po_item = v_temp1.
APPEND x_sched TO it_sched.
APPEND x_schedx TO it_schedx.
CLEAR: x_sched, x_schedx.
ENDFORM. " schedule
FORM BAPICALL *
FORM bapicall .
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = x_header
poheaderx = x_headerx
IMPORTING
exppurchaseorder = po_number
TABLES
return = it_return
poitem = it_item
poitemx = it_itemx
poschedule = it_sched
poschedulex = it_schedx.
IF po_number IS NOT INITIAL.
v_succsount = v_succsount + 1.
MOVE x_table-v_legacy TO x_alv-v_legs.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ELSE.
v_failcount = v_failcount + 1.
MOVE x_table-v_legacy TO x_alv-v_legf.
MOVE x_table-v_legacy TO x_alv1-v_legf1.
LOOP AT it_return INTO x_return.
IF x_alv1-v_msg IS INITIAL.
MOVE x_return-message TO x_alv1-v_msg.
ELSE.
CONCATENATE x_alv1-v_msg x_return-message INTO x_alv1-v_msg SEPARATED BY space.
ENDIF.
ENDLOOP.
APPEND x_alv1 TO it_alv1.
CLEAR x_alv1.
ENDIF.
ENDFORM. " bapicall
FORM DISPLAY_ALV *
FORM display_alv .
PERFORM x_list_header.
PERFORM build_fieldcat CHANGING x_fieldcat.
x_repid2 = sy-repid.
x_event1-name = 'TOP_OF_PAGE'.
x_event1-form = 'TOP_OF_PAGE'.
APPEND x_event1 TO x_event.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = x_repid2
is_layout = x_layout1
it_fieldcat = x_fieldcat
i_callback_user_command = 'USER_COMMAND'
i_callback_top_of_page = 'TOP_OF_PAGE'
i_save = 'A'
is_variant = x_variant1
it_events = x_event
TABLES
t_outtab = it_alv
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_master_data
FORM USER_COMMAND *
FORM user_command USING ucomm LIKE sy-ucomm selfield
TYPE slis_selfield.
READ TABLE it_alv INTO x_alv INDEX selfield-tabindex.
CLEAR : x_alv2,it_alv2[].
LOOP AT it_alv1 INTO x_alv1 WHERE v_legf1 = x_alv-v_legf.
x_alv2 = x_alv1.
APPEND x_alv2 TO it_alv2 .
ENDLOOP.
DATA : it_fieldcat TYPE slis_t_fieldcat_alv.
DATA : x3_fieldcat LIKE LINE OF it_fieldcat.
CLEAR : x3_fieldcat,it_fieldcat[].
CLEAR x3_fieldcat.
x3_fieldcat-col_pos = '1'.
x3_fieldcat-fieldname = 'V_LEGF1'.
x3_fieldcat-reptext_ddic = text-111.
x3_fieldcat-ref_tabname = 'IT_ALV2'.
APPEND x3_fieldcat TO it_fieldcat.
CLEAR x3_fieldcat.
CLEAR x3_fieldcat.
x3_fieldcat-col_pos = '1'.
x3_fieldcat-fieldname = 'V_MSG'.
x3_fieldcat-reptext_ddic = text-112.
x3_fieldcat-ref_tabname = 'IT_ALV2'.
APPEND x3_fieldcat TO it_fieldcat.
CLEAR x3_fieldcat.
x_layout1-colwidth_optimize = 'X'.
x_layout1-zebra = 'X'.
IF it_alv2[] IS NOT INITIAL.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = x_repid2
is_layout = x_layout1
it_fieldcat = it_fieldcat
i_save = 'A'
i_callback_top_of_page = 'TOP'
is_variant = x_variant1
it_events = x_event
TABLES
t_outtab = it_alv2
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDIF.
ENDFORM.
FORM USER_COMMAND *
FORM top.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = 'Commentry'.
ENDFORM.
FORM BUILD_FIELDCAT *
FORM build_fieldcat CHANGING et_fieldcat TYPE slis_t_fieldcat_alv.
DATA: x1_fieldcat TYPE slis_fieldcat_alv.
CLEAR x1_fieldcat.
x1_fieldcat-col_pos = '1'.
x1_fieldcat-fieldname = 'V_LEGS'.
x1_fieldcat-reptext_ddic = text-108.
x1_fieldcat-ref_tabname = 'IT_ALV'.
APPEND x1_fieldcat TO et_fieldcat.
CLEAR x1_fieldcat.
x1_fieldcat-col_pos = '2'.
x1_fieldcat-fieldname = 'SUCCESS'.
x1_fieldcat-key = 'X'.
x1_fieldcat-reptext_ddic = text-109.
x1_fieldcat-ref_tabname = 'IT_ALV'.
APPEND x1_fieldcat TO et_fieldcat.
CLEAR x1_fieldcat.
x1_fieldcat-col_pos = '3'.
x1_fieldcat-fieldname = 'V_LEGF'.
x1_fieldcat-key = 'X'.
x1_fieldcat-reptext_ddic = text-110.
x1_fieldcat-ref_tabname = 'IT_ALV'.
APPEND x1_fieldcat TO et_fieldcat.
CLEAR x1_fieldcat.
ENDFORM. " build_fieldcat
FORM BUILD_LIST_HEADER *
FORM x_list_header.
DATA: x_list_header1 TYPE slis_listheader.
*-----List Header: type H
CLEAR x_list_header1 .
x_list_header1-typ = 'H'.
x_list_header1-info = text-105.
APPEND x_list_header1 TO x_list_header.
*-----List Key: type S
x_list_header1-typ = 'S'.
x_list_header1-key = text-106.
x_list_header1-info = v_total.
APPEND x_list_header1 TO x_list_header.
*-----List Key: Type S
CLEAR x_list_header1 .
x_list_header1-typ = 'S'.
x_list_header1-key = text-107.
x_list_header1-info = v_succsount.
APPEND x_list_header1 TO x_list_header.
ENDFORM. " build_list_header
FORM TOP_OF_PAGE *
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = x_list_header.
ENDFORM. " TOP_OF_PAGE
regards.
sowjanya.b -
How to create service PO while using BAPI
Dear Experts
I am getting error while creating Service PO using BAPI
E 518
No account assignment exists for service line 0000000010
E 518
No account assignment exists for service line 0000000010
TYPES : BEGIN OF ty_header,
po_no(10) TYPE n,
purch_org TYPE bapimepoheader-purch_org,
pur_group TYPE bapimepoheader-pur_group,
doc_type TYPE bapimepoheader-doc_type,
vendor TYPE bapimepoheader-vendor,
doc_date TYPE bapimepoheader-doc_date,
currency TYPE bapimepoheader-currency,
comp_code TYPE bapimepoheader-comp_code,
END OF ty_header,
BEGIN OF ty_item,
po_no(10) TYPE n, " Internal Use
po_item TYPE bapimepoitem-po_item,
acctasscat TYPE bapimepoitem-acctasscat,
short_text TYPE bapimepoitem-short_text,
plant TYPE bapimepoitem-plant,
pckg_no TYPE bapimepoitem-pckg_no,
stge_loc TYPE bapimepoitem-stge_loc,
quantity TYPE bapimepoitem-quantity,
po_unit TYPE bapimepoitem-po_unit,
po_price TYPE bapimepoitem-po_price,
net_price TYPE bapimepoitem-net_price,
price_unit TYPE bapimepoitem-price_unit,
orderpr_un TYPE bapimepoitem-orderpr_un,
delivery_date TYPE bapimeposchedule-delivery_date, " bapimeposchedule
matl_group TYPE bapimepoitem-matl_group,
tax_code TYPE bapimepoitem-tax_code,
END OF ty_item,
BEGIN OF ty_service,
po_no(10) TYPE n, " Internal Use
po_item TYPE bapimepoitem-po_item, " Internal Use
pckg_no TYPE bapiesllc-pckg_no,
line_no TYPE bapiesllc-line_no,
ext_line TYPE bapiesllc-ext_line,
outl_ind TYPE bapiesllc-outl_ind,
subpckg_no TYPE bapiesllc-subpckg_no,
serial_no TYPE bapiesklc-serial_no, " bapiesklc
short_text TYPE bapiesllc-short_text,
quantity TYPE bapiesllc-quantity,
base_uom TYPE bapiesllc-base_uom,
gr_price TYPE bapiesllc-gr_price,
matl_group TYPE bapiesllc-matl_group,
END OF ty_service,
BEGIN OF ty_poaccount,
po_no(10) TYPE n, " Internal Use
po_item TYPE bapimepoaccount-po_item,
serial_no TYPE bapimepoaccount-serial_no,
gl_account TYPE bapimepoaccount-gl_account,
costcenter TYPE bapimepoaccount-costcenter,
asset_no TYPE bapimepoaccount-asset_no,
orderid TYPE bapimepoaccount-orderid,
END OF ty_poaccount.
DATA : it_header TYPE TABLE OF ty_header,
wa_header TYPE ty_header,
it_item TYPE TABLE OF ty_item,
wa_item TYPE ty_item,
it_service TYPE TABLE OF ty_service,
wa_service TYPE ty_service,
it_account TYPE TABLE OF ty_poaccount,
wa_account TYPE ty_poaccount.
DATA : it_excel1 TYPE TABLE OF alsmex_tabline,
wa_excel1 TYPE alsmex_tabline,
it_excel2 TYPE TABLE OF alsmex_tabline,
wa_excel2 TYPE alsmex_tabline,
it_excel3 TYPE TABLE OF alsmex_tabline,
wa_excel3 TYPE alsmex_tabline,
it_excel4 TYPE TABLE OF alsmex_tabline,
wa_excel4 TYPE alsmex_tabline.
DATA : number TYPE string,
number1 TYPE string.
********** BAPI**************
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.
*Structures to hold PO schedule data
DATA : itemschedule LIKE bapimeposchedule OCCURS 0 WITH HEADER LINE ,
itemschedulex LIKE bapimeposchedulx OCCURS 0 WITH HEADER LINE .
*Structures to hold PO services data
DATA : services LIKE bapiesllc OCCURS 0 WITH HEADER LINE .
*Structures to hold PO (distrib.imputac.lín.servicios) data
DATA : posrvaccessvalues LIKE bapiesklc OCCURS 0 WITH HEADER LINE .
*Structures to hold PO account data
DATA : account LIKE bapimepoaccount OCCURS 0 WITH HEADER LINE ,
accountx LIKE bapimepoaccountx OCCURS 0 WITH HEADER LINE .
*Internal table to hold messages from BAPI call
DATA : return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
purchaseorder LIKE bapimepoheader-po_number.
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : p_file1 TYPE rlgrap-filename OBLIGATORY,
p_brow1 TYPE i,
p_erow1 TYPE i.
SELECTION-SCREEN : END OF BLOCK b1.
SELECTION-SCREEN : BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS : p_file2 TYPE rlgrap-filename OBLIGATORY,
p_brow2 TYPE i,
p_erow2 TYPE i.
SELECTION-SCREEN : END OF BLOCK b2.
SELECTION-SCREEN : BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
PARAMETERS : p_file3 TYPE rlgrap-filename OBLIGATORY,
p_brow3 TYPE i,
p_erow3 TYPE i.
SELECTION-SCREEN : END OF BLOCK b3.
SELECTION-SCREEN : BEGIN OF BLOCK b4 WITH FRAME TITLE text-004.
PARAMETERS : p_file4 TYPE rlgrap-filename OBLIGATORY,
p_brow4 TYPE i,
p_erow4 TYPE i.
SELECTION-SCREEN : END OF BLOCK b4.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file1.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ' '
IMPORTING
file_name = p_file1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file2.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ' '
IMPORTING
file_name = p_file2.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file3.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ' '
IMPORTING
file_name = p_file3.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file4.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ' '
IMPORTING
file_name = p_file4.
START-OF-SELECTION.
PERFORM excel_to_itab.
PERFORM get_final.
*& Form excel_to_itab
* text
* --> p1 text
* <-- p2 text
FORM excel_to_itab .
************** Excel 1
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file1
i_begin_col = '1'
i_begin_row = p_brow1
i_end_col = '08'
i_end_row = p_erow1
TABLES
intern = it_excel1
* EXCEPTIONS
* INCONSISTENT_PARAMETERS = 1
* UPLOAD_OLE = 2
* OTHERS = 3
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT it_excel1 INTO wa_excel1.
CASE wa_excel1-col.
WHEN '0001'.
wa_header-po_no = wa_excel1-value.
WHEN '0002'.
wa_header-purch_org = wa_excel1-value.
WHEN '0003'.
wa_header-pur_group = wa_excel1-value.
WHEN '0004'.
wa_header-doc_type = wa_excel1-value.
WHEN '0005'.
wa_header-vendor = wa_excel1-value.
WHEN '0006'.
wa_header-doc_date = wa_excel1-value.
WHEN '0007'.
wa_header-currency = wa_excel1-value.
WHEN '0008'.
wa_header-comp_code = wa_excel1-value.
ENDCASE.
AT END OF row.
APPEND wa_header TO it_header.
CLEAR wa_header.
ENDAT.
ENDLOOP.
************** Excel 2
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file2
i_begin_col = '1'
i_begin_row = p_brow2
i_end_col = '16'
i_end_row = p_erow2
TABLES
intern = it_excel2
* EXCEPTIONS
* INCONSISTENT_PARAMETERS = 1
* UPLOAD_OLE = 2
* OTHERS = 3
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT it_excel2 INTO wa_excel2.
CASE wa_excel2-col.
WHEN '0001'.
wa_item-po_no = wa_excel2-value.
WHEN '0002'.
wa_item-po_item = wa_excel2-value.
WHEN '0003'.
wa_item-acctasscat = wa_excel2-value.
WHEN '0004'.
wa_item-short_text = wa_excel2-value.
WHEN '0005'.
wa_item-plant = wa_excel2-value.
WHEN '0006'.
wa_item-pckg_no = wa_excel2-value.
WHEN '0007'.
wa_item-stge_loc = wa_excel2-value.
WHEN '0008'.
wa_item-quantity = wa_excel2-value.
WHEN '0009'.
wa_item-po_unit = wa_excel2-value.
WHEN '0010'.
wa_item-po_price = wa_excel2-value.
WHEN '0011'.
wa_item-net_price = wa_excel2-value.
WHEN '0012'.
wa_item-price_unit = wa_excel2-value.
WHEN '0013'.
wa_item-orderpr_un = wa_excel2-value.
WHEN '0014'.
wa_item-delivery_date = wa_excel2-value.
WHEN '0015'.
wa_item-matl_group = wa_excel2-value.
WHEN '0016'.
wa_item-tax_code = wa_excel2-value.
ENDCASE.
AT END OF row.
APPEND wa_item TO it_item.
CLEAR wa_item.
ENDAT.
ENDLOOP.
************** Excel 3
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file3
i_begin_col = '1'
i_begin_row = p_brow3
i_end_col = '13'
i_end_row = p_erow3
TABLES
intern = it_excel3
* EXCEPTIONS
* INCONSISTENT_PARAMETERS = 1
* UPLOAD_OLE = 2
* OTHERS = 3
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT it_excel3 INTO wa_excel3.
CASE wa_excel3-col.
WHEN '0001'.
wa_service-po_no = wa_excel3-value.
WHEN '0002'.
wa_service-po_item = wa_excel3-value.
WHEN '0003'.
wa_service-pckg_no = wa_excel3-value.
WHEN '0004'.
wa_service-line_no = wa_excel3-value.
WHEN '0005'.
wa_service-ext_line = wa_excel3-value.
WHEN '0006'.
wa_service-outl_ind = wa_excel3-value.
WHEN '0007'.
wa_service-subpckg_no = wa_excel3-value.
WHEN '0008'.
wa_service-serial_no = wa_excel3-value.
WHEN '0009'.
wa_service-short_text = wa_excel3-value.
WHEN '0010'.
wa_service-quantity = wa_excel3-value.
WHEN '0011'.
wa_service-base_uom = wa_excel3-value.
WHEN '0012'.
wa_service-gr_price = wa_excel3-value.
WHEN '0013'.
wa_service-matl_group = wa_excel3-value.
ENDCASE.
AT END OF row.
APPEND wa_service TO it_service.
CLEAR wa_service.
ENDAT.
ENDLOOP.
************** Excel 3
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file4
i_begin_col = '1'
i_begin_row = p_brow4
i_end_col = '07'
i_end_row = p_erow4
TABLES
intern = it_excel4
* EXCEPTIONS
* INCONSISTENT_PARAMETERS = 1
* UPLOAD_OLE = 2
* OTHERS = 3
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT it_excel4 INTO wa_excel4.
CASE wa_excel4-col.
WHEN '0001'.
wa_account-po_no = wa_excel4-value.
WHEN '0002'.
wa_account-po_item = wa_excel4-value.
WHEN '0003'.
wa_account-serial_no = wa_excel4-value.
WHEN '0004'.
wa_account-gl_account = wa_excel4-value.
WHEN '0005'.
wa_account-costcenter = wa_excel4-value.
WHEN '0006'.
wa_account-asset_no = wa_excel4-value.
WHEN '0007'.
wa_account-orderid = wa_excel4-value.
ENDCASE.
AT END OF row.
APPEND wa_account TO it_account.
CLEAR wa_account.
ENDAT.
ENDLOOP.
ENDFORM. " excel_to_itab
*& Form GET_FINAL
* text
* --> p1 text
* <-- p2 text
FORM get_final .
LOOP AT it_header INTO wa_header.
* BAPI HEADER
header-purch_org = wa_header-purch_org.
header-pur_group = wa_header-pur_group.
header-doc_type = wa_header-doc_type.
header-vendor = wa_header-vendor.
header-doc_date = wa_header-doc_date.
header-currency = wa_header-currency.
header-comp_code = wa_header-comp_code.
* BAPI HEADERX
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.
headerx-doc_date = c_x. " Added
LOOP AT it_item INTO wa_item WHERE po_no = wa_header-po_no.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '01'
object = 'SERVICE'
* quantity = '1'
* SUBOBJECT = ' '
* TOYEAR = '0000'
* IGNORE_BUFFER = ' '
IMPORTING
number = number
* QUANTITY =
* RETURNCODE =
* EXCEPTIONS
* INTERVAL_NOT_FOUND = 1
* NUMBER_RANGE_NOT_INTERN = 2
* OBJECT_NOT_FOUND = 3
* QUANTITY_IS_0 = 4
* QUANTITY_IS_NOT_1 = 5
* INTERVAL_OVERFLOW = 6
* BUFFER_OVERFLOW = 7
* OTHERS = 8
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
item-po_item = wa_item-po_item.
item-acctasscat = wa_item-acctasscat.
item-item_cat = '9'.
item-short_text = wa_item-short_text.
item-plant = wa_item-plant.
item-pckg_no = number.
item-stge_loc = wa_item-stge_loc.
item-quantity = wa_item-quantity.
item-po_unit = wa_item-po_unit.
item-po_price = wa_item-po_price.
item-net_price = wa_item-net_price.
item-price_unit = wa_item-price_unit.
item-orderpr_un = wa_item-orderpr_un.
item-matl_group = wa_item-matl_group.
item-tax_code = wa_item-tax_code.
APPEND item.
CLEAR item.
itemx-po_item = wa_item-po_item.
itemx-item_cat = c_x.
itemx-po_itemx = 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-agreement = c_x.
itemx-agmt_item = c_x.
itemx-stge_loc = c_x.
itemx-quantity = c_x.
itemx-po_unit = 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 .
itemx-pckg_no = c_x.
itemx-po_price = c_x. " Added
itemx-orderpr_un = c_x. " Added
APPEND itemx.
CLEAR itemx.
itemschedule-po_item = wa_item-po_item.
itemschedule-del_datcat_ext = 'D'.
itemschedule-delivery_date = wa_item-delivery_date.
APPEND itemschedule.
CLEAR itemschedule.
itemschedulex-po_item = wa_item-po_item.
itemschedulex-po_itemx = c_x .
itemschedulex-del_datcat_ext = c_x.
itemschedulex-delivery_date = c_x .
APPEND itemschedulex.
CLEAR itemschedulex.
LOOP AT it_service INTO wa_service WHERE po_no = wa_item-po_no AND po_item = wa_item-po_item.
IF wa_service-outl_ind IS INITIAL.
IF number1 IS INITIAL.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '01'
object = 'SERVICE'
* quantity = '1'
* SUBOBJECT = ' '
* TOYEAR = '0000'
* IGNORE_BUFFER = ' '
IMPORTING
number = number1
* QUANTITY =
* RETURNCODE =
* EXCEPTIONS
* INTERVAL_NOT_FOUND = 1
* NUMBER_RANGE_NOT_INTERN = 2
* OBJECT_NOT_FOUND = 3
* QUANTITY_IS_0 = 4
* QUANTITY_IS_NOT_1 = 5
* INTERVAL_OVERFLOW = 6
* BUFFER_OVERFLOW = 7
* OTHERS = 8
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
services-pckg_no = number.
services-line_no = '1'.
services-ext_line = '0'.
services-outl_ind = 'X'.
services-subpckg_no = number1.
* services-short_text = wa_service-short_text.
* services-quantity = wa_service-quantity.
* services-base_uom = wa_service-base_uom.
* services-gr_price = wa_service-gr_price.
* services-matl_group = wa_service-matl_group.
APPEND services.
CLEAR services.
ENDIF.
* ELSE.
services-pckg_no = number1.
services-line_no = wa_service-line_no.
services-ext_line = wa_service-ext_line.
* services-outl_ind = wa_service-outl_ind.
services-subpckg_no = '0'.
services-short_text = wa_service-short_text.
services-quantity = wa_service-quantity.
services-base_uom = wa_service-base_uom.
services-gr_price = wa_service-gr_price.
services-matl_group = wa_service-matl_group.
APPEND services.
CLEAR services.
ENDIF.
IF wa_service-outl_ind IS INITIAL.
posrvaccessvalues-pckg_no = number1.
posrvaccessvalues-line_no = wa_service-line_no.
posrvaccessvalues-serno_line = '01'.
posrvaccessvalues-serial_no = wa_service-serial_no.
* posrvaccessvalues-percentage = '100'.
APPEND posrvaccessvalues . CLEAR posrvaccessvalues.
ENDIF.
ENDLOOP.
LOOP AT it_account INTO wa_account WHERE po_no = wa_item-po_no AND po_item = wa_item-po_item.
account-po_item = wa_account-po_item.
account-serial_no = wa_account-serial_no.
account-gl_account = wa_account-gl_account.
account-costcenter = wa_account-costcenter.
account-asset_no = wa_account-asset_no.
account-orderid = wa_account-orderid.
APPEND account.
CLEAR account.
accountx-po_item = wa_account-po_item.
accountx-po_itemx = c_x .
accountx-serial_no = wa_account-serial_no.
accountx-serial_nox = c_x .
* accountx-creat_date = c_x .
accountx-costcenter = c_x .
accountx-gl_account = c_x .
* accountx-co_area = c_x .
* accountx-tax_code = c_x .
* accountx-asset_no = c_x . " Added
* accountx-orderid = c_x . " Added
APPEND accountx. CLEAR accountx.
ENDLOOP.
ENDLOOP.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = header
poheaderx = headerx
* POADDRVENDOR =
* TESTRUN =
IMPORTING
exppurchaseorder = purchaseorder
* EXPHEADER =
* EXPPOEXPIMPHEADER =
TABLES
return = return
poitem = item
poitemx = itemx
poschedule = itemschedule
poschedulex = itemschedulex
poaccount = account
poaccountx = accountx
poservices = services.
posrvaccessvalues = posrvaccessvalues.
IF purchaseorder IS NOT INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
LOOP AT return.
WRITE : / return-type, return-number, return-message.
ENDLOOP.
ENDLOOP.
ENDFORM. " GET_FINALHi ganesh,
Please look at the SAP note 376424 - BAPI_PO_CREATE1: Error messages for parked POs.
Sap recommends to install the support service pack. Take a look at the note for detailed understanding.
Also take a look at SAP NOte
767284 - SE518 occurs although account assignment is supplied to BAPI (this requires Note 552114 must be applied as a prerequisite)
Consider contacting basis team after your analysis about the issue.
Regards,
Sivaganesh -
Problem in creating Service PO ?
Hi People,
I am creating a Service PO using Bapi_PO_Create1 and now the problem is , I could create Service PO only without
ServiceNumber ( Activity Number ) ( IF i include the service number iam getting a error ) , did i left anything in my code
or Service PO can be created only without ServiceNumber ?hi
We can create without using Service Number. Here are the links:
PO Upload through BAPI_PO_CREATE1 - Problem in Service Item
BAPI_PO_CREATE1 Error
Regards,
VIshwa.
Edited by: vishwa sri hari on Oct 3, 2008 9:29 AM -
Price (Catalog) COND_INACTIVE
Hi,
In the purchase order change version, i can see the above above subject message i.e Price (Catalog) COND_INACTIVE (Check box ticked)
How to make Catalog price condition Inactive.
I am getting below error while changing purchase order :in application monitor
PurchOrder xxxxxxxxx: Purchase order still contains faulty items
02.06.2009 14:17: 16 PurchOrder 6500031274: Net price must be greater than 0 (Zero)
Is this because of above setting?
Thanks,
JaiHi jai
SAP Note 973952 - Meaningful error messages not shown in
Application monitors
SAP Note 966323 - Service Item: Not able to create PO in
ERP backend
PO created with status : Transfer Failed (E.Sys.)
ECS describe requirement not transferred to backend
Transfer PO from SRM to R/3 - Error in Process
Problem with BAPI_PO_CREATE1
Error in transmission
Problem in creation of PO
STO classic scenario SRM 4.0
plz update which sap version? threre many threads discussion.
what is the history of sc /po details- what type of cart it was? look out all discussions.
so your po did not create in r/3 so far?
br
muthu -
How to create "service group" (ABAP webservice consumer) for SOAMANAGER
HI experts,
I'm trying to setup ABAP as a proper webservice consumer using SOAMANAGER in a 7.01 system. I would like to use Business Scenario Communication for this. I want to add Service Groups in the Consumer tab, and I find 2 servicegroups in the 7.01 (ERP 6.04) system: SRT_SG_TEST_01 and SRT_TEST_GROUP. However, I want to create my own Serivce Groups (Consumer), where do I do that? SE80?
All help appreciated, please don't bother describing the ABAP-as-Provider setup, which is the more common approach.
Gr, WoutHi ganesh,
Please look at the SAP note 376424 - BAPI_PO_CREATE1: Error messages for parked POs.
Sap recommends to install the support service pack. Take a look at the note for detailed understanding.
Also take a look at SAP NOte
767284 - SE518 occurs although account assignment is supplied to BAPI (this requires Note 552114 must be applied as a prerequisite)
Consider contacting basis team after your analysis about the issue.
Regards,
Sivaganesh -
Create a Service Purchase Requisition using BAPI_PR_CREATE
Hi Everyone,
I am using BAPI_PR_CREATE.
I am able to create Standard Purchase requisition.
But while creating Service Purchase Requisition, i am not able to create.
I am getting no errors for the PR Item, but even after entering Services for the PR Item i am getting error message in return table of bapi "Please Maintain Services or limits'.
Do i have to pass value to Package_No field in the item level table of BAPI_PR_CREATE.
Please help.
Regards,
AkashHi,
Check this link for creation of services.
Bapi_pr_change in services
PO Upload through BAPI_PO_CREATE1 - Problem in Service Item
BAPI_PO_CREATE1 Error
Hope it helps
Sujay -
Error while Creating a PO using BAPI_PO_CREATE1
Hi Friends,
The following issue that I have observed and as explained below is one of the weirdest scenarios that I have seen while working with SAP. Hence, kindly help me with possible errors from my end. I am working on ECC 6.0.
Requirement: To automatically create a PO.
Option used: I have used a BAPI: u2018BAPI_PO_CREATE1u2019
Scenario: When I execute the BAPI u2018BAPI_PO_CREATE1u2019 directly in sequence with u2018BAPI_TRANSACTION_COMMITu2019, the PO gets created successfully. The data entered as input is:
POHEADER-COMP_CODE
POHEADER-DOC_TYPE
POHEADER-PMNTTRMS
POITEM-PO_ITEM
POITEM-QUANTITY
POITEM-TAX_CODE
POITEM-TAXJURCODE
POITEM-RFQ_NO
POITEM-RFQ_ITEM
POITEM-PREQ_NO
POITEM-PREQ_ITEM
POITEM-PREQ_NAME
POSCHEDULE-PO_ITEM
POSCHEDULE-SCHED_LINE
POSCHEDULE-QUANTITY
POSCHEDULE-PREQ_NO
POSCHEDULE-PREQ_ITEM
Problem: I need to pass data to the BAPI through code, so I called the BAPI u2018BAPI_PO_CREATE1u2019 and u2018BAPI_TRANSACTION_COMMITu2019 in a test function module as well as report. I passed the same data as mentioned above i.e. while creating the PO by passing data to the BAPI directly.
But the BAPI returns an error BAPI header data still faulty, enter plant, Pur. Org., Pur. Grp., etc.
I tried by passing all the available data for the header and then for the items, but finally, I still get an error that the item is from a different order account and just cannot create a PO.
The Test FM code is as shown below:
DATA : PYMNT_TERMS TYPE YOAF_SEC_MASTER-TER_PYMNT.
DATA : ITEM_NO(4) .
DATA : CURRENCY TYPE LFM1-WAERS.
DATA : POHEAD TYPE BAPIMEPOHEADER.
DATA : POHEADX TYPE BAPIMEPOHEADERX.
DATA : EXP_HEAD TYPE BAPIMEPOHEADER.
DATA : POITEM TYPE TABLE OF BAPIMEPOITEM WITH HEADER LINE.
DATA : POITEMX TYPE TABLE OF BAPIMEPOITEMX WITH HEADER LINE.
DATA : POSCHED TYPE TABLE OF BAPIMEPOSCHEDULE WITH HEADER LINE.
DATA : POSCHEDX TYPE TABLE OF BAPIMEPOSCHEDULX WITH HEADER LINE.
DATA : EX_PO_NUMBER TYPE BAPIMEPOHEADER-PO_NUMBER.
CONSTANTS : C_X VALUE 'X'.
POHEAD-COMP_CODE = 'P110'.
POHEAD-DOC_TYPE = DOC_TYPE.
POHEAD-PMNTTRMS = 'P10'.
POHEADX-COMP_CODE = C_X.
POHEADX-DOC_TYPE = C_X.
POHEADX-PMNTTRMS = C_X.
POITEM-PO_ITEM = '00001'.
POITEM-QUANTITY = '1.000'.
POITEM-TAX_CODE = 'D2'.
POITEM-TAXJURCODE = 'MH01'.
POITEM-RFQ_NO = '2300009491'.
POITEM-RFQ_ITEM = '00001'.
POITEM-PREQ_NO = '200003583'.
POITEM-PREQ_ITEM = '00001'.
POITEM-PREQ_NAME = 'SACHIN'.
APPEND POITEM.
POITEMX-PO_ITEM = '00001'.
POITEMX-PO_ITEMX = C_X.
POITEMX-QUANTITY = C_X .
POITEMX-TAX_CODE = C_X .
POITEMX-TAXJURCODE = C_X .
POITEM-RFQ_NO = C_X.
POITEM-RFQ_ITEM = C_X.
POITEM-PREQ_NO = C_X.
POITEM-PREQ_ITEM = C_X.
POITEMX-PREQ_NAME = C_X.
APPEND POITEMX.
POSCHED-PO_ITEM = '00001'.
POSCHED-SCHED_LINE = '0001'.
POSCHED-QUANTITY = '1.000'.
POSCHED-PREQ_NO = '1200003583'.
POSCHED-PREQ_ITEM = '00001'.
APPEND POSCHED.
POSCHEDX-PO_ITEM = '1'.
POSCHEDX-SCHED_LINE = '0001'.
POSCHEDX-PO_ITEMX = C_X.
POSCHEDX-SCHED_LINEX = C_X.
POSCHEDX-QUANTITY = C_X.
POSCHEDX-PREQ_NO = C_X.
POSCHEDX-PREQ_ITEM = C_X.
APPEND POSCHEDX.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = POHEAD
POHEADERX = POHEADX
IMPORTING
EXPPURCHASEORDER = EX_PO_NUMBER
EXPHEADER = EXP_HEAD
EXPPOEXPIMPHEADER =
TABLES
RETURN = RETURN_ERROR
POITEM = POITEM
POITEMX = POITEMX
POADDRDELIVERY =
POSCHEDULE = POSCHED
POSCHEDULEX = POSCHEDX
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = RETURN_ERROR.Hi,
As mentioned that this error was one of the wierdest SAP issues I have faced, it was due to the silliest copy paste errors on my behalf. I completely overlooked the POITEMX naming.
For 4 values of RFQ_NO, RFQ_ITEM, PREQ_NO, PREQ_ITEM, I didnt have the 'X' for POITEMX and kept on looking for errors for days.
BAPI_PO_CREATE1 works with min. possible inputs successfully.
Thanks to all! -
Error while creating a Service PO using BAPI_PO_CREATE1
Hi,
Im facing Error as "In case of account assignment, please enter acc. assignment data for item" while creating Service PO using BAPI_PO_CREATE1.
Header Data
w_poheader-comp_code = w_src-bukrs. "Company Code
w_poheader-doc_type = w_src-bsart. "Document type
w_poheader-delete_ind = w_src-vrtkz. "Deletion Indicator
CLEAR: lv_date.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = w_src-aedat
IMPORTING
date_internal = lv_date
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
w_poheader-creat_date = lv_date. "Creation Date
w_poheader-created_by = sy-uname. "Creator Name
w_poheader-vendor = w_src-lifnr. "Vendor
w_poheader-pmnttrms = w_src-zterm. "Payment Terms
w_poheader-purch_org = w_src-ekorg. "Purchase Organization
w_poheader-pur_group = w_src-ekgrp. "Purchase Group
w_poheader-ref_1 = w_src-ihrez. "OLD PO
w_poheaderx-comp_code = 'X'. "Company Code
w_poheaderx-doc_type = 'X'. "Document type
w_poheaderx-delete_ind = 'X'. "Deletion Indicator
w_poheaderx-creat_date = 'X'. "Creation Date
w_poheaderx-created_by = 'X'.
w_poheaderx-vendor = 'X'.
w_poheaderx-pmnttrms = 'X'. "Payment Terms
w_poheaderx-purch_org = 'X'. "Purchase Organization
w_poheaderx-pur_group = 'X'. "Purchase Group
w_poheaderx-ref_1 = 'X'.
Item Data
w_poitem-po_item = w_src-ebelp.
IF NOT w_src-elikz IS INITIAL.
w_poitem-delete_ind = w_src-elikz.
ENDIF.
IF NOT w_src-txz01 IS INITIAL.
w_poitem-short_text = w_src-txz01.
ENDIF.
IF NOT w_src-werks IS INITIAL.
w_poitem-plant = w_src-werks.
ENDIF.
Material group
IF NOT w_src-matkl IS INITIAL.
w_poitem-matl_group = w_src-matkl.
ENDIF.
Open or Partial Qty
IF w_src-opqty IS NOT INITIAL.
w_poitem-quantity = w_src-opqty.
ELSEIF NOT w_src-paqty IS INITIAL.
w_poitem-quantity = w_src-paqty.
ENDIF.
IF NOT w_src-meins IS INITIAL.
w_poitem-po_unit = w_src-meins. "Base Unit of Measure
ENDIF.
IF NOT w_src-netpr IS INITIAL.
w_poitem-net_price = w_src-netpr. "Net Price
ENDIF.
IF NOT w_src-mwskz IS INITIAL.
w_poitem-tax_code = w_src-mwskz.
ENDIF.
IF NOT w_src-pstyp IS INITIAL.
w_poitem-item_cat = w_src-pstyp.
ENDIF.
IF NOT w_src-knttp IS INITIAL.
w_poitem-acctasscat = w_src-knttp.
ENDIF.
IF NOT w_src-vrtkz IS INITIAL.
w_poitem-distrib = w_src-vrtkz.
ENDIF.
Package No
IF NOT w_src-packno IS INITIAL.
w_poitem-pckg_no = w_src-packno. "Package no
ENDIF.
IF w_poitem-delete_ind IS INITIAL AND
w_poitem-short_text IS INITIAL AND
w_poitem-plant IS INITIAL AND
w_poitem-matl_group IS INITIAL AND
w_poitem-quantity IS INITIAL AND
w_poitem-po_unit IS INITIAL AND
w_poitem-net_price IS INITIAL AND
w_poitem-tax_code IS INITIAL.
CLEAR lv_item.
ELSE.
APPEND w_poitem TO i_poitem.
CLEAR: w_poitem.
lv_item = 'X'.
ENDIF.
w_poitemx-po_item = w_src-ebelp.
w_poitemx-delete_ind = 'X'.
w_poitemx-short_text = 'X'.
w_poitemx-plant = 'X'.
w_poitemx-matl_group = 'X'.
w_poitemx-quantity = 'X'.
w_poitemx-po_unit = 'X'.
w_poitemx-net_price = 'X'.
w_poitemx-tax_code = 'X'.
w_poitemx-item_cat = 'X'.
w_poitemx-acctasscat = 'X'.
w_poitemx-distrib = 'X'.
IF NOT w_src-packno IS INITIAL.
w_poitemx-pckg_no = 'X'.
ENDIF.
IF lv_item = 'X'.
APPEND w_poitemx TO i_poitemx.
CLEAR: w_poitemx,
lv_item.
ENDIF.
PO Deliery Address
w_poaddrdelivery-po_item = w_src-ebelp.
IF NOT w_src-adrn2 IS INITIAL.
w_poaddrdelivery-addr_no = w_src-adrn2.
APPEND w_poaddrdelivery TO i_poaddrdelivery.
CLEAR w_poaddrdelivery.
ENDIF.
POschedule
w_poschedule-po_item = w_src-ebelp.
CLEAR: lv_date.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = w_src-eindt
IMPORTING
date_internal = lv_date
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
IF NOT lv_date IS INITIAL.
w_poschedule-del_datcat_ext = 'D'. "Delivery Date in Day Format
w_poschedule-delivery_date = lv_date.
w_poschedule-quantity = w_src-menge.
APPEND w_poschedule TO i_poschedule.
CLEAR w_poschedule.
lv_schd = 'X'.
ENDIF.
w_poschedulex-po_item = w_src-ebelp.
w_poschedulex-del_datcat_ext = 'X'.
w_poschedulex-delivery_date = 'X'.
w_poschedulex-quantity = 'X'.
IF lv_schd = 'X'.
APPEND w_poschedulex TO i_poschedulex.
CLEAR : w_poschedulex,
lv_schd.
ENDIF.
PO Account Assignment
w_poaccount-po_item = w_src-ebelp.
w_poaccount-serial_no = w_src-zekkn.
Distribution Indicator is 1
IF w_src-vrtkz EQ '1'.
w_poaccount-distr_perc = w_src-vproz.
IF NOT w_src-menge IS INITIAL.
CLEAR lv_menge.
lv_menge = w_src-menge.
ENDIF.
lv_acct_qty = lv_menge * w_src-vproz / 100.
Get Round value of Quanity
frac = FRAC( lv_acct_qty ).
IF frac EQ 0.
lv_acct_qty = FLOOR( lv_acct_qty ).
ELSE.
lv_acct_qty = CEIL( lv_acct_qty ).
ENDIF.
w_poaccount-quantity = lv_acct_qty.
ELSEIF w_src-vrtkz IS INITIAL.
w_poaccount-quantity = w_src-menge.
ENDIF.
w_poaccount-gl_account = w_src-saknr.
w_poaccount-costcenter = w_src-kostl.
w_poaccount-asset_no = w_src-anln1.
w_poaccount-wbs_element = w_src-wbs.
w_poaccount-network = w_src-nplnr.
w_poaccount-tax_code = w_src-mwskz.
w_poaccount-activity = w_src-vornr.
APPEND w_poaccount TO i_poaccount.
CLEAR w_poaccount.
w_poaccountx-po_item = w_src-ebelp.
w_poaccountx-serial_no = w_src-zekkn.
IF w_src-vrtkz EQ '1'.
w_poaccountx-distr_perc = 'X'.
ENDIF.
w_poaccountx-quantity = 'X'.
w_poaccountx-gl_account = 'X'.
w_poaccountx-costcenter = 'X'.
w_poaccountx-wbs_element = 'X'.
w_poaccountx-network = 'X'.
w_poaccountx-tax_code = 'X'.
w_poaccountx-activity = 'X'.
APPEND w_poaccountx TO i_poaccountx.
CLEAR w_poaccountx.
PO Services
w_poservices-pckg_no = w_src-packno. "Package no
w_poservices-line_no = w_src-srv_line_no. "Line item
w_poservices-ext_line = w_src-extrow. "External line
w_poservices-outl_level = 0.
w_poservices-outl_ind = 'X'.
w_poservices-subpckg_no = w_src-sub_packno. "Sub package no
w_poservices-quantity = w_src-srqty. "Service Quantity
w_poservices-base_uom = w_src-srmeins. "Service Basic unit of Measure
w_poservices-price_unit = '1'.
w_poservices-from_line = '1'.
w_poservices-gr_price = w_src-brtwr. "GR Price
w_poservices-short_text = w_src-sh_text1. "Service Short Text
w_poservices-matl_group = w_src-matkl. "Material Group
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
PO Service Access values
w_posrvacc-pckg_no = w_src-packno. "Package no
w_posrvacc-line_no = w_src-srv_line_no. "Line item
w_posrvacc-serno_line = w_src-zekkn. "'01'..
IF w_src-vproz IS INITIAL.
w_posrvacc-percentage = '100.0'.
ENDIF.
w_posrvacc-serial_no = w_src-zekkn. "'01'.
w_posrvacc-quantity = w_src-srqty. "Service Quantity
w_posrvacc-net_value = w_src-srqty. "Net value
APPEND w_posrvacc TO i_posrvacc.
CLEAR w_posrvacc.
ENDIF.
***Create a NEW PO
AT END OF ihrez.
Call BAPI
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = w_poheader
poheaderx = w_poheaderx
IMPORTING
exppurchaseorder = gv_ebeln
TABLES
return = i_return
poitem = i_poitem[]
poitemx = i_poitemx[]
poaddrdelivery = i_poaddrdelivery[]
poschedule = i_poschedule[]
poschedulex = i_poschedulex[]
poaccount = i_poaccount[]
poaccountx = i_poaccountx[]
poservices = i_poservices[]
posrvaccessvalues = i_posrvacc[]
extensionin = i_extensionin[].
Commit the Transaction
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
Regards,
Deepthi.1. If we get error as "In case of account assignment, please enter acc. assignment data for item" than First cehck whetaher u have authorization to Tcode ME23n or not. In my case, I din't had authorization to Me23n tcode.
2. If we get Error as "Please Mainatain Services or Limits". Please create a Service PO in the following Order.
*& Internal Table Declaration
DATA : i_intern TYPE STANDARD TABLE OF alsmex_tabline WITH HEADER LINE,
i_poitem TYPE STANDARD TABLE OF bapimepoitem,
i_poitemx TYPE STANDARD TABLE OF bapimepoitemx,
i_poaddrdelivery TYPE STANDARD TABLE OF bapimepoaddrdelivery,
i_poschedule TYPE STANDARD TABLE OF bapimeposchedule,
i_poschedulex TYPE STANDARD TABLE OF bapimeposchedulx,
i_poaccount TYPE STANDARD TABLE OF bapimepoaccount,
i_poaccountx TYPE STANDARD TABLE OF bapimepoaccountx,
i_poservices TYPE STANDARD TABLE OF bapiesllc,
i_posrvacc TYPE STANDARD TABLE OF bapiesklc,
i_extensionin TYPE STANDARD TABLE OF bapiparex,
i_return TYPE STANDARD TABLE OF bapiret2.
*& Work Area Declaration
DATA:
w_poheader TYPE bapimepoheader,
w_poheaderx TYPE bapimepoheaderx,
w_poitem TYPE bapimepoitem,
w_poitemx TYPE bapimepoitemx,
w_poaddrdelivery TYPE bapimepoaddrdelivery,
w_poschedule TYPE bapimeposchedule,
w_poschedulex TYPE bapimeposchedulx,
w_poaccount TYPE bapimepoaccount,
w_poaccountx TYPE bapimepoaccountx,
w_poservices TYPE bapiesllc,
w_posrvacc TYPE bapiesklc,
w_extensionin TYPE bapiparex,
w_return TYPE bapiret2.
START-OF-SELECTION.
Header Data
w_poheader-comp_code = '5791'. "Company Code
w_poheader-doc_type = 'Z0CM'. "Document type
w_poheader-creat_date = sy-datum. "lv_date. "Creation Date
w_poheader-created_by = sy-uname. "Creator Name
w_poheader-vendor = '0005012343'. "Vendor
w_poheader-pmnttrms = 'Z004'. "Payment Terms
w_poheader-purch_org = 'P000'. "Purchase Organization
w_poheader-pur_group = '001'. "Purchase Group
w_poheader-ref_1 = '004500007671'. "OLD PO
w_poheaderx-comp_code = 'X'. "Company Code
w_poheaderx-doc_type = 'X'. "Document type
w_poheaderx-creat_date = 'X'. "Creation Date
w_poheaderx-created_by = 'X'.
w_poheaderx-vendor = 'X'.
w_poheaderx-pmnttrms = 'X'. "Payment Terms
w_poheaderx-purch_org = 'X'. "Purchase Organization
w_poheaderx-pur_group = 'X'. "Purchase Group
w_poheaderx-ref_1 = 'X'.
Item Data
w_poitem-po_item = '000010'.
w_poitem-short_text = 'Z0CM - Default Appr. Test '.
w_poitem-plant = '5368'.
Trackign no
w_poitem-trackingno = ''.
Material group
w_poitem-matl_group = '119'.
w_poitem-po_unit = 'EA'. "Base Unit of Measure
w_poitem-net_price = '17500.00'. "Net Price
w_poitem-tax_code = 'I0'.
w_poitem-item_cat = '9'.
w_poitem-acctasscat = 'K'.
w_poitem-distrib = space.
Package must be given in item to create Service PO
w_poitem-pckg_no = 0000000001.
APPEND w_poitem TO i_poitem.
CLEAR: w_poitem.
w_poitemx-po_item = '000010'.
w_poitemx-delete_ind = 'X'.
w_poitemx-short_text = 'X'.
w_poitemx-plant = 'X'.
w_poitemx-trackingno = 'X'.
w_poitemx-matl_group = 'X'.
w_poitemx-quantity = 'X'.
w_poitemx-po_unit = 'X'.
w_poitemx-net_price = 'X'.
w_poitemx-tax_code = 'X'.
w_poitemx-item_cat = 'X'.
w_poitemx-acctasscat = 'X'.
w_poitemx-distrib = 'X'.
w_poitemx-pckg_no = 'X'.
APPEND w_poitemx TO i_poitemx.
CLEAR: w_poitemx.
PO Deliery Address
w_poaddrdelivery-po_item = '000010'.
w_poaddrdelivery-addr_no = '0000061208'.
APPEND w_poaddrdelivery TO i_poaddrdelivery.
CLEAR w_poaddrdelivery.
POschedule
w_poschedule-po_item = '000010'..
DATA : LV_DATE TYPE SY-DATUM,
lv_schd.
CLEAR: lv_date.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = '12/2/2009'
IMPORTING
date_internal = lv_date
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
IF NOT lv_date IS INITIAL.
w_poschedule-del_datcat_ext = 'D'. "Delivery Date in Day Format
w_poschedule-delivery_date = lv_date.
w_poschedule-quantity = '1.000'.
APPEND w_poschedule TO i_poschedule.
CLEAR w_poschedule.
lv_schd = 'X'.
ENDIF.
w_poschedulex-po_item = '000010'.
w_poschedulex-del_datcat_ext = 'X'.
w_poschedulex-delivery_date = 'X'.
w_poschedulex-quantity = 'X'.
IF lv_schd = 'X'.
APPEND w_poschedulex TO i_poschedulex.
CLEAR : w_poschedulex,
lv_schd.
ENDIF.
PO Account Assignment
w_poaccount-po_item = '000010'.
w_poaccount-serial_no = '01'.
w_poaccount-distr_perc = ''.
w_poaccount-quantity = '1.000'.
w_poaccount-gl_account = '0000603064'.
w_poaccount-costcenter = '0053680100'.
w_poaccount-asset_no = ''.
w_poaccount-wbs_element = ''.
w_poaccount-network = ''.
w_poaccount-tax_code = 'I0'.
w_poaccount-activity = ''.
APPEND w_poaccount TO i_poaccount.
CLEAR w_poaccount.
w_poaccountx-po_item = '000010'.
w_poaccountx-serial_no = '01'.
w_poaccountx-distr_perc = 'X'.
w_poaccountx-quantity = 'X'.
w_poaccountx-gl_account = 'X'.
w_poaccountx-costcenter = 'X'.
w_poaccountx-wbs_element = 'X'.
w_poaccountx-network = 'X'.
w_poaccountx-tax_code = 'X'.
w_poaccountx-activity = 'X'.
w_poaccountx-cmmt_item = 'X'.
APPEND w_poaccountx TO i_poaccountx.
CLEAR w_poaccountx.
Extension for ZZSub
w_extensionin-structure = 'BAPI_TE_MEPOACCOUNTING'.
w_extensionin-valuepart1+0(5) = '00010'..
w_extensionin-valuepart1+5(2) = '01'.
w_extensionin-valuepart1+28(5) = ''.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
w_extensionin-structure = 'BAPI_TE_MEPOACCOUNTINGX'.
w_extensionin-valuepart1+0(5) = '00010'.
w_extensionin-valuepart1+5(2) = '01'.
w_extensionin-valuepart1+11(1) = 'X'.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
Extension to add Expense Type only
w_extensionin-structure = 'BAPI_TE_MEPOHEADER'.
w_extensionin-valuepart1+10(4) = '0131'.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
w_extensionin-structure = 'BAPI_TE_MEPOHEADERX'.
w_extensionin-valuepart1+10(4) = 'X'.
APPEND w_extensionin TO i_extensionin.
CLEAR w_extensionin.
EXPORT i_extensionin[] TO MEMORY ID 'SUB'.
PO Services
PO Services( One Line Iem)
Assign the dummy no as Pacakage no
w_poservices-pckg_no = 0000000001. "(assign package no as a dummy number)
w_poservices-line_no = 0000000001. "Line item
w_poservices-outl_ind = 'X'.
Assign Dummy no as sub package no
w_poservices-subpckg_no = 0000000003. "(Dummy No.) "Sub package no
w_poservices-from_line = '1'.
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
PO Services(Second Line Item )
Assign the same sub package dummy no which is mentioned above
w_poservices-pckg_no = 0000000003. "(Dummy No.) "Sub package no
w_poservices-line_no = 0000000002.
w_poservices-ext_line = '0000000010'. "External line
w_poservices-quantity = '17500.0'. "Service Quantity
w_poservices-base_uom = 'EA'. "Service Basic unit of Measure
w_poservices-price_unit = '1'.
w_poservices-gr_price = '1'. "GR Price
w_poservices-short_text = 'Z0CM - Default Appr. T'. "Service Short Text
w_poservices-matl_group = '119'. "w_src-matkl. "Material Group
APPEND w_poservices TO i_poservices.
CLEAR w_poservices.
PO Service Access values
w_posrvacc-pckg_no = 0000000003. "w_src-sub_packno. "Sub package no
w_posrvacc-line_no = 0000000002. "w_src-srv_line_no. "Line item
w_posrvacc-serno_line = '01'.
w_posrvacc-percentage = '100.0'.
w_posrvacc-serial_no = '01'.
w_posrvacc-quantity = '17500.0'. "w_src-srqty. "Service Quantity
APPEND w_posrvacc TO i_posrvacc.
CLEAR w_posrvacc.
DATA : gv_ebeln TYPE ebeln.
Call BAPI
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = w_poheader
poheaderx = w_poheaderx
IMPORTING
exppurchaseorder = gv_ebeln
TABLES
return = i_return
poitem = i_poitem[]
poitemx = i_poitemx[]
poaddrdelivery = i_poaddrdelivery[]
poschedule = i_poschedule[]
poschedulex = i_poschedulex[]
poaccount = i_poaccount[]
poaccountx = i_poaccountx[]
poservices = i_poservices[]
posrvaccessvalues = i_posrvacc[]
extensionin = i_extensionin[].
Commit the Transaction
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
WRITE:/5 gv_ebeln COLOR 5.
SKIP 2.
DATA : lv_msg TYPE string.
LOOP AT i_return INTO w_return WHERE type = 'E'.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = w_return-id
lang = 'EN'
no = w_return-number
v1 = w_return-message_v1
v2 = w_return-message_v2
v3 = w_return-message_v3
v4 = w_return-message_v4
IMPORTING
msg = lv_msg
EXCEPTIONS
not_found = 1
OTHERS = 2.
WRITE:/10 lv_msg.
ENDLOOP. -
Error in : Purchase order Creation using BAPI_PO_CREATE1
Hell guys,
I am trying to create a PO using a BAPI - BAPI_PO_CREATE1
I want the new PO to have all the characteristics of an existing PO. whose PO # is stored in wa_order_split_create-docnr and for the new PO, i want the quantity from wa_order_split_create-qty_acptd and the delivery data to be wa_order_split_create-dly_date. But this process and code below gives a short dump in the std FM - MEPO_DOC_ITEM_GET . It raises an exception of failure. I am trying to create many new PO's in the loop below. If there is just one row, sometimes, it creates the PO even with the exception failure ( which is pretty weird).
Am i making any mistake while filling the header or item or schedule lines for the BAPI_PO_CREATE1 ? Any tips or clues why I am getting a dump ?
DATA: i_insert,
i_create_order,
i_cycle TYPE cycle,
i_qty_acpt TYPE dzmeng,
i_dly_date TYPE vbak-vdatu,
i_item TYPE roijnomiio .
DATA: i_order TYPE symsgv,
i_return TYPE swd_return .
DATA: i_vbak TYPE vbak,
i_vbap TYPE vbap,
i_ekko TYPE ekko,
i_ekpo TYPE ekpo,
i_bsoh TYPE bapisdhd1,
i_bsohx TYPE bapisdhd1x,
i_bpoh TYPE bapimepoheader,
i_bpohx TYPE bapimepoheaderx,
i_vbeln TYPE vbeln_va,
i_posnr TYPE posnr_va,
i_contr TYPE vbeln_va,
i_conit TYPE posnr_va,
i_ebeln TYPE ebeln,
i_ebelp TYPE ebelp,
i_pargr TYPE pargr,
i_thead TYPE thead,
i_line TYPE tline,
i_note TYPE txw_note,
i_new_vbeln TYPE vbeln_va,
i_new_ebeln TYPE ebeln,
i_wa_bsoi TYPE bapisditm,
i_wa_bsoix TYPE bapisditmx,
i_wa_bsop TYPE bapiparnr,
i_wa_bsos TYPE bapischdl,
i_wa_bsosx TYPE bapischdlx,
i_wa_vbpa TYPE vbpa,
i_wa_vbkd TYPE vbkd,
i_wa_bpoi TYPE bapimepoitem,
i_wa_bpoix TYPE bapimepoitemx,
i_wa_bpos TYPE bapimeposchedule,
i_wa_bposx TYPE bapimeposchedulx,
i_wa_bpop TYPE bapiekkop,
i_wa_ekpa TYPE ekpa,
i_message TYPE char72,
i_bapiretn TYPE bapiret2,
i_bapiret2 TYPE TABLE OF bapiret2 INITIAL SIZE 1,
i_vbpa TYPE TABLE OF vbpa INITIAL SIZE 1,
i_vbkd TYPE TABLE OF vbkd INITIAL SIZE 1,
i_ekpa TYPE TABLE OF ekpa INITIAL SIZE 1,
i_bsoi TYPE TABLE OF bapisditm INITIAL SIZE 1,
i_bsoix TYPE TABLE OF bapisditmx INITIAL SIZE 1,
i_bsos TYPE TABLE OF bapischdl INITIAL SIZE 1,
i_bsosx TYPE TABLE OF bapischdlx INITIAL SIZE 1,
i_bsop TYPE TABLE OF bapiparnr INITIAL SIZE 1,
i_bpoi TYPE TABLE OF bapimepoitem INITIAL SIZE 1,
i_bpoix TYPE TABLE OF bapimepoitemx INITIAL SIZE 1,
i_bpos TYPE TABLE OF bapimeposchedule INITIAL SIZE 1,
i_bposx TYPE TABLE OF bapimeposchedulx INITIAL SIZE 1,
i_bpop TYPE TABLE OF bapiekkop INITIAL SIZE 1,
i_text_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_line_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_txw_note TYPE TABLE OF txw_note INITIAL SIZE 1,
i_oij_el_doc_mot TYPE oij_el_doc_mot .
CONSTANTS: c_char_c VALUE 'C',
c_char_e VALUE 'E',
c_char_p VALUE 'P',
c_char_g VALUE 'G',
c_char_i VALUE 'I',
c_char_s VALUE 'S',
c_char_x VALUE 'X',
c_zsw(3) VALUE 'ZSW',
c_nomit_stat(4) VALUE 'ZDNY' .
DATA : lv_nomtk_split TYPE oij_nomtk.
DATA : i_order_split_create TYPE TABLE OF zsws_order_split.
DATA : wa_order_split_create TYPE zsws_order_split.
LOOP AT i_order_split_create INTO wa_order_split_create.
IF NOT i_create_order IS INITIAL .
CLEAR: i_create_order .
MOVE: wa_order_split_create-docnr TO i_ebeln,
wa_order_split_create-docitm TO i_ebelp .
CALL FUNCTION 'ME_EKKO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
IMPORTING
po_ekko = i_ekko
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
ENDIF .
* Fill PO Header
i_bpoh-comp_code = i_ekko-bukrs .
i_bpoh-doc_type = i_ekko-bsart .
i_bpoh-vendor = i_ekko-lifnr .
i_bpoh-langu = i_ekko-spras .
i_bpoh-pmnttrms = i_ekko-zterm .
i_bpoh-purch_org = i_ekko-ekorg .
i_bpoh-pur_group = i_ekko-ekgrp .
i_bpoh-currency = i_ekko-waers .
i_bpoh-agreement = i_ekko-konnr .
i_bpoh-incoterms1 = i_ekko-inco1 .
i_bpoh-incoterms2 = i_ekko-inco2 .
* Fill PO update indicator 'X'
i_bpohx-comp_code = c_char_x .
i_bpohx-doc_type = c_char_x .
i_bpohx-vendor = c_char_x .
i_bpohx-langu = c_char_x .
i_bpohx-pmnttrms = c_char_x .
i_bpohx-purch_org = c_char_x .
i_bpohx-pur_group = c_char_x .
i_bpohx-currency = c_char_x .
i_bpohx-agreement = c_char_x .
i_bpohx-incoterms1 = c_char_x .
i_bpohx-incoterms2 = c_char_x .
CALL FUNCTION 'ME_EKPO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
pi_ebelp = i_ebelp
IMPORTING
po_ekpo = i_ekpo
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF .
* Fill PO Item
i_wa_bpoi-po_item = i_ekpo-ebelp .
i_wa_bpoi-material = i_ekpo-matnr .
i_wa_bpoi-plant = i_ekpo-werks .
i_wa_bpoi-stge_loc = i_ekpo-lgort .
i_wa_bpoi-quantity = wa_order_split_create-qty_acptd .
i_wa_bpoi-po_unit = i_ekpo-meins .
i_wa_bpoi-tax_code = i_ekpo-mwskz .
i_wa_bpoi-val_type = i_ekpo-bwtar .
i_wa_bpoi-item_cat = i_ekpo-pstyp .
i_wa_bpoi-acctasscat = i_ekpo-knttp .
i_wa_bpoi-agreement = i_ekpo-konnr .
i_wa_bpoi-agmt_item = i_ekpo-ktpnr .
APPEND i_wa_bpoi TO i_bpoi .
* Fill PO Item update indicator 'X'
i_wa_bpoix-po_item = i_ekpo-ebelp .
i_wa_bpoix-po_itemx = c_char_x .
i_wa_bpoix-material = c_char_x .
i_wa_bpoix-plant = c_char_x .
i_wa_bpoix-stge_loc = c_char_x .
i_wa_bpoix-quantity = c_char_x .
i_wa_bpoix-po_unit = c_char_x .
i_wa_bpoix-tax_code = c_char_x .
i_wa_bpoix-val_type = c_char_x .
i_wa_bpoix-item_cat = c_char_x .
i_wa_bpoix-acctasscat = c_char_x .
i_wa_bpoix-agreement = c_char_x .
i_wa_bpoix-agmt_item = c_char_x .
APPEND i_wa_bpoix TO i_bpoix .
* Fill PO Item Schedule
i_wa_bpos-po_item = i_ekpo-ebelp .
i_wa_bpos-sched_line = '0001' .
i_wa_bpos-delivery_date = wa_order_split_create-dly_date .
i_wa_bpos-quantity = wa_order_split_create-qty_acptd .
APPEND i_wa_bpos TO i_bpos .
* Fill PO Item schedule update indicator 'X'
i_wa_bposx-po_item = i_ekpo-ebelp .
i_wa_bposx-sched_line = '0001' .
i_wa_bposx-delivery_date = c_char_x .
i_wa_bposx-quantity = c_char_x .
APPEND i_wa_bposx TO i_bposx .
CLEAR: i_pargr .
SELECT SINGLE pargr
INTO i_pargr
FROM t161
WHERE bstyp = i_ekko-bstyp
AND bsart = i_ekko-bsart .
CLEAR i_ekpa[].
CALL FUNCTION 'MM_READ_PARTNERS'
EXPORTING
application = c_char_p
ebeln = i_ebeln
bstyp = i_ekko-bstyp
pargr = i_pargr
TABLES
x_ekpa = i_ekpa[].
LOOP AT i_ekpa INTO i_wa_ekpa .
i_wa_bpop-partnerdesc = i_wa_ekpa-parvw .
i_wa_bpop-langu = sy-langu .
IF NOT i_wa_ekpa-lifn2 IS INITIAL .
i_wa_bpop-buspartno = i_wa_ekpa-lifn2 .
ELSE .
i_wa_bpop-buspartno = i_wa_ekpa-parnr .
ENDIF .
APPEND i_wa_bpop TO i_bpop .
CLEAR: i_wa_ekpa, i_wa_bpop .
ENDLOOP .
CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = i_bpoh
poheaderx = i_bpohx
IMPORTING
exppurchaseorder = i_new_ebeln
TABLES
return = i_bapiret2
poitem = i_bpoi[]
poitemx = i_bpoix[]
poschedule = i_bpos[]
poschedulex = i_bposx[].
i_order = i_new_ebeln .
SHIFT i_order LEFT DELETING LEADING '0' .
i_return-errortype = c_char_i .
i_return-workarea = c_zsw .
i_return-message = '064' .
i_return-variable1 = i_order .
loop at i_bapiret2 into i_bapiretn where type ca 'EAX' .
append i_bapiretn to t_bapi_return .
endloop .
if t_bapi_return[] is initial .
i_create_order = c_char_x .
CALL FUNCTION 'SWD_POPUP_MESSAGE_SEND'
EXPORTING
act_return = i_return. "Popup with new PO no.
ENDCASE . " Docind
ENDIF .
ENDLOOP.Hi Shareen,
I think in the following parts of the code,
CALL FUNCTION 'MM_READ_PARTNERS'
EXPORTING
application = c_char_p
ebeln = i_ebeln
bstyp = i_ekko-bstyp
pargr = i_pargr
TABLES
x_ekpa = i_ekpa[].
Error in : Purchase order Creation using BAPI_PO_CREATE1
Posted: Mar 20, 2006 7:39 PM Reply E-mail this post
Hell guys,
I am trying to create a PO using a BAPI - BAPI_PO_CREATE1
I want the new PO to have all the characteristics of an existing PO. whose PO # is stored in wa_order_split_create-docnr and for the new PO, i want the quantity from wa_order_split_create-qty_acptd and the delivery data to be wa_order_split_create-dly_date. But this process and code below gives a short dump in the std FM - MEPO_DOC_ITEM_GET . It raises an exception of failure. I am trying to create many new PO's in the loop below. If there is just one row, sometimes, it creates the PO even with the exception failure ( which is pretty weird).
Am i making any mistake while filling the header or item or schedule lines for the BAPI_PO_CREATE1 ? Any tips or clues why I am getting a dump ?
DATA: i_insert,
i_create_order,
i_cycle TYPE cycle,
i_qty_acpt TYPE dzmeng,
i_dly_date TYPE vbak-vdatu,
i_item TYPE roijnomiio .
DATA: i_order TYPE symsgv,
i_return TYPE swd_return .
DATA: i_vbak TYPE vbak,
i_vbap TYPE vbap,
i_ekko TYPE ekko,
i_ekpo TYPE ekpo,
i_bsoh TYPE bapisdhd1,
i_bsohx TYPE bapisdhd1x,
i_bpoh TYPE bapimepoheader,
i_bpohx TYPE bapimepoheaderx,
i_vbeln TYPE vbeln_va,
i_posnr TYPE posnr_va,
i_contr TYPE vbeln_va,
i_conit TYPE posnr_va,
i_ebeln TYPE ebeln,
i_ebelp TYPE ebelp,
i_pargr TYPE pargr,
i_thead TYPE thead,
i_line TYPE tline,
i_note TYPE txw_note,
i_new_vbeln TYPE vbeln_va,
i_new_ebeln TYPE ebeln,
i_wa_bsoi TYPE bapisditm,
i_wa_bsoix TYPE bapisditmx,
i_wa_bsop TYPE bapiparnr,
i_wa_bsos TYPE bapischdl,
i_wa_bsosx TYPE bapischdlx,
i_wa_vbpa TYPE vbpa,
i_wa_vbkd TYPE vbkd,
i_wa_bpoi TYPE bapimepoitem,
i_wa_bpoix TYPE bapimepoitemx,
i_wa_bpos TYPE bapimeposchedule,
i_wa_bposx TYPE bapimeposchedulx,
i_wa_bpop TYPE bapiekkop,
i_wa_ekpa TYPE ekpa,
i_message TYPE char72,
i_bapiretn TYPE bapiret2,
i_bapiret2 TYPE TABLE OF bapiret2 INITIAL SIZE 1,
i_vbpa TYPE TABLE OF vbpa INITIAL SIZE 1,
i_vbkd TYPE TABLE OF vbkd INITIAL SIZE 1,
i_ekpa TYPE TABLE OF ekpa INITIAL SIZE 1,
i_bsoi TYPE TABLE OF bapisditm INITIAL SIZE 1,
i_bsoix TYPE TABLE OF bapisditmx INITIAL SIZE 1,
i_bsos TYPE TABLE OF bapischdl INITIAL SIZE 1,
i_bsosx TYPE TABLE OF bapischdlx INITIAL SIZE 1,
i_bsop TYPE TABLE OF bapiparnr INITIAL SIZE 1,
i_bpoi TYPE TABLE OF bapimepoitem INITIAL SIZE 1,
i_bpoix TYPE TABLE OF bapimepoitemx INITIAL SIZE 1,
i_bpos TYPE TABLE OF bapimeposchedule INITIAL SIZE 1,
i_bposx TYPE TABLE OF bapimeposchedulx INITIAL SIZE 1,
i_bpop TYPE TABLE OF bapiekkop INITIAL SIZE 1,
i_text_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_line_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_txw_note TYPE TABLE OF txw_note INITIAL SIZE 1,
i_oij_el_doc_mot TYPE oij_el_doc_mot .
CONSTANTS: c_char_c VALUE 'C',
c_char_e VALUE 'E',
c_char_p VALUE 'P',
c_char_g VALUE 'G',
c_char_i VALUE 'I',
c_char_s VALUE 'S',
c_char_x VALUE 'X',
c_zsw(3) VALUE 'ZSW',
c_nomit_stat(4) VALUE 'ZDNY' .
DATA : lv_nomtk_split TYPE oij_nomtk.
DATA : i_order_split_create TYPE TABLE OF zsws_order_split.
DATA : wa_order_split_create TYPE zsws_order_split.
LOOP AT i_order_split_create INTO wa_order_split_create.
IF NOT i_create_order IS INITIAL .
CLEAR: i_create_order .
MOVE: wa_order_split_create-docnr TO i_ebeln,
wa_order_split_create-docitm TO i_ebelp .
CALL FUNCTION 'ME_EKKO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
IMPORTING
po_ekko = i_ekko
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
ENDIF .
Fill PO Header
i_bpoh-comp_code = i_ekko-bukrs .
i_bpoh-doc_type = i_ekko-bsart .
i_bpoh-vendor = i_ekko-lifnr .
i_bpoh-langu = i_ekko-spras .
i_bpoh-pmnttrms = i_ekko-zterm .
i_bpoh-purch_org = i_ekko-ekorg .
i_bpoh-pur_group = i_ekko-ekgrp .
i_bpoh-currency = i_ekko-waers .
i_bpoh-agreement = i_ekko-konnr .
i_bpoh-incoterms1 = i_ekko-inco1 .
i_bpoh-incoterms2 = i_ekko-inco2 .
Fill PO update indicator 'X'
i_bpohx-comp_code = c_char_x .
i_bpohx-doc_type = c_char_x .
i_bpohx-vendor = c_char_x .
i_bpohx-langu = c_char_x .
i_bpohx-pmnttrms = c_char_x .
i_bpohx-purch_org = c_char_x .
i_bpohx-pur_group = c_char_x .
i_bpohx-currency = c_char_x .
i_bpohx-agreement = c_char_x .
i_bpohx-incoterms1 = c_char_x .
i_bpohx-incoterms2 = c_char_x .
CALL FUNCTION 'ME_EKPO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
pi_ebelp = i_ebelp
IMPORTING
po_ekpo = i_ekpo
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF .
Fill PO Item
i_wa_bpoi-po_item = i_ekpo-ebelp .
i_wa_bpoi-material = i_ekpo-matnr .
i_wa_bpoi-plant = i_ekpo-werks .
i_wa_bpoi-stge_loc = i_ekpo-lgort .
i_wa_bpoi-quantity = wa_order_split_create-qty_acptd .
i_wa_bpoi-po_unit = i_ekpo-meins .
i_wa_bpoi-tax_code = i_ekpo-mwskz .
i_wa_bpoi-val_type = i_ekpo-bwtar .
i_wa_bpoi-item_cat = i_ekpo-pstyp .
i_wa_bpoi-acctasscat = i_ekpo-knttp .
i_wa_bpoi-agreement = i_ekpo-konnr .
i_wa_bpoi-agmt_item = i_ekpo-ktpnr .
APPEND i_wa_bpoi TO i_bpoi .
Fill PO Item update indicator 'X'
i_wa_bpoix-po_item = i_ekpo-ebelp .
i_wa_bpoix-po_itemx = c_char_x .
i_wa_bpoix-material = c_char_x .
i_wa_bpoix-plant = c_char_x .
i_wa_bpoix-stge_loc = c_char_x .
i_wa_bpoix-quantity = c_char_x .
i_wa_bpoix-po_unit = c_char_x .
i_wa_bpoix-tax_code = c_char_x .
i_wa_bpoix-val_type = c_char_x .
i_wa_bpoix-item_cat = c_char_x .
i_wa_bpoix-acctasscat = c_char_x .
i_wa_bpoix-agreement = c_char_x .
i_wa_bpoix-agmt_item = c_char_x .
APPEND i_wa_bpoix TO i_bpoix .
Fill PO Item Schedule
i_wa_bpos-po_item = i_ekpo-ebelp .
i_wa_bpos-sched_line = '0001' .
i_wa_bpos-delivery_date = wa_order_split_create-dly_date .
i_wa_bpos-quantity = wa_order_split_create-qty_acptd .
APPEND i_wa_bpos TO i_bpos .
Fill PO Item schedule update indicator 'X'
i_wa_bposx-po_item = i_ekpo-ebelp .
i_wa_bposx-sched_line = '0001' .
i_wa_bposx-delivery_date = c_char_x .
i_wa_bposx-quantity = c_char_x .
APPEND i_wa_bposx TO i_bposx .
CLEAR: i_pargr .
SELECT SINGLE pargr
INTO i_pargr
FROM t161
WHERE bstyp = i_ekko-bstyp
AND bsart = i_ekko-bsart .
CLEAR i_ekpa[].
CALL FUNCTION 'MM_READ_PARTNERS'
EXPORTING
application = c_char_p
ebeln = i_ebeln
bstyp = i_ekko-bstyp
pargr = i_pargr
TABLES
x_ekpa = <b>i_ekpa[].</b>
LOOP AT i_ekpa INTO i_wa_ekpa .
i_wa_bpop-partnerdesc = i_wa_ekpa-parvw .
i_wa_bpop-langu = sy-langu .
IF NOT i_wa_ekpa-lifn2 IS INITIAL .
i_wa_bpop-buspartno = i_wa_ekpa-lifn2 .
ELSE .
i_wa_bpop-buspartno = i_wa_ekpa-parnr .
ENDIF .
APPEND i_wa_bpop TO i_bpop .
CLEAR: i_wa_ekpa, i_wa_bpop .
ENDLOOP .
CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = i_bpoh
poheaderx = i_bpohx
IMPORTING
exppurchaseorder = i_new_ebeln
TABLES
return = i_bapiret2
<b> poitem = i_bpoi[]
poitemx = i_bpoix[]
poschedule = i_bpos[]
poschedulex = i_bposx[].</b>
it should be only i_bpoi, i_bpoix, i_bpos, i_bposx but not i_bpoi[], i_bpoix[], i_bpos[], i_bposx[].
CHange the code as follows:
DATA: i_insert,
i_create_order,
i_cycle TYPE cycle,
i_qty_acpt TYPE dzmeng,
i_dly_date TYPE vbak-vdatu,
i_item TYPE roijnomiio .
DATA: i_order TYPE symsgv,
i_return TYPE swd_return .
DATA: i_vbak TYPE vbak,
i_vbap TYPE vbap,
i_ekko TYPE ekko,
i_ekpo TYPE ekpo,
i_bsoh TYPE bapisdhd1,
i_bsohx TYPE bapisdhd1x,
i_bpoh TYPE bapimepoheader,
i_bpohx TYPE bapimepoheaderx,
i_vbeln TYPE vbeln_va,
i_posnr TYPE posnr_va,
i_contr TYPE vbeln_va,
i_conit TYPE posnr_va,
i_ebeln TYPE ebeln,
i_ebelp TYPE ebelp,
i_pargr TYPE pargr,
i_thead TYPE thead,
i_line TYPE tline,
i_note TYPE txw_note,
i_new_vbeln TYPE vbeln_va,
i_new_ebeln TYPE ebeln,
i_wa_bsoi TYPE bapisditm,
i_wa_bsoix TYPE bapisditmx,
i_wa_bsop TYPE bapiparnr,
i_wa_bsos TYPE bapischdl,
i_wa_bsosx TYPE bapischdlx,
i_wa_vbpa TYPE vbpa,
i_wa_vbkd TYPE vbkd,
i_wa_bpoi TYPE bapimepoitem,
i_wa_bpoix TYPE bapimepoitemx,
i_wa_bpos TYPE bapimeposchedule,
i_wa_bposx TYPE bapimeposchedulx,
i_wa_bpop TYPE bapiekkop,
i_wa_ekpa TYPE ekpa,
i_message TYPE char72,
i_bapiretn TYPE bapiret2,
i_bapiret2 TYPE TABLE OF bapiret2 INITIAL SIZE 1,
i_vbpa TYPE TABLE OF vbpa INITIAL SIZE 1,
i_vbkd TYPE TABLE OF vbkd INITIAL SIZE 1,
i_ekpa TYPE TABLE OF ekpa INITIAL SIZE 1,
i_bsoi TYPE TABLE OF bapisditm INITIAL SIZE 1,
i_bsoix TYPE TABLE OF bapisditmx INITIAL SIZE 1,
i_bsos TYPE TABLE OF bapischdl INITIAL SIZE 1,
i_bsosx TYPE TABLE OF bapischdlx INITIAL SIZE 1,
i_bsop TYPE TABLE OF bapiparnr INITIAL SIZE 1,
i_bpoi TYPE TABLE OF bapimepoitem INITIAL SIZE 1,
i_bpoix TYPE TABLE OF bapimepoitemx INITIAL SIZE 1,
i_bpos TYPE TABLE OF bapimeposchedule INITIAL SIZE 1,
i_bposx TYPE TABLE OF bapimeposchedulx INITIAL SIZE 1,
i_bpop TYPE TABLE OF bapiekkop INITIAL SIZE 1,
i_text_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_line_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_txw_note TYPE TABLE OF txw_note INITIAL SIZE 1,
i_oij_el_doc_mot TYPE oij_el_doc_mot .
CONSTANTS: c_char_c VALUE 'C',
c_char_e VALUE 'E',
c_char_p VALUE 'P',
c_char_g VALUE 'G',
c_char_i VALUE 'I',
c_char_s VALUE 'S',
c_char_x VALUE 'X',
c_zsw(3) VALUE 'ZSW',
c_nomit_stat(4) VALUE 'ZDNY' .
DATA : lv_nomtk_split TYPE oij_nomtk.
DATA : i_order_split_create TYPE TABLE OF zsws_order_split.
DATA : wa_order_split_create TYPE zsws_order_split.
LOOP AT i_order_split_create INTO wa_order_split_create.
IF NOT i_create_order IS INITIAL .
CLEAR: i_create_order .
MOVE: wa_order_split_create-docnr TO i_ebeln,
wa_order_split_create-docitm TO i_ebelp .
CALL FUNCTION 'ME_EKKO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
IMPORTING
po_ekko = i_ekko
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
ENDIF .
Fill PO Header
i_bpoh-comp_code = i_ekko-bukrs .
i_bpoh-doc_type = i_ekko-bsart .
i_bpoh-vendor = i_ekko-lifnr .
i_bpoh-langu = i_ekko-spras .
i_bpoh-pmnttrms = i_ekko-zterm .
i_bpoh-purch_org = i_ekko-ekorg .
i_bpoh-pur_group = i_ekko-ekgrp .
i_bpoh-currency = i_ekko-waers .
i_bpoh-agreement = i_ekko-konnr .
i_bpoh-incoterms1 = i_ekko-inco1 .
i_bpoh-incoterms2 = i_ekko-inco2 .
Fill PO update indicator 'X'
i_bpohx-comp_code = c_char_x .
i_bpohx-doc_type = c_char_x .
i_bpohx-vendor = c_char_x .
i_bpohx-langu = c_char_x .
i_bpohx-pmnttrms = c_char_x .
i_bpohx-purch_org = c_char_x .
i_bpohx-pur_group = c_char_x .
i_bpohx-currency = c_char_x .
i_bpohx-agreement = c_char_x .
i_bpohx-incoterms1 = c_char_x .
i_bpohx-incoterms2 = c_char_x .
CALL FUNCTION 'ME_EKPO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
pi_ebelp = i_ebelp
IMPORTING
po_ekpo = i_ekpo
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF .
Fill PO Item
i_wa_bpoi-po_item = i_ekpo-ebelp .
i_wa_bpoi-material = i_ekpo-matnr .
i_wa_bpoi-plant = i_ekpo-werks .
i_wa_bpoi-stge_loc = i_ekpo-lgort .
i_wa_bpoi-quantity = wa_order_split_create-qty_acptd .
i_wa_bpoi-po_unit = i_ekpo-meins .
i_wa_bpoi-tax_code = i_ekpo-mwskz .
i_wa_bpoi-val_type = i_ekpo-bwtar .
i_wa_bpoi-item_cat = i_ekpo-pstyp .
i_wa_bpoi-acctasscat = i_ekpo-knttp .
i_wa_bpoi-agreement = i_ekpo-konnr .
i_wa_bpoi-agmt_item = i_ekpo-ktpnr .
APPEND i_wa_bpoi TO i_bpoi .
Fill PO Item update indicator 'X'
i_wa_bpoix-po_item = i_ekpo-ebelp .
i_wa_bpoix-po_itemx = c_char_x .
i_wa_bpoix-material = c_char_x .
i_wa_bpoix-plant = c_char_x .
i_wa_bpoix-stge_loc = c_char_x .
i_wa_bpoix-quantity = c_char_x .
i_wa_bpoix-po_unit = c_char_x .
i_wa_bpoix-tax_code = c_char_x .
i_wa_bpoix-val_type = c_char_x .
i_wa_bpoix-item_cat = c_char_x .
i_wa_bpoix-acctasscat = c_char_x .
i_wa_bpoix-agreement = c_char_x .
i_wa_bpoix-agmt_item = c_char_x .
APPEND i_wa_bpoix TO i_bpoix .
Fill PO Item Schedule
i_wa_bpos-po_item = i_ekpo-ebelp .
i_wa_bpos-sched_line = '0001' .
i_wa_bpos-delivery_date = wa_order_split_create-dly_date .
i_wa_bpos-quantity = wa_order_split_create-qty_acptd .
APPEND i_wa_bpos TO i_bpos .
Fill PO Item schedule update indicator 'X'
i_wa_bposx-po_item = i_ekpo-ebelp .
i_wa_bposx-sched_line = '0001' .
i_wa_bposx-delivery_date = c_char_x .
i_wa_bposx-quantity = c_char_x .
APPEND i_wa_bposx TO i_bposx .
CLEAR: i_pargr .
SELECT SINGLE pargr
INTO i_pargr
FROM t161
WHERE bstyp = i_ekko-bstyp
AND bsart = i_ekko-bsart .
CLEAR i_ekpa[].
CALL FUNCTION 'MM_READ_PARTNERS'
EXPORTING
application = c_char_p
ebeln = i_ebeln
bstyp = i_ekko-bstyp
pargr = i_pargr
TABLES
x_ekpa = i_ekpa.
LOOP AT i_ekpa INTO i_wa_ekpa .
i_wa_bpop-partnerdesc = i_wa_ekpa-parvw .
i_wa_bpop-langu = sy-langu .
IF NOT i_wa_ekpa-lifn2 IS INITIAL .
i_wa_bpop-buspartno = i_wa_ekpa-lifn2 .
ELSE .
i_wa_bpop-buspartno = i_wa_ekpa-parnr .
ENDIF .
APPEND i_wa_bpop TO i_bpop .
CLEAR: i_wa_ekpa, i_wa_bpop .
ENDLOOP .
CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = i_bpoh
poheaderx = i_bpohx
IMPORTING
exppurchaseorder = i_new_ebeln
TABLES
return = i_bapiret2
poitem = i_bpoi
poitemx = i_bpoix
poschedule = i_bpos
poschedulex = i_bposx.
i_order = i_new_ebeln .
SHIFT i_order LEFT DELETING LEADING '0' .
i_return-errortype = c_char_i .
i_return-workarea = c_zsw .
i_return-message = '064' .
i_return-variable1 = i_order .
loop at i_bapiret2 into i_bapiretn where type ca 'EAX' .
append i_bapiretn to t_bapi_return .
endloop .
if t_bapi_return[] is initial .
i_create_order = c_char_x .
CALL FUNCTION 'SWD_POPUP_MESSAGE_SEND'
EXPORTING
act_return = i_return. "Popup with new PO no.
ENDCASE . " Docind
ENDIF .
ENDLOOP. -
Error while creating service PO by BAPI_PO_CREATE1
Hi,
I am trying to create a service PO using the BAPI_PO_CREATE1 with reference to service PR and I am getting an "In case of account assignment, please enter acc. assignment data for item" for which i found so many threads but none had resolved this error in my case eventhough i filled up all the required structure such as
LOOP AT gt_esll INTO gs_esll.
gs_services-pckg_no = gs_esll-packno.
gs_services-line_no = gs_esll-introw.
gs_services-subpckg_no = gs_esll-sub_packno.
gs_services-quantity = gs_esll-menge.
gs_services-base_uom = gs_esll-meins.
gs_services-gr_price = gs_esll-brtwr.
gs_services-outl_ind = 'X'.
APPEND gs_services TO gt_services.
CLEAR gs_services.
ENDLOOP.
LOOP AT gt_esll1 INTO gs_esll1.
gs_services-pckg_no = gs_esll1-packno.
gs_services-line_no = gs_esll1-introw.
gs_services-ext_line = gs_esll1-extrow.
gs_services-quantity = gs_esll1-menge.
gs_services-base_uom = gs_esll1-meins.
gs_services-gr_price = gs_esll1-brtwr.
APPEND gs_services TO gt_services.
CLEAR gs_services.
gs_servalues-pckg_no = gs_esll1-packno.
gs_servalues-line_no = gs_esll1-introw.
gs_servalues-serno_line = '01'.
gs_servalues-quantity = gs_esll1-menge.
gs_servalues-net_value = gs_esll1-brtwr.
APPEND gs_servalues TO gt_servalues.
CLEAR: gs_servalues, gs_esll1.
ENDLOOP.
gs_poacct-po_item = gv_poitm.
gs_poacct-serial_no = gs_ebkn-zebkn.
gs_poacct-quantity = gs_ebkn-menge.
gs_poacct-gl_account = gs_ebkn-sakto.
gs_poacct-costcenter = gs_ebkn-kostl.
gs_poacct-co_area = gs_ebkn-kokrs.
APPEND gs_poacct TO gt_poacct.
CLEAR gs_poacct.
gs_poacctx-po_item = gv_poitm.
gs_poacctx-serial_no = gs_ebkn-zebkn.
gs_poacctx-po_itemx = 'X'.
gs_poacctx-serial_nox = 'X'.
gs_poacctx-quantity = 'X'.
gs_poacctx-gl_account = 'X'.
gs_poacctx-costcenter = 'X'.
gs_poacctx-co_area = 'X'.
APPEND gs_poacctx TO gt_poacctx.
CLEAR : gs_poacctx, gs_ebkn.
LOOP AT gt_ppsitm INTO gs_ppsitm.
CLEAR: gs_poitm. " gt_poitm.
READ TABLE gt_matnr INTO gs_matnr WITH KEY banfn = gs_ppsitm-banfn bnfpo = gs_ppsitm-bnfpo.
CLEAR: gs_poitm.
gv_poitm = gv_poitm + 10.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = gv_poitm
IMPORTING
OUTPUT = gv_poitm.
gs_poitm-po_item = gv_poitm.
gs_poitm-quantity = gs_ppsitm-menge.
gs_poitm-po_unit = gs_matnr-meins.
gs_poitm-net_price = gs_ppsitm-quote_price.
* gs_poitm-price_unit = '1'.
gs_poitm-tax_code = gs_ppsitm-mwskz.
gs_poitm-preq_no = gs_ppsitm-banfn.
gs_poitm-preq_item = gs_ppsitm-bnfpo.
IF gs_matnr-packno IS NOT INITIAL.
gs_poitm-pckg_no = gs_matnr-packno. " ADDED BY SKE FOR SERVICE PO
ENDIF.
gs_poitm-item_cat = gs_matnr-pstyp.
gs_poitm-acctasscat = gs_matnr-knttp.
APPEND gs_poitm TO gt_poitm.
ENDLOOP.
aftrer executing this bapi, the accounts structure has been cleared whereas other sturcture has values.
Please give me some hints to fix this.
Thanks in Advance,
Kalidass.Hi pranav,
from EBAN table i got the package no for a PR and passing that package No into ESLL table i am getting the subpaack No.
SELECT banfn bnfpo txz01 matnr bsart ekgrp meins pstyp knttp packno FROM eban
INTO TABLE gt_matnr
FOR ALL ENTRIES IN gt_ppsitm
WHERE banfn = gt_ppsitm-banfn
AND bnfpo = gt_ppsitm-bnfpo.
SELECT packno introw package sub_packno FROM esll
INTO CORRESPONDING FIELDS OF TABLE gt_esll
FOR ALL ENTRIES IN gt_matnr
WHERE packno = gt_matnr-packno.
IF gt_esll IS NOT INITIAL.
SELECT packno introw extrow package sub_packno menge meins brtwr ktext1 FROM ESLL
INTO TABLE gt_esll1
FOR ALL ENTRIES IN gt_esll
WHERE packno = gt_esll-sub_packno.
ENDIF.
LOOP AT gt_esll INTO gs_esll.
gs_services-pckg_no = gs_esll-packno.
gs_services-line_no = gs_esll-introw.
gs_services-subpckg_no = gs_esll-sub_packno.
gs_services-quantity = gs_esll-menge.
gs_services-base_uom = gs_esll-meins.
gs_services-gr_price = gs_esll-brtwr.
gs_services-outl_ind = 'X'.
APPEND gs_services TO gt_services.
CLEAR gs_services.
ENDLOOP.
LOOP AT gt_esll1 INTO gs_esll1.
gs_services-pckg_no = gs_esll1-packno.
gs_services-line_no = gs_esll1-introw.
gs_services-ext_line = gs_esll1-extrow.
gs_services-quantity = gs_esll1-menge.
gs_services-base_uom = gs_esll1-meins.
gs_services-gr_price = gs_esll1-brtwr.
APPEND gs_services TO gt_services.
CLEAR gs_services.
gs_servalues-pckg_no = gs_esll1-packno.
gs_servalues-line_no = gs_esll1-introw.
gs_servalues-serno_line = '01'.
gs_servalues-quantity = gs_esll1-menge.
gs_servalues-net_value = gs_esll1-brtwr.
APPEND gs_servalues TO gt_servalues.
CLEAR: gs_servalues, gs_esll1.
ENDLOOP.
Edited by: Kalidass Etienne.S on Jan 31, 2012 11:07 AM -
Error in PO using BAPI_PO_CREATE1
Hi ,
I got a error in the po that in my template the netpr is 8.00 but in the output always displaying the amount 1.00 only in POITEM-NET_PRICE.even i change in the template different values but no change in the output.why like this and how to solve this.
Thanks,
Regards,
Rajendra.Hi Eswar,
Below is the code,
tables: T100.
DATA : POHEADER LIKE BAPIMEPOHEADER ,
POHEADERX LIKE BAPIMEPOHEADERX,
POITEM LIKE BAPIMEPOITEM OCCURS 0 WITH HEADER LINE,
POITEMX LIKE BAPIMEPOITEMX OCCURS 0 WITH HEADER LINE,
POSCHEDULE LIKE BAPIMEPOSCHEDULE OCCURS 0 WITH HEADER LINE,
POSCHEDULEX LIKE BAPIMEPOSCHEDULX OCCURS 0 WITH HEADER LINE,
POACCOUNT LIKE BAPIMEPOACCOUNT OCCURS 0 WITH HEADER LINE,
POACCOUNTX LIKE BAPIMEPOACCOUNTX OCCURS 0 WITH HEADER LINE,
POCOND LIKE BAPIMEPOCOND OCCURS 0 WITH HEADER LINE,
POCONDX LIKE BAPIMEPOCONDX OCCURS 0 WITH HEADER LINE,
RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,
EXPPURCHASEORDER LIKE BAPIMEPOHEADER-PO_NUMBER.
POHEADER-COMP_CODE = '2006'.
DATA : BEGIN OF DATA_TAB OCCURS 0,
BSART(4) TYPE C,
LIFNR(10) TYPE C,
EKORG(4) TYPE C,
EKGRP(3) TYPE C,
EBELP(5) TYPE C,
MATNR(18) TYPE C,
MAKTX(40) TYPE C,
WERKS(4) TYPE C,
CHARG(10) TYPE C,
BEDNR(10) TYPE C,
PSTYP(1) TYPE C,
KNTTP(1) TYPE C,
ANLN1(12) TYPE C,
ANLN2(4) TYPE C,
AUFNR(12) TYPE C,
PS_PSP_PNR(8) TYPE C,
EINDT(8) TYPE C,
WAERS(5) TYPE C,
NETPR(11) TYPE C,
WKURS(9) TYPE C,
BEDAT(8) TYPE C,
SAKTO(10) TYPE C,
KOSTL(10) TYPE C,
MENGE(13) TYPE C,
MEINS(3) TYPE C,
KWERT(13) TYPE C,
KSCHL(4) TYPE C,
END OF DATA_TAB.
Data
DATA : wc_file type string,
wc_tabix like sy-tabix,
wc_fl(40) type c,
wc_tot(19) type n.
data: i_tab1 like alsmex_tabline occurs 0 with header line,
w_Data_tab like Data_tab occurs 0 with header line,
w_Data_tab like Data_tab,
w_totlines type i,
w_end_col type i.
DATA : C_X(1) TYPE c VALUE 'X'.
DATA : W_ERRSTAT(18) TYPE C.
DATA : W_ERRMSG(18) TYPE C.
DATA : I_EKKO LIKE EKKO OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF I_RETURN OCCURS 0.
DATA : EBELN LIKE EKKO-EBELN.
INCLUDE STRUCTURE DATA_TAB.
DATA : MESSAGE LIKE RETURN-MESSAGE.
DATA : END OF I_RETURN.
ALV
type-pools: slis.
data: txt_report like dokhl-object. "Reportname für Erläuterungsaufruf
data: gt_fieldcat type slis_t_fieldcat_alv,
gt_events type slis_t_event,
gt_sort type slis_t_sortinfo_alv,
gt_list_top_of_page type slis_t_listheader,
gs_layout type slis_layout_alv.
*Parameters
selection-screen begin of block mysel1 with frame.
parameters: pc_file like rlgrap-filename. " obligatory default 'C:'." default 'C:mat.xls'.
selection-screen end of block mysel1.
*AT SELECTION-SCREEN
at selection-screen on pc_file.
call function 'WS_QUERY'
exporting
query = 'FL'
filename = pc_file
importing
return = wc_fl.
condense wc_fl no-gaps.
if wc_fl eq space.
message e009 raising pc_file.
exit.
endif.
at selection-screen on value-request for pc_file.
wc_file = pc_file.
call function 'WS_FILENAME_GET'
exporting
mask = ' '
title = text-001
importing
filename = pc_file
exceptions
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
others = 5.
SELECTION-SCREEN
start-of-selection.
perform 1000_getfile.
perform 2000_process_bapi.
perform fieldcat_init using gt_fieldcat[].
perform layout_init using gs_layout.
perform comment_build using gt_list_top_of_page[].
perform eventtab_build using gt_events[].
PERFORM sort_build USING gt_sort[].
perform 3000_updation_log.
end-of-selection.
*& Form 1000_getfile
text
--> p1 text
<-- p2 text
FORM 1000_getfile .
*w_data_tab = data_tab.
Get the No of Rows in the file
CALL FUNCTION 'AA_FILE_UPLOAD_EXCEL'
EXPORTING
I_FILENAME = pc_file
I_TEST =
I_UCOMM =
I_MAXCOLS =
I_DELIMITER = ','
TABLES
ET_FILECONTENT = DATA_TAB
EXCEPTIONS
ERROR_ACCESSING_FILE = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
describe table Data_tab lines w_totlines.
w_end_col = 27.
w_totlines = 1.
Upload the data from file to Internal Table
refresh Data_tab.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = pc_file
i_begin_col = 1 " Starting col on each row from the upload excel file
i_begin_row = 4 " Starting row from the upload excel file
i_end_col = w_end_col " No. of columns in the upload excel file
i_end_row = w_totlines " Possible no. of rows in the upload excel file
tables
intern = i_tab1
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
endif.
sort i_tab1 by row col.
loop at i_tab1.
case i_tab1-col.
when 1.
clear w_Data_tab.
move i_tab1-value to w_Data_tab-bsart.
when 2.
move i_tab1-value to w_Data_tab-lifnr.
when 3.
move i_tab1-value to w_Data_tab-ekorg.
when 4.
move i_tab1-value to w_Data_tab-ekgrp.
when 5.
move i_tab1-value to w_Data_tab-ebelp.
when 6.
move i_tab1-value to w_Data_tab-matnr.
when 7.
move i_tab1-value to w_Data_tab-maktx.
when 8.
move i_tab1-value to w_Data_tab-werks.
when 9.
move i_tab1-value to w_Data_tab-charg.
when 10.
move i_tab1-value to w_Data_tab-bednr.
when 11.
move i_tab1-value to w_Data_tab-pstyp.
when 12.
move i_tab1-value to w_Data_tab-knttp.
when 13.
move i_tab1-value to w_Data_tab-anln1.
when 14.
move i_tab1-value to w_Data_tab-anln2.
when 15.
move i_tab1-value to w_Data_tab-aufnr.
when 16.
move i_tab1-value to w_Data_tab-ps_psp_pnr.
when 17.
move i_tab1-value to w_Data_tab-eindt.
when 18.
move i_tab1-value to w_Data_tab-waers.
when 19.
move i_tab1-value to w_Data_tab-netpr.
when 20.
move i_tab1-value to w_Data_tab-wkurs.
when 21.
move i_tab1-value to w_Data_tab-bedat.
when 22.
move i_tab1-value to w_Data_tab-sakto.
when 23.
move i_tab1-value to w_Data_tab-kostl.
when 24.
move i_tab1-value to w_Data_tab-menge.
when 25.
move i_tab1-value to w_Data_tab-meins.
when 26.
move i_tab1-value to w_Data_tab-kwert.
when 27.
move i_tab1-value to w_Data_tab-kschl.
endcase.
at end of row.
append w_Data_tab to Data_tab.
clear w_Data_tab.
endat.
endloop.
clear wc_tot.
describe table Data_tab lines wc_tot.
ENDFORM. " 1000_getfile
*& Form 2000_process_bapi
text
--> p1 text
<-- p2 text
FORM 2000_process_bapi .
LOOP AT DATA_TAB.
POHEADER-DOC_TYPE = DATA_TAB-BSART.
POHEADER-VENDOR = DATA_TAB-LIFNR.
POHEADER-PURCH_ORG = DATA_TAB-EKORG.
POHEADER-PUR_GROUP = DATA_TAB-EKGRP.
POHEADER-DOC_DATE = DATA_TAB-BEDAT.
POHEADER-EXCH_RATE = DATA_TAB-WKURS.
POHEADER-CURRENCY = DATA_TAB-WAERS.
APPEND POHEADER.
POHEADERX-DOC_TYPE = 'X'.
POHEADERX-VENDOR = 'X'.
POHEADERX-PURCH_ORG = 'X'.
POHEADERX-PUR_GROUP = 'X'.
POHEADERX-DOC_DATE = 'X'.
POHEADERX-EXCH_RATE = 'X'.
POHEADERX-CURRENCY = 'X'.
APPEND POHEADERX.
POITEM-PO_ITEM = DATA_TAB-EBELP.
POITEM-MATERIAL = DATA_TAB-MATNR.
POITEM-SHORT_TEXT = DATA_TAB-MAKTX.
POITEM-PLANT = DATA_TAB-WERKS.
POITEM-BATCH = DATA_TAB-CHARG.
POITEM-TRACKINGNO = DATA_TAB-BEDNR.
POITEM-ITEM_CAT = DATA_TAB-PSTYP.
POITEM-ACCTASSCAT = DATA_TAB-KNTTP.
POITEM-NET_PRICE = DATA_TAB-NETPR.
POITEM-QUANTITY = DATA_TAB-MENGE.
POITEM-PO_UNIT = DATA_TAB-MEINS.
APPEND POITEM.
POITEMX-PO_ITEM = DATA_TAB-EBELP.
POITEMX-PO_ITEM = 'X'.
POITEMX-MATERIAL = 'X'.
POITEMX-SHORT_TEXT = 'X'.
POITEMX-PLANT = 'X'.
POITEMX-BATCH = 'X'.
POITEMX-TRACKINGNO = 'X'.
POITEMX-ITEM_CAT = 'X'.
POITEMX-ACCTASSCAT = 'X'.
POITEMX-NET_PRICE = 'X'.
POITEMX-QUANTITY = 'X'.
POITEMX-PO_UNIT = 'X'.
APPEND POITEMX.
POACCOUNT-PO_ITEM = DATA_TAB-EBELP.
POACCOUNT-ASSET_NO = DATA_TAB-ANLN1.
POACCOUNT-SUB_NUMBER = DATA_TAB-ANLN2.
POACCOUNT-ORDERID = DATA_TAB-AUFNR.
POACCOUNT-WBS_ELEMENT = DATA_TAB-PS_PSP_PNR.
POACCOUNT-GL_ACCOUNT = DATA_TAB-SAKTO.
POACCOUNT-COSTCENTER = DATA_TAB-KOSTL.
POACCOUNT-QUANTITY = DATA_TAB-MENGE.
APPEND POACCOUNT.
POACCOUNTX-PO_ITEM = DATA_TAB-EBELP.
POACCOUNTX-ASSET_NO = 'X'.
POACCOUNTX-SUB_NUMBER = 'X'.
POACCOUNTX-ORDERID = 'X'.
POACCOUNTX-WBS_ELEMENT = 'X'.
POACCOUNTX-GL_ACCOUNT = 'X'.
POACCOUNTX-COSTCENTER = 'X'.
APPEND POACCOUNTX.
POCOND-ITM_NUMBER = DATA_TAB-EBELP.
POCOND-COND_VALUE = DATA_TAB-KWERT.
POCOND-CURRENCY = DATA_TAB-WAERS.
POCOND-COND_TYPE = DATA_TAB-KSCHL.
POCOND-CHANGE_ID = ' I '.
APPEND POCOND.
POCONDX-ITM_NUMBER = DATA_TAB-EBELP.
POCONDX-COND_VALUE = 'X'.
POCONDX-CURRENCY = 'X'.
POCONDx-COND_TYPE = 'X'.
POCONDx-CHANGE_ID = ' I '.
APPEND POCONDX.
POSCHEDULE-PO_ITEM = DATA_TAB-EBELP.
POSCHEDULE-DELIVERY_DATE = DATA_TAB-EINDT.
POSCHEDULE-QUANTITY = DATA_TAB-MENGE.
APPEND POSCHEDULE.
POSCHEDULEX-PO_ITEM = DATA_TAB-EBELP.
POSCHEDULEX-DELIVERY_DATE = 'X'.
POSCHEDULEx-QUANTITY = 'X'.
APPEND POSCHEDULEX.
ENDLOOP.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = POHEADER
POHEADERX = POHEADERX
IMPORTING
EXPPURCHASEORDER = EXPPURCHASEORDER
EXPHEADER =
EXPPOEXPIMPHEADER =
TABLES
RETURN = RETURN
POITEM = POITEM
POITEMX = POITEMX
POADDRDELIVERY =
POSCHEDULE = POSCHEDULE
POSCHEDULEX = POSCHEDULEX
POACCOUNT = POACCOUNT
POACCOUNTPROFITSEGMENT =
POACCOUNTX = POACCOUNTX
POCONDHEADER =
POCONDHEADERX =
POCOND = POCOND
POCONDX = POCONDX
POPARTNER =
IF SY-SUBRC = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = C_X
ENDIF.
data : w_ekko like ekko-ebeln.
LOOP AT DATA_TAB.
READ TABLE RETURN index 1.
MOVE-CORRESPONDING RETURN TO I_RETURN.
MOVE-CORRESPONDING DATA_TAB TO I_RETURN.
TO GET THE PO NUMBER *************
SELECT single EBELN FROM EKKO INTO w_EKKO
WHERE BSART EQ DATA_TAB-BSART
AND LIFNR EQ DATA_TAB-LIFNR
AND EKORG EQ DATA_TAB-EKORG
AND EKGRP EQ DATA_TAB-EKGRP.
MOVE w_EKKO TO I_RETURN-EBELN.
APPEND I_RETURN.
CLEAR I_RETURN.
ENDLOOP.
ENDFORM. " 2000_process_bapi
*& Form fieldcat_init
FORM fieldcat_init USING lt_fieldcat type slis_t_fieldcat_alv.
data: ls_fieldcat type slis_fieldcat_alv.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'EBELN'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-001.
ls_fieldcat-seltext_m = text-001.
ls_fieldcat-seltext_s = text-001.
ls_fieldcat-reptext_ddic = text-001.
ls_fieldcat-outputlen = '10'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'WERKS'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-002.
ls_fieldcat-seltext_m = text-002.
ls_fieldcat-seltext_s = text-002.
ls_fieldcat-reptext_ddic = text-002.
ls_fieldcat-outputlen = '4'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'KNTTP'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-003.
ls_fieldcat-seltext_m = text-003.
ls_fieldcat-seltext_s = text-003.
ls_fieldcat-reptext_ddic = text-003.
ls_fieldcat-outputlen = '4'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-004.
ls_fieldcat-seltext_m = text-004.
ls_fieldcat-seltext_s = text-004.
ls_fieldcat-reptext_ddic = text-004.
ls_fieldcat-outputlen = '18'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'MENGE'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-005.
ls_fieldcat-seltext_m = text-005.
ls_fieldcat-seltext_s = text-005.
ls_fieldcat-reptext_ddic = text-005.
ls_fieldcat-outputlen = '10'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'NETPR'.
ls_fieldcat-datatype = 'CURR'.
ls_fieldcat-seltext_l = text-006.
ls_fieldcat-seltext_m = text-006.
ls_fieldcat-seltext_s = text-006.
ls_fieldcat-reptext_ddic = text-006.
ls_fieldcat-outputlen = '11'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'MESSAGE'.
ls_fieldcat-datatype = 'C'.
ls_fieldcat-seltext_l = text-007.
ls_fieldcat-seltext_m = text-007.
ls_fieldcat-seltext_s = text-007.
ls_fieldcat-reptext_ddic = text-007.
ls_fieldcat-outputlen = '50'.
append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.
ENDFORM. " fieldcat_init
*& Form layout_init
text
-->P_GS_LAYOUT text
FORM layout_init USING ls_layout type slis_layout_alv.
ls_layout-zebra = 'X'.
ENDFORM. " layout_init
*& Form comment_build
text
-->P_GT_LIST_TOP_OF_PAGE[] text
FORM comment_build USING Lt_top_of_page type slis_t_listheader.
field-symbols: .
data: ls_line type slis_listheader.
data: i_sel like textpool occurs 0 with header line.
read textpool sy-repid into i_sel language sy-langu.
delete i_sel where id ne 'S'.
LIST HEADING LINE: TYPE H
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = text-020.
append ls_line to lt_top_of_page.
clear ls_line.
ls_line-typ = 'S'.
ls_line-key = text-021.
append ls_line to lt_top_of_page.
Selection-screen
loop at i_sel.
assign (i_sel-key) to .
append ls_line to lt_top_of_page.
endloop.
ENDFORM. " comment_build
*& Form eventtab_build
text
-->P_GT_EVENTS[] text
FORM eventtab_build USING lt_events type slis_t_event.
data: ls_event type slis_alv_event.
move 'PF_STATUS_SET' to ls_event-name.
move 'Z2006RMMPOUPLOAD' to ls_event-form.
append ls_event to lt_events.
clear ls_event.
ENDFORM. "eventtab_build
FORM PF_STATUS_SET
form Z2006RMMPOUPLOAD using extab type slis_t_extab. "#EC CALLED
set pf-status 'Z2006RMMPOUPLOAD'. "EXCLUDING extab.
endform. "Z2006RMMPOUPLOAD
FORM TOP_OF_PAGE *
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
i_logo = 'MECOMB'
it_list_commentary = gt_list_top_of_page.
endform. "top_of_page
*& Form 3000_updation_log
FORM 3000_updation_log .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = 'Z2006RMMPOUPLOAD'
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = gs_layout
IT_FIELDCAT = gt_fieldcat[]
IT_EVENTS = gt_events[]
TABLES
T_OUTTAB = I_RETURN
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
ENDFORM. " 3000_updation_log
*& Form sort_build
FORM sort_build USING lt_sort type slis_t_sortinfo_alv.
data: ls_sort type slis_sortinfo_alv.
ls_sort-fieldname = 'EBELN'.
ls_sort-up = 'X'.
ls_sort-subtot = 'X'.
append ls_sort to lt_sort.
clear ls_sort.
ls_sort-fieldname = 'MATNR'.
ls_sort-up = 'X'.
append ls_sort to lt_sort.
clear ls_sort.
ENDFORM. " sort_build
Thanks,
Rajendra.
Maybe you are looking for
-
Hello All, I am Working on Oracle Apps Data base and suddenly my System was Haning and Restart it self when i log in oracle apps data base it give me a instering problem when i enter this query Select * from Cat ; it gives me Error ORA-03113:End of F
-
Connecting to my wi-fi...
Im having trouble connecting to my residential wi-fi, even though the Touch recognizes the router etc. Any help would be very much appreciated.
-
How can I start AHT without an additional install disk - OS X 10.8 was upgraded using App Store so I do not have an install disk on it, When I keep the D key presses after pressing the power button, I do see only the plain gray screen. Few seconds af
-
Query returns list of objects with all fields = NULL
Hi there, I must be doing something wrong. I have tried to query for all activities and all contacts using the code pattern shown below (for activities): Activity_ServiceLocator serviceLocator = new Activity_ServiceLocator(); serviceLocator.setActivi
-
"Addthis" has appeared as a search tool when I highlight and right click. Is it reputable and how do I delete it.