BAPI_SALESORDER_CREATEFROMDAT2 conditions
Hi gurus!
I'm using BAPI_SALESORDER_CREATEFROMDAT2 to create SO document and need to pass SOME prices.
Searched the forum, but none of the solutions is right for me.
This is me test scenery: one order with two items. One has price (ZPVP) and the other doesn't. ZPVP condition is pre-set and it can be entered manually.
What I need is to override the value of condition ZPVP.
When I set BAPISDLS-PRICING = 'G' and BAPISDLS-COND_HANDL = 'X' : condition ZPVP is deleted for both items;
When I set BAPISDLS-PRICING = 'G' and BAPISDLS-COND_HANDL = ' ' : Condition ZPVP is filled with the value that I pass; Condition ZPVP is deleted if I don't pass any value;
When I set BAPISDLS-PRICING = 'C' and BAPISDLS-COND_HANDL = ' ':Duplicates condition ZPVP in the item where I pass the value; Item where no value is passed is OK (pre-set);
When I set BAPISDLS-PRICING = 'C' and BAPISDLS-COND_HANDL = 'X': The condition value that I pass to the BAPI is ignored. Both items are filled with pre-set value for condition ZPVP.
Can someone help?
Thanks in advance!
Carlos Constantino
Hi,
I think you need to pass the entire condition value instead of dividing by 10.
Instead of:
t_bapicond-cond_value = t_konv-kbetr / 10.
Use:
t_bapicond-cond_value = t_konv-kbetr.
Within include program L2032FXX, form move_condition_out, there is some special code for krech = 'A' that divides condition value by 10 for you. Here is the standard code:
if www_ex_konvkom-krech = 'A'. "prozentual ?
bapi_ex_konvkom-cond_value = www_ex_konvkom-kbetr / 10.
endif.
If that does not work for you, then take a look in include program L2032FXX, form move_condition_out to see some additional special handling for krech = 'A' that may or may not end up affecting your condition value results.
case www_ex_konvkom-krech.
when 'A' or 'H' or 'I'.
bapi_ex_konvkom-conbaseval =
www_ex_konvkom-kawrt.
if not www_ex_konvkom-kawrt is initial and
not da_waer is initial.
clear bapi_ex_konvkom-conbaseval.
call function 'BAPI_CURRENCY_CONV_TO_EXTERN_9'
exporting
currency = da_waer
amount_internal = www_ex_konvkom-kawrt
importing
amount_external = bapi_ex_konvkom-conbaseval.
endif.
when others.
bapi_ex_konvkom-conbaseval =
www_ex_konvkom-kawrt / 10.
endcase.
Regards,
James Gaddis
Similar Messages
-
BAPI_SALESORDER_CREATEFROMDAT2 :condition type
hi all,
I using above bapi for sales order creation . i using ORDER_CONDITIONS_IN for conditions , but i facing problem
i.e the condition type which i given is header type .
My question is how can we pass header and item condition in BAPI .
Thanks,
Sridhar.Hi Sridhar,
Did you try passing the header condition with item number as "000000" in the structure?
Also, is there a special header condition defined for the sales order or you are trying to accumulate item values and trying to populate at header level?
Raj
Reward points if helpful -
BAPI_SALESORDER_CREATEFROMDAT2 doesn't work for header Condition
Hi, All
I'm trying to create a sales order using BAPI_SALESORDER_CREATEFROMDAT2.
It doesn't work to create a heder condition.(HB00)
After BAPI, I check KONV data, HB00 data is broken.
KONV-STUNR and KONV-ZAEHK is blank.
but item condtion data is OK. no problem.
I don't know why.
my code is below.
If you have any idea, please let me know.
IW_LOGIC_SWITCH-PRICING = 'G'
CLEAR IW_CONDITIONS.
IW_CONDITIONS-ITM_NUMBER = '000000'.
IW_CONDITIONS-COND_COUNT = '01'.
IW_CONDITIONS-COND_TYPE = 'HB00'.
IW_CONDITIONS-COND_VALUE = W_VALUE.
IW_CONDITIONS-CURRENCY = W_WAERK.
IW_CONDITIONS-CONDCOINHD = '01'.
APPEND IW_CONDITIONS TO IT_CONDITIONS.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
ORDER_HEADER_IN = IW_HEADER
LOGIC_SWITCH = IW_LOGIC_SWITCH
IMPORTING
SALESDOCUMENT = W_SALEDOC
TABLES
RETURN = IT_RETURN
ORDER_ITEMS_IN = IT_ITEMS
ORDER_PARTNERS = IT_PARTNERS
ORDER_SCHEDULES_IN = IT_SCHEDULES
ORDER_CONDITIONS_IN = IT_CONDITIONS
ORDER_TEXT = IT_TEXT
EXTENSIONIN = IT_EXTENSIONIN
PARTNERADDRESSES = IT_PARTNERADDRESSES.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
Regards,
Rie.check the following link
Re: BAPI_SALESORDER_CREATEFROMDAT2 how to set condition type value as zero (0).
L_ORDER_PARTNERS-PARTN_ROLE = 'AG'.
L_ORDER_PARTNERS-PARTN_NUMB =
RECORD-KUNNR_1.
APPEND L_ORDER_PARTNERS TO
LI_ORDER_PARTNERS.
L_ORDER_PARTNERS-PARTN_ROLE = 'WE'.
L_ORDER_PARTNERS-PARTN_NUMB =
RECORD-KUNNR_2.
APPEND L_ORDER_PARTNERS TO
LI_ORDER_PARTNERS.
* Build order header
CLEAR: L_ORDER_HEADER_INX,
L_ORDER_HEADER_IN.
* Update flag
L_ORDER_HEADER_INX-UPDATEFLAG = 'I'.
* Sales document type
L_ORDER_HEADER_IN-DOC_TYPE =
RECORD-AUART.
L_ORDER_HEADER_INX-DOC_TYPE = 'X'.
* Sales organization
L_ORDER_HEADER_IN-SALES_ORG = RECORD-VKORG.
L_ORDER_HEADER_INX-SALES_ORG = 'X'.
* Distribution channel
L_ORDER_HEADER_IN-DISTR_CHAN = RECORD-VTWEG.
L_ORDER_HEADER_INX-DISTR_CHAN = 'X'.
* Division
L_ORDER_HEADER_IN-DIVISION = RECORD-SPART.
L_ORDER_HEADER_INX-DIVISION = 'X'.
* Sales Office
L_ORDER_HEADER_IN-SALES_OFF = RECORD-VKBUR.
L_ORDER_HEADER_INX-SALES_OFF = 'X'.
* Sales Group
L_ORDER_HEADER_IN-SALES_GRP = RECORD-VKGRP.
L_ORDER_HEADER_INX-SALES_GRP = 'X'.
* Purchase order
L_ORDER_HEADER_IN-PURCH_NO_C = RECORD-BSTNK.
L_ORDER_HEADER_INX-PURCH_NO_C = 'X'.
* Purchase order Date
L_ORDER_HEADER_IN-PURCH_DATE =
RECORD-BSTDK.
L_ORDER_HEADER_INX-PURCH_DATE = 'X'.
* Payment Terms
L_ORDER_HEADER_IN-PMNTTRMS = RECORD-ZTERM.
L_ORDER_HEADER_INX-PMNTTRMS = 'X'.
* Incoterm1
L_ORDER_HEADER_IN-INCOTERMS1 = RECORD-INCO1.
L_ORDER_HEADER_INX-INCOTERMS1 = 'X'.
* Incoterm2
L_ORDER_HEADER_IN-INCOTERMS2 = RECORD-INCO2.
L_ORDER_HEADER_INX-INCOTERMS2 = 'X'.
* Customer Group
L_ORDER_HEADER_IN-CUSGROUP = RECORD-KDGRP.
L_ORDER_HEADER_INX-CUSGROUP = 'X'.
ENDIF.
* Build order item(s)
CLEAR: L_ORDER_ITEMS_INX, L_ORDER_ITEMS_IN.
L_ORDER_ITEMS_IN-ITM_NUMBER = INO.
L_ORDER_ITEMS_INX-ITM_NUMBER = INO.
L_ORDER_ITEMS_IN-MATERIAL = RECORD-MABNR.
L_ORDER_ITEMS_INX-MATERIAL = 'X'.
L_ORDER_ITEMS_IN-PLANT = RECORD-WERKS.
L_ORDER_ITEMS_INX-PLANT = 'X'.
L_ORDER_ITEMS_IN-SALES_UNIT = RECORD-VRKME.
L_ORDER_ITEMS_INX-SALES_UNIT = 'X'.
L_ORDER_ITEMS_IN-WBS_ELEM = RECORD-PS_POSID.
L_ORDER_ITEMS_INX-WBS_ELEM = 'X'.
APPEND L_ORDER_ITEMS_IN TO LI_ORDER_ITEMS_IN.
L_ORDER_ITEMS_INX-UPDATEFLAG = 'I'.
APPEND L_ORDER_ITEMS_INX TO
LI_ORDER_ITEMS_INX.
* Build Schedule lines... Order Quantity
CLEAR: L_ORDER_SCHEDULES_IN,
L_ORDER_SCHEDULES_INX.
L_ORDER_SCHEDULES_IN-ITM_NUMBER = INO.
L_ORDER_SCHEDULES_INX-ITM_NUMBER = INO.
L_ORDER_SCHEDULES_IN-REQ_QTY = RECORD-KWMENG.
L_ORDER_SCHEDULES_INX-REQ_QTY = 'X'.
L_ORDER_SCHEDULES_INX-UPDATEFLAG = 'X'.
APPEND L_ORDER_SCHEDULES_IN TO
LI_ORDER_SCHEDULES_IN.
APPEND L_ORDER_SCHEDULES_INX TO
LI_ORDER_SCHEDULES_INX.
* Build Conditions
CLEAR: L_ORDER_CONDITIONS_IN,
L_ORDER_CONDITIONS_INX.
L_ORDER_CONDITIONS_IN-ITM_NUMBER = INO.
L_ORDER_CONDITIONS_IN-COND_COUNT = '01'.
L_ORDER_CONDITIONS_IN-COND_TYPE =
RECORD-KSCHL_1.
L_ORDER_CONDITIONS_IN-COND_VALUE =
RECORD-KBETR_1.
IF RECORD-KSCHL_1 = 'PR00'.
L_ORDER_CONDITIONS_IN-COND_VALUE =
L_ORDER_CONDITIONS_IN-COND_VALUE
/ 10.
ENDIF.
L_ORDER_CONDITIONS_INX-ITM_NUMBER = INO.
L_ORDER_CONDITIONS_INX-COND_COUNT = '01'.
L_ORDER_CONDITIONS_INX-COND_TYPE =
RECORD-KSCHL_1.
L_ORDER_CONDITIONS_INX-UPDATEFLAG = 'X'.
L_ORDER_CONDITIONS_INX-COND_VALUE = 'X'.
APPEND L_ORDER_CONDITIONS_IN TO
LI_ORDER_CONDITIONS_IN.
APPEND L_ORDER_CONDITIONS_INX TO
LI_ORDER_CONDITIONS_INX.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
ORDER_HEADER_IN =L_ORDER_HEADER_IN
ORDER_HEADER_INX = L_ORDER_HEADER_INX
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
END-OF-SELECTION -
Pricing conditions in BAPI_SALESORDER_CREATEFROMDAT2
hi all,
The Pricing conditions I pass in to the bapi BAPI_SALESORDER_CREATEFROMDAT2 are not picked up for my item.
I'm filling in the
wa_kbetr-itm_number = 'ZRSS'.
wa_kbetr-cond_value = wa_sourcedata-kbetr1.
APPEND wa_kbetr TO it_kbetr.
wa_kbetr-itm_number = 'ZOTB'.
wa_kbetr-cond_value = wa_sourcedata-kbetr2.
APPEND wa_kbetr TO it_kbetr.
fields of the ORDER_CONDITIONS_IN table.
iam getting the error as " Condition is missing in pricing procedure A V ZPCNOT"
I'd appreciate any suggestions.In that check the condition type which u r passing to BAPI is assinged to u r sales org,Dis channel & division combination.
In it not maintianed then this error will come.
No, that's not true...That transaction is for pricing procedure determination by sales area, dcoument indicator and customer indicator but the lack of a condition type there does not trigger this error, ESPECIALLY not 2 different Z-conditions... -
BAPI BAPI_SALESORDER_CREATEFROMDAT2 Header condition
Hi friends,
I am using function module BAPI_SALESORDER_CREATEFROMDAT2 for sales order creation. We are having one condition ZDIF as header and item condition. When we are entering the data in ORDER_CONDITON table and executing the BAPI, then it is taking as item condition. I need to use this condition as header condition and should pick in header only. Please suggest the way how can I use it as a header condition only.
Kraheja.Hi,
Conditions that you are entering in ORDER_CONDITIONS_IN is for items only and you need to enter the item conditions here .
And once your sales order is created with these conditions you will see that the header condition is also created with the total of the item conditions ...
For Example you have 2 items in your sales order.
Net Price of 1st item - 10,000 Rs
Net Price of 2nd Item - 40,000 Rs
THen Net Price in your header will be 50,000 .. that is 10,000 + 40,000.
so just enter the item conditions in ORDER_CONDITIONS_IN . . -
Bapi_salesorder_createfromdat2, zero price in conditions
Hi,
I create salesorder with bapi_salesorder_createfromdat2 and give price for material in ORDER_CONDITION_IN table. When price is >0 it works OK. But I need in some cases to create orderline with 0 (zero) price. When entering 0 in COND_VALUE field it is not taken into account, instead SAP takes listprice for this line.
When using VA01 to manually change item price to zero, it works OK.
Does anybody have experience with this?
br,
erkiI usually do not send ORDER_CONDITIONS_INX (or any .._INX) at all. But I tried with:
ORDER_CONDITIONS_INX-COND_VALUE = 'X'.
ORDER_CONDITIONS_INX-UPDATEFLAG = 'X'.
and just
ORDER_CONDITIONS_INX-COND_VALUE = 'X'.
and it makes no difference. Always when COND_VALUE is zero listprice is taken.
Any more suggestions? -
Duplicate condition records with BAPI_SALESORDER_CREATEFROMDAT2
you don't have to pass the bapisdls at all. Just don't pass the bapisdls. make sure that you're passing kschl, kbetr kmein kwert in the conditions_in parameter to the bapi. That should do it.
Hi Fuad,
I think there can be two ways.
1. Create SAles order as you are creating without pasing any value for this condition type. and then change this condition value ( which is being determined automatically) by using BAPI_SALESORDER_CHANGE wher you can use Update flag as 'X' In parameter CONDITIONS_INX of this BAPI.
<b>OR</b>
2. If you want to happen this chage at the time of sales order creation, then I think , this particual condition type should be "manual" and not "Automatic" One.
Hope this helps.
Regds,
Akshay Bhagwat
Note: Pls mark helpful answers. -
BAPI_SalesOrder_CreateFromDat2 fails for items with free goods
Hi all, I have a very weird problem when I am trying to create a sales order using SAP .net connector with the BAPI function BAPI_SalesOrder_CreateFromDat2(). The problem happens through the following scenario:
1 - Item X has a free good rule on it that states "If user buys 5 Cartoons of Item X he will take 1 pack of Item Y free of charge" while Item Z has no rules like this
2 - using BAPI and .net connector, an order is needed to be created with following details:
a - Item X with quantity 6 Cartoons.
b- Item Z with quantity 3 Cartoons
3 - If BAPI_SalesOrder_CreateFromDat2() assigns these details to Order_Items_In with the same order (a then b), SAP will return an error for Item z that states "No item category available (Table T184 ZKE NORM KEN)."; while if the function tries to create the order with details in reverse order (b then a ), the order will be created successfully.
I have done the following steps:
1 - Tried the same order in SAP GUI but it succeeded. (So no problem in Item Category Determination)
2 - Tries the same order with the suspicious order in the BAPI function Test inside SAP GUI (using tcode BAPI or SE37) but the function had not return any errors also.
3 - Tried to send Item Category in code when calling the bapi function (Forced the code to KEN), but the same message appeared as SAP insist on redetermining the Item Category and return this meaningless message.
thanksHi Mohamed Abd Elbaset,
I am facing the same issue while creating the Sales order through "BAPI_SALESORDER_CREATEFROMDAT2" All is going well in normal cases but when I process the contract with FREE GOODS line items for which free goods condition record is maintained it fails
to create the Sales order. Is there any special treatment for this Free goods case..
Regards, -
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. -
BAPI_SALESORDER_CREATEFROMDAT2 & Confirmed Qty NOT being set
Good day!
Creating orders via BAPI_SALESORDER_CREATEFROMDAT2. Orders are being created successfully. However, CONFIRMED QTY is set to 0, and NOT triggering.
The following settings have been confirmed.
- Majority of all communication field settings are set to "X" at Header, Item, schedule, and condition.
- All itm_number are set accordingly to respective posnr
- All updateflag are set accordingly
- Set comp_dlv and part_dlv to ' '.
From a functional perspective, what configurations HAVE to be completed to ensure Deliveries are triggered via respective BAPI? I understand, availability check is performed in background so screens cannot be performed--thus, no partial or full delivery can be filled.
Any pointers will be appreciative. Thanks in advance.I seem to remember having that issue before. I believe the fix in that particular case was that the storage location was not specified in the BAPI call for items that were ATP-relevant. Of course, if your ATP check is at the shipping point level, if you don't specify the shipping point, you won't get a confirmation either. As usual, I believe I tracked it down with the good old debugger.
-
Problem with conditions in creation of contract using BAPI_CONTRACT_CREATE
Hi,
I am using BAPI_CONTRACT_CREATE and it does creates contracts and items, but even I am sending condition information to the BAPI , but it is not create them and I donu2019t even get an error message.
Thanks and Regards,
Pavan MedaThis FM is pretty well documented, make sure all tables are filled in correctly (e.g. ITEM_CONDITION, ITEM_CONDITIONX). Also make sure you actually can enter those conditions in the online transaction - sometime people are trying to push something through that is not supposed to work.
Also search SDN for posts regarding conditions in BAPI_SALESORDER_CREATEFROMDAT2, you might find some similarities. -
Problem when creating a sales order using BAPI_SALESORDER_CREATEFROMDAT2
Hello All,
I am working on a requirement where i need to create a new sales order from old sales order (Not all the items of the old sales order are to be copied) i am doing this by getting the data using BAPISDORDER_GETDETAILEDLIST to get the old sales order details and send them to BAPI_SALESORDER_CREATEFROMDAT2.
My problem is that i when i send the condition also the system in addition to the conditions sent to the BAPI is also automatically proposing the condition types . So the final result is that the sales order ends up having the condition types twice .
For example VPRS AZWR are visible twice in the sales order.
Any inputs to solve the problem will be definitely rewarded.
Thanks in advance.
Regards,
Sowmya.Hello All,
I am working on a requirement where i need to create a new sales order from old sales order (Not all the items of the old sales order are to be copied) i am doing this by getting the data using BAPISDORDER_GETDETAILEDLIST to get the old sales order details and send them to BAPI_SALESORDER_CREATEFROMDAT2.
My problem is that i when i send the condition also the system in addition to the conditions sent to the BAPI is also automatically proposing the condition types . So the final result is that the sales order ends up having the condition types twice .
For example VPRS AZWR are visible twice in the sales order.
Any inputs to solve the problem will be definitely rewarded.
Thanks in advance.
Regards,
Sowmya. -
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 .. -
Quantity update into sales order using BAPI_SALESORDER_CREATEFROMDAT2
Hi All,
I am able to create a sales order using the BAPI "BAPI_SALESORDER_CREATEFROMDAT2".
But even after assinging the Target_quntity and the Target_quantity_units, the values are not getting updated into the Sales order, but the sales order gets created .
Did anyone of you had a similare problem, how was it solved.
cold some one please help me out on this.
RegardsHi
I had used below code (using <b>BAPI_SALESORDER_CREATEFROMDAT1</b>)..but never faced any problem.. you can try the same...
Regards,
Raj
REPORT z_sd_salesorder_create
NO STANDARD PAGE HEADING
LINE-SIZE 150
MESSAGE-ID zz.
S T R U C T U R E D E C L A R A T I O N S *
TYPES: BEGIN OF x_ppl,
ppl_order(18), " ppl Orderno
auart(4), " Sales Doc Type
vkorg(4), " Sales Organization
vtweg(2), " Distribution Channel
spart(2), " Division
div(3), " Division
kunnr(10), " Sold-to Party
date(10), " Doc Dt
matnr(18), " Item Matnr#
uom(3), " UOM
qty(15), " Qty
kschl(4), " Pricing condiiton type
kbetr(11), " Rate
END OF x_ppl.
TYPES: BEGIN OF x_file,
loc(30), " Location
div(3), " Division
ppl_order(18), " ppl Orderno
kunnr(10), " Sold-to Party
date(10), " Doc Dt
matnr(20), " Item Matnr#
qty(15), " Qty
uom(3), " UOM
kbetr(11), " Rate
discount(5), " Discount
END OF x_file.
TYPES: BEGIN OF x_output,
ppl_order(18), " ppl Orderno
mesg(130), " Mesg Success/Error
END OF x_output.
TYPES: BEGIN OF x_werks,
name2(30), " Location
werks TYPE werks_ext, " Plant
END OF x_werks.
TYPES: BEGIN OF x_info,
vkorg TYPE vkorg , " Sales org
vtweg TYPE vtweg, " Dist channel
werks TYPE werks_ext," Plant
spart TYPE spart, " Storage Loc
END OF x_info.
TYPES: BEGIN OF x_material,
ppl_prdid(20), " ppl Prd id
matnr TYPE matnr, " Material (SAP)
END OF x_material.
I N T E R N A L T A B L E D E C L A R A T I O N S *
DATA: it_file TYPE STANDARD TABLE OF x_file WITH HEADER LINE." File Data
DATA: it_data TYPE STANDARD TABLE OF x_ppl WITH HEADER LINE." ppl File
DATA: it_out TYPE STANDARD TABLE OF x_output WITH HEADER LINE. " Outcome
DATA: it_werks TYPE STANDARD TABLE OF x_werks WITH HEADER LINE. " Plant
DATA: it_info TYPE STANDARD TABLE OF x_info WITH HEADER LINE. " Othr Info
DATA: it_matnr TYPE STANDARD TABLE OF x_material WITH HEADER LINE. " Material Info
DATA: it_item TYPE STANDARD TABLE OF bapiitemin WITH HEADER LINE. "Order Itm data
DATA: it_partner TYPE STANDARD TABLE OF bapipartnr WITH HEADER LINE. "Order Partner data
V A R I A B L E S D E C L A R A T I O N S *
DATA : v_correct TYPE i,
v_error TYPE i,
v_total TYPE i,
v_return LIKE bapireturn1,
v_index LIKE sy-tabix.
*- Return values
DATA: it_orderh TYPE bapisdhead, "Order Hdr data
order TYPE bapivbeln-vbeln,
soldto TYPE bapisoldto,
shipto TYPE bapishipto,
return TYPE bapireturn1.
DATA: hdate TYPE sy-datum.
U S E R I N P U T S S C R E E N *
SELECTION-SCREEN: BEGIN OF BLOCK blk01 WITH FRAME TITLE text-t01.
PARAMETERS: p_file TYPE rlgrap-filename OBLIGATORY. " File name
SELECTION-SCREEN END OF BLOCK blk01.
S E L E C T I O N S C R E E N *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM get_file.
S t a r t o f S e l e c t i o n *
START-OF-SELECTION.
PERFORM get_upload.
PERFORM validate_data. " Validate the data
PERFORM data_swap. " Prepare the data for processing
IF NOT it_data[] IS INITIAL.
PERFORM get_update. " Create SalesOrders
ELSE.
MESSAGE i001(zz) WITH text-001.
STOP.
ENDIF.
E n d o f S e l e c t i o n *
END-OF-SELECTION.
IF NOT it_data[] IS INITIAL.
PERFORM get_write.
ENDIF.
*& Form get_file
Get File name
FORM get_file .
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
program_name = syst-repid
mask = '*'
CHANGING
file_name = p_file
EXCEPTIONS
mask_too_long = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " get_file
*& Form get_upload
to upload the file
FORM get_upload .
DATA l_file TYPE string.
CLEAR: it_file, it_file[].
l_file = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_file
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = it_file
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSEIF sy-subrc = 0.
SORT it_file BY loc ppl_order.
ENDIF.
ENDFORM. " get_upload
*& Form get_update
Creating mapping Data in Z table
FORM get_update .
DATA: l_itemno(2) TYPE n,
l_partner TYPE parvw,
l_kunnr TYPE kunnr,
l_matnr TYPE matnr,
l_mesg TYPE string,
l_kbetr TYPE p DECIMALS 2.
DATA: l_in_qty LIKE vbap-zmeng,
l_meins LIKE mara-meins,
l_qty LIKE vbap-zmeng.
CLEAR: v_correct, v_error, v_total.
SORT it_data BY ppl_order.
LOOP AT it_data.
CLEAR v_index.
v_index = sy-tabix.
*- New SalesOrder
AT NEW ppl_order.
READ TABLE it_data INDEX v_index.
CLEAR: it_orderh, it_item, it_partner,
order, soldto, shipto, return,
it_item[], it_partner[].
v_total = v_total + 1. "Increment Total SalesOrders counter
CLEAR l_itemno.
l_itemno = '10'.
*- Covert date fields into Internal format
CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'
EXPORTING
datum = it_data-date
dtype = 'DATS'
IMPORTING
idate = it_data-date.
*- Populate SalesOrder header data.
CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
EXPORTING
input = it_data-auart
IMPORTING
output = it_data-auart.
it_orderh-doc_type = it_data-auart.
it_orderh-sales_org = it_data-vkorg.
it_orderh-distr_chan = it_data-vtweg.
it_orderh-division = it_data-spart.
it_orderh-purch_no = 'DEPOT'.
it_orderh-price_date = it_data-date. "Doc Dt
it_orderh-req_date_h = it_data-date. "Del.Dt
it_orderh-purch_no_s = it_data-ppl_order.
*- Partner data
CLEAR: l_partner, l_kunnr.
*- Convert Partner type into internal format
l_partner = 'SP'. "SoldTo Party
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
input = l_partner
IMPORTING
output = l_partner.
*- Convert Customer into internal format
l_kunnr = it_data-kunnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = l_kunnr
IMPORTING
output = l_kunnr.
it_partner-partn_role = l_partner.
it_partner-partn_numb = l_kunnr.
APPEND it_partner.
CLEAR it_partner.
ENDAT.
*- Item data
it_item-itm_number = l_itemno.
*- Convert material number into internal format
CLEAR l_matnr.
l_matnr = it_data-matnr.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = l_matnr
IMPORTING
output = l_matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
it_item-material = l_matnr.
*- Call FM to get new qty based on SAP UOM
CLEAR: l_meins, l_qty, l_in_qty.
l_in_qty = it_data-qty.
CALL FUNCTION 'Z_GET_QTY_FROM_UOM'
EXPORTING
matnr = it_item-material
in_meins = it_data-uom
in_qty = l_in_qty
IMPORTING
out_meins = l_meins
quantity = l_qty.
IF sy-subrc = 0.
it_data-qty = l_qty.
it_data-uom = l_meins.
ENDIF.
it_data-qty = it_data-qty * 1000.
it_item-req_qty = it_data-qty.
it_item-sales_unit = it_data-uom.
it_item-req_date = it_data-date.
*- Pricing data
it_item-cond_type = it_data-kschl. "Pricing condition
CLEAR l_kbetr.
l_kbetr = it_data-kbetr / 10. "Price (Rate)
it_item-cond_value = l_kbetr.
APPEND it_item.
CLEAR it_item.
*- Increment Item counter.
l_itemno = l_itemno + 10.
*- At end of SalesOrder
AT END OF ppl_order.
READ TABLE it_data INDEX v_index.
*- Call the BAPI for SalesOrder creation
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT1'
EXPORTING
order_header_in = it_orderh
IMPORTING
salesdocument = order
sold_to_party = soldto
ship_to_party = shipto
return = return
TABLES
order_items_in = it_item
order_partners = it_partner.
IF sy-subrc = 0.
COMMIT WORK.
ENDIF.
v_return = return+0(1).
IF v_return = 'E'.
v_error = v_error + 1.
CLEAR l_mesg.
l_mesg = return.
CONDENSE l_mesg.
ELSE.
v_correct = v_correct + 1.
CLEAR l_mesg.
CONCATENATE 'Salesorder'(007) order 'successfully created.'(008)
INTO l_mesg SEPARATED BY space.
CONDENSE l_mesg.
ENDIF.
*- Populate the output table
CLEAR it_out.
it_out-ppl_order = it_data-ppl_order.
it_out-mesg = l_mesg.
APPEND it_out.
CLEAR it_out.
ENDAT.
ENDLOOP.
ENDFORM. " get_update
*& Form get_write
Write the results
FORM get_write .
WRITE:/ 'Total Number of Records :'(002), v_total COLOR 1.
WRITE:/ 'Total Correct Records :'(003), v_correct COLOR 3.
WRITE:/ 'Total Error Records :'(004), v_error COLOR 6.
SKIP 3.
IF NOT it_out[] IS INITIAL.
WRITE:/5 'ppl Order #'(005),
28 'Message'(006).
ENDIF.
SKIP 1.
LOOP AT it_out.
WRITE:/5 it_out-ppl_order,
28 it_out-mesg.
ENDLOOP.
ENDFORM. " get_write
*& Form validate_data
Validate the data
FORM validate_data .
DATA: l_bstkde TYPE bstkd_e.
LOOP AT it_file.
SELECT bstkd_e INTO l_bstkde
UP TO 1 ROWS
FROM vbkd
WHERE bstkd_e = it_file-ppl_order.
ENDSELECT.
IF sy-subrc = 0. " This ppl Order is already been created in SAP, so delete record
DELETE it_file.
ENDIF.
ENDLOOP.
SORT it_file BY ppl_order.
ENDFORM. " validate_data
*& Form data_swap
Prepare the data for processing
FORM data_swap .
CLEAR: it_werks, it_info, it_matnr, it_data,
it_werks[], it_info[], it_matnr[], it_data[].
IF NOT it_file[] IS INITIAL.
*- Get the plant from location
SELECT name2
werks
INTO CORRESPONDING FIELDS OF TABLE it_werks
FROM t001w FOR ALL ENTRIES IN it_file
WHERE name2 = it_file-loc.
IF sy-subrc = 0.
SORT it_werks BY name2 werks.
*- Get the Sales Org, Division and Distribution Channel
IF NOT it_werks[] IS INITIAL.
SELECT vkorg
vtweg
werks
INTO CORRESPONDING FIELDS OF TABLE it_info
FROM tvkwz FOR ALL ENTRIES IN it_werks
WHERE werks = it_werks-werks.
IF sy-subrc = 0.
LOOP AT it_info.
it_info-spart = '99'.
MODIFY it_info INDEX sy-tabix.
ENDLOOP.
SORT it_info BY vkorg vtweg werks.
ENDIF.
ENDIF.
ENDIF.
*- Get material from ppl material
SELECT ppl_prdid
matnr
FROM zppl_master
INTO TABLE it_matnr FOR ALL ENTRIES IN it_file
WHERE ppl_prdid = it_file-matnr.
IF sy-subrc = 0.
SORT it_matnr BY ppl_prdid matnr.
ENDIF.
ENDIF.
*- Update the data in it_data
LOOP AT it_file.
CLEAR it_data.
it_data-auart = 'OR'.
it_data-auart = 'OR'. " CHANGED BY Jo ON 3103005
READ TABLE it_werks WITH KEY name2 = it_file-loc BINARY SEARCH.
IF sy-subrc = 0.
READ TABLE it_info WITH KEY werks = it_werks-werks BINARY SEARCH.
IF sy-subrc = 0.
it_data-vkorg = it_info-vkorg.
it_data-vtweg = it_info-vtweg.
ENDIF.
ENDIF.
*- Material
READ TABLE it_matnr WITH KEY ppl_prdid = it_file-matnr BINARY SEARCH.
IF sy-subrc = 0.
it_data-matnr = it_matnr-matnr.
ENDIF.
it_data-ppl_order = it_file-ppl_order.
it_data-date = it_file-date.
CONCATENATE it_file-kunnr it_file-loc+1(2) INTO it_data-kunnr.
it_data-qty = it_file-qty.
it_data-uom = it_file-uom.
it_data-kbetr = it_file-kbetr.
*- Pricing condition
it_data-kschl = 'PR00'.
CASE it_file-div.
WHEN 'BRN'.
it_data-div = '04'.
WHEN 'GEN'.
it_data-div = '03'.
WHEN 'IVF'.
it_data-div = '02'.
WHEN 'OPH'.
it_data-div = '01'.
ENDCASE.
it_data-spart = it_data-div.
APPEND it_data.
CLEAR it_data.
ENDLOOP.
ENDFORM. " data_swap -
Using BAPI_SALESORDER_CREATEFROMDAT2
Hi! I would like to ask if anyone has sample code of a working call to the bapi BAPI_SALESORDER_CREATEFROMDAT2?
I've tried it and I've been able to create a sales order, however I have troubles with repeating items in Conditions.
Tried changing LOGIC_SWITCH-PRICING to all the values and somehow, still can't get the right price.
I'm running SAP ECC 6.0 (if it helps
Thanks!
Nevermind.
Found the answer at this thread:
BAPI_SALESORDER_CHANGE update conditions
He's right, it DOES work!
As posted by Ruong Tran:
Hi guys,
To update an existing pricing condition, you need to set the logic_switch field COND_HANDL = 'X'. This will not create a new entry but update the existing one, trust me, I've tried this and it works.
Ruong
Message was edited by: Alexandra CoHI Alexandra
You are right. Please check the below thread on the same topic.
Re: How to change pricing Conditions in Sales order in change sales order bapi
Kind Regards
Eswar
Maybe you are looking for
-
IPod touch generation 4 iMessage won't activate.
A day or so ago I tried to go into my iMessage and was greeted by a screen with a "Get Started" button on it as if I hadn't set up iMessage already. I promptly tapped the button and it asked me to enter my apple ID. (it already had my email addr
-
Send photos by e-mail from iPhoto.
I have problem to share by e-mail from iPhoto 11. I have fullly functional Mail on my macbook pro with 6th e-mail accounts. When i tryed to send some photos from iPhoto 11 i got message: Your email did not go through because the server did not reply.
-
Hey i'm missing the following drivers, and was hoping someone can point me in the right direction. PCI\VEN_197B&DEV_2382&SUBSYS_3637103C&REV_00 PCI\VEN_197B&DEV_2382&SUBSYS_3637103C PCI\VEN_197B&DEV_2382&CC_088000 PCI\VEN_197B&DEV_2382&CC_0880 PCI\VE
-
I have a 2009 MacBook running OSX Snow Leopard with the latest update. I wanted to upgrade to the new Mountain Lion but I got the message that my system couldn't run it. So now I'm wondering if I can upgrade to the Lion 10.7 OS but I can't find it
-
Jlist.setListData()
Hi everyone! I use a Jlist to display the contents of a vector,in which items are added and removed in run-time. I use the function: myList.setListData(myVector); but sometimes it works just fine, sometimes myList displays nothing and sometimes the l