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 FM: BAPI_SALESDOCU_CREATEWITHDIA

Former Member
0 Likes
2,252

Hi,

i will use the FM: BAPI_SALESDOCU_CREATEWITHDIA

and i try it with this Code:


* Daten für BAPISDORDER_GETDETAILEDLIST
DATA: SALES_HEADER_IN   TYPE           BAPISDHEAD1.
DATA: IT_RETURN         TYPE TABLE OF  BAPIRET2.
DATA: WA_RETURN         TYPE           BAPIRET2.
DATA: IT_SALES_PARTNERS TYPE TABLE OF  BAPIPARTNR.
DATA: WA_SALES_PARTNERS TYPE           BAPIPARTNR.
DATA: IT_SALES_ITEMS_IN TYPE TABLE OF  BAPISDITEM.
DATA: WA_SALES_ITEMS_IN TYPE           BAPISDITEM.
*
************************************************************************
*
SALES_HEADER_IN-SALES_ORG     = '1000'.
SALES_HEADER_IN-DOC_TYPE      = 'XX'.
SALES_HEADER_IN-DISTR_CHAN    = 'XX'.
SALES_HEADER_IN-DIVISION      = 'XX'.
SALES_HEADER_IN-PURCH_NO_C    = 'TEST via BAPI'.
SALES_HEADER_IN-REQ_DATE_H    = SY-DATUM.
*
*Partners
WA_SALES_PARTNERS-PARTN_ROLE = 'AU'.
WA_SALES_PARTNERS-PARTN_NUMB = '0000004711'.
APPEND WA_SALES_PARTNERS TO IT_SALES_PARTNERS.
WA_SALES_PARTNERS-PARTN_ROLE = 'RE'.
APPEND WA_SALES_PARTNERS TO IT_SALES_PARTNERS.
WA_SALES_PARTNERS-PARTN_ROLE = 'RG'.
APPEND WA_SALES_PARTNERS TO IT_SALES_PARTNERS.
WA_SALES_PARTNERS-PARTN_ROLE = 'WE'.
APPEND WA_SALES_PARTNERS TO IT_SALES_PARTNERS.
*Positionen
WA_SALES_ITEMS_IN-MATERIAL   = '000000000000004711'.
WA_SALES_ITEMS_IN-TARGET_QTY = 100.
WA_SALES_ITEMS_IN-TARGET_QU  = 'ST'.
APPEND WA_SALES_ITEMS_IN TO IT_SALES_ITEMS_IN.
WA_SALES_ITEMS_IN-MATERIAL   = '000000000000004712'.
APPEND WA_SALES_ITEMS_IN TO IT_SALES_ITEMS_IN.
*
CALL FUNCTION 'BAPI_SALESDOCU_CREATEWITHDIA'
  EXPORTING
    SALES_HEADER_IN = SALES_HEADER_IN
  TABLES
    RETURN          = IT_RETURN
    SALES_ITEMS_IN  = IT_SALES_ITEMS_IN
    SALES_PARTNERS  = IT_SALES_PARTNERS.

All is OK but the field TARGET_QTY will not be filled (it's empty). Has sanyone an idea wich error i do?

Isn't it the right field?

thanks.

regards, Dieter

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,952

hi Dieter

after the 'BAPI_SALESDOCU_CREATEWITHDIA' you must call the BAPI_TRANSCTION_COMMIT...

for update the quantity if with target quantity not work you must use schedline sructure and it will work..

best regards

Marco

hi Dieter

after the 'BAPI_SALESDOCU_CREATEWITHDIA' you must call the BAPI_TRANSCTION_COMMIT...

for update the quantity if with target quantity not work you must use schedline sructure and it will work..

best regards

Marco

14 REPLIES 14
Read only

Former Member
0 Likes
1,952

Hi,

Fill the data in the structures "SALES_SCHEDULES_IN" & "SALES_SCHEDULES_INX".

Total quantity filled in structure "SALES_SCHEDULES_IN-REQ_QTY" will be updated as item level order quantity or corresponding line item.

Regards

Vinod

Edited by: Vinod Kumar on May 25, 2010 3:10 PM

Read only

0 Likes
1,952

Hi,

thanks for your answer. This problem is solved, but i get another one.

I fill also the codition table. The problem is, that a automatic condition has now 2 value (lines).

First from the Kondition which we have inserted via VK11. second the contition we put in

the FM BAPI_SALESDOCU_CREATEWITHDIA.

How can i avoid two conditons, or can i set any flag for updating or a flag for manuell not automatic?

Thanks.

Regards, Dieter

Read only

0 Likes
1,952

Hi Dieter

with a similar steps for add conditions with the FM BAPI_SALESDOCU_CREATEWITHDIA. you can also delete conditions.

so before update a new condition you can delete the condition that you not want.

regards

Marco

Read only

0 Likes
1,952

Hi,

how can i delete the conditions?

i insert the conditions like this:


*Konditionen
WA_SALES_CONDITIONS_IN-ITM_NUMBER = '000010'.
WA_SALES_CONDITIONS_IN-COND_TYPE  = 'PR00'.
WA_SALES_CONDITIONS_IN-COND_VALUE = 100.
WA_SALES_CONDITIONS_IN-CURRENCY   = 'EUR'.
WA_SALES_CONDITIONS_IN-COND_UNIT  = 'ST'.
WA_SALES_CONDITIONS_IN-COND_P_UNT = 1.
APPEND WA_SALES_CONDITIONS_IN TO IT_SALES_CONDITIONS_IN.
*
CALL FUNCTION 'BAPI_SALESDOCU_CREATEWITHDIA'
  EXPORTING
    SALES_HEADER_IN     = SALES_HEADER_IN
  TABLES
    RETURN              = IT_RETURN
    SALES_ITEMS_IN      = IT_SALES_ITEMS_IN
    SALES_SCHEDULES_IN  = IT_SALES_SCHEDULES_IN
    SALES_PARTNERS      = IT_SALES_PARTNERS
    SALES_CONDITIONS_IN = IT_SALES_CONDITIONS_IN.

Regards, Dieter

Read only

0 Likes
1,952

sorry i said you a wrong thing....you cannot delete condition with this..but with order_maintain......

altought you can set the condition like a manual condition with this field

WA_SALES_CONDITIONS_IN-CONDCHAMAN.

regards

Marco

Read only

0 Likes
1,952

Hi,

i have set: WA_SALES_CONDITIONS_IN-CONDCHAMAN ='X'.

but now result, 2 conditionslines for PR00 again.

Regards, Dieter

Read only

0 Likes
1,952

Hi..

if you are in CRM you can delete the condition with FM CRM_ORDER_MAINTAIN.

best regards

marco

Read only

0 Likes
1,952

Hi,

no, we don't have CRM.

Regards, Dieter

Read only

0 Likes
1,952

Fill the structure SALES_CONDITIONS_INX. pass 'D' in the structure field SALES_CONDITIONS_INX-UPDATEFLAG to delete specific record. I have not tested this scenario with this BAPI. But definitely this works with the BAPI "BAPI_SALESORDER_CREATEFROMDAT2".

Regards

Vinod

Read only

0 Likes
1,952

Hi,

thanks for your answer. I have test it like this:


*Konditionen
WA_SALES_CONDITIONS_IN-ITM_NUMBER  = '000010'.
WA_SALES_CONDITIONS_IN-COND_TYPE   = 'PR00'.
WA_SALES_CONDITIONS_IN-COND_VALUE  = 100.
WA_SALES_CONDITIONS_IN-CURRENCY    = 'EUR'.
WA_SALES_CONDITIONS_IN-COND_UNIT   = 'ST'.
WA_SALES_CONDITIONS_IN-COND_P_UNT  = 1.
APPEND WA_SALES_CONDITIONS_IN TO IT_SALES_CONDITIONS_IN.
*
WA_SALES_CONDITIONS_INX-ITM_NUMBER = '000010'.
WA_SALES_CONDITIONS_INX-COND_TYPE  = 'PR00'.
WA_SALES_CONDITIONS_INX-UPDATEFLAG = 'D'.
APPEND WA_SALES_CONDITIONS_INX TO IT_SALES_CONDITIONS_INX.
*
CALL FUNCTION 'BAPI_SALESDOCU_CREATEWITHDIA'
  EXPORTING
    SALES_HEADER_IN      = SALES_HEADER_IN
  TABLES
    RETURN               = IT_RETURN
    SALES_ITEMS_IN       = IT_SALES_ITEMS_IN
    SALES_SCHEDULES_IN   = IT_SALES_SCHEDULES_IN
    SALES_PARTNERS       = IT_SALES_PARTNERS
    SALES_CONDITIONS_IN  = IT_SALES_CONDITIONS_IN
    SALES_CONDITIONS_INX = IT_SALES_CONDITIONS_INX.

Unfortunately it deletes the condition wich i want to insert, not the automatic from VK11.

Regards, Dieter

Read only

0 Likes
1,952

Hi,

As far as I know, the bapi which you are using doesn't have to parameter to control the Pricing. The parameter LOGIC_SWITCH in BAPI "BAPI_SALESORDER_CREATEFROMDAT2" is used to control the pricing.

Regards

Vinod

Read only

0 Likes
1,952

Hi,

thanks.

Now i use BAPI_SALESORDER_CREATEFROMDAT2 and BAPI_TRANSACTION_COMMIT.

After this i make CALL TRANSACTION 'VA02' AND SKIP FIRST SCREEN.

to go to the created salesorder.

Every think is OK.

Now i will insert text too and use parameter ORDER_TEXT.

position text are filled correct.

Header text are filled partly correct. One text which will normaly autmaticly included will

not set correct. Do you know any parameter to set automatic include off?

The incuded text has some formatted lines. Can this be the reason.

Other normaly included text with no formatting can be inserted correct!

Regards, Dieter

Read only

0 Likes
1,952

Hi,

solved.

In BAPI_SALESORDER_CREATEFROMDAT2 i don't use ORDER_TEXT.

I use FM: CSO_SD_SALES_TEXTS_SAVE to set text. It works like i need.

Thanks to all.

Regards, Dieter

Read only

Former Member
0 Likes
1,953

hi Dieter

after the 'BAPI_SALESDOCU_CREATEWITHDIA' you must call the BAPI_TRANSCTION_COMMIT...

for update the quantity if with target quantity not work you must use schedline sructure and it will work..

best regards

Marco