SlideShare una empresa de Scribd logo
1 de 25
UiPath Community Event
SAP Tips’n’Tricks for
Automation Developers from
ABAP Developer
2
• RPA Developers, who would like to understand more about SAP and learn more about SAP BAPI
and its benefits and challenges
• Automation Developers who are heavily involved with SAP related automation projects, not only
using RPA solutions.
• Everyone wants to know how data can be retrieved from SAP and pushed into SAP, in most
efficient way.
More, knowledge about SAP Automation can be found here:
https://community.uipath.com/events/details/uipath-emeaapac-virtual-events-presents-aut[…]-sap-
s4hana-business-processes-across-all-user-interfaces/
https://community.uipath.com/events/details/uipath-global-virtual-events-presents-sap-api-automation-
with-the-help-of-uipath/
Who is this event best suited for?
3
• Basics:
How to navigate SAP GUI and find some technical information we need. How to get data from SAP
in a variety of ways.
• BAPI:
More advanced introduction to BAPI. BAPI is every developer’s dream, but it’s also a nightmare
• Forbidden fruit:
Rather advanced features.
You want to know those features exist, but you never want to use them ;)
Agenda
4
“T-code” is a short name for “Transaction Code”. SAP Transactions have unique names. In SAP,
every activity is completed by using Transaction.
• SU01, SU01D – User management (check what authorization your user has)
• SE12 – ABAP dictionary
• SE37, SE38 – Function Module/Program Repository (part of ABAP Editor)
• SE80 – ABAP Developer Workbench (don’t go there if you are not ABAP Developer)
• SE16, SE16N – DB Data browser
• SU53 – Authorization access audit
• ST22 – “Short Dump” analysis
• ST01 – Trace (including RFC trace)
Useful “t-codes”
5
A lot of useful information about SAP input fields
Example: How to find where Purchase Order (4600000263) header data are stored.
Where do I start? Powerful “F1”
6
A lot of useful information about SAP input fields
Database browser T-Codes SE16, SE16N
7
• Via User Interface (SAP GUI, Web GUI, Fiori, etc.)
• Via RFC calls (BAPI, but not only)
• Via Web Services (not easy as it sounds)
• Via direct DB reads (show me an SAP Admin who will let you do this in production 
How can we exchange data with SAP?
8
SAP BAPI (Business Application Programming Interface) 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.
In short: BAPI is a program which can be called by external systems to do something “inside” SAP.
https://searchsap.techtarget.com/definition/BAPI
What is “BAPI”?
9
What is “BAPI”?
External system
(initiator)
SAP
BAPI
Function
Module
Other FMs
SAP DB
External system
RFC
10
What is RFC?
“Remote Function Call is the proprietary SAP SE interface. Remote Function Call (RFC) is the
standard SAP interface for communication between SAP systems. The RFC calls a function to be
executed in a remote system”
https://en.wikipedia.org/wiki/Remote_Function_Call
• RFC is a protocol. BAPI is a set of SAP Function Modules
• RFC can be used to trigger non-BAPI Function Modules as well
• RFC connection must be established before BAPI FM can be executed
• Once RFC connection is established, all SAP BAPIs become available.
BAPI vs. RFC
11
“BADI stands for Business Add Ins Just like Customer Exits , BADI help hook custom enhancements
to SAP functionality.“
• BADI is a way SAP programs, functions and screens are customized to match customer-specific
requirements
• BAPI are programs (Function Modules).
• BAPI Function modules can be customized using variety of BADIs
• Note: BADIs will, most likely, not come up during sales stage but if Professional Services are
included in the deal PS team should enquire about BADIs (as they may significantly affect SAP
functionality and implementation effort).
• A lot of BAPIs used by customer = 
A lot of BADIs used by customer = *
* More information is necessary to determine impact to implementation (if any).
BAPI vs. BADI
12
• RFC Connectivity must be enabled by
Customer’s network and SAP teams.
• RFC connection requires User credentials
(Dialog user account can be used for POC
but this is not recommended for production
(e.g. dialog user passwords expire)
• RFC connectivity can be established with
selected SAP Application server directly or
via Message server.
• Establishing RFC connection does not guarantee ability to execute BAPI – authorizations are
required and SNC (secure communication) may need to be configured.
• Useful information can be found here: https://docs.uipath.com/activities/docs/about-the-sap-bapi-
activities-pack
Establishing RFC connection
13
 Network is configured (Firewall allows RFC connections on ports 32xx, 33xx)
 RFC connection parameters are available
(Application server IP/HN, System ID, etc.)
 SAP User credentials for RFC use are available.
 SAP User account RFC authorization has been granted
 SAP User BAPI-specific authorizations have been granted
 … you actually know which BAPI you want to execute.
Execute BAPI – final checklist.
14
• RFC protocol can be used to execute
any RFC-enabled SAP Function Module.
• There are thousands of standard and
custom RFC-enabled modules in SAP
but not all qualify as BAPI.
• In order to qualify as BAPI Function Module
SAP program must satisfy certain development
requirements.
• UiPath RFC connector can be used to any
RFC-enabled module (BAPI and non-BAPI)
• Some companies scrutinize use of RFC-enabled modules and allow use of only BAPI FMs.
Note: check company/organization internal policies before implementation !
BAPI or not BAPI?
15
There’s a very simple rule:
Standard SAP code:
• Function module name
starts with any character
except “Z” or “Y”
• Author is denoted as “SAP”
Custom ABAP code:
• Function module name
starts with Z* or Y* (always)
• Author is not “SAP”.
SAP BAPI FM, Custom BAPI FMs, how to tell?
16
• Companies, who are not using RFC may feel insecure about use of BAPI and may not have
resources to enable/configure it.
• Companies who use dedicated RFC SAP User account may face internal compliance or audit
issues (SAP logging is very limited).
• Implementation requires more SAP knowledge than using GUI
• It usually takes longer time to start with BAPI than with SAP UI due to the fact necessary
authorizations need to be granted by SAP team.
• SAP BAPI is poorly documented (even in standard SAP documentation)
• Troubleshooting is challenging. Requires SAP knowledge.
• Debugging is challenging. Do you want to learn ABAP?
Major challenges: using/implementing SAP BAPI
17
Mother of all issues – code customizations: Execution of action via BAPI (e.g. PO creation) may
offer different results than execution of the same action via SAP UI. SAP customizations may not
be implemented to work for RFC calls !!!
Major challenges: using/implementing SAP BAPI
SAP UI
BAPI
via RFC
SAP PO Creation logic
SAP PO
User Exit
TCODE: ME21N
TCODE:
?
Code:
...
If sy-tcode EQ ‘ME21N’
Add 10 to AMOUNT
Endif
...
18
• Yes, if customer is tech savvy and sees BAPI-enabled implementation as a value.
• Yes, if you want to create fast and reliable SAP automation
• Yes, if customer SAP connectivity is unreliable or very slow.
• No, if SAP part of the process is simple and short and connection is OK
• No, if customer want to see what is actually robot doing on his PC (BAPI kills some “wow factor”
as robot actions are executed in background and user can’t see it.
• No, if customer’s SAP system is not configured for RFC or customer is not using BAPI/RFC in any
other scenario and is not comfortable with BAPI use.
• No, if you want to minimize IT involvement (getting IT support usually requires time so plan your
POC accordingly)
• No, if you are not familiar with SAP BAPI. Preparing data for BAPI call (BAPI interface) is
simplified by UiPath connector but can still take some additional time.
Should I use BAPI in my project?
19
• SAP Documentation – Scarce, superficial and hard to access
• Google it ! – This is the best source of knowledge about BAPI
• Experiment with SAP Transaction code SE37 (Function Module Builder) and use search facilities
(Press F4) or read SAP FM documentation (Press F9).
How to find right BAPI (or RFC FM) for my purpose
20
Import: values passed into FM (read only inside FM)
Export: values returned by FM
Changing: values passed into FM which can be changed by FM and read upon return
Tables: table structured values (handled like “Changing”)
Exceptions: list of pre-defined exceptions FM can throw
Function Module interface
21
Use SAP Transaction Code (tcode) “SE37”. You can execute BAPIs (actually, you can run any FM
using this tcode with input parameters and see execution results).
Select Function Module you want to try and press F8 (authorization required)
How to check if BAPI does what I need?
22
Some BAPI Function modules execute its code but do not trigger explicit commit. If commit is not
triggered manually, actions completed by BAPI will be discarded when RFC connection is terminated.
Commit (or Rollback) is required only if BAPI changed DB contents (e.g. created new PO) and it’s not
applicable for data reading BAPIs.
Proper sequence of actions:
1. Establish RFC connection
2. Execute desired BAPI
3. Execute BAPI_TRANSACTION_COMMIT to commit changes or
BAPI_TRANSACTION_ROLLBACK to roll-back the changes.
4. Terminate RFC connection if done.
Tricky case of BAPI commit
23
SAP offers dedicated functionality to test execution of multiple BAPIs (FM) within single LUW
(Logical Unit of Work). This allows you to
execute BAPI Commit or Rollback after your
functional BAPI executed (e.g. PO created)
Use of “Test sequences” to Commit/Rollback
24
• OK-Codes
What are they? What do the do? How to use them if, for some strange reason, you hate “Click”
activity.
• FM RFC_READ_TABLE
What does this Function Module do? How to use it? Why is it every auditor’s nightmare?
• No external debugger – No problem
What is the problem here? Why would I need it? What is “SM50”? And why I shouldn’t do it?
Dark zone ;)
Thank you
Tomasz Gaczynski
tomasz.gaczynski@uipath.com
Think
Automation
First

Más contenido relacionado

La actualidad más candente

Enhancing data sources with badi in SAP ABAP
Enhancing data sources with badi in SAP ABAPEnhancing data sources with badi in SAP ABAP
Enhancing data sources with badi in SAP ABAP
Aabid Khan
 
Sap table relation
Sap table relationSap table relation
Sap table relation
Rameeza09
 
SAP Fiori Competence
SAP Fiori CompetenceSAP Fiori Competence
SAP Fiori Competence
Ankit Jain
 
Hybrid provider based on dso using real time data acquisition in sap bw 7.30
Hybrid provider based on dso using real time data acquisition in sap bw 7.30Hybrid provider based on dso using real time data acquisition in sap bw 7.30
Hybrid provider based on dso using real time data acquisition in sap bw 7.30
Sabyasachi Das
 
Sap sapscripts tips and tricks
Sap sapscripts tips and tricksSap sapscripts tips and tricks
Sap sapscripts tips and tricks
Kranthi Kumar
 

La actualidad más candente (20)

Enhancing data sources with badi in SAP ABAP
Enhancing data sources with badi in SAP ABAPEnhancing data sources with badi in SAP ABAP
Enhancing data sources with badi in SAP ABAP
 
Fox formula in sap bi integrated planning
Fox formula in sap bi integrated planningFox formula in sap bi integrated planning
Fox formula in sap bi integrated planning
 
Table maintenance generator and its modifications
Table maintenance generator and its modificationsTable maintenance generator and its modifications
Table maintenance generator and its modifications
 
Sap basis ppt
Sap basis pptSap basis ppt
Sap basis ppt
 
Introduction to ABAP
Introduction to ABAPIntroduction to ABAP
Introduction to ABAP
 
Discover SAP BusinessObjects BI 4.3
Discover SAP BusinessObjects BI 4.3Discover SAP BusinessObjects BI 4.3
Discover SAP BusinessObjects BI 4.3
 
Inspirage Webinar on Epm integration agent
Inspirage Webinar on Epm integration agentInspirage Webinar on Epm integration agent
Inspirage Webinar on Epm integration agent
 
Sap table relation
Sap table relationSap table relation
Sap table relation
 
sap fiori architecture
sap fiori architecturesap fiori architecture
sap fiori architecture
 
Rise with sap one pager
Rise with sap one pagerRise with sap one pager
Rise with sap one pager
 
SAP Fiori Competence
SAP Fiori CompetenceSAP Fiori Competence
SAP Fiori Competence
 
Sap abap tutorials
Sap abap tutorialsSap abap tutorials
Sap abap tutorials
 
Hybrid provider based on dso using real time data acquisition in sap bw 7.30
Hybrid provider based on dso using real time data acquisition in sap bw 7.30Hybrid provider based on dso using real time data acquisition in sap bw 7.30
Hybrid provider based on dso using real time data acquisition in sap bw 7.30
 
How to use abap cds for data provisioning in bw
How to use abap cds for data provisioning in bwHow to use abap cds for data provisioning in bw
How to use abap cds for data provisioning in bw
 
Smartforms interview questions with answers
Smartforms interview questions with answersSmartforms interview questions with answers
Smartforms interview questions with answers
 
Sap basis certification and interview questions answers
Sap basis certification and interview questions answersSap basis certification and interview questions answers
Sap basis certification and interview questions answers
 
SAP Adobe forms
SAP Adobe formsSAP Adobe forms
SAP Adobe forms
 
Sap sapscripts tips and tricks
Sap sapscripts tips and tricksSap sapscripts tips and tricks
Sap sapscripts tips and tricks
 
Sap alv excel inplace with macro recording sapignite
Sap alv excel inplace with macro recording sapigniteSap alv excel inplace with macro recording sapignite
Sap alv excel inplace with macro recording sapignite
 
Treinamento SAP ABAP
Treinamento SAP ABAPTreinamento SAP ABAP
Treinamento SAP ABAP
 

Similar a SAP Tips and Tricks for Automation Developers from ABAP Developer

Similar a SAP Tips and Tricks for Automation Developers from ABAP Developer (20)

Integrating SAP and Low-Code Plaforms
Integrating SAP and Low-Code PlaformsIntegrating SAP and Low-Code Plaforms
Integrating SAP and Low-Code Plaforms
 
Integration with SAP using Mule ESB
Integration with SAP using Mule ESBIntegration with SAP using Mule ESB
Integration with SAP using Mule ESB
 
Features of Mule SAP Connector
Features of Mule SAP ConnectorFeatures of Mule SAP Connector
Features of Mule SAP Connector
 
sap abap training in chennai
sap abap training in chennaisap abap training in chennai
sap abap training in chennai
 
Mule sap connector
Mule sap connectorMule sap connector
Mule sap connector
 
Sap Fiori Tutorial - Live interactive sap fiori online training
Sap Fiori Tutorial - Live interactive sap fiori online trainingSap Fiori Tutorial - Live interactive sap fiori online training
Sap Fiori Tutorial - Live interactive sap fiori online training
 
Sap integration by mule esb
Sap integration by mule esbSap integration by mule esb
Sap integration by mule esb
 
SAP PI/PO FAQ’s
SAP PI/PO FAQ’sSAP PI/PO FAQ’s
SAP PI/PO FAQ’s
 
SE - Lecture 9 n 10 Intro Robotic Process Automation.pptx
SE - Lecture 9 n 10 Intro Robotic Process Automation.pptxSE - Lecture 9 n 10 Intro Robotic Process Automation.pptx
SE - Lecture 9 n 10 Intro Robotic Process Automation.pptx
 
Key takeaways for SAP PI Integration 2018
Key takeaways for SAP PI Integration 2018Key takeaways for SAP PI Integration 2018
Key takeaways for SAP PI Integration 2018
 
How to Implement Fiori Central Hub 1610
How to Implement Fiori Central Hub 1610How to Implement Fiori Central Hub 1610
How to Implement Fiori Central Hub 1610
 
Sap Integrations
Sap IntegrationsSap Integrations
Sap Integrations
 
Future-Proof Your Business Processes by Automating SAP S/4HANA processes with...
Future-Proof Your Business Processes by Automating SAP S/4HANA processes with...Future-Proof Your Business Processes by Automating SAP S/4HANA processes with...
Future-Proof Your Business Processes by Automating SAP S/4HANA processes with...
 
Extending SAP SuccessFactors in the Cloud and how not to do it
Extending SAP SuccessFactors in the Cloud and how not to do itExtending SAP SuccessFactors in the Cloud and how not to do it
Extending SAP SuccessFactors in the Cloud and how not to do it
 
SAP ABAP web services creation.
SAP ABAP web services creation. SAP ABAP web services creation.
SAP ABAP web services creation.
 
SAP Interview Questions for Experienced to Assess & Hire SAP Specialists_Part 2
SAP Interview Questions for Experienced to Assess & Hire SAP Specialists_Part 2SAP Interview Questions for Experienced to Assess & Hire SAP Specialists_Part 2
SAP Interview Questions for Experienced to Assess & Hire SAP Specialists_Part 2
 
Different termininologies & transaction codes used_in_sap
Different termininologies & transaction codes used_in_sapDifferent termininologies & transaction codes used_in_sap
Different termininologies & transaction codes used_in_sap
 
How to go about your SAP Integration 2019, SAP PI, and cloud
How to go about your SAP Integration 2019, SAP PI, and cloudHow to go about your SAP Integration 2019, SAP PI, and cloud
How to go about your SAP Integration 2019, SAP PI, and cloud
 
troubleshooting Fiori.pdf
troubleshooting Fiori.pdftroubleshooting Fiori.pdf
troubleshooting Fiori.pdf
 
SAP ABAP
SAP ABAP SAP ABAP
SAP ABAP
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

SAP Tips and Tricks for Automation Developers from ABAP Developer

  • 1. UiPath Community Event SAP Tips’n’Tricks for Automation Developers from ABAP Developer
  • 2. 2 • RPA Developers, who would like to understand more about SAP and learn more about SAP BAPI and its benefits and challenges • Automation Developers who are heavily involved with SAP related automation projects, not only using RPA solutions. • Everyone wants to know how data can be retrieved from SAP and pushed into SAP, in most efficient way. More, knowledge about SAP Automation can be found here: https://community.uipath.com/events/details/uipath-emeaapac-virtual-events-presents-aut[…]-sap- s4hana-business-processes-across-all-user-interfaces/ https://community.uipath.com/events/details/uipath-global-virtual-events-presents-sap-api-automation- with-the-help-of-uipath/ Who is this event best suited for?
  • 3. 3 • Basics: How to navigate SAP GUI and find some technical information we need. How to get data from SAP in a variety of ways. • BAPI: More advanced introduction to BAPI. BAPI is every developer’s dream, but it’s also a nightmare • Forbidden fruit: Rather advanced features. You want to know those features exist, but you never want to use them ;) Agenda
  • 4. 4 “T-code” is a short name for “Transaction Code”. SAP Transactions have unique names. In SAP, every activity is completed by using Transaction. • SU01, SU01D – User management (check what authorization your user has) • SE12 – ABAP dictionary • SE37, SE38 – Function Module/Program Repository (part of ABAP Editor) • SE80 – ABAP Developer Workbench (don’t go there if you are not ABAP Developer) • SE16, SE16N – DB Data browser • SU53 – Authorization access audit • ST22 – “Short Dump” analysis • ST01 – Trace (including RFC trace) Useful “t-codes”
  • 5. 5 A lot of useful information about SAP input fields Example: How to find where Purchase Order (4600000263) header data are stored. Where do I start? Powerful “F1”
  • 6. 6 A lot of useful information about SAP input fields Database browser T-Codes SE16, SE16N
  • 7. 7 • Via User Interface (SAP GUI, Web GUI, Fiori, etc.) • Via RFC calls (BAPI, but not only) • Via Web Services (not easy as it sounds) • Via direct DB reads (show me an SAP Admin who will let you do this in production  How can we exchange data with SAP?
  • 8. 8 SAP BAPI (Business Application Programming Interface) 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. In short: BAPI is a program which can be called by external systems to do something “inside” SAP. https://searchsap.techtarget.com/definition/BAPI What is “BAPI”?
  • 9. 9 What is “BAPI”? External system (initiator) SAP BAPI Function Module Other FMs SAP DB External system RFC
  • 10. 10 What is RFC? “Remote Function Call is the proprietary SAP SE interface. Remote Function Call (RFC) is the standard SAP interface for communication between SAP systems. The RFC calls a function to be executed in a remote system” https://en.wikipedia.org/wiki/Remote_Function_Call • RFC is a protocol. BAPI is a set of SAP Function Modules • RFC can be used to trigger non-BAPI Function Modules as well • RFC connection must be established before BAPI FM can be executed • Once RFC connection is established, all SAP BAPIs become available. BAPI vs. RFC
  • 11. 11 “BADI stands for Business Add Ins Just like Customer Exits , BADI help hook custom enhancements to SAP functionality.“ • BADI is a way SAP programs, functions and screens are customized to match customer-specific requirements • BAPI are programs (Function Modules). • BAPI Function modules can be customized using variety of BADIs • Note: BADIs will, most likely, not come up during sales stage but if Professional Services are included in the deal PS team should enquire about BADIs (as they may significantly affect SAP functionality and implementation effort). • A lot of BAPIs used by customer =  A lot of BADIs used by customer = * * More information is necessary to determine impact to implementation (if any). BAPI vs. BADI
  • 12. 12 • RFC Connectivity must be enabled by Customer’s network and SAP teams. • RFC connection requires User credentials (Dialog user account can be used for POC but this is not recommended for production (e.g. dialog user passwords expire) • RFC connectivity can be established with selected SAP Application server directly or via Message server. • Establishing RFC connection does not guarantee ability to execute BAPI – authorizations are required and SNC (secure communication) may need to be configured. • Useful information can be found here: https://docs.uipath.com/activities/docs/about-the-sap-bapi- activities-pack Establishing RFC connection
  • 13. 13  Network is configured (Firewall allows RFC connections on ports 32xx, 33xx)  RFC connection parameters are available (Application server IP/HN, System ID, etc.)  SAP User credentials for RFC use are available.  SAP User account RFC authorization has been granted  SAP User BAPI-specific authorizations have been granted  … you actually know which BAPI you want to execute. Execute BAPI – final checklist.
  • 14. 14 • RFC protocol can be used to execute any RFC-enabled SAP Function Module. • There are thousands of standard and custom RFC-enabled modules in SAP but not all qualify as BAPI. • In order to qualify as BAPI Function Module SAP program must satisfy certain development requirements. • UiPath RFC connector can be used to any RFC-enabled module (BAPI and non-BAPI) • Some companies scrutinize use of RFC-enabled modules and allow use of only BAPI FMs. Note: check company/organization internal policies before implementation ! BAPI or not BAPI?
  • 15. 15 There’s a very simple rule: Standard SAP code: • Function module name starts with any character except “Z” or “Y” • Author is denoted as “SAP” Custom ABAP code: • Function module name starts with Z* or Y* (always) • Author is not “SAP”. SAP BAPI FM, Custom BAPI FMs, how to tell?
  • 16. 16 • Companies, who are not using RFC may feel insecure about use of BAPI and may not have resources to enable/configure it. • Companies who use dedicated RFC SAP User account may face internal compliance or audit issues (SAP logging is very limited). • Implementation requires more SAP knowledge than using GUI • It usually takes longer time to start with BAPI than with SAP UI due to the fact necessary authorizations need to be granted by SAP team. • SAP BAPI is poorly documented (even in standard SAP documentation) • Troubleshooting is challenging. Requires SAP knowledge. • Debugging is challenging. Do you want to learn ABAP? Major challenges: using/implementing SAP BAPI
  • 17. 17 Mother of all issues – code customizations: Execution of action via BAPI (e.g. PO creation) may offer different results than execution of the same action via SAP UI. SAP customizations may not be implemented to work for RFC calls !!! Major challenges: using/implementing SAP BAPI SAP UI BAPI via RFC SAP PO Creation logic SAP PO User Exit TCODE: ME21N TCODE: ? Code: ... If sy-tcode EQ ‘ME21N’ Add 10 to AMOUNT Endif ...
  • 18. 18 • Yes, if customer is tech savvy and sees BAPI-enabled implementation as a value. • Yes, if you want to create fast and reliable SAP automation • Yes, if customer SAP connectivity is unreliable or very slow. • No, if SAP part of the process is simple and short and connection is OK • No, if customer want to see what is actually robot doing on his PC (BAPI kills some “wow factor” as robot actions are executed in background and user can’t see it. • No, if customer’s SAP system is not configured for RFC or customer is not using BAPI/RFC in any other scenario and is not comfortable with BAPI use. • No, if you want to minimize IT involvement (getting IT support usually requires time so plan your POC accordingly) • No, if you are not familiar with SAP BAPI. Preparing data for BAPI call (BAPI interface) is simplified by UiPath connector but can still take some additional time. Should I use BAPI in my project?
  • 19. 19 • SAP Documentation – Scarce, superficial and hard to access • Google it ! – This is the best source of knowledge about BAPI • Experiment with SAP Transaction code SE37 (Function Module Builder) and use search facilities (Press F4) or read SAP FM documentation (Press F9). How to find right BAPI (or RFC FM) for my purpose
  • 20. 20 Import: values passed into FM (read only inside FM) Export: values returned by FM Changing: values passed into FM which can be changed by FM and read upon return Tables: table structured values (handled like “Changing”) Exceptions: list of pre-defined exceptions FM can throw Function Module interface
  • 21. 21 Use SAP Transaction Code (tcode) “SE37”. You can execute BAPIs (actually, you can run any FM using this tcode with input parameters and see execution results). Select Function Module you want to try and press F8 (authorization required) How to check if BAPI does what I need?
  • 22. 22 Some BAPI Function modules execute its code but do not trigger explicit commit. If commit is not triggered manually, actions completed by BAPI will be discarded when RFC connection is terminated. Commit (or Rollback) is required only if BAPI changed DB contents (e.g. created new PO) and it’s not applicable for data reading BAPIs. Proper sequence of actions: 1. Establish RFC connection 2. Execute desired BAPI 3. Execute BAPI_TRANSACTION_COMMIT to commit changes or BAPI_TRANSACTION_ROLLBACK to roll-back the changes. 4. Terminate RFC connection if done. Tricky case of BAPI commit
  • 23. 23 SAP offers dedicated functionality to test execution of multiple BAPIs (FM) within single LUW (Logical Unit of Work). This allows you to execute BAPI Commit or Rollback after your functional BAPI executed (e.g. PO created) Use of “Test sequences” to Commit/Rollback
  • 24. 24 • OK-Codes What are they? What do the do? How to use them if, for some strange reason, you hate “Click” activity. • FM RFC_READ_TABLE What does this Function Module do? How to use it? Why is it every auditor’s nightmare? • No external debugger – No problem What is the problem here? Why would I need it? What is “SM50”? And why I shouldn’t do it? Dark zone ;)