Error in bapi BAPI_SALESORDER_CREATEFROMDAT2
Hi,
I am using BAPI BAPI_SALESORDER_CREATEFROMDAT2 for sales order upload.
Now the problem is that i am entering value in condition type PR00 in condition table for BAPI.
After data gets uploaded and saled order is created; In VA02 when i check for the conditions it shows me 2 values for PR00 . One which i entered in BAPI and other which is coming from system.
I have made the settings , So while calculating final value its taking manual enter value only but it
still displays the system generated value and thats what i dont want.
Can there be a way with which i can overwrite(using BAPI) the system generated value for condition type 'PR00'.
regards
vivek
Vivek-
You need to set the BAPI data to overwrite the pricing conditions that automatically generate.
When you set up the pricing condition table to be passed to the BAPI, you need to set the "Step Number" - COND_ST_NO and "Condition Counter" - COND_COUNT so it overwrites the standard pricing that wants to automatically determine. You can get the step number from your pricing procedure. For the counter, just check the counter number of a sales order that was created manually and match it. In my case, it was '01', which I believe is typical.
Hope this helps,
Mark
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. -
Reg BAPI BAPI_SALESORDER_CREATEFROMDAT2
Hi All,
We are creating the sales order using the BAPI BAPI_SALESORDER_CREATEFROMDAT2 the BAPI is successfully creating Sales order successfully with out any issues,but the problem is the sales order line item which has been created through BAPI is being greyed out it is not allowing changes changes to be done for the line item.
The same we checked manually executing the BAPI from Se37 it is creating sales order and also it is allowing to change the line item details manually(by going through VA02).We cross checked the parameters that we are passing through SE37 and through program both are same but I am not getting what is cause for the error.Please suggest some body some resolution for this.
Regards
MaheshHi All,
We are creating the sales order using the BAPI BAPI_SALESORDER_CREATEFROMDAT2 the BAPI is successfully creating Sales order successfully with out any issues,but the problem is the sales order line item which has been created through BAPI is being greyed out it is not allowing changes changes to be done for the line item.
The same we checked manually executing the BAPI from Se37 it is creating sales order and also it is allowing to change the line item details manually(by going through VA02).We cross checked the parameters that we are passing through SE37 and through program both are same but I am not getting what is cause for the error.Please suggest some body some resolution for this.
Regards
Mahesh -
Sales order for variant material using BAPI "BAPI_SALESORDER_CREATEFROMDAT2
Hi,
I am using BAPI "BAPI_SALESORDER_CREATEFROMDAT2" for creating salesorder for variant configuration material. I am able to create a salesorder when have only one variant material, However when i have more than one variant material getting errors. Can some one tell me how to fill the material data in the config tables provided in the BAPI.
Thanks.Hai Vinit
Check the following Code & also Check the following Standard Programs
L2032U12
LCRMAU01
LCRMAU11
LZOC1U01
MWWMJF32
RBUS2032
Structures for order header
DATA: l_order_header_in LIKE bapisdhd1,
l_order_header_inx LIKE bapisdhd1x,
Tables for order items
li_order_items_in TYPE STANDARD TABLE OF bapisditm,
li_order_items_inx TYPE STANDARD TABLE OF bapisditmx,
Order partners
li_order_partners TYPE STANDARD TABLE OF bapiparnr,
*Schedule lines
li_ORDER_SCHEDULES_IN TYPE STANDARD TABLE OF BAPISCHDL,
li_ORDER_SCHEDULES_INX TYPE STANDARD TABLE OF BAPISCHDLX,
*-condition type
li_ORDER_CONDITIONS_IN TYPE STANDARD TABLE OF BAPICOND,
li_ORDER_CONDITIONS_INX TYPE STANDARD TABLE OF BAPICONDX,
Return table from bapi call
li_return TYPE STANDARD TABLE OF bapiret2,
Sales document number
l_vbeln LIKE bapivbeln-vbeln,
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = l_order_header_in
order_header_inx = l_order_header_inx
testrun = 'X'
IMPORTING
salesdocument = l_vbeln
TABLES
return = li_return
order_items_in = li_order_items_in
order_items_inx = li_order_items_inx
order_partners = li_order_partners
ORDER_SCHEDULES_IN = li_ORDER_SCHEDULES_IN
ORDER_SCHEDULES_INX = li_ORDER_SCHEDULES_INX
ORDER_CONDITIONS_IN = li_ORDER_CONDITIONS_IN
ORDER_CONDITIONS_INX = li_ORDER_CONDITIONS_INX.
Thanks & Regards
Sreenivasulu P -
Wrong CFOP determination via BAPI BAPI_SALESORDER_CREATEFROMDAT2
Hello Gurus,
I need some help on the following:
When I create a Sales document manually (tcode VA01), CFOP code is determined correctly. But when I try to do the same process, using BAPI BAPI_SALESORDER_CREATEFROMDAT2, with same data ( Sold-To Party and Ship-To Party, material code...), CFOP code is determined wrong.
The SD consultant already checked the configuration in SPRO and everything looks fine.
I went thru debug and found that the FM SD_PARTNER_DATA_GET is called for both process, but internal table GVT_LOCAL_MEMORY is NOT filled when running BAPI and it IS filled when running VA01 (this internal table has VBPA - Partners - data).
This causes a NO_OBJECT_FOUND exception, which makes the program to read the address data from KNA1 (FM J_1B_SD_ADDRESS_READ), with the wrong address number, instead the address form Sales Order, since it's an On Time Customer - WE.
The weirdest thing is that it was working perfectly 3 days ago. We first noticed the problem in QAS environment, but in DEV Sandbox the error is the same now.
The scenario is an Interstate Sales Order. We are about 30 days from Go-Live and now this came thru.
Thanks in advance!Hi Thiago,
I succeeded to let it work even without SD_SALES_DOCUMENT_INIT.
You have two tables used by BAPI_SALESORDER_CREATEFROMDAT2 order_items_in and order_items_inx
Field cfop_long in all order_items_in lines and in all order_items_inx should be empty
Don't forget the BAPI_TRANSACTION_COMMIT after the BAPI_SALESORDER_CREATEFROMDAT2
Tell me if it's not working for you ...
Moez. -
Order quantity in BAPI BAPI_SALESORDER_CREATEFROMDAT2
Hi,
I'm using BAPI 'BAPI_SALESORDER_CREATEFROMDAT2' to create a sale order.
But the order quantity isn't upadate when I check the sales order number.
The field I used is target_qty in BAPISDITM.
Is the field wrong or some other problems?
Best Regards,
RachelHi,
I created SO using BAPI_SALESDOCU_CREATEFROMDATA1. while filling the header and item data, i used to do the following,
If you are passing some value to 'target_qty', make sure that you are filling the sales_items_inx-req_qty with 'X'. then pass them to the tables import parameters. Please refer the following code.
fs_sorder-doc_type = w_auart.
fs_sorderx-doc_type = c_flag.
fs_sorder-sales_org = w_vkorg.
fs_sorderx-sales_org = c_flag.
fs_sorder-distr_chan = w_vtweg.
fs_sorderx-distr_chan = c_flag.
fs_sorder-division = w_spart.
fs_sorderx-division = c_flag.
fs_sorderx-updateflag = c_flag.
fs_partner-partn_role = c_pship.
fs_partner-partn_numb = w_pship.
APPEND fs_partner TO t_partner.
fs_partner-partn_role = c_psold.
fs_partner-partn_numb = w_psold.
APPEND fs_partner TO t_partner.
loop at t_mdata into fs_mdata.
fs_item-itm_number = fs_mdata-posnr.
fs_itemx-itm_number = c_flag.
fs_item-material = fs_mdata-matnr.
fs_itemx-material = c_flag.
fs_item-target_qty = fs_mdata-kwmeng.
fs_itemx-target_qty = c_flag.
fs_item-item_categ = fs_mdata-pstyv.
fs_itemx-item_categ = c_flag.
fs_itemx-updateflag = c_flag.
APPEND fs_item TO t_item.
APPEND fs_itemx TO t_itemx.
fs_sline-ITM_NUMBER = fs_mdata-posnr.
fs_slinex-ITM_NUMBER = c_flag.
fs_sline-SCHED_LINE = c_sline.
fs_slinex-SCHED_LINE = c_flag.
fs_sline-REQ_QTY = fs_mdata-kwmeng.
fs_slinex-REQ_QTY = c_flag.
APPEND fs_sline TO t_sline.
APPEND fs_slinex TO t_slinex.
endloop. " Loop t_mdata
ENDFORM. " data_fill
* FORM CREATE_SO *
* This subroutine calls a BAPI BAPI_SALESDOCU_CREATEFROMDATA1 for *
* creating a sales document. *
* There are no interface parameters to be passed to this subroutine. *
FORM create_so .
CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
EXPORTING
sales_header_in = fs_sorder
sales_header_inx = fs_sorderx
IMPORTING
salesdocument_ex = w_sonum
TABLES
return = t_return
sales_items_in = t_item
sales_items_inx = t_itemx
sales_partners = t_partner
sales_schedules_in = t_sline
sales_schedules_inx = t_slinex.
ENDFORM. " create_SO
Hope this helps. -
Error during BAPI while uploading Material data through MM01
Hi all,
i am facing one problem when uploading Material data thorough BAPI in MM01.i am attaching the code below and the error given.
but in the debugger all the value is being stored.
REPORT ZFINISHED_MAT.
Data: Begin of legacy_data occurs 0,
MATNR LIKE MARA-MATNR,
MBRSH LIKE MARA-MBRSH, "Industry Sector
MTART LIKE MARA-MTART, "Matl Type
WERKS LIKE MARD-WERKS, "Plant
LGORT LIKE MARD-LGORT, "Storage location
VKORG LIKE MVKE-VKORG,
VTWEG LIKE MVKE-VTWEG,
MAKTX LIKE MAKT-MAKTX, "Matl Desc.
MEINS LIKE MARA-MEINS, "Base UOM
MATKL LIKE MARA-MATKL, "Matl.Grp
* BISMT LIKE MARA-BISMT,
SPART LIKE MARA-SPART, "Division
* BRGEW LIKE MARA-BRGEW, "Gross weight
GROES LIKE MARA-GROES,
FERTH LIKE MARA-FERTH,
ZEINR LIKE MARA-ZEINR,
TAXKM1 LIKE MLAN-TAXM1,
TAXKM2 LIKE MLAN-TAXM2,
TAXKM3 LIKE MLAN-TAXM3,
TAXKM4 LIKE MLAN-TAXM4,
KTGRM LIKE MVKE-KTGRM,
* GEWEI LIKE MARA-GEWEI, "Weight unit
* NTGEW LIKE MARA-NTGEW, "Net weight
* KLART LIKE RMCLF-KLART,
MTVFP LIKE MARC-MTVFP, "Availibility Check
* XGCHP LIKE MARA-XGCHP,
XCHPF LIKE MARA-XCHPF, "Batch Management
TRAGR LIKE MARA-TRAGR,
LADGR TYPE MARC-LADGR,
VPRSV LIKE MBEW-VPRSV, "Price Control
VERPR LIKE MBEW-VERPR,
* SPRAS LIKE MAKT-SPRAS,
END OF LEGACY_DATA.
DATA: BEGIN OF IT_MAKT OCCURS 0.
INCLUDE STRUCTURE BAPI_MAKT.
DATA: END OF IT_MAKT.
*--- BAPI structures
DATA: BAPI_HEAD LIKE BAPIMATHEAD, " Header Segment with Control Information
BAPI_MAKT LIKE BAPI_MAKT, " Material Description
BAPI_MARA1 LIKE BAPI_MARA, " Client Data
BAPI_MARAX LIKE BAPI_MARAX, " Checkbox Structure for BAPI_MARA
BAPI_MARD1 LIKE BAPI_MARD,
BAPI_MARDX1 LIKE BAPI_MARDX, " Checkbox Structure for BAPI_MARD
BAPI_MARC1 LIKE BAPI_MARC, " Plant View
BAPI_MARCX LIKE BAPI_MARCX, " Checkbox Structure for BAPI_MARC
BAPI_MVKE1 LIKE BAPI_MVKE,
BAPI_MVKEX1 LIKE BAPI_MVKEX, " Checkbox Structure for BAPI_MVKE
BAPI_MLAN1 LIKE BAPI_MLAN,
BAPI_MLANX1 LIKE bapi_mlan1, " Checkbox Structure for BAPI_MLAN
BAPI_MBEW1 LIKE BAPI_MBEW, " Accounting View
BAPI_MBEWX LIKE BAPI_MBEWX, " Checkbox Structure for BAPI_MBEW
BAPI_RETURN LIKE BAPIRET2. " Return Parameter
* $PARAMETERS DECLARATION$
SELECTION-SCREEN BEGIN OF BLOCK B11
WITH FRAME TITLE TEXT-001.
PARAMETERS: P_FILE LIKE RLGRAP-FILENAME. " DEFAULT 'C:\TEST1.XLS'.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN END OF BLOCK B11 .
* $DATA DECLARATION$
*DATA : BDC_DATA LIKE STANDARD TABLE OF BDCDATA WITH HEADER LINE.
DATA : IT_EXCEL TYPE STANDARD TABLE OF ALSMEX_TABLINE INITIAL SIZE 0 WITH HEADER LINE,
IT_EXCEL_DUMMY TYPE ALSMEX_TABLINE.
DATA : MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA : L_MSTRING(480).
DATA :L_SUBRC LIKE SY-SUBRC.
DATA: V_FILE TYPE STRING.
* $AT-SELECTON SCREEN DECLARATION$
AT SELECTION-SCREEN ON P_FILE.
IF P_FILE IS INITIAL.
MESSAGE E398(00) WITH 'FILE NAME NEEDS TO BE SPECIFIED'.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
* DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = P_FILE
start-of-selection.
perform data_fetch_to_xls.
perform insertion.
*& Form data_fetch_to_xls
* text
* --> p1 text
* <-- p2 text
FORM data_fetch_to_xls .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = 1
I_BEGIN_ROW = 2
I_END_COL = 25
I_END_ROW = 2
TABLES
INTERN = IT_EXCEL
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
WRITE: /'ERROR UPLOADING XLS FILE FROM PRESENTATION SERVER !' ,
/'RETURN CODE : ', SY-SUBRC.
ELSE.
*************NOW FILL DATA FROM EXCEL INTO FINAL LEGACY DATA ITAB----LEGACY_DATA***************
IF NOT IT_EXCEL[] IS INITIAL.
CLEAR LEGACY_DATA.
REFRESH LEGACY_DATA[].
LOOP AT IT_EXCEL.
IT_EXCEL_DUMMY = IT_EXCEL.
AT NEW COL.
CASE IT_EXCEL_DUMMY-COL.
WHEN 1.
LEGACY_DATA-MATNR = IT_EXCEL_DUMMY-VALUE(18).
WHEN 2.
LEGACY_DATA-MBRSH = IT_EXCEL_DUMMY-VALUE(1).
WHEN 3.
LEGACY_DATA-MTART = IT_EXCEL_DUMMY-VALUE(4).
WHEN 4.
LEGACY_DATA-WERKS = IT_EXCEL_DUMMY-VALUE(4).
WHEN 5.
LEGACY_DATA-LGORT = IT_EXCEL_DUMMY-VALUE(4).
WHEN 6.
LEGACY_DATA-VKORG = IT_EXCEL_DUMMY-VALUE(4).
WHEN 7.
LEGACY_DATA-VTWEG = IT_EXCEL_DUMMY-VALUE(2).
WHEN 8.
LEGACY_DATA-MAKTX = IT_EXCEL_DUMMY-VALUE(40).
WHEN 9.
LEGACY_DATA-MEINS = IT_EXCEL_DUMMY-VALUE(3).
WHEN 10.
LEGACY_DATA-MATKL = IT_EXCEL_DUMMY-VALUE(9).
WHEN 11.
LEGACY_DATA-SPART = IT_EXCEL_DUMMY-VALUE(2).
WHEN 12.
LEGACY_DATA-GROES = IT_EXCEL_DUMMY-VALUE(32).
WHEN 13.
LEGACY_DATA-FERTH = IT_EXCEL_DUMMY-VALUE(18).
WHEN 14.
LEGACY_DATA-ZEINR = IT_EXCEL_DUMMY-VALUE(22).
WHEN 15.
LEGACY_DATA-TAXKM1 = IT_EXCEL_DUMMY-VALUE(1).
WHEN 16.
LEGACY_DATA-TAXKM2 = IT_EXCEL_DUMMY-VALUE(1).
WHEN 17.
LEGACY_DATA-TAXKM3 = IT_EXCEL_DUMMY-VALUE(1).
WHEN 18.
LEGACY_DATA-TAXKM4 = IT_EXCEL_DUMMY-VALUE(1).
WHEN 19.
LEGACY_DATA-KTGRM = IT_EXCEL_DUMMY-VALUE(2).
WHEN 20.
LEGACY_DATA-MTVFP = IT_EXCEL_DUMMY-VALUE(2).
WHEN 21.
LEGACY_DATA-XCHPF = IT_EXCEL_DUMMY-VALUE(1).
WHEN 22.
LEGACY_DATA-TRAGR = IT_EXCEL_DUMMY-VALUE(4).
WHEN 23.
LEGACY_DATA-LADGR = IT_EXCEL_DUMMY-VALUE(4).
WHEN 24.
LEGACY_DATA-VPRSV = IT_EXCEL_DUMMY-VALUE(1).
WHEN 25.
LEGACY_DATA-VERPR = IT_EXCEL_DUMMY-VALUE(14).
APPEND LEGACY_DATA.
CLEAR LEGACY_DATA.
ENDCASE.
ENDAT.
AT END OF ROW.
ENDAT.
ENDLOOP.
ENDIF.
ENDIF.
ENDFORM. " data_fetch_to_xls
*& Form insertion
* text
* --> p1 text
* <-- p2 text
FORM insertion .
LOOP AT legacy_data.
* Header
BAPI_HEAD-MATERIAL = legacy_data-MATNR.
BAPI_HEAD-IND_SECTOR = legacy_data-MBRSH.
BAPI_HEAD-MATL_TYPE = legacy_data-MTART.
BAPI_HEAD-BASIC_VIEW = 'X'.
BAPI_HEAD-SALES_VIEW = 'X'.
BAPI_HEAD-STORAGE_VIEW = 'X'.
*BAPI_HEAD-PURCHASE_VIEW = 'X'.
BAPI_HEAD-ACCOUNT_VIEW = 'X'.
* Material Description
REFRESH IT_MAKT.
*IT_MAKT-LANGU = legacy_data-SPRAS.
IT_MAKT-MATL_DESC = legacy_data-MAKTX.
APPEND IT_MAKT.
BAPI_MARD1-PLANT = legacy_data-WERKS.
BAPI_MARD1-STGE_LOC = legacy_data-LGORT.
BAPI_MARDX1-PLANT = legacy_data-WERKS.
BAPI_MARDX1-STGE_LOC = legacy_data-LGORT.
** Client Data - Basic
BAPI_MARA1-MATL_GROUP = legacy_data-MATKL.
*bapi_mara1-OLD_MAT_NO = legacy_data-bismt.
BAPI_MARA1-BASE_UOM = legacy_data-MEINS.
BAPI_MARA1-PROD_MEMO = LEGACY_DATA-FERTH.
BAPI_MARA1-SIZE_DIM = LEGACY_DATA-GROES.
BAPI_MARA1-DOCUMENT = LEGACY_DATA-ZEINR.
BAPI_MARA1-BATCH_MGMT = LEGACY_DATA-XCHPF.
*BAPI_MARA1-UNIT_OF_WT = legacy_data-GEWEI.
BAPI_MARA1-TRANS_GRP = legacy_data-TRAGR.
BAPI_MARA1-DIVISION = legacy_data-SPART.
BAPI_MARAX-MATL_GROUP = 'X'.
*BAPI_MARAX-OLD_MAT_NO = 'X'.
BAPI_MARAX-BASE_UOM = 'X'.
BAPI_MARAX-PROD_MEMO = 'X'.
BAPI_MARAX-SIZE_DIM = 'X'.
BAPI_MARAX-DOCUMENT = 'X'.
BAPI_MARAX-BATCH_MGMT = 'X'.
*BAPI_MARAX-UNIT_OF_WT = 'X'.
BAPI_MARAX-TRANS_GRP = 'X'.
BAPI_MARAX-DIVISION = 'X'.
*SALES
BAPI_MVKE1-SALES_ORG = legacy_data-VKORG.
BAPI_MVKE1-DISTR_CHAN = legacy_data-VTWEG.
*BAPI_MVKE1-DELYG_PLNT = legacy_data-DWERK.
BAPI_MVKE1-ACCT_ASSGT = legacy_data-KTGRM.
BAPI_MVKEX1-SALES_ORG = legacy_data-VKORG.
BAPI_MVKEX1-DISTR_CHAN = legacy_data-VTWEG.
*BAPI_MVKEX1-DELYG_PLNT = 'X'.
BAPI_MVKEX1-ACCT_ASSGT = 'X'.
** Plant - Purchasing
BAPI_MARC1-PLANT = legacy_data-WERKS.
BAPI_MARC1-LOADINGGRP = legacy_data-LADGR.
BAPI_MARC1-AVAILCHECK = legacy_data-MTVFP.
*BAPI_MARC1-MRP_GROUP = legacy_data-disgr.
BAPI_MARCX-PLANT = legacy_data-WERKS.
BAPI_MARCX-LOADINGGRP = 'X'.
BAPI_MARCX-AVAILCHECK = 'X'.
*BAPI_MARCX-MRP_GROUP = 'X'.
* Accounting
BAPI_MBEW1-VAL_AREA = legacy_data-WERKS.
BAPI_MBEW1-PRICE_CTRL = legacy_data-VPRSV.
BAPI_MBEW1-STD_PRICE = legacy_data-VERPR.
*BAPI_MBEW1-VAL_CLASS = legacy_data-BKLAS.
*BAPI_MBEW1-STD_PRICE = legacy_data-STPRS.
*BAPI_MBEW1-PRICE_UNIT = legacy_data-PEINH.
BAPI_MBEWX-VAL_AREA = legacy_data-WERKS.
BAPI_MBEWX-PRICE_CTRL = 'X'.
BAPI_MBEWX-STD_PRICE = 'X'.
*BAPI_MBEWX-VAL_CLASS = 'X'.
* TAX JURISDICTION CODE
BAPI_MLAN1-TAXCLASS_1 = LEGACY_DATA-TAXKM1.
BAPI_MLAN1-TAXCLASS_2 = LEGACY_DATA-TAXKM2.
BAPI_MLAN1-TAXCLASS_3 = LEGACY_DATA-TAXKM3.
BAPI_MLAN1-TAXCLASS_4 = LEGACY_DATA-TAXKM4.
BAPI_MLAN1-TAXCLASS_1 = 'X'.
BAPI_MLAN1-TAXCLASS_2 = 'X'.
BAPI_MLAN1-TAXCLASS_3 = 'X'.
BAPI_MLAN1-TAXCLASS_4 = 'X'.
*--- BAPI to create material
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
HEADDATA = BAPI_HEAD
CLIENTDATA = BAPI_MARA1
CLIENTDATAX = BAPI_MARAX
*PLANTDATA = BAPI_MARC1
*PLANTDATAX = BAPI_MARCX
* FORECASTPARAMETERS =
* FORECASTPARAMETERSX =
* PLANNINGDATA =
* PLANNINGDATAX =
* STORAGELOCATIONDATA =
* STORAGELOCATIONDATAX =
VALUATIONDATA = BAPI_MBEW1
VALUATIONDATAX = BAPI_MBEWX
* WAREHOUSENUMBERDATA =
* WAREHOUSENUMBERDATAX =
* SALESDATA = BAPI_MVKE1
* SALESDATAX = BAPI_MVKEX
* STORAGETYPEDATA =
* STORAGETYPEDATAX =
IMPORTING
RETURN = BAPI_RETURN
TABLES
MATERIALDESCRIPTION = IT_MAKT
* UNITSOFMEASURE =
* UNITSOFMEASUREX =
* INTERNATIONALARTNOS =
* MATERIALLONGTEXT =
* TAXCLASSIFICATIONS =
* RETURNMESSAGES =
* PRTDATA =
* PRTDATAX =
* EXTENSIONIN =
* EXTENSIONINX =
IF BAPI_RETURN-TYPE = 'E'.
WRITE:/ 'Error:' ,BAPI_RETURN-MESSAGE ,'for material:' ,legacy_data-maTNR.
ELSEIF BAPI_RETURN-TYPE = 'S'.
WRITE: 'Successfully created material' ,legacy_data-maTNR.
ENDIF.
ENDLOOP.
ENDFORM. " insertion
The error: The field MARC-MTVFP/BAPI_MARC-AVAILCHECK is defined as a required field; it does not contain an entr
suggestion will be vry helpful,
Kind Regards,
Edited by: Prasenjit Sengupta on Nov 16, 2009 9:11 AMHi Prasenjit,
Did you get any solution for this as I am getting same error from BAPI to update MRP controller in MARC table.
Regards,
Suruchi -
Problem in lock Sales order create with BAPI BAPI_SALESORDER_CREATEFROMDAT2
Hi All,
i have the z program to create the sales order with reff quotation in SD With BAPI BAPI_SALESORDER_CREATEFROMDAT2.
this program will excute every 30 mins .
Problem: Some times if i excute the program in background it is taking morethan 30mins so second batch excution also gets starting to create the sales order for same quotation then it is creating 2 sales orders at atime with 1 quotation.
here i am getting duplicate sales orders so i want to lock the creation of duplicate sales order.Some solutions
- Just lock (ENQUEUE) any object at the start of the job(*), if not locked, you can exit or wait in a loop, will be released at end of job (use a _SCOPE '3' so commit work wont release the lock)
-> This will insure the job runs only once at a time
- Lock the quotation before calling the BAPI, will be released by the COMMIT_WORK (from where do you fetch the quotation, if it is a customer Z_table, you can use the lock object that you have surely created ?) (use a _scope '2')
-> This will insure that at most one job will convert a quotation (i suppose you set a "done" flag or status in the quotation record)
Read [SAP Locks |http://help.sap.com/abapdocu_70/en/ABENSAP_LOCK.htm] if you are not familiar with the concept of lock in SAP.
Regards,
Raymond
(*) E_TABLEE for table, E_TRDIR for program, anything not required by another process -
Program for Sales Order cretaion using BAPI BAPI_SALESORDER_CREATEFROMDAT2
Hi All,
Can any one please give me one modal program which uses the BAPI 'BAPI_SALESORDER_CREATEFROMDAT2' to create Sales Orders...
Thank You very much in advance.....................Hi Krishna ,
Please check the below links .
[http://www.sap-basis-abap.com/abap/bapi-sample-to-upload-data-from-flat-file-to-va01.htm]
[http://abapreports.blogspot.com/2008/06/bapi-sample-code-for.html] -- > Select and Copy from this one. -
Hi Frinds..
I am Creating Program Sales Order Uplaod Progrm using BAPI BAPI_SALESORDER_CREATEFROMDAT2.
All header and Po data uploaded Properly . But Item Leal data not updated.. Please let me know any Conditions need to pass to update item data.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
salesdocumentin = v_extr
order_header_in = l_vbak
order_header_inx = l_vbakx
behave_when_error = 'P'
IMPORTING
salesdocument = v_vbeln
TABLES
return = return
order_items_in = l_vbap
order_items_inx = l_vbapx
order_partners = l_vbpa
order_schedules_in = l_shline
order_schedules_inx = l_shlinex .
I can pass like that.hi Prabu,
It is not uploading for company code 1100 .. -
Creating the Sales Order using the bapi BAPI_SALESORDER_CREATEFROMDAT2
Hi,
My problem is , i have created one module pool program for accelerating the Sales Order creation.
I am using the bapi BAPI_SALESORDER_CREATEFROMDAT2 for sales order creation. After executing the program
bapi is given an errot that, incomplete sales order document is saved.
Can any body tell me plz what are the necessary fields i need to take in the header and item level , so that the complete
document will be saved through BAPI.
<removed_by_moderator>
Thanks
Edited by: Julius Bussche on Jan 11, 2010 12:09 PMTABLES: VBAK, "Sales Document: Header Data
VBAP. "Sales Document: Item Data
*************************************WORK AREA DECELERATION************************
DATA: BEGIN OF WA_HEADER,
LI TYPE I, "LINE TYPE
AUART TYPE VBAK-AUART, "Sales Document Type
VKORG TYPE VBAK-VKORG, "Sales Organization
VTWEG TYPE VBAK-VTWEG, "Distribution Channel
SPART TYPE VBAK-SPART, "Division
KUNNR TYPE BAPIPARNR-PARTN_NUMB, "Customer number
END OF WA_HEADER.
DATA: BEGIN OF WA_ITEM,
LI TYPE I,
MATNR TYPE VBAP-MATNR, "MATERIAL NUMBER
ZMENG TYPE VBAP-ZMENG, "QUANTITY
END OF WA_ITEM.
***********************************INTERNAL TABLE DECELERATION***************************************
DATA: IT_HEADER LIKE TABLE OF WA_HEADER WITH HEADER LINE. "IT FOR HEADER
DATA: IT_ITEM LIKE TABLE OF WA_ITEM WITH HEADER LINE. "IT FOR ITEM
DATA: IT LIKE VBAK OCCURS 0 WITH HEADER LINE.
***************************SALES ORDER INTERNAL TABLE DECELERATION********************************
DATA:
HEADER TYPE TABLE OF BAPISDHEAD WITH HEADER LINE, "SALES HEADER DATA
ITEMS TYPE TABLE OF BAPIITEMIN WITH HEADER LINE, "SALES ITEM DATA
PARTNERS TYPE TABLE OF BAPIPARTNR WITH HEADER LINE. "SALLES PARTNERS
***********************************DYNAMIC FIEL PATH GETTING DECELERATION************************
DATA : HL_FIELD_NAME TYPE DYNPREAD-FIELDNAME VALUE 'G_P_SPATH', "SCREEN FIELD NAME
HL_FILE_NAME TYPE IBIPPARMS-PATH VALUE 'G_P_SPATH', "Local file for upload/download
IL_FIELD_NAME TYPE DYNPREAD-FIELDNAME VALUE 'G_P_EPATH', "SCREEN FIELD NAME
IL_FILE_NAME TYPE IBIPPARMS-PATH VALUE 'G_P_EPATH', "Local file for upload/download
FL_FIELD_NAME TYPE DYNPREAD-FIELDNAME VALUE 'G_P_EPATH', "SCREEN FIELD NAME
FL_FILE_NAME TYPE IBIPPARMS-PATH VALUE 'G_P_EPATH'. "Local file for upload/download
DATA : CTR TYPE I .
DATA : CTR2 TYPE STRING.
DATA : CTR1 TYPE STRING.
Sales document number
DATA : L_VBELN LIKE BAPIVBELN-VBELN.
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE T1.
SELECTION-SCREEN : SKIP.
PARAMETER : P_HPATH TYPE STRING.
PARAMETER : P_IPATH TYPE STRING.
SELECTION-SCREEN : SKIP.
SELECTION-SCREEN : END OF BLOCK B1.
SELECTION-SCREEN : BEGIN OF BLOCK B2 WITH FRAME TITLE T2.
SELECTION-SCREEN : SKIP.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN : PUSHBUTTON 10(14) UPLOAD USER-COMMAND CLICK1.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN END OF BLOCK B2.
******************************************INITIALIZATION.***************************************************
INITIALIZATION.
T1 = 'Putchase Order Source File Path'.
T2 = 'Push Button'.
UPLOAD = 'Upload'.
*******************************************AT SELECTION SCREE EVENT********************************************
AT SELECTION-SCREEN.
CASE SY-UCOMM.
WHEN 'CLICK1'.
IF P_HPATH IS INITIAL AND P_IPATH IS INITIAL. "CHECKING BTHE THE TEXT BOX
MESSAGE I009.
ELSE.
PERFORM SELECT. "CALLING THE SELECT SUBROUTINE
ENDIF.
WHEN OTHERS.
MESSAGE 'PRESS FORM BUTTON' TYPE 'I'. "WHEN EXECUTE BUTTON IS PRESSED
ENDCASE.
***********************************GETTING HEADER FIEL PATH*******************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_HPATH.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = HL_FIELD_NAME
IMPORTING
FILE_NAME = HL_FILE_NAME.
P_HPATH = HL_FILE_NAME.
***********************************GETTING ITEM FIEL PATH*******************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_IPATH.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = IL_FIELD_NAME
IMPORTING
FILE_NAME = IL_FILE_NAME.
P_IPATH = IL_FILE_NAME.
START-OF-SELECTION.
*& Form SELECT
text
--> p1 text
<-- p2 text
FORM SELECT .
CALL FUNCTION 'GUI_UPLOAD' " function resposible to get the local flat
EXPORTING " and upload it in a internal table
FILENAME = P_HPATH
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = '#'
TABLES
DATA_TAB = IT_HEADER.
CALL FUNCTION 'GUI_UPLOAD' " function resposible to get the local flat
EXPORTING " and upload it in a internal table
FILENAME = P_IPATH
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = '#'
TABLES
DATA_TAB = IT_ITEM.
LOOP AT IT_HEADER.
Initialize Header values
HEADER-DOC_TYPE = IT_HEADER-AUART.
HEADER-SALES_ORG = IT_HEADER-VKORG.
HEADER-DISTR_CHAN = IT_HEADER-VTWEG.
HEADER-DIVISION = IT_HEADER-SPART.
APPEND HEADER.
PARTNERS-PARTN_ROLE = 'WE'.
PARTNERS-PARTN_NUMB = IT_HEADER-KUNNR.
APPEND PARTNERS.
CTR = 10.
LOOP AT IT_ITEM WHERE LI = IT_HEADER-LI.
CTR2 = CTR.
CONCATENATE '0000' CTR2 INTO CTR1.
***Initialize Item values
ITEMS-ITM_NUMBER = IT_ITEM-ITEM.
ITEMS-ITM_NUMBER = CTR1.
ITEMS-MATERIAL = IT_ITEM-MATNR.
ITEMS-REQ_QTY = IT_ITEM-ZMENG.
APPEND ITEMS.
CTR = CTR + 10.
ENDLOOP.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT1'
EXPORTING
ORDER_HEADER_IN = HEADER "SALES HEADER DATA
IMPORTING
SALESDOCUMENT = L_VBELN "RETRIEVED SALES DOCUMENT NUMBER
TABLES
ORDER_ITEMS_IN = ITEMS "SALES ITEM LEVEL DATA
ORDER_PARTNERS = PARTNERS. "SAKES PARTNERS
APPEND L_VBELN TO IT.
COMMIT WORK AND WAIT.
CLEAR : HEADER , ITEMS[] ,PARTNERS,CTR,CTR1,CTR2.
REFRESH : ITEMS.
ENDLOOP.
IF IT[] IS NOT INITIAL.
LOOP AT IT.
WRITE: / 'SALES ORDER', IT-VBELN , 'CREATED'.
ENDLOOP.
LEAVE TO LIST-PROCESSING.
SET PF-STATUS SPACE.
ELSE.
MESSAGE I044.
ENDIF .
ENDFORM. " SELECT -
Problems with running BAPI BAPI_SALESORDER_CREATEFROMDAT2
Hi all,
I’ve got a problem running BAPIs in SD invironment.
I’m creating contract releases in SD via BAPI.
First I run BAPI BAPISORDER_GETDETAILEDLIST in my program to get detaildata of the contract.
Then I run the BAPI BAPI_SALESORDER_CREATEFROMDAT2 filled with contract reference data and in addition with order data to create the contract release.This works properly so far. On both sides in the contract and in he contract release I find the correct document flow. Means: in document flow of the contract I find all the releases created . Also I find the contract in the documentflow of the releases.
But…something does not work: In the contract the released values are not updated. When I create a release manually, the release values are accumulated in the contract in field ‘value released’ under flag ‘item detail’. But this does not work, when the leases are created via BAPI. However I checked several parameters in the BAPIS but I cannot find something that leads to an update .
Can somebody help me and can tell me what is to be done to get this field updated? Thanks in advance.
same in German...
Ich habe ein Problem mit BAPIs im SD.
Ich erzeuge Abrufe zum Kontrakt im SD mittels BAPIs.
Zuerst lasse ich den BAPI BAPISORDER_GETDETAILEDLIST laufen, um mittels Kontraktnummer alle Daten zum Kontrakt zu bekommen. Dann lasse ich den BAPI BAPI_SALESORDER_CREATEFROMDAT2 gefüllt mit SD-Abrufdaten und den Referenzdaten des Kontraktes laufen Dies funktioniert soweit sehr gut. Sowohl im Kontrakt als auch im Abruf sind jeweils die übergeordneten bzw. untergeordneten Vertiebsbelege zu sehen. Die Referenz wird also hergestellt. Jedoch wird im Kontrakt nicht die Abrufwerte aufsummiert. Normalerweise wird bei manueller Erstellung der Abrufe im Kontrakt die jeweilgen abgerufenen Werte gegen den Kontraktwert aufsummiert (Feld abgerufene Werte im Kontrakt unter Reiter ‚Positionsdetail‘. Ich habe alle möglichen Parameter im BAPI geprüft und getestet aber nichts gefunden, was mir die abgerufenen Werten aufsummiert.
Kann mir dazu einen Tip geben, was ich tun kann, damit auch die Werte richtig referenzieren ? Danke im Voraus.the usage of exactly this BAPIs in the way I described is in according to SAP note 370988.
BAPI_SALES_DEL_SCHEDULE_CREATE ist for SD schedule agreements and not for SD contracts and does not offer Input parameters for e.g. adding price conditions what is needed for my task.
The field in contract I mentioned e.g. in Transaction VA42 VA43 is filled / gets its Information out of Infostructure/table S135. The BAPI seems not be able to fill this structure while creating the contract release.
I'm looking for example an input parameter I did not found already or any other option that leads to an update of infostructure S135 while creating/posting a release via BAPI. -
How can we find error in BAPI Creation?
Can any one help out in How to findout Errors in BAPI Creation and Usage?
HI,
you can findout error by declaring BAPI RETURN type structure .
for ex:"
DATA : return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
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_partners = partner
sales_conditions_in = i_conditions.
LOOP AT return WHERE type = 'E' OR type = 'A'.
EXIT.
ENDLOOP.
if helpful reward points. -
Problem for bapi: BAPI_SALESORDER_CREATEFROMDAT2
Hi all,
when creating sales order via BAPI_SALESORDER_CREATEFROMDAT2 in the testing mode,
it returns a sales order no successfully.
But when a veiw it via VA03, the system says that this sales order doesn't exist.
What's wrong? ThanksHi Macy,
The Sales order will not be saved in the database till the time you call the bapi from an ABAP Program.
Also you have call the FM BAPI_TRANSACTION_COMMIT after the calling the BAPI BAPI_SALESORDER_CREATEFROMDAT2.
If you are simply testing the BAPI from SE37, no Sales Order will be saved in the database tables and hence will not be seen in VA03. Testing BAPI from se37 is simply a simulation of the sales order.
So create a test program, call the bapi
BAPI_SALESORDER_CREATEFROMDAT2.. pass all the required data.
Then if sy-subrc = 0
call FM BAPI_TRANSACTION_COMMIT....
It will work...
Lokesh
Pls. reward appropriate points -
Hi frnds i m unable to know the answer for the q?
How do u handle errors in BAPI.
i.e i m using standard BAPI po creation if some errors occurs then how to handle those errors
how can we know the errors.
plz reply me back frnds...
thnks...Hi Sanjay,
Call BAPI like this :
data: it_retrun typa table of bapireturn.
CALL FUNCTION 'BAPI_PO_CREATE'
EXPORTING
po_header =
PO_HEADER_ADD_DATA =
HEADER_ADD_DATA_RELEVANT =
PO_ADDRESS =
SKIP_ITEMS_WITH_ERROR = 'X'
ITEM_ADD_DATA_RELEVANT =
HEADER_TECH_FIELDS =
IMPORTING
PURCHASEORDER =
tables
po_items =
PO_ITEM_ADD_DATA =
po_item_schedules =
PO_ITEM_ACCOUNT_ASSIGNMENT =
PO_ITEM_TEXT =
RETURN = it_return
PO_LIMITS =
PO_CONTRACT_LIMITS =
PO_SERVICES =
PO_SRV_ACCASS_VALUES =
PO_SERVICES_TEXT =
PO_BUSINESS_PARTNER =
EXTENSIONIN =
POADDRDELIVERY =
IT_RETURN will contains all message returned from BAPI. For error message you can read IT_RETURN table where type = 'E'.
Thanks
Swagatika
Maybe you are looking for
-
Fire Wire HDD not showing in Desktop
Hi, I am using a maxtor 300GB Firewire HDD, Suddenly it is not showing in my Desk Top, but it is showing in Disk Utility. I am not able to use the disk. I already have valuble data in it. I am only able to eject it from disk utility. I also want some
-
WMy Geforce 3 Ti-200 Pro-T (MS-8851) Not working in D3d!!!!!
;( I have a G3Ti200Pro-T (MS-8851) When i play any game in D3d it comes on until the loading screen comes up.... then it crashes and goes back to desktop.. I tried to play UT2k3, and MotoGP but the same thing happens goes back to desktop... I can o
-
Disabling Format Font flyout display
As per instructions in the FM Online manual "Customizing Frame Products", here are the steps to disable the popup Format > Fonts display menu. 1. assuming that you do not already have a customui.cfg file: create a new text file named "customui.cfg".
-
A simple JSF Table CRUD - How To
Hello, I have to build a few CRUDs for very simple tables (3 columns at most) implemented as JSF tables. I wish the "Create" function to work as: 1. By clicking the "Create" button (or link?), append an empty row at the end of the table (or perhaps i
-
When I download CC from my Adobe account it installs and launches, but the dialogue box is completely blank; I cannot sign in or do anything except go to help. I have CC on my desktop already, this machine, the one I'm trying to install it on, is a l