# BAPI_SAG_CHANGE — Change Scheduling Agreement

> Changes the header, items, account assignments, conditions, partners, texts and subcontracting components of a scheduling agreement (ME32L). Developers use it in programs that update agreement prices or item data in bulk from external systems. Fill the matching …X structure (HEADERX, ITEMX, ITEM_CONDITIONX and so on) with 'X' for every field you change, try it first with TESTRUN and call BAPI_TRANSACTION_COMMIT when RETURN has no errors; delivery schedule lines are maintained separately, not through this BAPI.

- Modules: MM
- Type: BAPI
- Function group: 2013
- Remote-enabled (RFC): Yes
- S/4HANA status: Used the same way in S/4HANA
- URL: https://nekuhub.com/en/functions/bapi-sag-change/

## Importing parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| PURCHASINGDOCUMENT | BAPIMEOUTHEADER-NUMBER | Scheduling agreement number | Yes |
| HEADER | BAPIMEOUTHEADER | Header data | - |
| HEADERX | BAPIMEOUTHEADERX | Header data change flags | - |
| VENDOR_ADDRESS | BAPIMEOUTADDRVENDOR | Vendor address | - |
| HEAD_EXPORT_IMPORT | BAPIMEOUTEIKP | Header foreign trade data | - |
| HEAD_EXPORT_IMPORTX | BAPIMEOUTEIKPX | Header foreign trade data change flags | - |
| TESTRUN | BAPIFLAG-BAPIFLAG | Test run (no update) | - |
| TECHNICAL_DATA | BAPIMEOUTTECH | Technical control data | - |

## Exporting parameters

| Parameter | Type | Description |
|---|---|---|
| EXP_HEADER | BAPIMEOUTHEADER | Resulting header data |
| EXP_HEAD_EXPORT_IMPORT | BAPIMEOUTEIKP | Resulting header foreign trade data |

## Tables parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| ITEM | BAPIMEOUTITEM | Item data | - |
| ITEMX | BAPIMEOUTITEMX | Item data change flags | - |
| ACCOUNT | BAPIMEOUTACCOUNT | Account assignments | - |
| ACCOUNTX | BAPIMEOUTACCOUNTX | Account assignment change flags | - |
| HEAD_CONDITION | BAPIMEOUTHEADERCOND | Header conditions | - |
| HEAD_CONDITIONX | BAPIMEOUTHEADERCONDX | Header condition change flags | - |
| ITEM_COND_VALIDITY | BAPIMEOUTVALIDITY | Item condition validity periods | - |
| ITEM_COND_VALIDITYX | BAPIMEOUTVALIDITYX | Validity period change flags | - |
| ITEM_CONDITION | BAPIMEOUTCONDITION | Item conditions | - |
| ITEM_CONDITIONX | BAPIMEOUTCONDITIONX | Item condition change flags | - |
| ITEM_COND_SCALE_QUAN | BAPIMEOUTITEMSCALEQUAN | Item condition quantity scales | - |
| PARTNER | BAPIMEOUTPARTNER | Partners | - |
| PARTNERX | BAPIMEOUTPARTNERX | Partner change flags | - |
| SC_COMPONENT | BAPIMEOUTCOMPONENT | Subcontracting components | - |
| SC_COMPONENTX | BAPIMEOUTCOMPONENTX | Subcontracting component change flags | - |
| HEADER_TEXT | BAPIMEOUTTEXT | Header texts | - |
| ITEM_TEXT | BAPIMEOUTITEMTEXT | Item texts | - |
| EXTENSIONIN | BAPIPAREX | Customer extension fields (input) | - |
| RETURN | BAPIRET2 | Return messages | - |

## Call template (ABAP)

```abap
CALL FUNCTION 'BAPI_SAG_CHANGE'
  EXPORTING
    purchasingdocument = lv_purchasingdocument
  IMPORTING
    exp_header = lv_exp_header
    exp_head_export_import = lv_exp_head_export_import
  TABLES
    item = lt_item
    itemx = lt_itemx
    account = lt_account
    accountx = lt_accountx
    head_condition = lt_head_condition
    head_conditionx = lt_head_conditionx
    item_cond_validity = lt_item_cond_validity
    item_cond_validityx = lt_item_cond_validityx
    item_condition = lt_item_condition
    item_conditionx = lt_item_conditionx.
```

## Related tables

EKKN, EKKO, EKPO, KONP

