# BAPI_QUOTATION_CREATEFROMDATA2 — Create Customer Quotation

> Creates a customer quotation with header, item, partner, schedule line and condition data, like VA21. It is used by CRM, CPQ or web tools that send quotations into SAP. Fill the X structures for the fields you pass, use TESTRUN to validate, and call BAPI_TRANSACTION_COMMIT afterwards only when RETURN contains no message of type E or A.

- Modules: SD
- Type: BAPI
- Function group: 2031
- Remote-enabled (RFC): Yes
- S/4HANA status: Used the same way in S/4HANA
- URL: https://nekuhub.com/en/functions/bapi-quotation-createfromdata2/

## Importing parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| SALESDOCUMENTIN | BAPIVBELN-VBELN | External sales document number | - |
| QUOTATION_HEADER_IN | BAPISDHD1 | Quotation header data | Yes |
| QUOTATION_HEADER_INX | BAPISDHD1X | Quotation header change flags (X structure) | - |
| SENDER | BAPI_SENDER | Logical sender system (ALE) | - |
| BEHAVE_WHEN_ERROR | BAPIFLAG-BAPIFLAG | Error handling behavior | - |
| TESTRUN | BAPIFLAG-BAPIFLAG | Test run (no update) | - |
| CONVERT | BAPIFLAG-BAPIFLAG | Convert partner roles and document types to internal format | - |
| LOGIC_SWITCH | BAPISDLS | SD logic switch (pricing, ATP control) | - |

## Exporting parameters

| Parameter | Type | Description |
|---|---|---|
| SALESDOCUMENT | BAPIVBELN-VBELN | Quotation number created |

## Tables parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| RETURN | BAPIRET2 | Return messages | - |
| QUOTATION_ITEMS_IN | BAPISDITM | Quotation item data | - |
| QUOTATION_ITEMS_INX | BAPISDITMX | Quotation item change flags (X structure) | - |
| QUOTATION_PARTNERS | BAPIPARNR | Quotation partners | Yes |
| QUOTATION_SCHEDULES_IN | BAPISCHDL | Schedule lines | - |
| QUOTATION_SCHEDULES_INX | BAPISCHDLX | Schedule line change flags (X structure) | - |
| QUOTATION_CONDITIONS_IN | BAPICOND | Pricing conditions | - |
| QUOTATION_CONDITIONS_INX | BAPICONDX | Condition change flags (X structure) | - |
| QUOTATION_TEXT | BAPISDTEXT | Texts | - |
| QUOTATION_KEYS | BAPISDKEY | Reference keys of created objects | - |
| PARTNERADDRESSES | BAPIADDR1 | Partner addresses | - |
| EXTENSIONIN | BAPIPAREX | Customer enhancement fields (EXTENSIONIN) | - |

## Call template (ABAP)

```abap
CALL FUNCTION 'BAPI_QUOTATION_CREATEFROMDATA2'
  EXPORTING
    quotation_header_in = lv_quotation_header_in
  IMPORTING
    salesdocument = lv_salesdocument
  TABLES
    return = lt_return
    quotation_items_in = lt_quotation_items_in
    quotation_items_inx = lt_quotation_items_inx
    quotation_partners = lt_quotation_partners
    quotation_schedules_in = lt_quotation_schedules_in
    quotation_schedules_inx = lt_quotation_schedules_inx
    quotation_conditions_in = lt_quotation_conditions_in
    quotation_conditions_inx = lt_quotation_conditions_inx
    quotation_text = lt_quotation_text
    quotation_keys = lt_quotation_keys.
```

## Related tables

VBAK, VBAP, VBEP, VBPA

