Creation of purchase order using bapi
hi gurus,
Can anyone give me an example of how to create purchase order using bapi
Hi use BAPI_PO_CREATE.. I have an eg. of changing a PO using BAPI. This is almost similar to create.. Go thru and let me know if u need more info..
Dont forget to use 'BAPI COMMIT' after the function call...
DATA:
*Update Short text, qty, net price, item no.,
*agreement no. and agreement line no.
it_po_item TYPE TABLE OF bapimepoitem,
*Select fields
it_po_item_x TYPE TABLE OF bapimepoitemx,
*Delivery date
it_po_schedule TYPE TABLE OF bapimeposchedule,
*Select fields
it_po_schedule_x TYPE TABLE OF bapimeposchedulx,
*Return parameters
it_return TYPE TABLE OF bapiret2,
*PO Account
it_po_account TYPE TABLE OF bapimepoaccount,
*Select fields
it_po_account_x TYPE TABLE OF bapimepoaccountx,
Condition Types
it_po_cond TYPE TABLE OF bapimepocond,
*Select fields
it_po_cond_x TYPE TABLE OF bapimepocondx,
it_po_text type table of BAPIMEPOTEXT.
Structures
DATA:
st_po_header TYPE bapimepoheader,
st_po_header_x TYPE bapimepoheaderx,
st_po_item LIKE LINE OF it_po_item,
st_po_item_x LIKE LINE OF it_po_item_x,
st_po_schedule LIKE LINE OF it_po_schedule,
st_po_schedule_x LIKE LINE OF it_po_schedule_x,
st_return TYPE bapiret2,
st_po_account LIKE LINE OF it_po_account,
st_po_account_x LIKE LINE OF it_po_account_x,
st_po_cond LIKE LINE OF it_po_cond,
st_po_cond_x LIKE LINE OF it_po_cond_x,
st_po_text like line of it_po_text.
Variables
DATA : po_number TYPE bapimepoheader-po_number,
w_item_no(10) TYPE n VALUE '1'.
START-OF-SELECTION.
test values
po_number = '94490'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = po_number
IMPORTING
OUTPUT = po_number
st_po_item-po_item = w_item_no.
st_po_item-quantity = '00.000'.
st_po_item-delete_ind = 'X'.
st_po_item-short_text = 'ZMU-test1'.
st_po_item-agreement = '0060000128'.
st_po_item-agmt_item = '1'.
st_po_item-net_price = '1'.
st_po_item_x-po_item = w_item_no.
st_po_item_x-po_itemx = 'X'.
st_po_item_x-delete_ind = 'X'.
st_po_item_x-quantity = 'X'.
st_po_item_x-short_text = 'X'.
st_po_item_x-agreement = 'X'.
st_po_item_x-agmt_item = 'X'.
st_po_item_x-net_price = 'X'.
st_po_schedule-po_item = w_item_no.
st_po_schedule-delivery_date = '9/19/2008'.
st_po_schedule-quantity = '1'.
st_po_schedule_x-po_item = w_item_no.
st_po_schedule_x-po_itemx = 'X'.
st_po_schedule_x-delivery_date = 'X'.
st_po_schedule_x-quantity = 'X'.
st_po_cond-itm_number = w_item_no.
st_po_cond-cond_type = 'PB00'.
st_po_cond-cond_value = '1.000'.
st_po_cond-currency = 'USD'.
st_po_cond-change_id = 'U'.
st_po_cond_x-itm_number = w_item_no.
st_po_cond_x-itm_numberx = 'X'.
st_po_cond_x-cond_type = 'X'.
st_po_cond_x-cond_value = 'X'.
st_po_cond_x-currency = 'X'.
st_po_cond_x-change_id = 'X'.
st_po_text-PO_NUMBER = po_number.
st_po_text-PO_ITEM = w_item_no.
st_po_text-TEXT_LINE = 'MU_TEST1 MU_TEST2'.
APPEND:
st_po_item_x TO it_po_item_x,
st_po_item TO it_po_item.
st_po_schedule_x TO it_po_schedule_x,
st_po_schedule TO it_po_schedule,
st_po_cond TO it_po_cond,
st_po_cond_x TO it_po_cond_x,
st_po_text to it_po_text.
st_po_text-PO_NUMBER = po_number.
st_po_text-PO_ITEM = w_item_no.
st_po_text-TEXT_LINE = 'MU_TEST2'.
st_po_text-TEXT_FORM = '03'.
append st_po_text to it_po_text.
PERFORM function_call.
LOOP AT it_return INTO st_return.
WRITE:/ st_return-message, 'Message type =', st_return-type,/.
ENDLOOP.
REFRESH:
it_return,
it_po_item,
it_po_item_x,
it_po_cond,
it_po_cond_x.
PERFORM update_price.
WRITE:/ 'After update - Messages'.
LOOP AT it_return INTO st_return.
WRITE:/ st_return-message, 'Message type =', st_return-type,/.
ENDLOOP.
data: begin of test occurs 0,
f1,
end of test.
FORM function_call *
FORM function_call.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = po_number
POHEADER =
POHEADERX =
POADDRVENDOR =
TESTRUN =
MEMORY_UNCOMPLETE =
MEMORY_COMPLETE =
IMPORTING
EXPHEADER =
TABLES
return = it_return
poitem = it_po_item
poitemx = it_po_item_x
POADDRDELIVERY =
poschedule = it_po_schedule
poschedulex = it_po_schedule_x
poaccount =
POACCOUNTPROFITSEGMENT =
poaccountx =
POCONDHEADER =
POCONDHEADERX =
pocond = it_po_cond
pocondx = it_po_cond_x
POLIMITS =
POCONTRACTLIMITS =
POSERVICES =
POSRVACCESSVALUES =
POSERVICESTEXT =
EXTENSIONIN =
EXTENSIONOUT =
POTEXTHEADER =
POTEXTITEM = it_po_text
POPARTNER =
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = st_return.
ENDFORM.
Similar Messages
-
Creation of sale order using bapi in webdynpro using table control
only first row is getting updated when checked in va03, the line items are not getting replaced, only first row is committed..
Here is the code for table control i used...
http://www.scribd.com/doc/51879492/creation-of-sale-order-using-bapi-in-webdynpro-using-table-control
pls help me out with this..Duplicate Posting. Original is here: Sales order creation with bapi in webdynpro using table control
-
HOW TO CREATE PURCHASE ORDER USING BAPI
HI FRIENDS,
I HAVE URGENT REQUIREMNT ,TO CREATE PURCHASE ORDER USING BAPI.PLS HELP ON THIS.
UR'S
RAVIHi
See the sample code and do accordingly
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
Reward points if useful
Anji -
Problem in creating Purchase order Using BAPI
Dear ABAPers,
I am creating the Purchase order Using BAPI_PO_CREATE1. In that the Purchase order Line item i am giving the Net Price for the Material.But While creating the purchase order the system creates the puchase order with the net price which is already available in the memory.So how to solve this problem.
Thanks & Regards,
Ashok.Hi,
Try to pass the value NO_PRICE_FROM_PO in the BAPI and see
NO_PRICE_FROM_PO = 'X'
Regards
Bala Krishna -
Problem regarding the creation of sales order using bapi.
Hai all,
I am creating sales order using bapi but i am, get following error messages :
TYPE ID NUMBER MESSAGE
E VP 112 Please enter sold-to party or ship-to party
E V4 219 Sales document was not changed
I have entered all the parameters.
my program is as follows :
*& Report ZSD_SALES_ORDER
REPORT ZSD_SALES_ORDER.
Tables
*table definitions
TABLES:vbak, "Sales Document: Header Data
knvv, "Customer Master Sales Data
mara, "General Material Data
t001l, "Plants/Branches
mvke, "Sales Data for Material
vbap, "Sales Document: Item Data
konv. "Conditions (Transaction Data)
Types
*type for upload data
TYPES :BEGIN OF ty_upload,
matnr(20) TYPE c, " Old material number
quantity(20) TYPE c, " Cumulative order quantity in sales units
VALUE TYPE BAPIKWERT1,
value(20) TYPE c, " Condition value
value TYPE konv-kwert, " Condition value
END OF ty_upload.
*type for final output table
TYPES :BEGIN OF ty_main,
bismt TYPE mara-bismt, "Old material number
matnr TYPE vbap-matnr, "Material Number
kunnr TYPE vbak-kunnr, "customer number
auart TYPE vbak-auart, "Sales Document Type
vkorg TYPE vbak-vkorg, "Sales Organization
vtweg TYPE vbak-vtweg, "Distribution Channel
spart TYPE vbak-spart, "Division
vbeln TYPE vbak-vbeln, "Sales document
werks TYPE marc-werks, " Plant
lgort TYPE mard-lgort, "Storage Location
posnr TYPE vbap-posnr, "Sales Document Item
parvw TYPE vbpa-parvw, "Partner function
kwmeng TYPE vbap-kwmeng, "Cumulative order quantity in sales units
kschl TYPE konv-kschl, "Condition type
kwert TYPE konv-kwert, "Condition value
KWERT TYPE BAPIKWERT1,
kwert(20) TYPE c, "Condition value
waers TYPE konv-waers, "Currency
END OF ty_main.
*type for old material number
TYPES: BEGIN OF ty_matnr,
matnr TYPE mara-matnr,
bismt TYPE mara-bismt,
END OF ty_matnr.
*type for order number
TYPES :BEGIN OF ty_output,
vbeln TYPE vbak-vbeln, "Sales Document
END OF ty_output.
Constants Begin with C_ *
CONSTANTS:
c_zpmu(4) TYPE c VALUE 'ZPMU',
c_zpmm(4) TYPE c VALUE 'ZPMM'.
DATA: c_ch(1) TYPE c VALUE 'X'.
Data Begin with W_ *
*global data for validations
DATA: w_count TYPE i,
w_vkorg TYPE vbak-vkorg,
w_vtweg TYPE vbak-vtweg,
w_spart TYPE vbak-spart,
w_werks TYPE t001l-werks,
w_check TYPE c,
w_itemno TYPE posnr_va,
W_COND TYPE C.
w_cond(3) TYPE c.
Internal tables Begin with IT_ *
*internal table definitions
DATA : it_upload TYPE STANDARD TABLE OF ty_upload ,
wa_upload TYPE ty_upload.
DATA : it_main TYPE STANDARD TABLE OF ty_main,
wa_main TYPE ty_main.
DATA: it_matnr TYPE STANDARD TABLE OF ty_matnr,
wa_matnr TYPE ty_matnr.
DATA : it_output TYPE STANDARD TABLE OF ty_output.
Internal table for BAPI.
DATA: it_bapisdhd1 TYPE STANDARD TABLE OF bapisdhd1, "Sales and Distribution Document Header
wa_bapisdhd1 TYPE bapisdhd1.
DATA: it_bapisditm TYPE STANDARD TABLE OF bapisditm , "Sales and Distribution Document Item
wa_bapisditm TYPE bapisditm.
DATA: it_bapiparnr TYPE STANDARD TABLE OF bapiparnr, "SD Document Partner: WWW
wa_bapiparnr TYPE bapiparnr.
DATA: it_bapischdl TYPE STANDARD TABLE OF bapischdl, "Schedule Lines
wa_bapischdl TYPE bapischdl.
DATA: it_bapicond TYPE STANDARD TABLE OF bapicond, "Communication Fields for Maintaining Conditions in the Order
wa_bapicond TYPE bapicond.
DATA: it_bapiret2 TYPE STANDARD TABLE OF bapiret2, "Return Parameter
wa_bapiret2 TYPE bapiret2.
Parameters Begin with PR_ *
*selection screen definition
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME .
PARAMETERS: pr_vkorg TYPE vbak-vkorg OBLIGATORY,
pr_vtweg TYPE vbak-vtweg OBLIGATORY,
pr_spart TYPE vbak-spart OBLIGATORY,
pr_kunnr TYPE kna1-kunnr OBLIGATORY,
pr_werks TYPE marc-werks OBLIGATORY,
pr_lgort TYPE mard-lgort OBLIGATORY.
PARAMETERS: pr_auart TYPE vbak-auart OBLIGATORY,
PR_AUGRU TYPE VBAK-AUGRU OBLIGATORY.
pr_augru TYPE vbak-augru.
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME.
PARAMETERS : pr_file TYPE ibipparms-path OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk2.
At selection-screen *
AT SELECTION-SCREEN.
PERFORM f006_validate_vkorg.
PERFORM f007_validate_vtweg.
PERFORM f008_validate_spart.
PERFORM f009_validate_kunnr.
PERFORM f010_validate_werks.
PERFORM f011_validate_lgort.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pr_file.
*for f4 help----
PERFORM f003_f4_help.
S T A R T O F S E L E C T I O N *
START-OF-SELECTION.
*for material ,quantity and value upload
PERFORM f001_upload_file.
*get data
PERFORM f003_get_data.
*for check the data
PERFORM f002_check_data .
PERFORM f004_process.
*for posting
PERFORM f005_posting.
END-OF-SELECTION.
E N D O F S E L E C T I O N *
*& Form f001_upload_file
upload file
FORM f001_upload_file .
DATA : lw_fname TYPE string.
CLEAR lw_fname.
lw_fname = pr_file.
REFRESH it_upload.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lw_fname
filetype = 'ASC'
has_field_separator = c_ch
TABLES
data_tab = it_upload
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT it_upload INTO wa_upload.
wa_upload-value = ( wa_upload-value ) / 10.
MODIFY it_upload FROM wa_upload.
ENDLOOP.
ENDFORM. "F001_UPLOAD_FILE
*& Form f003_f4_help
f4 help
FORM f003_f4_help .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ' '
IMPORTING
file_name = pr_file.
ENDFORM. " f003_f4_help
*& Form check_data
text
FORM f002_check_data .
DATA: lw_lines TYPE i.
DESCRIBE TABLE it_main LINES lw_lines.
IF lw_lines LE 0.
RETURN.
ENDIF.
SELECT a~matnr
a~bismt FROM mara AS a INNER JOIN mvke AS b
ON amatnr = bmatnr
INTO CORRESPONDING FIELDS OF TABLE it_matnr
FOR ALL ENTRIES IN it_main
WHERE a~bismt = it_main-bismt.
IF sy-subrc = 0.
LOOP AT it_main INTO wa_main.
CLEAR : wa_matnr.
READ TABLE it_matnr INTO wa_matnr WITH KEY bismt = wa_main-bismt.
IF sy-subrc = 0.
MOVE: wa_matnr-matnr TO wa_main-matnr.
ENDIF.
MODIFY it_main FROM wa_main TRANSPORTING matnr WHERE bismt = wa_main-bismt.
ENDLOOP.
ELSE.
MESSAGE e000(zmsd) WITH text-001.
ENDIF.
ENDFORM. "CHECK_DATA
*& Form F009_validate_vkorg
text
FORM f006_validate_vkorg .
CLEAR w_vkorg.
SELECT SINGLE vkorg
INTO w_vkorg FROM tvko
WHERE vkorg EQ pr_vkorg.
IF sy-subrc <> 0.
MESSAGE e000(zmsd) WITH text-012 pr_vkorg.
ENDIF.
ENDFORM. " F009_validate_vkorg
*& Form f007_validate_vtweg
text
FORM f007_validate_vtweg .
CLEAR:w_vtweg.
SELECT SINGLE vtweg
INTO w_vtweg FROM tvtw
WHERE vtweg EQ pr_vtweg.
IF sy-subrc <> 0.
MESSAGE e089(zmsd).
ENDIF.
ENDFORM. " f007_validate_vtweg
*& Form f008_validate_spart
text
FORM f008_validate_spart .
CLEAR:w_spart.
SELECT SINGLE spart
INTO w_spart FROM tspa
WHERE spart EQ pr_spart.
IF sy-subrc <> 0.
MESSAGE e087(zmsd).
ENDIF.
ENDFORM. " f008_validate_spart
*& Form F010_validate_kunnr
text
FORM f009_validate_kunnr .
DATA: l_kunnr TYPE kunnr.
CLEAR: w_vkorg, w_vtweg,w_spart.
SELECT SINGLE kunnr FROM knvv
INTO l_kunnr
WHERE kunnr = pr_kunnr
AND vkorg = pr_vkorg
AND vtweg = pr_vtweg
AND spart = pr_spart.
IF sy-subrc <> 0.
MESSAGE e000(zmsd) WITH text-010 pr_kunnr text-011 pr_vkorg .
ENDIF.
ENDFORM. " F010_validate_kunnr
*& Form f010_validate_werks
text
FORM f010_validate_werks .
CLEAR:w_werks.
SELECT SINGLE werks
INTO w_werks FROM t001w
WHERE werks EQ pr_werks.
IF sy-subrc <> 0.
MESSAGE e088(zmsd).
ENDIF.
ENDFORM. " f010_validate_werks
*& Form F011_validate_lgort
text
FORM f011_validate_lgort .
CLEAR:w_werks .
SELECT SINGLE werks FROM t001l
INTO w_werks
WHERE werks = pr_werks
AND lgort = pr_lgort.
IF sy-subrc <> 0.
MESSAGE e000(zmsd) WITH text-007 pr_lgort text-008 pr_werks .
ENDIF.
ENDFORM. " F011_validate_lgort
*& Form f003_get_data
text
FORM f003_get_data .
CLEAR wa_main.
REFRESH it_main.
LOOP AT it_upload INTO wa_upload.
CLEAR : wa_main.
MOVE: wa_upload-matnr TO wa_main-bismt,
wa_upload-quantity TO wa_main-kwmeng,
wa_upload-value TO wa_main-kwert,
pr_vkorg TO wa_main-vkorg,
pr_vtweg TO wa_main-vtweg,
pr_spart TO wa_main-spart,
pr_kunnr TO wa_main-kunnr,
pr_werks TO wa_main-werks,
pr_lgort TO wa_main-lgort.
APPEND wa_main TO it_main.
ENDLOOP.
ENDFORM. " f003_get_data
*& Form f004_process
text
FORM f004_process .
CLEAR w_check.
LOOP AT it_main INTO wa_main.
IF wa_main-matnr = ''.
WRITE:/ text-006,
wa_main-bismt.
w_check = 1.
ENDIF.
IF wa_main-kwmeng = 0.
WRITE:/ text-005,
wa_main-bismt.
w_check = 1.
ENDIF.
IF pr_auart <> 'ZM01'.
IF wa_main-kwert IS INITIAL.
WRITE:/ text-004,
wa_main-bismt.
w_check = 1.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " f004_process
*& Form f005_posting
text
FORM f005_posting .
CLEAR: w_itemno,
w_cond.
w_itemno = 10.
w_cond = 1.
IF w_check = '' OR w_check = 1.
wa_bapisdhd1-doc_type = pr_auart.
wa_bapisdhd1-ord_reason = pr_augru.
LOOP AT it_main INTO wa_main.
IF w_cond = 1.
CLEAR: it_bapiret2,
it_bapisditm,
it_bapiparnr,
it_bapischdl,
it_bapicond.
REFRESH:it_bapiret2,
it_bapisditm,
it_bapiparnr,
it_bapischdl,
it_bapicond.
MOVE: wa_main-vkorg TO wa_bapisdhd1-sales_org,
wa_main-vtweg TO wa_bapisdhd1-distr_chan,
wa_main-spart TO wa_bapisdhd1-division.
wa_bapisdhd1-wbs_eleM = 'Y561.1'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = pr_kunnr
IMPORTING
OUTPUT = pr_kunnr.
wa_bapisdhd1-PURCH_NO_S = pr_kunnr.
wa_bapisdhd1-PURCH_NO_C = pr_kunnr.
ENDIF.
MOVE: w_itemno TO wa_bapisditm-itm_number,
wa_main-matnr TO wa_bapisditm-material,
wa_main-BISMT TO wa_bapisditm-material,
wa_main-werks TO wa_bapisditm-plant,
wa_main-lgort TO wa_bapisditm-store_loc.
wa_bapisditm-target_qty = '10'.
wa_bapisditm-PURCH_NO_S = pr_kunnr.
wa_bapisditm-PURCH_NO_C = pr_kunnr.
APPEND wa_bapisditm TO it_bapisditm.
IF w_cond = 1.
wa_bapiparnr-partn_numb = pr_kunnr.
wa_bapiparnr-itm_number = 10.
wa_bapiparnr-partn_role = 'SP'.
APPEND wa_bapiparnr TO it_bapiparnr.
wa_bapiparnr-partn_role = 'AG'.
APPEND wa_bapiparnr TO it_bapiparnr.
CLEAR wa_bapiparnr-partn_role.
wa_bapiparnr-partn_numb = pr_kunnr.
wa_bapiparnr-partn_role = 'RE'.
APPEND wa_bapiparnr TO it_bapiparnr.
CLEAR wa_bapiparnr-partn_role.
wa_bapiparnr-partn_numb = pr_kunnr.
wa_bapiparnr-partn_role = 'RG'.
APPEND wa_bapiparnr TO it_bapiparnr.
CLEAR wa_bapiparnr-partn_role.
wa_bapiparnr-partn_numb = pr_kunnr.
wa_bapiparnr-partn_role = 'WE'.
APPEND wa_bapiparnr TO it_bapiparnr.
ENDIF.
wa_bapischdl-itm_number = w_itemno.
wa_bapischdl-req_qty = wa_main-kwmeng.
wa_bapischdl-PURCH_NO_S = pr_kunnr.
APPEND wa_bapischdl TO it_bapischdl.
wa_bapicond-itm_number = w_itemno.
wa_bapicond-cond_type = 'ZECL'.
IF ( wa_bapisdhd1-doc_type = 'ZPMU' ) OR ( wa_bapisdhd1-doc_type = 'ZPMM' ).
wa_bapicond-cond_type = 'ZVAL'.
ELSE.
wa_bapicond-cond_type = 'ZMRP'. "+PK12122006
ENDIF.
wa_bapicond-cond_value = wa_main-kwert.
APPEND wa_bapicond TO it_bapicond.
w_itemno = w_itemno + 10.
w_cond = w_cond + 1.
ENDLOOP.
data : SALESDOCUMENTIN like BAPIVBELN-VBELN.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = wa_bapisdhd1
IMPORTING
salesdocument = SALESDOCUMENTIN
TABLES
return = it_bapiret2
order_items_in = it_bapisditm
order_partners = it_bapiparnr
order_schedules_in = it_bapischdl
order_conditions_in = it_bapicond.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = c_ch.
ENDIF.
LOOP AT it_bapiret2 INTO wa_bapiret2.
DATA : w_err(100) TYPE c,
w_matnr TYPE matnr.
IF wa_bapiret2-type = 'E' AND wa_bapiret2-id = 'V1' AND wa_bapiret2-number = 392.
UNPACK wa_bapiret2-message_v1 TO w_matnr.
READ TABLE it_matnr INTO wa_matnr WITH KEY matnr = w_matnr.
IF sy-subrc EQ 0.
CONCATENATE text-013 wa_matnr-bismt INTO w_err SEPARATED BY space.
MESSAGE w_err TYPE 'S'.
ENDIF.
ENDIF.
IF WA_BAPIRET2-TYPE = 'S'. " Comment
WRITE: 40 TEXT-009, WA_BAPIRET2-MESSAGE_V2+0(10).
ENDIF.
ENDLOOP.
ENDFORM. " f005_posting
I have given all the necessary parameters. it is telling that error is in parameter
sales_header_in.
I have checked it.
i have assigned purch_no_s and purch_no_c of the structure BAPISDHD1(ORDER_HEADER_IN)
in the bapi with customer number.
and also i have assigned the partnumber of the structure BAPIPARNR ORDER_PARTNERS
in the bapi with customer number.
but still , it is diplaying the error message, please enter the sold to or ship to party number.
how to resolve this error.
this is urgent requirement.
points will be awarded.
thanking u in advance,
a.srinivas.Hi,
Did u have a look at the standard programs which make use of BAPI_SALESORDER_CREATEFROMDAT1
Heres a list...
LWSSOU08
MV45WF0S
MWWMJF21_BAPI_SALESORDER_CREAT
RBUS2032
Regards,
Tanveer.
<b>Please mark helpful answers</b> -
Creation of Purchase Requisition using BAPI
Hi Experts
Can anyone provide me the sample code for creating Purchase Requisition using BAPI
Thanks in advanceHi siri,
go throught this, hope
http://www.erpgenie.com/abap/bapi/example.htm
Also refer to the following links..
www.sappoint.com/abap/bapiintro.pdf
www.sap-img.com/bapi.htm
www.sap-img.com/abap/bapi-conventions.htm
www.planetsap.com/Bapi_main_page.htm
www.sapgenie.com/abap/bapi/index.htm
Checkout !!
http://searchsap.techtarget.com/originalContent/0,289142,sid21_gci948835,00.html
http://techrepublic.com.com/5100-6329-1051160.html#
http://www.sap-img.com/bapi.htm
http://www.sap-img.com/abap/bapi-conventions.htm
http://www.sappoint.com/abap/bapiintro.pdf
http://sap-img.com/bapi.htm
Thanks
Naveen khan
Message was edited by:
Pattan Naveen -
Hi experts, Upload purchase order using BAPI
hi
Could you please help me how to do PURCHASE ORDER CREATION using BAPI.
Thank you.Satyendra,
The forum that you have posted your question in is for questions related to the SAP Business One Integration for SAP NetWeaver. Your question is or seems to be related to R/3 and should be posted in that forum.
Eddy -
Creation of sales order Using BAPI
Dear Friends,
I need a complete program for Sales order creation using BAPI with all mandatory fields.
I got some sample programs from our friends (SDN) but its not working perfectly.
( Complete working copy of Sales order creation using BAPI. )
Please help me, Expecting your quick reply.
Thanks in Advance.
ShankarHi,
Did u have a look at the standard programs which make use of BAPI_SALESORDER_CREATEFROMDAT1
Heres a list...
LWSSOU08
MV45WF0S
MWWMJF21_BAPI_SALESORDER_CREAT
RBUS2032
Regards,
Tanveer.
<b>Please mark helpful answers</b> -
Closing Purchase order using BAPI : BAPI_PO_CHANGE
Hi ABAPers,
I have a requirement to develope a new report program which should accept a file which contains a list of PO and related Line Items to be closed. Basically the u201CDelivery completedu201D (EKPO-ELIKZ) check-box should be ticked and the PO should be saved.
I know I have to use BAPI: BAPI_PO_CHANGE.
But I am not aware how the parameters of this BAPI is populated.
Please let me know how to populate the parameters of this BAPI in order to Close the list of POs from file.
Input for this BAPI - I have only PO number, item number.
Thanks,
~Sachin>
Sachin Dandekar wrote:
> Hi all,
>
> Now I am able to close the PO using BAPI BAPI_PO_CHANGE.
>
> Here I have one requirement to stop triggering messages while closing PO.
> Please tell me how to stop triggering of output type if I close PO using this program.
>
> Thanks,
> ~Sachin
check parameter to BAPI
NO_MESSAGING = 'X' -
Problem in creation of sales order using BAPI
Hi Guru's,
I am currently working on Minimum Order Value problem. If the ordered item is less than 5$, the requirement is to add a new material MOV to the existing order by filling the difference amount and making it to 5 pounds. I am using the bapi BAPI_SALESORDER_CHANGE to amend the existing order with the MOV material. The material is getting created successfully and the order is getting amended. When i tried to process the order for billing It shows incompletion log exist. On checking the incompletion log it shows "missing configuration". But when i go to the configuration of the material it shows green sign. <b>The most important thing is the material MOV has 2 configuration profile, I believe there is a confusion in selecting the configuration profile for creation of MOV </b>. I came to know about that problem because when i go to change mode (VA02) and try to check the configuration, It askes me to choose the configuration profile and when i choose the configuration profile incompletion log is cleared. When i save the order and send it to billing the billing happens successfully. Could any one help me on this issue.......
Parameters passed to BAPI for configuration.
st_order_cfgs_ref-posex = '900010'. "PM14/06/07
st_order_cfgs_ref-config_id = '000010'. "PM14/06/07
st_order_cfgs_ref-root_id = '10000010'. "PM14/06/07
append st_order_cfgs_ref to t_order_cfgs_ref. "PM14/06/07
st_order_cfgs_inst-config_id = '000010'. "PM14/06/07
st_order_cfgs_inst-inst_id = '10000010'. "PM14/06/07
append st_order_cfgs_inst to t_order_cfgs_inst. "PM14/06/07
st_order_cfgs_refinst-posex = '900010'. "PM14/06/07
st_order_cfgs_refinst-config_id = '000010'. "PM14/06/07
st_order_cfgs_refinst-inst_id = '10000010'. "PM14/06/07
append st_order_cfgs_refinst to t_order_cfgs_refinst. "PM14/06/07
Thanks in advance...
ShivHi,
Did u have a look at the standard programs which make use of BAPI_SALESORDER_CREATEFROMDAT1
Heres a list...
LWSSOU08
MV45WF0S
MWWMJF21_BAPI_SALESORDER_CREAT
RBUS2032
Regards,
Tanveer.
<b>Please mark helpful answers</b> -
To change the header text of Purchase order using BAPI
Hi,
I am using BAPI_PO_CHANGE to change the header text of PO. But it s not reflecting. Can anyone help me by providing solution for this.
<i><b>Points will be rewarded for the useful answers.</b></i>Hi,
I need to change the text using this BAPI alone. I am using this because i need to change many parameters of PO.
Can u please say me solution using BAPI_PO_CHANGE. I need to know what are all the parameters need to be passed to BAPI to change the text.
Thank you for replying. -
Goods Receipt for Purchase Order Using BAPI 'BAPI_GOODSMVT_CREATE'
MB01->....->Adopt+details->...........
How to fill the table GOODSMVT_ITEM(TALBE of BAPI_GOODSMVT_CREATE'), and final document created like following:
Item Quantity EUn Material Plnt SLoc PO Item S DCI
BUn Material description Batch R MvT S T
1 1 KG CB-602 8010 WH06 4500000752 10
DDDD 101 +
2 1.020 KG CRB-2120 8010 4500000752 10 O
9999 543 -Hi
<u>Please take a look at the links for sample coding of the function module - BAPI_GOODSMVT_CREATE.</u>
<b>http://www.sap-img.com/abap/bapi-goodsmvt-create-to-post-goods-movement.htm
http://www.4ap.de/abap/bapi_goodsmvt_create.php</b>
Hope this will help.
Please reward suitable points.
Regards
- Atul -
I want to create purchase orders using LSMW. But i am unaware of standard object or BAPI to do the same. I got it in the list present in LSMW but i am unable to use them..getting errors.So can anybody tell me process for creation of purchase order using LSMW?
Check this thread.
LSMW For T-code ME21N
Regards,
Maha -
Error while creation of PUrchase order by using BAPI.
Hi All,
We are creating a purchase order thru BAPI ("BAPI_POEC_CREATE") and we are passing the following parameters ( I_PO_HEADER , I_PO_ITEMS , I_PO_ACCASS , I_PO_PARTNER and I_PO_ORGDATA) to the bapi and after processing we are getting the following error and Abend messages.
Messages:
1) Enter at least one item or one limit ( we have added line items in I_PO_ITEMS structure).
2) Incorrect interface data for set 78 in method C.
3) Interface data contains errors.
Can anyone help me in fixing these errors inorder to proceed further.
Regards
DharmarajuHi there,
Did you manage to sort this problem ?
If not let me know
I am using the same and know how to overcome
Thanks
Turlock
T -
Create a Purchase order using the BAPI using the data in the XML file.
Hello Gurus,
here is the scenario can anyone help me how to proceed explaining the procedure?
Create a Purchase order using the BAPI using the data in the XML file.
comprehensive explanations are appreciated.
thanks in advance.hi,
first use fm "bapi_po_create".
then use fm "BAPI_ACC_GL_POSTING_POST"
The demo environment was made with real business scenario in mind, but following subjects need to be addressed in a live implementation:
No exceptions and error handling is implemented, except the order rejection (e.g. partly delivery);
In Navision both XML Ports and the XML DOM has been used to integrate with SAP XI, because XML ports has some drawbacks regarding to Namespaces in XML Documents (mandatory in SAP XI);
A minimum of SAP and Navision customization is required to implement this solution. (e.g. user exit in SAP, Navision XML DOM).
Maybe you are looking for
-
Dear All, I am trying to do Remote client copy from Production to Dev system (two system landscape).Below is my hardware configuration of DEV and PRD system : SAP - R/3 4.7(NU) , O/S - AIX , DB - ORACLE 9 PRD SYSTEM : DATABASE Server CPU - 2 (375 MHZ
-
Why can't I access the iBooks store from my iPad?
The Store link in my iStore app is greyed out. No such problem on my iPhone5..
-
CR2 files from 7D not working in Lightroom.
These files open up in other programs, however, when I try to look at them in LR5 it reads "PREVIEW UNAVAILABLE FOR THIS FILE". These files are CR2 files. Any suggestions?
-
Can't get itunes store account
Hi, I live in Bolivia and i just got an iPod touch 32GB but I can't registered to itunes store because my country is not on the list. How can I get apps and games??? is there something I can do???
-
Get some help with some java questions
Parameters are formal arguments passed to: methods, constructors, events handlers and objects or all? What arithmetic operator can be used with characters? If you pass an argument to a math method that is not a number, it returns? If anyone could giv