cancel
Showing results for 
Search instead for 
Did you mean: 

Creating quotes with Bapi_Quotation_Createfromdata2

Former Member
0 Kudos

Hi,

I'm trying to call Bapi_Quotation_Createfromdata2 to create a quote. I can easily create a quote through SAPGUI using VA21.

This bapi has plenty of properties to set.

1) Has anyone used this BAPI to create quotes? If so, can someone post the absolute minimum properties that need to be set to successfully create a quote.

2) Do i need to fill out all properties/tables when calling this bapi or can i just submit with basic information and SAP will infer the rest of the information (like the SAPGUI does)?

3) No matter how much information i send to SAP when calling this BAPI, i always seem to be getting the error "Sales document type is not defined". Does anyone have a mapping of the attributes to named fields from the SAPGUI? What does this error mean and which property's value am i not sending in properly?

Any help appreciated.

H

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Ok, so i managed to create quotes via the bapi listed above just fine from .NET v2.0 (and from the previous version for that matter). New question. How do i get the quote out of SAP? I can't find any BAPIs to do that....like pass in the sales document number and receive all details about the quote. Any help appreciated.

Thx.

Former Member
0 Kudos

I solved this. The BAPI to call is BAPI_SALESORDER_GETSTATUS.

H

Former Member
0 Kudos

Hi Hithesh,

I use the BAPI from a bsp in the following way.

Maybe you can leave somedata away, but this worked for us. It's been done in 1 hour so it doesn't receive a tidyness award )

Oh loc_bp should be a valid businesspartner but you probably will figure that one out. Material in our case is a string from a bsp, but just enter a valid material number there.

Good luck.

Data: loc_bp type BAPIBUS1006_HEAD-BPARTNER.

data: re_return like BAPIRET2 occurs 0.

data: wa_return type BAPIRET2.

data: re_order_header_in like BAPISDHD1.

data: wa_BAPISDH1X type BAPISDH1X.

data: order_partners like BAPIPARNR occurs 0 with header line.

data: order_items_in like BAPISDITM occurs 0 with header line.

data: order_items_sched LIKE bapischdl OCCURS 0 WITH HEADER LINE.

data: g_vbeln like smovbak-vbeln,

l_vbeln like smovbak-vbeln.

move BUSINESSPARTNER to loc_bp.

*delete line if middleware active.

*loc_bp = '0030000309'.

re_order_header_in-DOC_TYPE = 'TA'.

re_order_header_in-SALES_ORG = 'NL01'.

re_order_header_in-DISTR_CHAN = '02'.

re_order_header_in-DIVISION = '01'.

order_partners-partn_role = 'AG'.

order_partners-partn_numb = loc_bp.

append order_partners.

order_partners-partn_role = 'WE'.

order_partners-partn_numb = loc_bp.

append order_partners.

order_items_in-itm_number = '000010'.

order_items_in-MATERIAL = MATERIAL.

order_items_sched-itm_number = '00010'.

order_items_sched-req_qty = '1'.

append order_items_sched.

append order_items_in.

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

DESTINATION 'zorder'

EXPORTING

ORDER_HEADER_IN = re_order_header_in

TESTRUN = ' '

importing

salesdocument = g_vbeln

TABLES

RETURN = re_return

ORDER_ITEMS_IN = order_items_in

ORDER_PARTNERS = order_partners

order_schedules_in = order_items_sched.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

DESTINATION 'zorder'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = wa_return.