Page tree
Skip to end of metadata
Go to start of metadata

Purpose

This page is created to clarify how the outline agreement BAPIs (BAPI_CONTRACT_CREATE, BAPI_CONTRACT_CHANGE, BAPI_SAG_CREATE, BAPI_SAG_CHANGE) works.

Overview

This page mainly focuses on outline agreements and requires basic BAPI knowledge. If you would like to first get familiar with BAPIs in general, refer to Wiki page Purchasing BAPIs.

The guide includes the following parts:

  1. basic troubleshooting steps,
  2. explaining how to handle net price and conditions,
  3. clarifying the main coding logic of BAPI.

Recommendation to start analysis / debugging

Error is raised by BAPI

In case an error is raised by the BAPI, execute the BAPI in debugging mode and set a breakpoint on the message class and number.

You can find the overview of the BAPI application logic in Section Outline Agreements BAPIs coding logic overview below.

Value is not updating correctly by BAPI execution

If a value is not correctly updated after BAPI execution, verify the corresponding BAPI parameter and X structure. If the parameters are correct, find the relevant Rule for the field that is not updating correctly using the steps below:

  1. Execute transaction SE80.
  2. Display Function Group MEOUT.
  3. Expand Classes.
  4. Find the field, which isn't updated correctly (for example for Unit of Measure (EKPO-MEINS), the relevant Rule is LCL_R_MEINS).
  5. Expand the found class.
  6. Expand Method Implementations.
  7. Double-click IS_VALID.
  8. Set a breakpoint and execute BAPI to debug how the value is determined or changed.

You can find the overview of the BAPI application logic in Section Outline Agreements BAPIs coding logic overview below.

Pricing, Condition related errors

If the price / condition is not updated correctly or you receive a condition error, verify the BAPI parmeters based on Section Handling net price and conditions while using BAPI below.

If the parameters are correct, you can debug the relevant logic based on the following Debugging Guides:

Handling net price and conditions while using BAPI

When creating contract or scheduling agreement with BAPI, there are two options to add net price and condition:

By filling parameter ITEM-NET_PRICE and ITEMX-NET_PRICE

If Info Record condition exists, system will overwrite the added price with the price found in Info Record. To avoid this happening, use the update the price by filling condition parameters (second option).
If no Info Record condition exists, system will generate a condition using the Net Price automatically with default condition type and validity period starting from the Contract validity start date and ending at 31.12.9999. The condition type is determined using the Pricing Procedure with FM ME_GET_CONDITION_TO_SEARCH. If the procedure is configured to have more than one gross condition type, system won't be able to determine a unique condition type, so an error will occur. To avoid it, it is necessary to change the procedure or implement BAdI MEOUT_BAPI_CUST Method DETERMINE_GROSS_COND_TYPE to determine a unique condition type using your own logic.

By filling ITEM_CONDITION, ITEM_COND_VALIDITY and their X structure.

This option is useful, when you would like to add different condition type from default, different validity periods or avoid price determination from Info Record.

When you change the contract with BAPI, you can only use the second option. It is not possible to change the price by filling ITEM-NET_PRICE only.

Points to consider when using condition BAPI parameters

In case you use condition parameters to create or change conditions, the minimum required fields to fill are:

ITEM_COND_VALIDITY:

  • ITEM_NO: item number
  • SERIAL_ID: any number (it is used to connect validity periods to the proper conditions in ITEM_CONDITION parameter)
  • VALID_FROM: start of validity period for condition
  • VALID_TO: end of validity period for condition

Plant is only necessary to fill, if you would like to create plant-dependent conditions.

ITEM_CONDITION:

  • ITEM_NO: item number
  • SERIAL_ID: use the SERIAL_ID that you filled for the desired validity period
  • COND_COUNT: starting from 01, incrementing +1 for each line for the same SERIAL_ID
  • COND_TYPE: condition type (e.g.: PB00)
  • COND_VALUE: condition amount
  • CURRENCY: condition currency
  • COND_UNIT: condition unit

Additional points to consider for filling parameter ITEM_COND_VALIDITY in case multiple periods are filled:

  • fill the periods sorted (from first to last period based on validity date),
  • do not fill overlapping periods,
  • in case you would like to split an already existing period into smaller periods, do not send the last period in the same BAPI call (system creates it automatically), but change it in an additional BAPI call, if different price is expected for last period.

Outline Agreements BAPIs coding logic overview

When you display one of the BAPIs in SE37, you can find the following PROCESS call, which triggers the relevant changes in the system.

In PROCESS method, the most important parts are the followings:

  • FM MEOUTBADI_BAPI: BADI call MEOUT_BAPI_CUST - Method INBOUND to overwrite the BAPI parameter values.
  • Method PROCESS

    In this method, the following parts are the most relevant:
    • Include L2014I02 Method IF_BAPI_MEOUT~MAP2I: mapping header data.
    • Include L2014I03 Method IF_BAPI_MEOUT~MAP2I: mapping basic item data. For accounting, condition etc., press F7 in debugging to return one call stack from here.
  • Method SET_OBJECT_ATTRIBUTES

    In this method, the following parts are the most relevant:
    • Include L2014I02 Method IF_BAPI_MEOUT~SET_ATTRIBUTE: header field selection
    • Include L2014I03 Method IF_BAPI_MEOUT~SET_ATTRIBUTE: item field selection
  • Method PROCESS_OUT

    In this method, the following parts are the most relevant:
    • Method PROCESS: validating, determining all data via rule execution (Method EXECUTE class CL_RULE_INTERPRETER_MM)
    • Method CHECK: validating all processed data via rule execution (Method EXECUTE class CL_RULE_INTERPRETER_MM)
    • Checking if the process is error free and DB change can be performed
    • Method POST: preparing and filling DB structures that will be used for DB update
    • Method COMMIT: calling FMs that updates the required DBs

Related Content

Related Documents

SAP Community Wiki - Purchasing BAPIs

SAP Community Wiki - Net Price determination in BAPI_CONTRACT_CREATE and BAPI_CONTRACT_CHANGE - Debugging Guide

SAP Community Wiki - Condition update process - Debugging Guide (ME816)

Related SAP Notes/KBAs

SAP Note: 1046794 FAQ: BAPI for Outline Agreement