[ABAP] Create sales order using FM BAPI_SALESORDER_CREATEFROMDAT2 problem
Hello All,
In a report I have to create sales orders, I use function BAPI_SALESORDER_CREATEFROMDAT2, but I got the message like "ship-to-party xxxx is not assigned to sold-to-party" if I_PARTNERS-PARTN_ROLE = 'WE' and when is 'SH' I get 'please enter ship-to-party or sold-to-party'. Please suggest how to correct this. Thank you
Bogdan
Here is the code:
order header values
HEADER-DOC_TYPE = 'ZRTA'.
HEADER-SALES_ORG = '4301'.
HEADER-DISTR_CHAN = '43'.
HEADER-DIVISION = '40'.
HEADER-PURCH_DATE = '20051109'.
HEADER-PURCH_NO_C = '11111'.
header-date_type = 'D'.
*HEADER-REF_DOC = .
*HEADER-REFDOC_CAT = 'E'.
*HEADER-***_NUMBER = ZCONSGACTVSV-HUBREFNUM.
order item level data
I_ITEM-ITM_NUMBER = '000010'.
I_ITEM-MATERIAL = '950700129'.
*I_ITEM-ROUTE = CON-ROUTE.
*IF NOT ZCONSGAGRMSV-CHARG IS INITIAL.
I_ITEM-BATCH = ZCONSGAGRMSV-CHARG.
*ELSE.
I_ITEM-BATCH = '1'.
*ENDIF.
I_SCHEDULE-ITM_NUMBER = '000010'.
I_SCHEDULE-REQ_QTY = '13'.
*shipto = 'WE'.
I_PARTNERS-PARTN_ROLE = 'SH'. " Ship to
I_PARTNERS-PARTN_NUMB = '2000001'.
*I_PARTNERS-PARTN_ROLE = 'SH'. " Ship to
*I_PARTNERS-PARTN_NUMB = '2000001'.
I_PARTNERS-name =
APPEND: I_ITEM,
I_SCHEDULE,
I_PARTNERS.
CLEAR: I_ITEM,
I_SCHEDULE,
I_PARTNERS.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
SALESDOCUMENTIN =
ORDER_HEADER_IN = HEADER
ORDER_HEADER_INX =
SENDER =
BINARY_RELATIONSHIPTYPE =
INT_NUMBER_ASSIGNMENT =
BEHAVE_WHEN_ERROR =
LOGIC_SWITCH =
TESTRUN =
CONVERT = ' '
IMPORTING
SALESDOCUMENT = ORDER
TABLES
RETURN = RETURN
ORDER_ITEMS_IN = I_ITEM
ORDER_ITEMS_INX =
ORDER_PARTNERS = I_PARTNERS
ORDER_SCHEDULES_IN = I_SCHEDULE
ORDER_SCHEDULES_INX =
ORDER_CONDITIONS_IN =
ORDER_CFGS_REF =
ORDER_CFGS_INST =
ORDER_CFGS_PART_OF =
ORDER_CFGS_VALUE =
ORDER_CFGS_BLOB =
ORDER_CFGS_VK =
ORDER_CFGS_REFINST =
ORDER_CCARD =
ORDER_TEXT =
ORDER_KEYS =
EXTENSIONIN =
PARTNERADDRESSES =
Hi Bogdan,
The documentation says
Document Partner
Description
This table parameter is used to enter partners such as sold-to party, or ship-to party, both at header and item level.
The minimum requirement is that the sold-to party is entered at header level. Additional partner functions can then be automatically determined.
You can also enter different addresses in the structure.
Check if it is useful to you in some way.
Regards,
Ravi
Similar Messages
-
Not able to create sales order using BAPI - BAPI_SALESORDER_CREATEFROMDAT2
Hi Experts,
I am not able to create sales order . I am using BAPI - BAPI_SALESORDER_CREATEFROMDAT2
to create sales order .I am passing external sales order number to the parameter
SALESDOCUMENTIN.
I am getting following error.
"524 |Only quantity 1 EA is allowed (Item 00001"
Here EA is UOM(Unit of measurement).
Below is the sample program through which i am trying to create the sales order.
*& Report ZSDC_SALES_TEST
report zsdc_sales_test.
*DATA: wa_bapi_header TYPE bapisdhd1.
Include Name - ZSDC_SALES_ORD_UPLOAD_TOP
Program Name - ZSDC_SALES_ORD_UPLOAD_1393
Program Title - Include for Data Declaration and selection screen
Created by - Lalitha W
Created on - 18-Nov-2008
Object ID - SD_C_1393_SALES_ORDER_UPLOAD
Request Id - SD3K905579
Description - This is a common INCLUDE for data declarations and
*selection screen details.
HISTORY
Date |Developer |Req by | Description |Reference ID
| | | |
| | | |
TYPE-POOLS
*TYPE-POOLS: truxs, abap, slis.
TABLES
*TABLES: t100.
TYPES
types:begin of ty_header,
auart(4) type c, " Sales Order Type
vkorg(4) type c, " Sales Organization
vtweg(2) type c, " Distrubution Channel
spart(2) type c, " Division
kunnr_1(10) type c, " Sold to Party
kunnr_2(10) type c, " Ship to Party
augru(3) type c, " Order Reason
bstkd(35) type c, " PO Number
bstdk(10) type c, " PO Date
ketdat(10) type c, " Required Delivery Date
zterm(4) type c, " Payment Terms
inco1(3) type c, " Inco Terms -1
inco2(28) type c, " Inco Terms -2
prsdt(10) type c, " pricing date
waerk(5) type c, " Document Currency
vkbur(4) type c, " Sales Office
vkgrp(3) type c, " Sales group
pltyp(2) type c, " Price List type
kdgrp(2) type c, " Customer Group
bstkd_e(35) type c, " Ship-to-party PO number
submi(10) type c, " Collective Number
bname(35) type c, " Name
ihrez(12) type c, " Your Reference
kschl_1(4) type c, " Condition Type
kbetr_1(11) type c, " Amount
kschl_2(4) type c, " Condition Type
kbetr_2(11) type c, " Amount
kschl_3(4) type c, " Condition Type
kbetr_3(11) type c, " Amount
partner_1(25) TYPE c, " Partner(Bill To Party Number)
partner_2(25) TYPE c, " Partner(Payer Number)
partner_3(25) TYPE c, " Partner(Sales Responsible Number)
partner_4(25) TYPE c, " Partner(Order admin)
partner_5(25) TYPE c, " Partner(Contact person)
partner_1(10) type c, " Partner(Bill To Party Number)
partner_2(10) type c, " Partner(Payer Number)
partner_3(10) type c, " Partner(Sales Responsible Number)
partner_4(10) type c, " Partner(Order admin)
partner_5(10) type c, " Partner(Contact person)
tdspras_1(2) type c,
text_1(500) type c, " Text Before Items Z012
tdspras_2(2) type c,
text_2(500) type c, " Invocie Up Z034
tdspras_3(2) type c,
text_3(500) type c, " Invocie Down Z035
tdspras_4(2) type c,
text_4(500) type c, " Customer Reference Continue Z018
tdspras_5(2) type c,
text_5(500) type c, " Dispatch Marks/ Order Z019
tdspras_6(2) type c,
text_6(500) type c, " Ordered By Z003
tdspras_7(2) type c,
text_7(500) type c, " Sales Parameters Z002
kvgr1(3) type c, " Industry
kvgr2(3) type c, " customer BU
end of ty_header.
types: begin of ty_item,
bstkd(35) type c, " PO Number
bstdk(10) type c, " PO Date
bstkd_e(35) type c, " Ship-to-party PO number
posnr(6) type c, " POSTION NUMBER
matnr(18) type c, " Material Number
kwmeng(18) type c, " Order Quantity
pstyv(4) type c, " Sales doc. item categ
kursk(18) type c, " EXCHANGE RATE****
ffprf(8) type c, " DIP PROFILE
werks(4) type c, " Delivering Plant
vstel(4) type c, " SHIPPING POINT
lgort(4) type c, " STORAGE LOCATION
route(6) type c, " Route
kurrf(18) type c, " EXCHANGE RATE-FI
ntgew(18) type c, " Net Weight
brgew(18) type c, " Gross Weight
gewei(3) type c, " Weight Unit
prctr(10) type c, " profit center
abgrs(6) type c, " RESULT ANALYSIS KEY
kalsm_k(4) type c, " COSTING SHEET
kschl_1(4) type c, " Condition Type
kbetr_1(11) type c, " Amount
kschl_2(4) type c, " Condition Type
kbetr_2(11) type c, " Amount
kschl_3(4) type c, " Condition Type
kbetr_3(11) type c, " Amount
text_1(500) type c, " material Text 0001
tdspras_1(1) type c,
text_2(500) type c, " Pr Text 9001
tdspras_2(1) type c,
end of ty_item.
types: begin of ty_schedule_line,
bstkd(35) type c, "PO number
bstdk(10) type c, "PO date
bstkd_e(35) type c, "Ship-to-party PO number
posnr(6) type c, "sales doc.Item
etdat(10) type c, "Schedule line date
wmeng(2) type c, "Order Quantity
end of ty_schedule_line.
types: begin of ty_err ,
auart(4) type c, " Sales Order Type
vkorg(4) type c, " Sales Organization
vtweg(2) type c, " Distrubution Channel
spart(2) type c, " Division
kunnr_1(10) type c, " Sold to Party
kunnr_2(10) type c, " Ship to Party
augru(3) type c, " Order Reason
bstkd(35) type c, " PO Number
bstdk(10) type c, " PO Date
ketdat(10) type c, " Required Delivery Date
zterm(4) type c, " Payment Terms
inco1(3) type c, " Inco Terms -1
inco2(28) type c, " Inco Terms -2
prsdt(10) type c, " pricing date
waerk(5) type c, " Document Currency
vkbur(2) type c, " Sales Office
vkgrp(3) type c, " Sales group
pltyp(2) type c, " Price List type
kdgrp(2) type c, " Customer Group
bstkd_e(35) type c, " Ship-to-party PO number
submi(10) type c, " Collective Number
bname(35) type c, " Name
ihrez(12) type c, " Your Reference
kschl_1(4) type c, " Condition Type
kbetr_1(11) type c, " Amount
kschl_2(4) type c, " Condition Type
kbetr_2(11) type c, " Amount
kschl_3(4) type c, " Condition Type
kbetr_3(11) type c, " Amount
partner_1(25) type c, " Partner(Bill To Party Number)
partner_2(25) type c, " Partner(Payer Number)
partner_3(25) type c, " Partner(Sales Responsible Number)
partner_4(25) type c, " Partner(Order admin)
partner_5(25) type c, " Partner(Contact person)
tdspras_1(2) type c,
text_1(500) type c, " Text Before Items Z012
tdspras_2(2) type c,
text_2(500) type c, " Invocie Up Z034
tdspras_3(2) type c,
text_3(500) type c, " Invocie Down Z035
tdspras_4(2) type c,
text_4(500) type c, " Customer Reference Continue Z018
tdspras_5(2) type c,
text_5(500) type c, " Dispatch Marks/ Order Z019
tdspras_6(2) type c,
text_6(500) type c, " Ordered By Z003
tdspras_7(2) type c,
text_7(500) type c, " Sales Parameters Z002
kvgr1(3) type c, " Industry
kvgr2(3) type c, " customer BU
message(600) type c,
end of ty_err.
types: begin of ty_t685a,
kschl type kschl,
krech type krech,
end of ty_t685a.
INTERNAL TABLES
***header
data: g_krech_1(4) type c, " Calculation type for condition
g_krech_2(4) type c, " Calculation type for condition
g_krech_3(4) type c. " Calculation type for condition
g_krech_4(4) TYPE c, " Calculation type for condition
g_krech_5(4) TYPE c, " Calculation type for condition
g_krech_6(4) TYPE c, " Calculation type for condition
g_krech_7(4) TYPE c, " Calculation type for condition
g_krech_8(4) TYPE c, " Calculation type for condition
g_krech_9(4) TYPE c, " Calculation type for condition
g_krech_10(4) TYPE c, " Calculation type for condition
g_krech_11(4) TYPE c, " Calculation type for condition
g_krech_12(4) TYPE c, " Calculation type for condition
g_krech_13(4) TYPE c, " Calculation type for condition
g_krech_14(4) TYPE c, " Calculation type for condition
g_krech_15(4) TYPE c, " Calculation type for condition
g_krech_16(4) TYPE c, " Calculation type for condition
g_krech_17(4) TYPE c, " Calculation type for condition
g_krech_18(4) TYPE c, " Calculation type for condition
g_krech_19(4) TYPE c, " Calculation type for condition
g_krech_20(4) TYPE c. " Calculation type for condition
Items
data: g_krech_item_1(4) type c, " Calculation type for condition
g_krech_item_2(4) type c, " Calculation type for condition
g_krech_item_3(4) type c. " Calculation type for condition
g_krech_item_4(4) TYPE c, " Calculation type for condition
g_krech_item_5(4) TYPE c, " Calculation type for condition
g_krech_item_6(4) TYPE c, " Calculation type for condition
g_krech_item_7(4) TYPE c, " Calculation type for condition
g_krech_item_8(4) TYPE c, " Calculation type for condition
g_krech_item_9(4) TYPE c, " Calculation type for condition
g_krech_item_10(4) TYPE c, " Calculation type for condition
g_krech_item_11(4) TYPE c, " Calculation type for condition
g_krech_item_12(4) TYPE c, " Calculation type for condition
g_krech_item_13(4) TYPE c, " Calculation type for condition
g_krech_item_14(4) TYPE c, " Calculation type for condition
g_krech_item_15(4) TYPE c, " Calculation type for condition
g_krech_item_16(4) TYPE c. " Calculation type for condition
data: it_t685a type standard table of ty_t685a.
data: wa_bapi_header type bapisdhd1,
wa_bapi_headerx TYPE bapisdhd1x,
it_bapi_item type table of bapisditm,
it_bapi_itemx TYPE TABLE OF bapisditmx,
it_bapi_cond type table of bapicond,
it_bapi_condx TYPE TABLE OF bapicondx,
it_bapi_partner type table of bapiparnr,
it_bapi_shdl type table of bapischdl,
it_bapi_shdlx TYPE TABLE OF bapischdlx,
it_bapi_order_text type TABLE OF BAPISDTEXT,
it_bapireturn type table of bapiret2.
data: wa_bapi_item like line of it_bapi_item,
wa_bapi_itemx LIKE LINE OF it_bapi_itemx,
wa_bapi_cond like line of it_bapi_cond,
wa_bapi_condx LIKE LINE OF it_bapi_condx,
wa_bapi_partner like line of it_bapi_partner,
wa_bapi_shdl like line of it_bapi_shdl,
wa_bapi_shdlx LIKE LINE OF it_bapi_shdlx,
wa_bapi_order_text like LINE OF it_bapi_order_text,
wa_bapireturn like line of it_bapireturn.
*DATA: zmode(1) VALUE 'N'.
data: it_header type standard table of ty_header.
*DATA: it_temp_header TYPE STANDARD TABLE OF ty_header.
data: it_item type standard table of ty_item.
*DATA: it_temp_item TYPE STANDARD TABLE OF ty_item.
data: it_err type standard table of ty_err.
data: it_fline1 type standard table of tline,
wa_fline1 type tline.
data: it_thead1 type thead.
data: it_fline2 type standard table of tline,
wa_fline2 type tline.
data: it_thead2 type thead.
data: it_fline3 type standard table of tline,
wa_fline3 type tline.
data: it_thead3 type thead.
data: it_fline4 type standard table of tline,
wa_fline4 type tline.
data: it_thead4 type thead.
data: it_fline5 type standard table of tline,
wa_fline5 type tline.
data: it_thead5 type thead.
data: wa_header like line of it_header,
wa_item like line of it_item,
wa_err type ty_err,
wa_bill LIKE LINE OF it_bill,
wa_bill1 LIKE LINE OF it_bill,
wa_iterr like line of it_err,
wa_t685a like line of it_t685a.
wa_bill_item TYPE ty_bill_item.
data: it_schedule_line type standard table of ty_schedule_line,
wa_schedule_line type ty_schedule_line.
data: sales_order_no type bapivbeln-vbeln.
data: ext_sales_order_no type bapivbeln-vbeln.
Variable to be used to separate the fields which are concatenated by a
runtime character
*DATA: g_tabchar(1) TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
*DATA: wa_truxs_t_text_data TYPE truxs_t_text_data.
*DATA: g_filename TYPE string,
g_path TYPE string,
g_fullpath TYPE string,
g_user_action TYPE i,
g_file_encoding TYPE abap_encoding.
*DATA : g_text(8192),
data : g_mstring1(100) type c,
g_mstring2(100) type c,
g_mstring3(100) type c,
g_mstring4(100) type c,
g_mstring5(100) type c.
data: g_count1 type ebelp,
g_str_count1(6) type c.
data: g_count type ebelp,
g_str_count(6) type c.
*DATA: f_subrc LIKE sy-subrc,
f_subrc1 LIKE sy-subrc,
f_error(500) TYPE c,
item1(27) TYPE c,
item2(27) TYPE c,
item3(27) TYPE c,
item4(27) TYPE c,
i TYPE ekpo-ebelp.
*DATA: g_billplan_header TYPE c,
g_billplan_item TYPE c.
data : g_external_so type vbak-vbeln. "SO
SELECTION-SCREEN
selection-screen begin of block frame1 with frame title text-001 .
parameters:p_file1 type rlgrap-filename, "OBLIGATORY, "Header data.
p_file2 type rlgrap-filename, "OBLIGATORY, "Item Data.
p_file3 type rlgrap-filename, "Schedule line.
p_file4 type rlgrap-filename ."OBLIGATORY. "Error file.
selection-screen end of block frame1.
start-of-selection.
wa_bapi_header-doc_type = 'Z0MX'. "order type
wa_bapi_header-sales_org = '0130'."sales org
wa_bapi_header-distr_chan = '13'. "distr channel
wa_bapi_header-division = '13'. "division
Old code from copied program
wa_bapi_header-purch_no_s = wa_header-kunnr_2. " Ship to party
New code as required in Finland project
We are using to Header ->Order Tab -> Ship to Party -> Purchase order no (BSTKD_E) to store Old legacy SO number
wa_bapi_header-purch_no_s = 'MX100443'. "External SO i.e Old legacey SO number
wa_bapi_header-ref_1_s = '0000666666'. "Sold to party
wa_bapi_header-ord_reason = wa_header-augru.
wa_bapi_header-purch_no_c = 'ddr1234'. " PO number
wa_bapi_header-purch_date = sy-datum. " PO date
wa_bapi_header-req_date_h = sy-datum. " Required Delivery Date
wa_bapi_header-pmnttrms = '01'. " Payment Terms
wa_bapi_header-incoterms1 = wa_header-inco1.
wa_bapi_header-incoterms2 = wa_header-inco2.
wa_bapi_header-price_date = wa_header-prsdt. " Pricing date
wa_bapi_header-currency = wa_header-waerk. " Document Currency
wa_bapi_header-sales_grp = wa_header-vkgrp. " Sales group
wa_bapi_header-price_list = wa_header-pltyp. " Price list type
wa_bapi_header-cust_group = wa_header-kdgrp. " Cust Group
wa_bapi_header-ship_type = wa_header-vsart. " Shipping Type
wa_bapi_header-purch_no_s = wa_header-bstkd_e. " Ship-to-party po number
wa_bapi_header-collect_no = wa_header-submi. " Collective No.
wa_bapi_header-name = wa_header-bname. " Name
wa_bapi_header-ref_1 = wa_header-ihrez. " Your Reference
wa_bapi_header-cust_grp1 = wa_header-kvgr1. " Industry
wa_bapi_header-cust_grp2 = wa_header-kvgr2. " Customer BU
*ENDFORM. " f_header
IF wa_header-partner_1 IS NOT INITIAL.
wa_bapi_partner-partn_role = 'AG'.
wa_bapi_partner-partn_numb = '0000666666'.
wa_bapi_partner-itm_number = '000000'.
append wa_bapi_partner to it_bapi_partner.
clear wa_bapi_partner.
ENDIF.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = wa_header-partner_2
importing
output = wa_header-partner_2.
IF wa_header-partner_2 IS NOT INITIAL.
wa_bapi_partner-partn_role = 'WE'.
wa_bapi_partner-partn_numb = '0000666666'.
wa_bapi_partner-itm_number = '000000'.
append wa_bapi_partner to it_bapi_partner.
clear wa_bapi_partner.
ENDIF.
perform f_item.
data : order_items_inx type table of bapisditmx with header line.
order_items_inx-material = 'X'. "
order_items_inx-target_qty = 'X'. "
order_items_inx-comp_quant = 'X'. "
order_items_inx-trgqty_den = 'X'.
order_items_inx-rnddlv_qty = 'X'.
order_items_inx-updateflag = 'I'.
order_items_inx-target_qu = 'X'.
order_items_inx-plant = 'X'. "
append order_items_inx.
call function 'BAPI_SALESORDER_CREATEFROMDAT2'
exporting
salesdocumentin = 'MX11111152'
order_header_in = wa_bapi_header
order_header_inx = wa_bapi_headerx
importing
salesdocument = sales_order_no
tables
return = it_bapireturn
order_items_in = it_bapi_item
order_items_inx = order_items_inx
order_partners = it_bapi_partner
order_conditions_in = it_bapi_cond.
if sy-subrc is initial.
commit work.
endif.
*& Form f_item
text
form f_item .
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = wa_item-posnr
importing
output = wa_item-posnr.
wa_item-posnr = '000010'.
IF sy-subrc EQ 0. "IS INITIAL.
move wa_item-posnr to g_str_count."commented out by shakti
ENDIF.
wa_bapi_item-itm_number = wa_item-posnr. " Line item
WA_BAPI_ITEM-PO_ITM_NO = WA_ITEM-EBELP.
wa_bapi_item-division = wa_item-spart.
wa_bapi_item-purch_no_c = 'ddr1234'. " po number
wa_bapi_item-purch_date = sy-datum. " po date
wa_bapi_item-purch_no_s = 'MX11111112'. " Ship-to-party po number
wa_item-matnr = 'MAXIMO_SERVICE'.
call function 'CONVERSION_EXIT_MATN1_INPUT'
exporting
input = wa_item-matnr
importing
output = wa_item-matnr
exceptions
length_error = 1
others = 2.
if sy-subrc is initial.
wa_bapi_item-material = wa_item-matnr. "material
endif.
wa_bapi_item-target_qty = '1'. " Order qty
wa_bapi_item-comp_quant = '1'.
wa_bapi_item-target_qu = 'EA'.
wa_bapi_item-fixed_quan = '1'.
wa_bapi_item-comp_quant = wa_item-kwmeng.
wa_bapi_item-trgqty_den = '1'.
wa_bapi_item-rnddlv_qty = wa_item-kwmeng.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_item-ps_psp_pnr
IMPORTING
output = wa_item-ps_psp_pnr.
IF sy-subrc = 0.
wa_bapi_item-wbs_elem = wa_item-ps_psp_pnr.
ENDIF.
wa_bapi_item-item_categ = 'ZMAX'.
wa_bapi_item-ex_rate_fi = wa_item-kurrf.
wa_bapi_item-dli_profil = wa_item-ffprf. " Dynamic item processor profile
wa_bapi_item-route = wa_item-route. " route
wa_bapi_item-exchg_rate = wa_item-kursk.
wa_bapi_item-plant = '2090'. " Plant
wa_bapi_item-ship_point = 'FN11'. " Shipping point
wa_bapi_item-store_loc = wa_item-lgort. " stg loc
REPLACE ALL OCCURRENCES OF ',' IN wa_item-ntgew WITH '.'.
REPLACE ALL OCCURRENCES OF ',' IN wa_item-brgew WITH '.'.
wa_bapi_item-net_weight = wa_item-ntgew. "
wa_bapi_item-gross_wght = wa_item-brgew. "
call function 'CONVERSION_EXIT_CUNIT_INPUT'
exporting
input = wa_item-gewei
language = sy-langu
importing
output = wa_item-gewei.
EXCEPTIONS
unit_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
wa_bapi_item-untof_wght = 'KG'. " weight unit
replace all occurrences of ',' in wa_item-kursk with '.'.
replace all occurrences of ',' in wa_item-kurrf with '.'.
wa_bapi_item-profit_ctr = wa_item-prctr. " Profit center
wa_bapi_item-resanalkey = wa_item-abgrs. " RESULT ANALYSIS KEY
wa_bapi_item-cstg_sheet = wa_item-kalsm_k. " COSTING SHEET
append wa_bapi_item to it_bapi_item.
endform. " f_item
Thanks & regards,
Chetansee the following to create sales order:-
*& Report ZSALESORDER
*&DEVELOPED BY JANI KRUPA 4.10.2008
REPORT ZSALESORDER.
Parameters
Sales document type
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text FOR FIELD p_auart.
PARAMETERS: p_auart TYPE auart OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Sales organization
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD p_vkorg.
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Distribution channel
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text2 FOR FIELD p_vtweg.
PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Division.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text3 FOR FIELD p_spart.
PARAMETERS: p_spart TYPE spart OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SKIP 1.
Sold-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text4 FOR FIELD p_sold.
PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Ship-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text5 FOR FIELD p_ship.
PARAMETERS: p_ship TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SKIP 1.
Material
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text6 FOR FIELD p_matnr.
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Quantity.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text7 FOR FIELD p_menge.
PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Plant
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text9 FOR FIELD p_plant.
PARAMETERS: p_plant TYPE werks_d .
SELECTION-SCREEN END OF LINE.
Complete Deliver
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text10 FOR FIELD p_autlf.
PARAMETERS: p_autlf TYPE autlf DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
Data declarations.
DATA: v_vbeln LIKE vbak-vbeln.
DATA: header LIKE bapisdhead1.
DATA: headerx LIKE bapisdhead1x.
DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.
DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.
DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx
WITH HEADER LINE.
DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl
WITH HEADER LINE.
DATA: lt_schedules_ink TYPE STANDARD TABLE OF bapisdhead1
WITH HEADER LINE.
Initialization.
INITIALIZATION.
v_text = 'Order type'.
v_text1 = 'Sales Org'.
v_text2 = 'Distribution channel'.
v_text3 = 'Division'.
v_text4 = 'Sold-to'.
v_text5 = 'Ship-to'.
v_text6 = 'Material'.
v_text7 = 'Quantity'.
v_text9 = 'Plant'.
v_text10 = 'Complete delivery'.
Start-of-selection.
START-OF-SELECTION.
Header data
Sales document type
header-doc_type = p_auart.
headerx-doc_type = 'X'.
Sales organization
header-sales_org = p_vkorg.
headerx-sales_org = 'X'.
Distribution channel
header-distr_chan = p_vtweg.
headerx-distr_chan = 'X'.
Division
header-division = p_spart.
headerx-division = 'X'.
headerx-updateflag = 'I'.
*Complete delivery
header-COMPL_DLV = p_autlf.
header-COMPL_DLV = 'X'.
Partner data
Sold to
partner-partn_role = 'AG'.
partner-partn_numb = p_sold.
APPEND partner.
Ship to
partner-partn_role = 'WE'.
partner-partn_numb = p_ship.
APPEND partner.
ITEM DATA
itemx-updateflag = 'I'.
Line item number.
item-itm_number = '000010'.
itemx-itm_number = 'X'.
Material
item-material = p_matnr.
itemx-material = 'X'.
Plant
item-plant = p_plant.
itemx-plant = 'X'.
Quantity
item-target_qty = p_menge.
itemx-target_qty = 'X'.
item category
itemx-ITEM_CATEG = 'X'.
APPEND item.
APPEND itemx.
ITEM DATA
itemx-updateflag = 'I'.
Line item number.
item-itm_number = '000020'.
itemx-itm_number = 'X'.
Material
item-material = p_matnr.
itemx-material = 'X'.
Plant
item-plant = p_plant.
itemx-plant = 'X'.
Quantity
item-target_qty = p_menge.
itemx-target_qty = 'X'.
APPEND item.
APPEND itemx.
Fill schedule lines
lt_schedules_in-itm_number = '000010'.
lt_schedules_in-sched_line = '0001'.
lt_schedules_in-req_qty = p_menge.
APPEND lt_schedules_in.
Fill schedule line flags
lt_schedules_inx-itm_number = '000010'.
lt_schedules_inx-sched_line = '0001'.
lt_schedules_inx-updateflag = 'X'.
lt_schedules_inx-req_qty = 'X'.
APPEND lt_schedules_inx.
Fill schedule lines
lt_schedules_in-itm_number = '000020'.
lt_schedules_in-sched_line = '0001'.
lt_schedules_in-req_qty = p_menge.
APPEND lt_schedules_in.
Fill schedule line flags
lt_schedules_inx-itm_number = '000020'.
lt_schedules_inx-sched_line = '0001'.
lt_schedules_inx-updateflag = 'X'.
lt_schedules_inx-req_qty = 'X'.
APPEND lt_schedules_inx.
Call the BAPI to create the sales order.
CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
EXPORTING
sales_header_in = header
sales_header_inx = headerx
IMPORTING
salesdocument_ex = v_vbeln
TABLES
return = return
sales_items_in = item
sales_items_inx = itemx
sales_schedules_in = lt_schedules_in
sales_schedules_inx = lt_schedules_inx
sales_partners = partner.
Check the return table.
LOOP AT return WHERE type = 'E' OR type = 'A'.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
WRITE: / 'Error in creating document'.
ELSE.
Commit the work.
COMMIT WORK AND WAIT.
WRITE: / 'Document ', v_vbeln, ' created'.
ENDIF. -
Setting user specific contract data while creating sales order using BAPI
Hi all,
I am creating sales order using BAPI - BAPI_SALESORDER_CREATEFROMDAT2.
Now my problem is that there is no structure for contract data (i.e. VEDA), system automatically set contract data using customization values.
I am doing some validations on cotract data in MV45AFZZ which fails, because these validations are performed on standard values, user specific values r not set.
How to handle this issue, your small clue may help a lot.
Regards,
S@meerHI
Pricing will be carried basing on the pricing
procedure.
Case1: Prices will be carried out automatically if
necessary condition records are maintained for the
condition type.
For this you can go to Sales Order-> Item Conditions
In the screen you can click on command button Analysis,
which gives you the list of condition types associated
to the pricing procedure. By clicking on the condition
type you can know the action that has taken place.
Case2: Manually forcing prices for Items.
To do this, you have to populate ORDER_CONDITIONS_IN &
ORDER_CONDITIONS_INX. Also note to identify the item
numbers, you manually pass the item number for each item
in the sales order, use the same item number for
populating conditions.
Parameters required:
ORDER_CONDITIONS_IN:
ITM_NUMBER, COND_TYPE, COND_VALUE, CURRENCY
ORDER_CONDITIONS_INX:
ITM_NUMBER, COND_TYPE, UPDATEFLAG, COND_VALUE,CURRENCY.
Hope the above info helps you. Do revert back if you
need more info.
Kind Regards
Eswar -
How to create sales order using bapi( test purpose)
Hi all,
while i was creating sales order using the BAPI_SALESORDER_CREATEFROMDAT1 it is giving some error,
version 0 is not defined for the fiscal year ****.
I have given the fallowing parameters as input
ORDER_HEADER_IN
DOC_TYPE OR
SALES_ORG 1000
DISTR_CHAN 10
DIVISION 00
ORDER_PATNERS
PARTN_ROLE SP
PARTN_NUMB 1000
ORDER_ITEMSIN
MATERIAL M-13
I need to create sample sales order . Please help me how to create sales order with an example( for test purpose).
Regards
Deviprasad.Hi Prasad,
Try using BAPI_SALESORDER_CREATEFROMDAT2.
While creating sales order using FM: BAPI_SALESORDER_CREATEFROMDAT2, please make sure ORDER_ITEMS_IN, ORDER_ITEMS_INX, ORDER_SCHEDULES_IN, ORDER_SCHEDULES_INX.
Pricing Conditions will not be mandatory to create a sales order via BAPI.
As you were saying, you can create a sales order but not with items. Do populate the internal tables that i have specified above.
Also try to pass the item number internally, this will help you in identifying the schedule lines.
Regards,
Priyanka. -
TO CREATE SALES ORDER USING BAPI PROBLEM
I am trying to create Sales Order using bapi function, this is giving me error as mentioned below
*Please enter SHIP-TO-PARTY OR SOLD TO PARTY
*SALES DOCUMENT WAS NOT CHANGED.
it does not GIVE ME THE SALES DOCUMENT NO .
The BAPI I am using is BAPI_SALESORDER_CREATEFROMDAT2.
Would someone know which parameters I have to papulate,or have any other suggestion
THE INTERNAL TABLES I AM PASSING TO BAPI FUNCTION ARE
DATA: IT_BAPI_HEADER LIKE BAPISDHD1.
DATA: IT_BAPI_SOLD_TO_PARTY LIKE BAPIPARNR occurs 0 with header line.
DATA: SO_NO LIKE BAPIVBELN-VBELN.
DATA: IT_BAPI_ITEMS_IN LIKE BAPISDITM occurs 0 with header line.
DATA: IT_BAPI_RETURN LIKE BAPIRET2 occurs 0 with header line.
IS THERE ANYTHING ELSE TO POPULATE OTHER THAN THIS STRUCTURES
HEADER
Sales-Document type:
* Sales-Organization
* Distrubution-Channel:
* Division
PARTNER
Partner Function
Customer Number
ITEM DETAIL
Material Number
how to accomplish my task?Nandan,
Please go through the documentation of the BAPI. It gives you details of what needs to be filled in in which structure/parmater. Also, read the documentation associated with each structure, that will tell what to fill.
It is really hard to explain it in simple terms as to what are required. But, you need the header, items and partners at the minimum. Also, with some of these structures there are also 'X' structures(like ORDER_ITEMS_INX for ORDER_ITEMS_IN) which should also be filled based on what fields you filled in the original structure. For example, if you filled 'MATERIAL' field on the ORDER_ITEMS_IN structure, you should also fill in the same field on the ORDER_ITEMS_INX structure with an 'X' in it.
All this is well documented in the BAPI.
Srinivas -
Creating sales order using ' BAPI_SALESORDER_CREATEFROMDAT1'
Hi ,
i have a problem in creating sales order using ' BAPI_SALESORDER_CREATEFROMDAT1 ' .
order number is created and every thing unless the order quantity isn't created for material item .
my inputs are .
in "ORDER_HEADER_IN"
(DOC_TYPE , SALES_ORG , DISTR_CHAN , DIVISION ,SALES_OFF )
in " ORDER_ITEMS_IN"
(MATERIAL ,PLANT ,REQ_QTY )
in "ORDER_PARTNERS"
(PARTN_ROLE , PARTN_NUMB)
so the order created but as i say the the order quqntity isn't created for the material so the "net value and maertial net valve )
aren't calcoluted .
<< Moderator message - Everyone's problem is important. But the answers in the forum are provided by volunteers. Please do not ask for help quickly. >>
waiting .
thanks for all
Edited by: Rob Burbank on Jan 7, 2011 4:28 PMHi Mr. Ahmed Tohamy,
my point is just create a schedule line with each item line. The relevant code we used was (excerpt)
perform bapi_map_filled using:
lv_matnr 'MATERIAL' space
changing ls_in ls_inx,
lv_tax_class1 'TAX_CLASS1' gc_true
changing ls_in ls_inx,
lv_qty 'TARGET_QTY' space
changing ls_in ls_inx, "QTY to item line
lv_qty 'REQ_QTY' space
changing ls_schdl ls_schdlx,"QTY to schedule line
lv_itm_number 'ITM_NUMBER' space
changing ls_in ls_dummy,
lv_itm_number 'ITM_NUMBER' space
changing ls_schdl ls_dummy,
lv_ref_doc_ca 'REF_DOC_CA' space
changing ls_in ls_inx,
lv_orderid 'ORDERID' space
changing ls_in ls_inx,
lv_ref_doc 'REF_DOC' space
changing ls_in ls_inx.
append:
ls_in to pt_order_items_in,
ls_inx to pt_order_items_inx,
ls_schdl to pt_order_schdl,
ls_schdlx to pt_order_schdlx.
Here the quantity is put to item line and schedule line, we always mark the correspoing X structure fields:
*& Form bapi_map_filled
* if the value passed is not initial, it is moved to the field
* and the corresponding (BAPI-) X-field is marked
* if no x-structure is required, a dummy structure is passed
* if p_initial parameter is filled, initial fields will be marked
* in x-structure. Purpose: transfer of initial values to BAPI
form bapi_map_filled using p_value type any
p_fieldname type fieldname
p_initial type flag
changing p_structure type any
p_structurex type any.
field-symbols:
<any> type any,
<c> type c.
check:
not ( p_value is initial and p_initial is initial ).
assign:
component p_fieldname of structure p_structure to <any>,
component p_fieldname of structure p_structurex to <c>.
<any> = p_value.
check <c> is assigned.
<c> = gc_true.
endform. " bapi_map_filled
Also, we did something to create conditions (i.e. tax) but I think that was project-specific.
We used BAPI_SALESORDER_CREATEFROMDAT2, I do not know about BAPI_SALESORDER_CREATEFROMDAT1.
Regards,
Clemens -
How to create sales order using BAPI.
Hi all,
I am trying to create sales order using standard BAPI
"BAPI_SALESORDER_CREATEFROMDAT2". But, even I had entered all mandatory fields, I am unable to create sales order sucessfully.
I had gone through the documentaion of this BAPI and entered these fields.
These are the mandatory fields that which I had tried to create,
ORDER_HEADER_IN :
DOC_TYPE Sales document type
SALES_ORG Sales organization
DISTR_CHAN Distribution channel
DIVISION Division
ORDER_PARTNERS..:
PARTN_ROLE Partner role, SP sold-to party
PARTN_NUMB Customer number
ORDER_ITEMS_IN..:
MATERIAL Material number
Do we have anymore fields to give as inputs? I am getting this error message as below :
Msg: Personal number 00007176 does not exit.
But, I am not giving any personal number manually. This personal number was having connection with partner role field,
I had reffered this from the VBPA (Sales Document: Partner Table). Now, please suggest me how to solve this?
Can anyone tell me how to solve this problem and create sales order sucessfully.
Thanks in advance,
Surender Batlanki.hi surendra ,
chech with below code.
REPORT z_bapi_salesorder_create.
Parameters
Sales document type
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text FOR FIELD p_auart.
PARAMETERS: p_auart TYPE auart OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Sales organization
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD p_vkorg.
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Distribution channel
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text2 FOR FIELD p_vtweg.
PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Division.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text3 FOR FIELD p_spart.
PARAMETERS: p_spart TYPE spart OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SKIP 1.
Sold-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text4 FOR FIELD p_sold.
PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Ship-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text5 FOR FIELD p_ship.
PARAMETERS: p_ship TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SKIP 1.
Material
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text6 FOR FIELD p_matnr.
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Quantity.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text7 FOR FIELD p_menge.
PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Plant
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text9 FOR FIELD p_plant.
PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Data declarations.
DATA: v_vbeln LIKE vbak-vbeln.
DATA: header LIKE bapisdhead1.
DATA: headerx LIKE bapisdhead1x.
DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.
DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.
DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx
WITH HEADER LINE.
DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl
WITH HEADER LINE.
Initialization.
INITIALIZATION.
v_text = 'Order type'.
v_text1 = 'Sales Org'.
v_text2 = 'Distribution channel'.
v_text3 = 'Division'.
v_text4 = 'Sold-to'.
v_text5 = 'Ship-to'.
v_text6 = 'Material'.
v_text7 = 'Quantity'.
v_text9 = 'Plant'.
Start-of-selection.
START-OF-SELECTION.
Header data
Sales document type
header-doc_type = p_auart.
headerx-doc_type = 'X'.
Sales organization
header-sales_org = p_vkorg.
headerx-sales_org = 'X'.
Distribution channel
header-distr_chan = p_vtweg.
headerx-distr_chan = 'X'.
Division
header-division = p_spart.
headerx-division = 'X'.
headerx-updateflag = 'I'.
Partner data
Sold to
partner-partn_role = 'AG'.
partner-partn_numb = p_sold.
APPEND partner.
Ship to
partner-partn_role = 'WE'.
partner-partn_numb = p_ship.
APPEND partner.
ITEM DATA
itemx-updateflag = 'I'.
Line item number.
item-itm_number = '000010'.
itemx-itm_number = 'X'.
Material
item-material = p_matnr.
itemx-material = 'X'.
Plant
item-plant = p_plant.
itemx-plant = 'X'.
Quantity
item-target_qty = p_menge.
itemx-target_qty = 'X'.
APPEND item.
APPEND itemx.
Fill schedule lines
lt_schedules_in-itm_number = '000010'.
lt_schedules_in-sched_line = '0001'.
lt_schedules_in-req_qty = p_menge.
APPEND lt_schedules_in.
Fill schedule line flags
lt_schedules_inx-itm_number = '000010'.
lt_schedules_inx-sched_line = '0001'.
lt_schedules_inx-updateflag = 'X'.
lt_schedules_inx-req_qty = 'X'.
APPEND lt_schedules_inx.
Call the BAPI to create the sales order.
CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
EXPORTING
sales_header_in = header
sales_header_inx = headerx
IMPORTING
salesdocument_ex = v_vbeln
TABLES
return = return
sales_items_in = item
sales_items_inx = itemx
sales_schedules_in = lt_schedules_in
sales_schedules_inx = lt_schedules_inx
sales_partners = partner.
Check the return table.
LOOP AT return WHERE type = 'E' OR type = 'A'.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
WRITE: / 'Error in creating document'.
ELSE.
Commit the work.
COMMIT WORK AND WAIT.
WRITE: / 'Document ', v_vbeln, ' created'.
ENDIF.
let us know if you have any qauistions.
~linganna -
Dump while creating sales order using BAPI
Hi Experts,
I am trying to create a sales order in my alv report using BAPI_SALESORDER_CREATEFROMDAT2. I get a dump while executing the program. Please suggest me where I am going wrong.
|Source Code Extract |
|Line |SourceCde |
| 1|FORM FRM_KOND_BASIS_604. |
| 2|*{ INSERT DEVK910738 1 |
| 3| |
| 4|data: zuomqtyo LIKE ekpo-menge, |
| 5| zuomqtyn LIKE ekpo-menge, |
| 6| zqty1 type i, |
| 7| zqty2(11) type n. |
| 8| |
| 9|** Round up billing qty |
| 10| if komp-zzLTKZA ne 'VAR'. |
| 11| |
|>>>>>| zqty1 = xkwert. |
| 13| compute zqty2 = zqty1 / 1000. |
| 14| xkwert = zqty2 * 1000. |
| 15| |
| 16| exit. |
| 17| endif. |
| 18| |
| 19| |
| 20|** Samples |
| 21| |
| 22| if komp-MATKL = '5400'. |
| 23| |
| 24| check not xkomv-kmein is initial. |
| 25| check not komp-vrkme is initial. |
| 26| |
| 27|** Make sure base is correct when sales unit and pricing unit differ |
| 28| if komp-vrkme ne xkomv-kmein. |
| 29| |
| 30| zuomqtyo = komp-MGAME. |
| 31| |
Thanks.John,
Here is what I am doing.
*Assign Header Data And Move To Header Data Final Table
GS_ORDERHEADERIN-DOC_TYPE = GC_AUART.
GS_ORDERHEADERIN-SALES_ORG = GC_SORG.
GS_ORDERHEADERIN-DISTR_CHAN = GC_DISTC.
GS_ORDERHEADERIN-DIVISION = GC_DIVI.
GS_ORDERHEADERIN-ORD_REASON = GC_AUGRU.
GS_ORDERHEADERIN-REQ_DATE_H = WA-USAGE_DATE.
GS_ORDERHEADERIN-PURCH_DATE = WA-USAGE_DATE.
GS_ORDERHEADERIN-PURCH_NO_C = WA-USAGE_DOC.
*Assign Header Data And Move To Header Data Final Table
GS_ORDERHEADERINX-DOC_TYPE = GC_FLAG.
GS_ORDERHEADERINX-SALES_ORG = GC_FLAG.
GS_ORDERHEADERINX-DISTR_CHAN = GC_FLAG.
GS_ORDERHEADERINX-DIVISION = GC_FLAG.
GS_ORDERHEADERINX-ORD_REASON = GC_FLAG.
GS_ORDERHEADERINX-REQ_DATE_H = GC_FLAG.
GS_ORDERHEADERINX-PURCH_DATE = GC_FLAG.
GS_ORDERHEADERINX-PURCH_NO_C = GC_FLAG.
*ASSIGN ITEMS DATA AND MOVE TO ITEMS DATA FINAL TABLE
GS_ORDERITEMSIN-ITM_NUMBER = WA-POSNR.
GS_ORDERITEMSIN-MATERIAL = WA-MATERIAL.
GS_ORDERITEMSIN-TARGET_QTY = WA-EXT_QTY. "EXT_QTY is of type LFIMG
GS_ORDERITEMSIN-TARGET_QU = WA-EXT_UOM. "EXT_UOM is of type VRKME
APPEND GS_ORDERITEMSIN TO GT_ORDERITEMSIN.
CLEAR GS_ORDERITEMSIN.
*Assign Items Data And Move To Items Data Final Table
GS_ORDERITEMSINX-ITM_NUMBER = WA-POSNR.
GS_ORDERITEMSINX-MATERIAL = GC_FLAG.
GS_ORDERITEMSINX-TARGET_QTY = GC_FLAG.
GS_ORDERITEMSINX-TARGET_QU = GC_FLAG.
APPEND GS_ORDERITEMSINX TO GT_ORDERITEMSINX.
CLEAR GS_ORDERITEMSINX.
*Assign Schedule Lines Data And Move To Schedule Lines Final Table
GS_ORDER_SCHEDULES_IN-ITM_NUMBER = WA-POSNR.
GS_ORDER_SCHEDULES_IN-REQ_DATE = WA-USAGE_DATE.
GS_ORDER_SCHEDULES_IN-REQ_QTY = WA-EXT_QTY. "EXT_QTY is of type LFIMG
APPEND GS_ORDER_SCHEDULES_IN TO GT_ORDER_SCHEDULES_IN.
CLEAR GS_ORDER_SCHEDULES_IN.
*Assign Schedule Lines Data And Move To Schedule Lines Final Table
GS_ORDER_SCHEDULES_INX-ITM_NUMBER = WA-POSNR.
GS_ORDER_SCHEDULES_INX-REQ_DATE = GC_FLAG.
GS_ORDER_SCHEDULES_INX-REQ_QTY = GC_FLAG.
APPEND GS_ORDER_SCHEDULES_INX TO GT_ORDER_SCHEDULES_INX.
CLEAR GS_ORDER_SCHEDULES_INX.
*Assign Sold-To-Partner Data And Move To Final Partners Table
GS_ORDERPARTNERS-PARTN_ROLE = GC_SP.
GS_ORDERPARTNERS-PARTN_NUMB = GV_SOLD.
APPEND GS_ORDERPARTNERS TO GT_ORDERPARTNERS.
CLEAR GS_ORDERPARTNERS.
*Assign Ship-To-Partner Data And Move To Partners Table
GS_ORDERPARTNERS-PARTN_ROLE = GC_SH.
GS_ORDERPARTNERS-PARTN_NUMB = GV_SHIP.
APPEND GS_ORDERPARTNERS TO GT_ORDERPARTNERS.
CLEAR GS_ORDERPARTNERS.
*Clear Global Variable Field Of Sales Document
CLEAR:GV_SALESDOCUMENT.
"Right after pressing F6 button after this. It gives me dump.
*Call Function Module To Create Sales Order
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
ORDER_HEADER_IN = GS_ORDERHEADERIN
ORDER_HEADER_INX = GS_ORDERHEADERINX
IMPORTING
SALESDOCUMENT = GV_SALESDOCUMENT
TABLES
ORDER_ITEMS_IN = GT_ORDERITEMSIN
ORDER_ITEMS_INX = GT_ORDERITEMSINX
ORDER_SCHEDULES_IN = GT_ORDER_SCHEDULES_IN
ORDER_SCHEDULES_INX = GT_ORDER_SCHEDULES_INX
ORDER_PARTNERS = GT_ORDERPARTNERS
RETURN = GT_BAPIRETURN.
IF SY-SUBRC = 0.
*Call Function Module For BAPI Commit
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = GC_FLAG.
ENDIF.
All my BAPI tables have been filled with required data in them. But, still it is giving me a dump.
I would really appreciate if some one could suggest me where I am going wrong.
Thanks. -
ISSUE ON CREATE SALES ORDER USING BAPI
Hi,
I am creating a sales order using bapi BAPI_SALESORDER_CREATEFROMDAT2.But it it fails to create a sales order abd below is my code pls check and correct me to create a sales order.
LOOP AT DATA_TAB.
clear: l_order_header_in,
l_salesdocument,
l_order_partners,
l_order_items_IN,
l_order_schedules_IN.
refresh: l_order_items_in,
l_order_partners,
l_order_schedules_IN,
l_return.
Order header
l_order_header_in-DOC_TYPE = DATA_TAB-AUART.
l_order_header_IN-SALES_ORG = DATA_TAB-VKORG.
l_order_header_IN-DISTR_CHAN = data_tab-vtweg.
l_order_header_in-division = DATA_TAB-SPART.
l_order_header_in-REF_1_S = DATA_TAB-IHREZ_E.
l_order_header_in-PURCH_NO_S = DATA_TAB-BSTKD_E.
l_order_header_in-PO_DAT_S = data_tab-bstdk_e.
l_order_header_in-PO_METH_S = DATA_TAB-BSARK_E.
l_order_header_in-DOC_DATE = DATA_TAB-AUDAT.
l_order_header_in-REC_POINT = DATA_TAB-EMPST.
l_order_header_inX-DOC_TYPE = 'X'.
l_order_header_INX-SALES_ORG = 'X'.
l_order_header_INX-DISTR_CHAN = 'X'.
l_order_header_inX-division = 'X'.
l_order_header_inX-REF_1_S = 'X'.
l_order_header_inX-PURCH_NO_S = 'X'.
l_order_header_inX-PO_DAT_S = 'X'.
l_order_header_inX-PO_METH_S = 'X'.
l_order_header_inX-DOC_DATE = 'X'.
l_order_header_inX-REC_POINT = 'X'.
Partner data SOLD TO PARTY
l_order_partners-ITM_NUMBER = DATA_TAB-POSNR.
l_order_partners-partn_role = 'SP'.
l_order_partners-partn_numb = DATA_TAB-kunnr1.
append l_ordeR_partners.
Partner data SHOP TO PARTY
l_order_partners-ITM_NUMBER = DATA_TAB-POSNR.
l_order_partners-partn_role = 'SH'.
l_order_partners-partn_numb = DATA_TAB-kunnr2.
append l_ordeR_partners.
Order items
l_order_items_IN-ITM_NUMBER = DATA_TAB-POSNR.
l_order_items_IN-material = DATA_TAB-MABNR.
l_order_items_IN-BATCH = DATA_TAB-CHARG.
l_order_items_IN-REASON_REJ = DATA_TAB-ABGRU.
append l_order_items_IN.
l_order_items_INX-ITM_NUMBER = DATA_TAB-POSNR.
l_order_items_INX-material = 'X'.
l_order_items_INX-BATCH = 'X'.
l_order_items_INX-REASON_REJ = 'X'.
append l_order_items_INX.
Schedules for quantity
l_order_schedules_IN-itm_number = DATA_TAB-POSNR.
l_order_schedules_IN-req_qty = DATA_TAB-KWMENG.
append l_order_schedules_IN.
Schedules for quantity
l_order_schedules_INX-itm_number = data_tab-posnr.
l_order_schedules_INX-req_qty = 'X'.
append l_order_schedules_INX.
Conditions for value
l_order_conditions_IN-itm_number = DATA_TAB-POSNR.
l_order_conditions_IN-cond_type = DATA_TAB-KSCHL.
l_order_conditions_IN-cond_value = DATA_TAB-KBETR.
l_order_conditions_IN-currency = DATA_TAB-KOEIN.
append l_order_conditions_IN.
Conditions for value
l_order_conditions_INX-itm_number = DATA_TAB-POSNR.
l_order_conditions_INX-cond_type = 'X'.
l_order_conditions_INX-cond_value = 'X'.
l_order_conditions_INX-currency = 'X'.
append l_order_conditions_INX .
endloop.
BAPI to create sales order
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
SALESDOCUMENTIN =
ORDER_HEADER_IN = l_order_header_IN
ORDER_HEADER_INX = l_order_header_INX
IMPORTING
SALESDOCUMENT = l_salesdocument
TABLES
RETURN = l_return
ORDER_ITEMS_IN = l_order_items_IN
ORDER_ITEMS_INX = l_order_items_INX
ORDER_PARTNERS = l_order_partners
ORDER_SCHEDULES_IN = l_order_schedules_in
ORDER_SCHEDULES_INX = l_order_schedules_inX
ORDER_CONDITIONS_IN = l_order_conditions_in
ORDER_CONDITIONS_INX = l_order_conditions_inX
IF SY-SUBRC = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = C_X
IMPORTING
RETURN =
ENDIF.
Pls help me to solve the issue.
Thanks,
Rajendra.Hi Raj
This is the sameple code which works fine for me,
REPORT zkb_sales_order.
DATA: w_order_header_in TYPE bapisdhd1,
i_order_partners TYPE TABLE OF bapiparnr,
w_order_partners TYPE bapiparnr,
i_return TYPE TABLE OF bapiret2,
w_return TYPE bapiret2,
i_order_items_in TYPE TABLE OF bapisditm,
w_order_items_in TYPE bapisditm,
i_order_items_inx TYPE TABLE OF bapisditmx,
w_order_items_inx TYPE bapisditmx,
i_order_conditions_in TYPE TABLE OF bapicond,
w_order_conditions_in TYPE bapicond,
i_order_conditions_inx TYPE TABLE OF bapicondx,
w_order_conditions_inx TYPE TABLE OF bapicondx.
CLEAR w_order_header_in.
w_order_header_in-doc_type = 'ZSO'.
w_order_header_in-sales_org = '1000'.
w_order_header_in-distr_chan = '01'.
w_order_header_in-division = '01'.
w_order_header_in-req_date_h = sy-datum.
w_order_header_in-sales_dist = '000001'.
CLEAR: i_order_items_in,w_order_items_in.
w_order_items_in-material = 77.
w_order_items_in-salqtynum = 1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = w_order_items_in-material
IMPORTING
output = w_order_items_in-material.
APPEND w_order_items_in TO i_order_items_in.
* SP
CLEAR: i_order_partners,w_order_partners.
w_order_partners-partn_role = 'AG'.
w_order_partners-partn_numb = '2000016'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = w_order_partners-partn_numb
IMPORTING
output = w_order_partners-partn_numb.
APPEND w_order_partners TO i_order_partners.
CLEAR: i_order_conditions_in,w_order_conditions_in.
w_order_conditions_in-itm_number = '000010'.
w_order_conditions_in-cond_type = 'PR00'.
w_order_conditions_in-cond_value = 100.
APPEND w_order_conditions_in TO i_order_conditions_in.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
* SALESDOCUMENTIN =
order_header_in = w_order_header_in
* ORDER_HEADER_INX =
* SENDER =
* BINARY_RELATIONSHIPTYPE =
* INT_NUMBER_ASSIGNMENT =
* BEHAVE_WHEN_ERROR =
* LOGIC_SWITCH =
* TESTRUN =
* CONVERT = ' '
* IMPORTING
* SALESDOCUMENT =
TABLES
return = i_return
order_items_in = i_order_items_in
* ORDER_ITEMS_INX =
order_partners = i_order_partners
* ORDER_SCHEDULES_IN =
* ORDER_SCHEDULES_INX =
order_conditions_in = i_order_conditions_in
* ORDER_CONDITIONS_INX =
* ORDER_CFGS_REF =
* ORDER_CFGS_INST =
* ORDER_CFGS_PART_OF =
* ORDER_CFGS_VALUE =
* ORDER_CFGS_BLOB =
* ORDER_CFGS_VK =
* ORDER_CFGS_REFINST =
* ORDER_CCARD =
* ORDER_TEXT =
* ORDER_KEYS =
* EXTENSIONIN =
* PARTNERADDRESSES =
READ TABLE i_return INTO w_return WITH KEY type = 'E'.
IF sy-subrc NE 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
LOOP AT i_return INTO w_return .
WRITE: / w_return-type,
w_return-id,
w_return-number,
w_return-message.
ENDLOOP.
Regards
Kathirvel -
Issue in creating sales order using process_header API
Hi all,
We have a requirement to create sales order using apps adapter in ebiz from SOA suite composite.I used OE_ORDER_PUB.Process_header API to create order header.
When I pass the inputs and test the service,I get output with return_status='S'. But no record falls at the OE_ORDER_HEADER_ALL table.
I cant identify where the problem is.Pls suggest me with the things to resolve this issue.
Thanks,
gouthamHi all,
We have a requirement to create sales order using apps adapter in ebiz from SOA suite composite.I used OE_ORDER_PUB.Process_header API to create order header.
When I pass the inputs and test the service,I get output with return_status='S'. But no record falls at the OE_ORDER_HEADER_ALL table.
I cant identify where the problem is.Pls suggest me with the things to resolve this issue.
Thanks,
goutham -
How to Create Sales Order using BAPI with Variant configurations
Hi All,
I need to create a sales order using BAPI BAPI_SALESORDER_CREATEFROMDAT2 with Varaint confiugartions. I will get Header ITEM and variant configuration items in the flat file. Kindly help me in this regard.
One more thing, is there any way to findout all the Varaint classifications for a particular Material?
I have done the below coding. Sales order is getting created but variant configurations are not populating.
*...Configuration: Reference Data
DATA: gt_order_cfgs_ref TYPE TABLE OF bapicucfg,
wa_order_cfgs_ref TYPE bapicucfg.
*...Configuration: Instances
DATA: gt_order_cfgs_inst TYPE TABLE OF bapicuins,
wa_order_cfgs_inst TYPE bapicuins.
*...Configuration: Part-of Specifications
DATA: gt_order_cfgs_part_of TYPE TABLE OF bapicuprt,
wa_order_cfgs_part_of TYPE bapicuprt .
*...Configuration: Characteristic Values
DATA: gt_order_cfgs_value TYPE TABLE OF bapicuval,
wa_order_cfgs_value TYPE bapicuval.
*...Configuration: BLOB Internal Data (SCE)
DATA: gt_order_cfgs_blob TYPE TABLE OF bapicublb ,
wa_order_cfgs_blob TYPE bapicublb.
*...Configuration: Variant Condition Key
DATA: gt_order_cfgs_vk TYPE TABLE OF bapicuvk,
wa_order_cfgs_vk TYPE bapicuvk.
*...Configuration: Reference Item / Instance
DATA: gt_order_cfgs_refinst TYPE TABLE OF bapicuref,
wa_order_cfgs_refinst TYPE bapicuref.
*...Configuration: Reference Data
wa_order_cfgs_ref-posex = '10'.
wa_order_cfgs_ref-config_id = '1'.
wa_order_cfgs_ref-root_id = '1'.
wa_order_cfgs_ref-SCE = '1'.
wa_order_cfgs_ref-CBASE_ID_TYPE = 'G'.
wa_order_cfgs_ref-CONSISTENT = 'T'.
wa_order_cfgs_ref-COMPLETE = 'T'.
APPEND wa_order_cfgs_ref TO gt_order_cfgs_ref.
*..2nd item
wa_order_cfgs_ref-posex = '20'.
wa_order_cfgs_ref-config_id = '2'.
wa_order_cfgs_ref-root_id = '1'.
wa_order_cfgs_ref-SCE = '1'.
wa_order_cfgs_ref-CBASE_ID_TYPE = 'G'.
wa_order_cfgs_ref-CONSISTENT = 'T'.
wa_order_cfgs_ref-COMPLETE = 'T'.
APPEND wa_order_cfgs_ref TO gt_order_cfgs_ref.
*...Configuration: Instances
wa_order_cfgs_inst-config_id = '1'.
wa_order_cfgs_inst-inst_id = '1'.
wa_order_cfgs_inst-obj_type = 'MARA'.
wa_order_cfgs_inst-class_type = '300'.
wa_order_cfgs_inst-obj_key = '2021B'.
wa_order_cfgs_inst-quantity = 1.
wa_order_cfgs_inst-PERSIST_ID_TYPE = 'G'.
wa_order_cfgs_inst-CONSISTENT = 'T'.
wa_order_cfgs_inst-COMPLETE = 'T'.
APPEND wa_order_cfgs_inst TO gt_order_cfgs_inst.
*..2nd item
wa_order_cfgs_inst-config_id = '2'.
wa_order_cfgs_inst-inst_id = '1'.
wa_order_cfgs_inst-obj_type = 'MARA'.
wa_order_cfgs_inst-class_type = '300'.
wa_order_cfgs_inst-obj_key = '2021B'.
wa_order_cfgs_inst-quantity = 1.
wa_order_cfgs_inst-PERSIST_ID_TYPE = 'G'.
wa_order_cfgs_inst-CONSISTENT = 'T'.
wa_order_cfgs_inst-COMPLETE = 'T'.
APPEND wa_order_cfgs_inst TO gt_order_cfgs_inst.
*...Configuration: Characteristic Values
wa_order_cfgs_value-config_id = '1'.
wa_order_cfgs_value-inst_id = '1'.
wa_order_cfgs_value-charc = 'BASIC_MACHINE'.
wa_order_cfgs_value-value = 'L28'.
wa_order_cfgs_value-VALCODE = '1'.
APPEND wa_order_cfgs_value TO gt_order_cfgs_value.
wa_order_cfgs_value-config_id = '1'.
wa_order_cfgs_value-inst_id = '1'.
wa_order_cfgs_value-charc = 'BUCKET'.
wa_order_cfgs_value-value = 'PL1001'.
wa_order_cfgs_value-VALCODE = '1'.
APPEND wa_order_cfgs_value TO gt_order_cfgs_value.
*..2nd item
wa_order_cfgs_value-config_id = '2'.
wa_order_cfgs_value-inst_id = '1'.
wa_order_cfgs_value-charc = 'BUCKET_FOC'.
wa_order_cfgs_value-value = '023OP0049'.
wa_order_cfgs_value-VALCODE = '1'.
APPEND wa_order_cfgs_value TO gt_order_cfgs_value.
wa_order_cfgs_value-config_id = '2'.
wa_order_cfgs_value-inst_id = '1'.
wa_order_cfgs_value-charc = 'BUCKET_HOE'.
wa_order_cfgs_value-value = '028MS0004'.
wa_order_cfgs_value-VALCODE = '1'.
APPEND wa_order_cfgs_value TO gt_order_cfgs_value.
wa_order_cfgs_value-config_id = '2'.
wa_order_cfgs_value-inst_id = '1'.
wa_order_cfgs_value-charc = 'TYRE_PRESSURE_GAUGE'.
wa_order_cfgs_value-value = '81004402'.
APPEND wa_order_cfgs_value TO gt_order_cfgs_value.
*...Configuration: Reference Item / Instance
wa_order_cfgs_refinst-posex = '10'.
wa_order_cfgs_refinst-config_id = '1'.
wa_order_cfgs_refinst-inst_id = '1'.
APPEND wa_order_cfgs_refinst TO gt_order_cfgs_refinst.
*..2nd item
wa_order_cfgs_refinst-posex = '20'.
wa_order_cfgs_refinst-config_id = '2'.
wa_order_cfgs_refinst-inst_id = '1'.
APPEND wa_order_cfgs_refinst TO gt_order_cfgs_refinst.
Regards,
RajeshHi all,
Please help me in solving the issue.
Rajesh -
PS Project description when creating sales order using BAPI
I am trying to create sales orders using BAPI_SALESORDER_CREATE_FROMDAT2.
Because of the material configuration in table TCN61 the material will trigger a project creation in the project system.
Now, in order to create a project, we must provide the project description.
I would like to ask you if anyone knows how to pass the project description in one of the BAPI parameters.
Thank you for your help.Thank you Sreedhar for the answer.
I tried the CAMPAIGN field but did not work...
In fact, I am not able to find a field, in any of the of the tables, that could hold the project description (PROJ-POST1).
An entry is created in PROJ table when we manually create a sales order for materials specified in table TCN61.
Thanks. -
Creating sales order using bapi
while creating sales order using bapi serial no is added in dat but its not saving.
plz replyHi
See tha sample code for sales order creation
SALES ORDER INPUT CREATION.
PARAMETERS: p_auart TYPE auart OBLIGATORY.
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
PARAMETERS: p_spart TYPE vtweg OBLIGATORY.
PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
PARAMETERS: p_ship TYPE kunnr OBLIGATORY.
*ITEM
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
PARAMETERS: p_itcat TYPE pstyv OBLIGATORY.
DATA DECLARATIONS.
DATA: v_vbeln LIKE vbak-vbeln.
DATA: header LIKE bapisdhead1.
DATA: headerx LIKE bapisdhead1x.
DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.
DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.
DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx
WITH HEADER LINE.
DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl
WITH HEADER LINE.
HEADER DATA
header-doc_type = p_auart.
headerx-doc_type = 'X'.
header-sales_org = p_vkorg.
headerx-sales_org = 'X'.
header-distr_chan = p_vtweg.
headerx-distr_chan = 'X'.
header-division = p_spart.
headerx-division = 'X'.
headerx-updateflag = 'I'.
PARTNER DATA
partner-partn_role = 'AG'.
partner-partn_numb = p_sold.
APPEND partner.
partner-partn_role = 'WE'.
partner-partn_numb = p_ship.
APPEND partner.
ITEM DATA
itemx-updateflag = 'I'.
item-itm_number = '000010'.
itemx-itm_number = 'X'.
item-material = p_matnr.
itemx-material = 'X'.
item-plant = p_plant.
itemx-plant = 'X'.
item-target_qty = p_menge.
itemx-target_qty = 'X'.
item-target_qu = 'EA'.
itemx-target_qu = 'X'.
item-item_categ = p_itcat.
itemx-item_categ = 'X'.
APPEND item.
APPEND itemx.
Fill schedule lines
lt_schedules_in-itm_number = '000010'.
lt_schedules_in-sched_line = '0001'.
lt_schedules_in-req_qty = p_menge.
APPEND lt_schedules_in.
Fill schedule line flags
lt_schedules_inx-itm_number = '000010'.
lt_schedules_inx-sched_line = '0001'.
lt_schedules_inx-updateflag = 'X'.
lt_schedules_inx-req_qty = 'X'.
APPEND lt_schedules_inx.
Call the BAPI
CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
EXPORTING
sales_header_in = header
sales_header_inx = headerx
IMPORTING
salesdocument_ex = v_vbeln
TABLES
return = return
sales_items_in = item
sales_items_inx = itemx
sales_schedules_in = lt_schedules_in
sales_schedules_inx = lt_schedules_inx
sales_partners = partner.
Check the return table.
LOOP AT return WHERE type = 'E' OR type = 'A'.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
WRITE: / 'Error in creating document'.
ELSE.
COMMIT WORK AND WAIT.
WRITE: / 'Document ', v_vbeln, ' created'.
ENDIF.
after that check in the table VBAP whether serial number is cretaed or not
Reward points if useful
Regards
Anji -
Creating sales order using BDC
I need to create sales order using BDC by reading material from material master(R/3) and customer from
customer master(R/3).
For example. combination should be like this
Customer1 + Material 1 = Sales order 1
Customer2 + Material 2 = Sales order 2
Other than customer and material, all other values are fixed... Could you please help me......Hi,
Better go for BDC rather then BAPI for this requirement.
Simply, record the transaction and upload the data, Hope you know how it works.
Try this, In case of any clarification feel free to reply.
Regards,
Vikas -
HI,
I need to create sales orders using BAPI.
these sales orders are different sales order type and it need to upload from excel file. anyone send me some sample programs for this one.
kathir.use this code to create salesorder using bapi.
REPORT z_bapi_salesorder_create.
Parameters
Sales document type
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text FOR FIELD p_auart.
PARAMETERS: p_auart TYPE auart OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Sales organization
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD p_vkorg.
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Distribution channel
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text2 FOR FIELD p_vtweg.
PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Division.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text3 FOR FIELD p_spart.
PARAMETERS: p_spart TYPE spart OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SKIP 1.
Sold-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text4 FOR FIELD p_sold.
PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Ship-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text5 FOR FIELD p_ship.
PARAMETERS: p_ship TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SKIP 1.
Material
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text6 FOR FIELD p_matnr.
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Quantity.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text7 FOR FIELD p_menge.
PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Plant
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text9 FOR FIELD p_plant.
PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Data declarations.
DATA: v_vbeln LIKE vbak-vbeln.
DATA: header LIKE bapisdhead1.
DATA: headerx LIKE bapisdhead1x.
DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.
DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.
DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx
WITH HEADER LINE.
DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl
WITH HEADER LINE.
Initialization.
INITIALIZATION.
v_text = 'Order type'.
v_text1 = 'Sales Org'.
v_text2 = 'Distribution channel'.
v_text3 = 'Division'.
v_text4 = 'Sold-to'.
v_text5 = 'Ship-to'.
v_text6 = 'Material'.
v_text7 = 'Quantity'.
v_text9 = 'Plant'.
Start-of-selection.
START-OF-SELECTION.
Header data
Sales document type
header-doc_type = p_auart.
headerx-doc_type = 'X'.
Sales organization
header-sales_org = p_vkorg.
headerx-sales_org = 'X'.
Distribution channel
header-distr_chan = p_vtweg.
headerx-distr_chan = 'X'.
Division
header-division = p_spart.
headerx-division = 'X'.
headerx-updateflag = 'I'.
Partner data
Sold to
partner-partn_role = 'AG'.
partner-partn_numb = p_sold.
APPEND partner.
Ship to
partner-partn_role = 'WE'.
partner-partn_numb = p_ship.
APPEND partner.
ITEM DATA
itemx-updateflag = 'I'.
Line item number.
item-itm_number = '000010'.
itemx-itm_number = 'X'.
Material
item-material = p_matnr.
itemx-material = 'X'.
Plant
item-plant = p_plant.
itemx-plant = 'X'.
Quantity
item-target_qty = p_menge.
itemx-target_qty = 'X'.
APPEND item.
APPEND itemx.
Fill schedule lines
lt_schedules_in-itm_number = '000010'.
lt_schedules_in-sched_line = '0001'.
lt_schedules_in-req_qty = p_menge.
APPEND lt_schedules_in.
Fill schedule line flags
lt_schedules_inx-itm_number = '000010'.
lt_schedules_inx-sched_line = '0001'.
lt_schedules_inx-updateflag = 'X'.
lt_schedules_inx-req_qty = 'X'.
APPEND lt_schedules_inx.
Call the BAPI to create the sales order.
CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
EXPORTING
sales_header_in = header
sales_header_inx = headerx
IMPORTING
salesdocument_ex = v_vbeln
TABLES
return = return
sales_items_in = item
sales_items_inx = itemx
sales_schedules_in = lt_schedules_in
sales_schedules_inx = lt_schedules_inx
sales_partners = partner.
Check the return table.
LOOP AT return WHERE type = 'E' OR type = 'A'.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
WRITE: / 'Error in creating document'.
ELSE.
Commit the work.
COMMIT WORK AND WAIT.
WRITE: / 'Document ', v_vbeln, ' created'.
bye
Maybe you are looking for
-
I have a small code that fails in FF but works in ie and chrome
Following is a pop up which fails in FF. works fine in ie and chrome <pre><nowiki><a href="audioplayer.php" onClick= "window.open('audioplayer.php? mkt=xyz.mp3','myWin','width=430, height=100');return false"><img src="img/audioicon.jpg"></a></nowiki>
-
Pricing conditions changed should get approval
Dear Experts, We have a requirement. A report should run every night which should output the changes in an existing condition record. The result of the report should be sent to the respective manager for approval. How can we configure this please hel
-
Don't understand the 240Hz thing
I bought the Samsung B750 240Hz LCD. When viewing HD channels they are all in 60Hz (standard) and I was wondering why I don't get higher Hz from these channels. Is it based on what Cox transmits at or something?
-
My ipod is disabled and is not recovering now...what to do?
i have an 4th generation ipod. it got disabled after series of wrng passwrds and it is not recovering now.
-
File compare won't launch on mac
mtn lion tried two diff file compare utilities both open fine when launched directly neither actually open a file compare when trying from within the dreamweaver interface. e.g., select a file and try a compare with remote. or resolve when syncing. j