Creation of Purchase Requisition (BAPI)
Creation of Purchase Requisition (BAPI)
2/9
© 2023 SAP SE or an SAP affiliate company. All rights reserved. See Legal Notice on www.sap.com/legal-notice for use terms, disclaimers, disclosures, or restrictions related to SAP Materials for general audiences.
Change Log
© 2023 SAP SE or an SAP affiliate company. All rights reserved. See Legal Notice on www.sap.com/legal-notice for use terms, disclaimers, disclosures, or restrictions related to SAP Materials for general audiences.
Overview
This document provides the information about the configuration & execution of BAPI (Business Application
programming Interface) business project. This project ‘Creation of Purchase Requisition (BAPI)’ is used for
creation of Purchase Requisition through BAPI function execution.
SAP BAPI is a standard interface to the business object models in SAP products. BAPIs are the primary
method through which customer code and third-party applications interact with SAP products. BAPIs wrap the
internal layers of SAP's business object model to ensure that all business logic, validations, and authorization
checks are executed properly when accessing or changing business objects (For more information click here).
This package consists of list of sub automations including Creation of Purchase Requisition-Start, BAPI
Execution & Excel Update. It also includes BAPI action group, data types to handle BAPI inputs & system
details and input excel file. The BAPI Action group is a collection of actions that is responsible for execution of
BAPI functions & return of BAPI response.
The actions from BAPI action group also contains following features.
• The BAPI Action group allows us to execute multiple operations such as set connection, open
connection, execute BAPI, commit transaction & close connection as a single automation activity.
• It provides the data type for BAPI input & BAPI response that contains all the input, output & test
parameters for BAPI function BAPI_PR_CREATE (for Creation of Purchase Requisition).
Prerequisites
- The project template requires SAP Build Process Automation subscription or CPEA contract.
Follow the setup and configuration section.
- The setup of desktop agent can be checked under “Configure Automation Capabilities” section
from the above link.
- Desktop agent version greater than 3.15.23.
- For usage of BAPI methods in an automation please check the prerequisites here.
- Configure SAP connection (SSO or Basic based on your requirement). For more information
you can check following links:
o BAPI Connection System
o Best Practices for SAP BAPI Activities
Capabilities
© 2023 SAP SE or an SAP affiliate company. All rights reserved. See Legal Notice on www.sap.com/legal-notice for use terms, disclaimers, disclosures, or restrictions related to SAP Materials for general audiences.
Name Description
BAPI function name: This is the BAPI function module that gets executed to create Purchase
BAPI_PR_CREATE Requisition.
Business project name: This is used for creation of Purchase Requisition based on the input
Creation of Purchase data provided in input configuration file.
Requisition (BAPI)
Procedure
Followings provides the project setup & configuration details along with project features & execution details:
Project Configuration
© 2023 SAP SE or an SAP affiliate company. All rights reserved. See Legal Notice on www.sap.com/legal-notice for use terms, disclaimers, disclosures, or restrictions related to SAP Materials for general audiences.
Project Execution Flow
START
No Yes
Loops through BAPI input data till loop Loop Counter > max. sequence
counter is less than max. sequence number
Yes No
Stop
End
© 2023 SAP SE or an SAP affiliate company. All rights reserved. See Legal Notice on www.sap.com/legal-notice for use terms, disclaimers, disclosures, or restrictions related to SAP Materials for general audiences.
Project Overview
• The project execution starts with the sub automation ‘Creation of Purchase Requisition - Start’.
• Automation reads the input file for the system data & BAPI info data from input excel file & supports
the obtained data in project for further execution.
• Automation performs the check for mandatory system details.
Mandatory System Details missing:
- Logs error message about missing system details.
- Automation stops the execution.
• Automation loops through BAPI input sheets (PRHEADER, PRHEADERX, PRITEMS, PRITEMX) &
reads the required data & supports it for further execution.
• Automation loops through BAPI input data for all the sequence number as provided in input excel:
- Automation utilizes BAPI input data variable created through action group for BAPI execution
& updates its values with provided input data.
- Sub automation ‘BAPI Execution’ is called that performs actual BAPI execution via action
group functionality.
- Action group of ‘BAPI Execution’ sub automation establishes the connection to SAP system,
executes the BAPI function (i.e., BAPI_PR_CREATE), commits the BAPI transaction, closes
the SAP connection & finally returns the BAPI response.
- For any exception/error during the BAPI execution, automation performs followings or else it
continues with further execution:
Execution Error:
- Automation catches the error & logs the error message.
- Automation updates the error message in the ‘Error’ sheet of the output excel file.
- Automations stops the execution.
- Automation loops through BAPI output parameters (RETURN, NUMBER) as provided in BAPI
Info sheet of input excel file:
- Automation checks if output parameter is of type ‘Tables’ or not.
- If property is a Table, automation loop through the array values of the property &
updates the rows of the output sheet (‘RETURN’ sheet of the output excel) with the
values.
- If property is not a Table (i.e., it’s an Exports property), automation updates the output
sheet with the property values. (Here ‘NUMBER sheet of output excel file is updated
with NUMBER value from the BAPI response).
- Automation increments the loop counter for next sequence number & continues with the
execution.
© 2023 SAP SE or an SAP affiliate company. All rights reserved. See Legal Notice on www.sap.com/legal-notice for use terms, disclaimers, disclosures, or restrictions related to SAP Materials for general audiences.
Release & Deploy Project
Modes of Execution
Once you have your project deployed successfully, you will have following two options to trigger the
automation bot:
- Standard/Unattended execution:
Unattended execution of the project can be created by selecting scheduled option during the
automation trigger & providing required scheduling information.
- Attended execution:
The package has a project pane with a menu item for triggering attended execution. Attended
execution can be created by selecting attended option during automation trigger & your automation
will be available as menu item within the agent menu in the system.
- Automation “Creation of Purchase Requisition – Start” starts the execution of project which requires
path of the input excel file that must be provided by clicking “Input parameter” while creating the
automation trigger.
Debugging Automation
Automations can be tested in the automation editor & its debugging feature can be utilized to test your
automation flow & data values.
© 2023 SAP SE or an SAP affiliate company. All rights reserved. See Legal Notice on www.sap.com/legal-notice for use terms, disclaimers, disclosures, or restrictions related to SAP Materials for general audiences.
Dependencies
The table below details the versions used to generate the mentioned automation bot.
Component Version
Factory/Tenant 2304.04
Application Version
© 2023 SAP SE or an SAP affiliate company. All rights reserved. See Legal Notice on www.sap.com/legal-notice for use terms, disclaimers, disclosures, or restrictions related to SAP Materials for general audiences.