Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem with BAPI_SALESORDER_CREATEFROMDAT2

Former Member
0 Likes
5,069

Hi All,

I am creating sales order through BAPI_SALESORDER_CREATEFROMDAT2.Everything is working fine except pricing conditions.We maintain our item price through ZDAH condition.While creating order through VA01 this condition comes automatically and we put the price.Through bapi,I am

passing price through ORDER_CONDITIONS_IN table.But what is happening is that system is creating two rows in pricing procedure with ZDAH condition type.First does not have any value,and second has the value that i have passed.But that is not acceptable.We need only one row with ZDAH condition.

Please let me know how to do that.

10 REPLIES 10
Read only

Former Member
0 Likes
2,415

I experienced the same behavior.

In your conditions table, you need to set the condition step number (-cond_st_no) and the counter (-cond_count) to match that of the pricing procedure where ZDAH is found. You will need to do this in the 'X' condition table as well. The counter in my case is '01', but I don't know if this holds true in every instance.

This causes the ZDAH condition you pass in the BAPI to overwrite any automatically determined pricing that would have normally occurred in VA01.

Please note, you are then over-riding the value that would have been determined in VA01. Whatever you pass to the BAPI is accepted as the value for ZDAH.

Hope this helps,

Mark

Read only

0 Likes
2,415

Hi,

I have different condition (ZPRS), but the same behaviour here. Following Mark's suggestions, I found and filled step number (11 in my case) and counter (01), and it still doesn't works - means I have 2 conditions of type ZPRS created per item in final document. Checking the analysis for pricing, It seems the system first got my condition entered manualy, and just after that found the same condition without any condition value. Here is a sniip from the analysis:

Overview

Condition type Message Description

ZCOV 001 Manual condition

ZPRS 201 Condition entered manually

ZPRS 207 Condition has been found (without condition record)

So for me cond_count = '01' seems to have no effect. In the table KONV I have the following:

KNUMV KPOSN STUNR ZAEHK KAPPL KSCHL KBETR

0000000647 1 11 1 V ZPRS 0.00

0000000647 1 11 2 V ZPRS 14.40

I know there is UPDATEFLAG in the BAPICONDX structure but without any description what are possible field values. There is also COND_UPDAT ('X' or ' ') in BAPICOND. I've played quite a lot with different values without any success.

Have you (or anybody else) fased similar problem and can help me with this?

Thanks in advance.

Regards,

Ivaylo Mutafchiev

Read only

0 Likes
2,415

Hi,

In my early post I didn't mention it - but I do set the UPDATEFLAG to 'U' for the CONDX table. This update flag is also seen as the UPDKZ field, I have used it in the sales order user exit. The allowed values are initial, "I" = insert, "D" = delete and "U" = update.

So, if you set this field to a "U", it will update the found value, rather than inserting a new value.

Hope this helps,

Regards,

Mark

Read only

0 Likes
2,415

Mark,

thanks for a quick reply. As I mention in my previous post I played with this values without success. Now after your suggestion I tryed to set UPDATEFLAG = 'U' again and sadly it still won't work.

Ok, let me clarify the situation once again:

I have ZPRS condition which I pass through BAPI at item level and I set these values:

bapicond-itm_number = bapicondx-itm_number = 10. "(for example)

bapicond-cond_st_no = bapicondx-cond_st_no = '011'. "as found from pricing procedure

bapicond-cond_count = bapicondx-cond_count = '01'. "after investigation in KONV table

bapicond-cond_type = 'ZPRS'. bapicondx-cond_type = 'X'.

bapicond-cond_value = some_value. bapicondx-cond_value = 'X'.

bapicond-stat_con = 'X'. "also as from pricing procedure, even without this the system creates my condition in a same way

bapicondx-updateflag = 'U'.

APPEND: bapicond, bapicondx.

Well, in a matther of fact my internal tables are named in different way, I changed their names here for clarity.

As a result from this snip of code I have 2 ZPRS conditions - one in red without condition value and with ZAEHK = 1 (condition counter field in KONV), and next one in green with my condition value, and ZAEHK = 2.

What I did further was to try to pass my condition twise - once with updateflag = 'D' and second time with update flag = 'I' (such an approach worked fine in case of creation of purchase order conditions), but here in this case it creates 3 ZPRS conditions - 2 in red and 1 i green. Tryied several different variants again without success.

It seems I would have to swim down into the FM code via debugger.

Any ideas what am I doing wrong?

Thanks agan,

Ivaylo

Read only

0 Likes
2,415

Dear Ivaylo,

I tried to create a sales order using bapi . Here there is a problem with condition type. When iam passing some values to the condition table and it is presenting in pricing tables. Here i am facing the same problem like duplicate entries. I have seen your thread having the same problem . Please share your ideas with me in this . Here i am keeping my code.

***DISCOUNT conditions

wa_order_cond-ITM_NUMBER = '000010'.

wa_order_cond-COND_TYPE = 'ZJCD'.

"wa_order_cond-COND_VALUE = 5.

WA_ORDER_COND-cond_st_no = '20'.

WA_ORDER_COND-COND_VALUE = '3'.

"WA_ORDER_COND-cond_COUNT = '0'.

"wa_order_cond-currency = 'INR'.

"wa_order_cond-cond_updat = 'U'.

insert wa_order_cond into table tab_order_cond.

*****************************************************

wa_order_condINX-ITM_NUMBER = '000010'.

wa_order_condINX-COND_TYPE = 'ZJCD'.

"wa_order_cond-COND_VALUE = 5.

WA_ORDER_CONDINX-cond_st_no = '20'.

WA_ORDER_CONDINX-COND_VALUE = '3'.

WA_ORDER_CONDINX-cond_COUNT = '0'.

wa_order_condINX-updatEFLAG = 'U'.

WA_ORDER_COND-stat_con = 'X'.

Insert wa_order_condINX into table tab_order_condINX.

After executing this it is showing two condition of same name .

1) ZJCD Customer Discount % 0.00 INR 0 0 0.00

2) ZJCD Customer Discount 0.300- % 50,340.00- INR 0 0 0.00

Here both of them have same names. One is duplicate and othe one is correct . I need only one of them which is having the values. I hope i will get a good solution from our sdn.

Regards,

Madhu.

Read only

Former Member
0 Likes
2,415

Checking over your code, the X-table value for condition type is the actual condition type, not 'X'.

So, bapicond-cond_type = bapicondx-cond_type = 'ZPRS'.

In the past, I have not used the -stat_con field, so I am not aware of it's effect.

Try the above fix and see if that works.

Regards,

Mark

Read only

0 Likes
2,415

That's it!

Thanks a lot.

Hmm, I can't see how can I give to your answer any value.... It seems if I'm not an owner of the thread it is impossible.

Thanks again!

Ivaylo

Read only

0 Likes
2,415

Hi All,

I have a problem whit BAPI_SALESORDER_CREATEFROMDAT2 when I try to use pricing conditions with two values on the same sales item.

Iu2019m tried to pass these values:

bapicond-itm_number = bapicondx-itm_number = 10. "(for example)

bapicond-cond_st_no = bapicondx-cond_st_no = '017'. "as found from pricing procedure

bapicond-cond_count = bapicondx-cond_count = '0'. "after investigation in KONV table

bapicond-cond_type = bapicondx-cond_type = 'ZDES'.

bapicond-cond_value = some_value. bapicondx-cond_value = 'X'.

bapicondx-updateflag = 'U'.

APPEND: bapicond, bapicondx.

And

bapicond-itm_number = bapicondx-itm_number = 10. "(for example)

bapicond-cond_st_no = bapicondx-cond_st_no = '021'. "as found from pricing procedure

bapicond-cond_count = bapicondx-cond_count = '0'. "after investigation in KONV table

bapicond-cond_type = bapicondx-cond_type = 'ZMER'.

bapicond-cond_value = some_value. bapicondx-cond_value = 'X'.

bapicondx-updateflag = 'U'.

APPEND: bapicond, bapicondx.

But only the first item has successfullyu2026

Any ideas what am I doing wrong?

Thanks,

Alesandro

Read only

0 Likes
2,415

Hi All,

I have a problem whit BAPI_SALESORDER_CREATEFROMDAT2 when I try to use pricing conditions with two values on the same sales item.

Iu2019m tried to pass these values:

bapicond-itm_number = bapicondx-itm_number = 10. "(for example)

bapicond-cond_st_no = bapicondx-cond_st_no = '017'. "as found from pricing procedure

bapicond-cond_count = bapicondx-cond_count = '0'. "after investigation in KONV table

bapicond-cond_type = bapicondx-cond_type = 'ZDES'.

bapicond-cond_value = some_value. bapicondx-cond_value = 'X'.

bapicondx-updateflag = 'U'.

APPEND: bapicond, bapicondx.

And

bapicond-itm_number = bapicondx-itm_number = 10. "(for example)

bapicond-cond_st_no = bapicondx-cond_st_no = '021'. "as found from pricing procedure

bapicond-cond_count = bapicondx-cond_count = '0'. "after investigation in KONV table

bapicond-cond_type = bapicondx-cond_type = 'ZMER'.

bapicond-cond_value = some_value. bapicondx-cond_value = 'X'.

bapicondx-updateflag = 'U'.

APPEND: bapicond, bapicondx.

But only the first item has successfullyu2026

Any ideas what am I doing wrong?

Thanks,

Alesandro

Read only

Former Member
0 Likes
2,415

HI Vivek and Mark,

I am experiencing the same situation right now.

Please let me know the solution for the same.

Thanks,

Suhas.