Application Development 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: 

SD_SALESDOCUMENT_CREATE - Duplicate sales conditions

Former Member
0 Kudos

Hello,

I'm creating a sales document via SD_SALESDOCUMENT_CREATE but am geting duplicate condition items after the insert. The sales document gets assigned default conditions and during the creation I would like to override some of these values. I place the lines in "SALES_CONDITIONS_IN" but instead of these being edited, the result is duplicate lines with the same condition code but different values. There is a "COND_UPDAT" field but I'm not sure if this is what I'm after or what values to pass it.

Is this at all possible with SD_SALESDOCUMENT_CREATE or would I have to use SD_SALESDOCUMENT_CHANGE after the insert?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try with Cond_UPDAT = 'X'.

Cheers,

Sasi

14 REPLIES 14

Former Member
0 Kudos

Hi,

Try with Cond_UPDAT = 'X'.

Cheers,

Sasi

0 Kudos

Nope. "COND_UPDAT" doesn't seem to make any difference. Thanks anyway.

Former Member

You probably have to define how you want to update it by field UPDATEFLAG of structure SALES_CONDITIONS_INX (BAPICONDX)

0 Kudos

Max,

Please could you explain the use of the SALES_CONDITIONS_INX table and what type of data it is expecting?

Thanks

0 Kudos

Hi,

It will be similar to :

DATA: L_WA_BAPISCHDL TYPE BAPISCHDL,

L_WA_BAPISCHDLX TYPE BAPISCHDLX.

MOVE: FP_WA_ITEM-POSNR TO L_WA_BAPISCHDL-ITM_NUMBER,

FP_WA_ITEM-ETDAT TO L_WA_BAPISCHDL-REQ_DATE,

FP_WA_ITEM-PRGBZ TO L_WA_BAPISCHDL-DATE_TYPE,

FP_WA_ITEM-KWMENG TO L_WA_BAPISCHDL-REQ_QTY.

APPEND L_WA_BAPISCHDL TO FP_I_BAPISCHDL.

MOVE: FP_WA_ITEM-POSNR TO L_WA_BAPISCHDLX-ITM_NUMBER,

X TO L_WA_BAPISCHDLX-REQ_DATE,

X TO L_WA_BAPISCHDLX-REQ_QTY,

X TO L_WA_BAPISCHDLX-DATE_TYPE,

I TO L_WA_BAPISCHDLX-UPDATEFLAG.

APPEND L_WA_BAPISCHDLX TO FP_I_BAPISCHDLX.

  • Call Function Module to upload Sales Order

CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'

EXPORTING

SALES_HEADER_IN = L_WA_BAPISDHD1

SALES_HEADER_INX = L_WA_BAPISDHD1X

BUSINESS_OBJECT = L_V_OBJTYPE

TABLES

RETURN = L_I_RETURN[]

SALES_ITEMS_IN = L_I_BAPISDITM[]

SALES_ITEMS_INX = L_I_BAPISDITMX[]

SALES_PARTNERS = L_I_BAPIPARNR[]

SALES_SCHEDULES_IN = L_I_BAPISCHDL[]

SALES_SCHEDULES_INX = L_I_BAPISCHDLX[]

.

regards

Aveek

0 Kudos

You can use the structure SALE_CONDITIONS_INX to define how you want to update the conditions: it's an extension of SALE_CONDITIONS_IN.

So you have to fill it with the keys of SALE_CONDITIONS_IN (ITM_NUMBER, COND_ST_NO...) and then fill the several flags that define what you are doing.

For example flag UPDATEFLAG

= 'I' or space, if it creates a new condition,

= 'U', if it updates an existing condition

= 'D', if it deletes an existing condition,

flag COND_VALUE = 'X' if it updates the value of conditions and so...

In the pricing there are conditions which the system automatically loads, other are loaded by user. So It's probable that you want to change an automatic condition you have to fill SALE_CONDITIONS_INX-UPDATEFLAG with U.

0 Kudos

Max,

Thanks very much for the explaination. I have added a line in SALE_CONDITIONS_INX with the correct U flag but it doesn't seem to remove the original condition. Interesting to note is that if i don't put "COND_VALUE" = X I still get duplicate lines but both with the default price and not the on i am providing. I also tested the D flag for UPDATE_FLAG and this time I only get one condition but it is the default one. The condition details show that the condition is not active because there is a subsequent price but the end user says this is not acceptable and that there can only be one condition per condition type.

Any other ideas?

0 Kudos

So you are trying to load an automatic condition, the result is that system loads two condition: the old one is not active and new condition is active.

I think it's correct: it'd occurs that if you added a new condition by standard transaction.

So I think you should use the FM SD_SALESDOCUMENT_CHANGE to delete inactive condition.

0 Kudos

Go to SPRO, follow the path


Implementation Guide for R/3 Customizing (IMG)
   --> Sales and Distribution
         --> Basic Functions
              --> Pricing
                   --> Pricing Control
                        --> Define Condition Types
                             --> Maintain Condition Types

In here, select the condition type you are interested in and see its settings. In the screen for 'Change condition type', there is a section 'Changes which can be made'. The value for 'Manual Entries', should be set to 'C'(manual entry has priority). Otherwise, you will see the same results as you see now.

Hope this helps,

Srinivas

0 Kudos

If answered, please reward and close the post. If not please let us know.

Regards,

Srinivas

0 Kudos

Srinivas,

Thanks for the information but this is a client's system and we do not have access to change these settings.

Former Member
0 Kudos

Hi,

I m also facing same problem ,

Please guide.

Hi,

I've also encountered problems where the condition I am using is not changing the condition value but adding a second entry. I therefore end up with one being the value I have created and another entry with the original pricing.

I found that changing LOGIC_SWITCH-COND_HANDL = 'X' corrected the issue.

Cheers

jayakumarkb_81
Participant
0 Kudos

Tony , you answer worked for me.