This document provides instructions on integrating Excel with SAP to allow for data posting capabilities. It describes preparing an RFC function module in SAP to interface with an Excel VBA macro. The RFC FM handles mapping data from Excel to standard SAP BAPIs to create a sales order. The VBA macro calls the RFC FM and maps the returned sales order number back to Excel. The end-to-end process is tested by entering sample sales order data in Excel and having it successfully posted to SAP.
As an ABAP Developer, we often have to develop ABAP reports that displays some data from the database. SAP provides a set of ALV (ABAP List Viewer) function modules which can be put into use to embellish the output of a report. Object oriented ALV is more robust and is more advanced when compared to Traditional ALV.
500+ SAP ABAP INTERVIEW QUESTIONS WITH ANSWERSIICT Chromepet
Most Important SAP ABAP Interview Questions along with answers are Shared. These questions are useful to clear any kinds of interview. Especially for freshers its mostly useful. Dont forget to read these question and answers in SAP ABAP Module.
For training requirement please visit:
https://iicttechnologies.com/
(Or)
http://www.traininginchennai.co.in/
(Or)
https://traininginchrompet.com/
As an ABAP Developer, we often have to develop ABAP reports that displays some data from the database. SAP provides a set of ALV (ABAP List Viewer) function modules which can be put into use to embellish the output of a report. Object oriented ALV is more robust and is more advanced when compared to Traditional ALV.
500+ SAP ABAP INTERVIEW QUESTIONS WITH ANSWERSIICT Chromepet
Most Important SAP ABAP Interview Questions along with answers are Shared. These questions are useful to clear any kinds of interview. Especially for freshers its mostly useful. Dont forget to read these question and answers in SAP ABAP Module.
For training requirement please visit:
https://iicttechnologies.com/
(Or)
http://www.traininginchennai.co.in/
(Or)
https://traininginchrompet.com/
study material for beginners of SAP ABAP .
1. Introduction to SAP 06
2. ABAB Data Dictionary 60
3. Introduction to ASAP Programming 89
4. Control Structures 12
5. Strings 6
6. Internal Tables 23
7. Open SQL
8. ABAB Debugging 13
9. Reports 74
10. Modularizing Techniques 44
Understanding SAP Workflow Development for Purchase Order Process
How to use transaction codes for SAP Workflow Development
Programming in Business Objects for Workflow
Using Workflow Builder to build a Workflow Template
In SAP R/3 and SAP ECC, report painter is one of the reporting functionalities. In this presentation an introduction is given to report painter in SAP.
Technical Overview of CDS View – SAP HANA Part IAshish Saxena
SAP HANA has introduced new paradigms to SAP ABAP application programming. Before SAP HANA, development paradigm in SAP was based on DATA-to-Code where intensive calculation was done at the application layer and database utilization was minimized. New programming paradigm in SAP HANA is Code-to-Data, where the intensive calculation is done at the database layer and less programming at application layer.
When the volume of data to process is too large in SAP, background jobs are created to run reports or interfaces. But as the business grows, the volume of data increases and such jobs will take many hours to complete. Parallel Processing reduces the time taken by usual background jobs in SAP by optimally utilizing the available background work processes in the server.
Sap alv excel inplace with macro recording sapigniteAromal Raveendran
This article explains how we can make use of MS Excel Inplace functionality in the SAP ALV toolbar with macro recording to avoid repetitive tasks such as adding custom calculation field in the standard /Custom/ Query reports (e.g. Order Qty- Delivery Qty, Pivot Table chart etc)
study material for beginners of SAP ABAP .
1. Introduction to SAP 06
2. ABAB Data Dictionary 60
3. Introduction to ASAP Programming 89
4. Control Structures 12
5. Strings 6
6. Internal Tables 23
7. Open SQL
8. ABAB Debugging 13
9. Reports 74
10. Modularizing Techniques 44
Understanding SAP Workflow Development for Purchase Order Process
How to use transaction codes for SAP Workflow Development
Programming in Business Objects for Workflow
Using Workflow Builder to build a Workflow Template
In SAP R/3 and SAP ECC, report painter is one of the reporting functionalities. In this presentation an introduction is given to report painter in SAP.
Technical Overview of CDS View – SAP HANA Part IAshish Saxena
SAP HANA has introduced new paradigms to SAP ABAP application programming. Before SAP HANA, development paradigm in SAP was based on DATA-to-Code where intensive calculation was done at the application layer and database utilization was minimized. New programming paradigm in SAP HANA is Code-to-Data, where the intensive calculation is done at the database layer and less programming at application layer.
When the volume of data to process is too large in SAP, background jobs are created to run reports or interfaces. But as the business grows, the volume of data increases and such jobs will take many hours to complete. Parallel Processing reduces the time taken by usual background jobs in SAP by optimally utilizing the available background work processes in the server.
Sap alv excel inplace with macro recording sapigniteAromal Raveendran
This article explains how we can make use of MS Excel Inplace functionality in the SAP ALV toolbar with macro recording to avoid repetitive tasks such as adding custom calculation field in the standard /Custom/ Query reports (e.g. Order Qty- Delivery Qty, Pivot Table chart etc)
Deciding on how you integrate your SAP system with Low-Code platform is a complex architectural problem to solve. We look at a sample scenario and consider the various SAP integration options.
ERP Magazine is a monthly publication focusing on ERP/SAP software technical insights and innovations, for both new and advanced learners. In every issue, leading authors and consultants from a diverse set of companies present their ideas and/or achievements in a clear fashion. Each article is carefully reviewed both by technical and English-language experts. The graphics are rich in content and visual style, and the articles feature illustrative real-world coding. Our readers are Basis, ABAP, Workflow, Web Dynpro, HANA, Fiori and Mobility consultants. We publish SAP/ERP technical articles in a variety of lengths and sizes. And we include general tips and feature-length articles as well. We will be showcasing a number of published book chapters in upcoming editions, along with including white papers about useful tools and products.
ERP Magazine April 2018 - The magazine for SAP ABAP ProfessionalsRehan Zaidi
ERP Magazine is a monthly publication focusing on ERP/SAP software technical insights and innovations, for both new and advanced learners. In every issue, leading authors and consultants from a diverse set of companies present their ideas and/or achievements in a clear fashion. Each article is carefully reviewed both by technical and English-language experts. The graphics are rich in content and visual style, and the articles feature illustrative real-world coding. Our readers are Basis, ABAP, Workflow, Web Dynpro, HANA, Fiori and Mobility consultants. We publish SAP/ERP technical articles in a variety of lengths and sizes. And we include general tips and feature-length articles as well. We will be showcasing a number of published book chapters in upcoming editions, along with including white papers about useful tools and products. Available on Amazon Worldwide in Kindle format.
Quick Development and Deployment of Industrial Applications using Excel/VBA, ...Alkis Vazacopoulos
Presented in this document is a description of how to develop and deploy industrial applications in a timely fashion using Excel/VBA as the user-interface (UI) and systems-integration (SI) system, IMPL as the industrial modeller and CPLEX as the commercial solver. A small jobshop scheduling example is overviewed to help describe to some extent, the details of this advanced decision-making application where this type of problem can be found in both the manufacturing and process industries.
The purpose of developing and deploying quickly is to acquire feedback from the end-users, to assess the difficulty and tractability of the problem, to ascertain the expected costs and benefits of the application and to address any other issues and requirements regarding the project as a whole as soon as possible. For some projects, proof-of-concepts, prototypes and/or pilots are also useful and these should also be performed ASAP as well using the same approach highlighted here. Ultimately, once a business problem solution has been achieved and full or partial benefits have been captured, then a more robust and sophisticated end-user experience and system architecture can be implemented in the operating system and computer programming environment of choice which will hopefully enhance and maintain the solution over its expected life-cycle.
What is it like to work with an ERP suite in an MNC environment? What are the real opportunities and challenges involved? Employees/Managers nowadays are expected to handle cross-discipline assignments. Consultants/Analysts are not only expected to be techno-functional, but also cross-functional. ERP skills, in short, are career differentiators. Jumpstart your ERP career or journey with this book now!
ABAP/4 Mindmap!! - for busy functional consultants
Ever wonder what are the functional improvements in S/4HANA? for more details, please checkout: https://www.amazon.com/dp/B083C3X8YY ERP Made Simple: ERP Explained in 80 Pages or Less
This is a highlevel view of PS.
For more comprehensive details, please checkout: https://www.amazon.com/dp/B083C3X8YY ERP Made Simple: ERP Explained in 80 Pages or Less
This is a highlevel view of PP.
For more comprehensive details, please checkout: https://www.amazon.com/dp/B083C3X8YY ERP Made Simple: ERP Explained in 80 Pages or Less
Ever wonder what are the functional improvements in S/4HANA? for more details, please checkout: https://www.amazon.com/dp/B083C3X8YY ERP Made Simple: ERP Explained in 80 Pages or Less
SAP MTS-To-COPA Flow Diagram. for more details, please checkout: https://www.amazon.com/dp/B083C3X8YY ERP Made Simple: ERP Explained in 80 Pages or Less
SAP Core Account Determination Diagram. for more details, please checkout: https://www.amazon.com/dp/B083C3X8YY ERP Made Simple: ERP Explained in 80 Pages or Less
This is an overview of the CO integration with all other modules through the COPA module. for more details, please checkout: https://www.amazon.com/dp/B083C3X8YY ERP Made Simple: ERP Explained in 80 Pages or Less
This is an overview for SAP S/4HANA Cloud 1808. for more details, please checkout: https://www.amazon.com/dp/B083C3X8YY ERP Made Simple: ERP Explained in 80 Pages or Less
Highlevel Overview of S4 Improvements. for more details, please checkout: https://www.amazon.com/dp/B083C3X8YY ERP Made Simple: ERP Explained in 80 Pages or Less
This is an overview for SAP HANA MM S/4 1709. for more details, please checkout: https://www.amazon.com/dp/B083C3X8YY ERP Made Simple: ERP Explained in 80 Pages or Less
This is an overview for SAP HANA SD S/4 1709. for more details, please checkout: https://www.amazon.com/dp/B083C3X8YY ERP Made Simple: ERP Explained in 80 Pages or Less
SAP S4 HANA CO Certification mindmap. for more details, please checkout: https://www.amazon.com/dp/B083C3X8YY ERP Made Simple: ERP Explained in 80 Pages or Less
SAP S4 HANAFI Certification mindmap. for more details, please checkout: https://www.amazon.com/dp/B083C3X8YY ERP Made Simple: ERP Explained in 80 Pages or Less
Tata Group Dials Taiwan for Its Chipmaking Ambition in Gujarat’s DholeraAvirahi City Dholera
The Tata Group, a titan of Indian industry, is making waves with its advanced talks with Taiwanese chipmakers Powerchip Semiconductor Manufacturing Corporation (PSMC) and UMC Group. The goal? Establishing a cutting-edge semiconductor fabrication unit (fab) in Dholera, Gujarat. This isn’t just any project; it’s a potential game changer for India’s chipmaking aspirations and a boon for investors seeking promising residential projects in dholera sir.
Visit : https://www.avirahi.com/blog/tata-group-dials-taiwan-for-its-chipmaking-ambition-in-gujarats-dholera/
Top mailing list providers in the USA.pptxJeremyPeirce1
Discover the top mailing list providers in the USA, offering targeted lists, segmentation, and analytics to optimize your marketing campaigns and drive engagement.
Personal Brand Statement:
As an Army veteran dedicated to lifelong learning, I bring a disciplined, strategic mindset to my pursuits. I am constantly expanding my knowledge to innovate and lead effectively. My journey is driven by a commitment to excellence, and to make a meaningful impact in the world.
LA HUG - Video Testimonials with Chynna Morgan - June 2024Lital Barkan
Have you ever heard that user-generated content or video testimonials can take your brand to the next level? We will explore how you can effectively use video testimonials to leverage and boost your sales, content strategy, and increase your CRM data.🤯
We will dig deeper into:
1. How to capture video testimonials that convert from your audience 🎥
2. How to leverage your testimonials to boost your sales 💲
3. How you can capture more CRM data to understand your audience better through video testimonials. 📊
Implicitly or explicitly all competing businesses employ a strategy to select a mix
of marketing resources. Formulating such competitive strategies fundamentally
involves recognizing relationships between elements of the marketing mix (e.g.,
price and product quality), as well as assessing competitive and market conditions
(i.e., industry structure in the language of economics).
Digital Transformation and IT Strategy Toolkit and TemplatesAurelien Domont, MBA
This Digital Transformation and IT Strategy Toolkit was created by ex-McKinsey, Deloitte and BCG Management Consultants, after more than 5,000 hours of work. It is considered the world's best & most comprehensive Digital Transformation and IT Strategy Toolkit. It includes all the Frameworks, Best Practices & Templates required to successfully undertake the Digital Transformation of your organization and define a robust IT Strategy.
Editable Toolkit to help you reuse our content: 700 Powerpoint slides | 35 Excel sheets | 84 minutes of Video training
This PowerPoint presentation is only a small preview of our Toolkits. For more details, visit www.domontconsulting.com
Structural Design Process: Step-by-Step Guide for BuildingsChandresh Chudasama
The structural design process is explained: Follow our step-by-step guide to understand building design intricacies and ensure structural integrity. Learn how to build wonderful buildings with the help of our detailed information. Learn how to create structures with durability and reliability and also gain insights on ways of managing structures.
Navigating the world of forex trading can be challenging, especially for beginners. To help you make an informed decision, we have comprehensively compared the best forex brokers in India for 2024. This article, reviewed by Top Forex Brokers Review, will cover featured award winners, the best forex brokers, featured offers, the best copy trading platforms, the best forex brokers for beginners, the best MetaTrader brokers, and recently updated reviews. We will focus on FP Markets, Black Bull, EightCap, IC Markets, and Octa.
At Techbox Square, in Singapore, we're not just creative web designers and developers, we're the driving force behind your brand identity. Contact us today.
Best practices for project execution and deliveryCLIVE MINCHIN
A select set of project management best practices to keep your project on-track, on-cost and aligned to scope. Many firms have don't have the necessary skills, diligence, methods and oversight of their projects; this leads to slippage, higher costs and longer timeframes. Often firms have a history of projects that simply failed to move the needle. These best practices will help your firm avoid these pitfalls but they require fortitude to apply.
Agency Managed Advisory Board As a Solution To Career Path Defining Business ...
SAP Integration With Excel - Advanced Guide
1. 1
SAP integration with Excel -
Advanced Guide
Summary
This document is a follow-up of ‘SAP integration with Excel - Basic Guide’. It documents how Excel can be
made to interface with SAP and perform data posting activities.
Perquisites:
Basic SAP ABAP knowledge is required. SAP terminologies and jargons are applied for brevity.
Review ‘SAP integration with Excel - Basic Guide, by Benedict Yong’, as it is the part 1 of this two-part
series.
Disclaimers:
Although the author and publisher have made every reasonable attempt to achieve complete accuracy of the
content, they assume no responsibility for errors or omissions. You should use this information as you see fit,
and at your own risk.
This publication is not affiliated with, sponsored by, or approved by SAP. Any trademarks, service marks,
product names or named features are assumed to be the property of their respective owners, and are used
only for reference.
2. SAP Excel Integration
2
Table of Contents
Business Requirements ........................................................................................................................... 3
System Architecture ................................................................................................................................ 5
Preparatory work in RFC FM.................................................................................................................... 6
Preparatory work in Excel VBA............................................................................................................... 12
Integration & Testing ............................................................................................................................. 14
Conclusion............................................................................................................................................ 16
Appendix .............................................................................................................................................. 17
Author Bio............................................................................................................................................. 23
Reference............................................................................................................................................. 24
3. SAP Excel Integration
3
Business Requirements
In an enterprise with SAP, there can be business units where sales order creation is minimal. Hence, there is
a requirement to create a streamlined user entry/retrieval interface.
It would be a dream come true to have sales order data input in Excel and have these data posted into SAP
at a click of a button and review them back again in Excel. In this document, we will go through how to create
a SAP RFC Function Module that can be called by an Excel VBA.
Base on the above, we will design a simple proof of concept.
Step 1: This is the Excel Sales Order Creation screen, with Sales Order information that will be posted.
Step 2: This is the Excel Screen after successful posting into SAP. SAP Sales Order number will be shown.
5. SAP Excel Integration
5
System Architecture
As the Excel Integration process comprises of various components and interactions, a 3-Tier Model-View-
Controller Framework should be applied to manage the complexity. (This is also applied in the Basic Guide)
3-Tier Model-View-Controller Framework
In the 3-Tier MVC Framework, there are
View/ Interface:The role focuseson userinteraction;collectinganddisplayinginformation.Inour
specificcase,thiswill be ourExcel anditsembeddedVBA.
Controller:The role focusesontransmittingandmanipulationof information.Inourspecificcase,
thiswill be ourSAPRFC FunctionModule.
Model:The role focusesondata storage and itsrelatedprocesses. Inourspecificcase,thiswillbe
the underlyingDatabase.
This document will now be divided into 2 sections:
Preparatory work in RFC FM – this explains how the Controller of the architecture is coded.
Preparatory work in Excel VBA – this explains how the View/Interface of the architecture is
scripted.
6. SAP Excel Integration
6
Preparatory work in RFC FM
The purpose of RFC FM/BAPI is to populate sales header and line items data into SAP backend.
This can be achieved by creating a wrapper RFC FM as “ZZZ_SO_BAPI_CREATE_N”. This RFC FM will
perform appropriate coordination and relay information to/from the standard BAPI
“BAPI_SALESORDER_CREATEFROMDAT2” & “BAPI_TRANSACTION_COMMIT”. The standard BAPI
“BAPI_SALESORDER_CREATEFROMDAT2” will generate a new sales order number after all checking is done;
while the “BAPI_TRANSACTION_COMMIT” actually post the document. In the case, where BAPI
“BAPI_SALESORDER_CREATEFROMDAT2” is ran but “BAPI_TRANSACTION_COMMIT” is not, the sales order
number will be exhausted.
7. SAP Excel Integration
7
At the specific mapping level, it is required for us to understand what are the fields required from the frontend
(i.e. Excel) and what are the variables to transfer to at the backend (i.e. Standard BAPI).
8. SAP Excel Integration
8
The wrapper RFC FM is designed to take in minimal data from its incoming interfaces (i.e. Excel VBA). This
is a good practice. The incoming parameters (imports) will take in flat type structures instead of table types.
The flat type structures include sales header data (i.e. SO_HEADER of type ZZSOHEADER) and line items
data (i.e. SO_ITEM1 and SO_ITEM2 of type ZSSOITEM). Once successfully posted, the system generated
Sales Order number will be relay back to the call interface.
Note: full code at appendix.
9. SAP Excel Integration
9
Definition of sales header data (i.e. SO_HEADER of type ZZSOHEADER)
Definition of line items data (i.e. SO_ITEM1 and SO_ITEM2 of type ZSSOITEM)
Note: there is more than one way to implement RFC Sales Order Creation. The above is one of the
possibilities. It should also be noted that Table objects transferring can be cumbersome between SAP and
VBA (it might be better with JAVA/C++/C#), to be safe we have chosen to transfer line items as flat type
structure instead of collection type table (i.e. in the TABLE parameter | the IMPORT paramater for Table-type
Structure).
10. SAP Excel Integration
10
Function Module Unit Testing is as per expectation. A Sales Order header and two line items information is
entered, and Sales Order number 13308 is generated.
Processing messages are as below:
12. SAP Excel Integration
12
Preparatory work in Excel VBA
To be able to perform scripting in Excel VBA, the Developer Tab needs to be turned on. (This is documented
in the Basic Guide)
The start of the script is to instantiate ActiveX Components “SAP LogonControl.1” and “SAP.Functions” as
per below.
13. SAP Excel Integration
13
The actual function call to “ZZZ_SO_BAPI_CREATE_N” is as per below.
Note: full script at appendix.
14. SAP Excel Integration
14
Integration & Testing
With both the Excel VBA scripting and SAP RFC FM coding completed, we can perform end-to-end testing.
We start with data entry to the customer code cell (=D6), customer reference cell (=D7), line item 1 row
(=C10:G10) and line item 2 row (=C11:G11).
Note that Sales Order number cell (=D4) will be updated by the system upon successful update.
Once the ‘Submit SO’ button is pressed, the Excel VBA will make connection with SAP RFC FM via the
ActiveX components. The SAP RFC FM (custom), will populate appropriate information to various structures
required by the standard BAPI, and invoke the BAPI. The SAP RFC FM finally relay the generated Sales
Order number back to the VBA. The VBA projects the returned information in the Sales Order number cell
(=D4), with a message box notification. Noting the Sales Order number is #13309.
16. SAP Excel Integration
16
Conclusion
The standard way of access SAP is via SAP GUI. However, it is technically possible to access SAP using
ActiveX control delivered by SAP. This greatly enriches the developer toolset to provide user a wide array of
connectivity options (such as Excel VBA, JAVA, C++, ASP/C#, JavaScript). From a business perspective,
an intuitive user interface greatly enhances user experiences and potentially reduces user training cost.
Based on this two-part series, we can observe the feasibility of writing and retrieving SAP information using
intuitive interfaces – which can then be further scaled into enterprise-level. However, one needs to be
mindful, integration always takes two parts to work: one part SAP; one part third-party.
17. SAP Excel Integration
17
Appendix
Full RFC FM ABAP
FUNCTION zzz_so_bapi_create_n.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(SO_HEADER) TYPE ZSSOHEADER
*" VALUE(SO_ITEMS1) TYPE ZSSOITEM
*" VALUE(SO_ITEMS2) TYPE ZSSOITEM
*" EXPORTING
*" VALUE(SD_DOC_NUMBER) LIKE BAPIVBELN-VBELN
*" VALUE(E_INFO) TYPE CHAR256
*" TABLES
*" RETURN STRUCTURE BAPIRET2 OPTIONAL
*"----------------------------------------------------------------------
DATA l_order_header_in LIKE bapisdhd1.
DATA t_order_partners TYPE STANDARD TABLE OF bapiparnr.
DATA t_order_items_in TYPE STANDARD TABLE OF bapisditm.
DATA t_order_schedules_in TYPE STANDARD TABLE OF bapischdl.
DATA t_order_schedules_inx TYPE STANDARD TABLE OF bapischdlx.
PERFORM add_header TABLES t_order_partners
CHANGING l_order_header_in
so_header.
PERFORM add_items TABLES t_order_items_in
t_order_schedules_in
t_order_schedules_inx
CHANGING so_items1.
PERFORM add_items TABLES t_order_items_in
t_order_schedules_in
t_order_schedules_inx
CHANGING so_items2.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = l_order_header_in
IMPORTING
salesdocument = sd_doc_number
TABLES
return = return
order_items_in = t_order_items_in
order_partners = t_order_partners
order_schedules_in = t_order_schedules_in
order_schedules_inx = t_order_schedules_inx.
PERFORM return_op TABLES return
CHANGING sd_doc_number
so_header-purch_no_c
e_info.
IF e_info+0(2) = 'S:'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
ENDFUNCTION.
18. SAP Excel Integration
18
*----------------------------------------------------------------------*
***INCLUDE LZZZ_MDF01 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form ADD_ITEMS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM add_items TABLES t_order_items_in STRUCTURE bapisditm
t_order_schedules_in STRUCTURE bapischdl
t_order_schedules_inx STRUCTURE bapischdlx
CHANGING so_item TYPE zssoitem.
CHECK so_item IS NOT INITIAL.
DATA l_order_items_in LIKE bapisditm.
DATA l_order_schedules_in LIKE bapischdl.
DATA l_order_schedules_inx LIKE bapischdlx.
l_order_items_in-itm_number = so_item-itm_number.
IF so_item-item_categ IS NOT INITIAL.
l_order_items_in-item_categ = so_item-item_categ.
ENDIF.
l_order_items_in-target_qty = so_item-quantity.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = so_item-material
IMPORTING
output = l_order_items_in-material.
l_order_items_in-plant = so_item-plant.
l_order_items_in-short_text = so_item-short_text.
APPEND l_order_items_in TO t_order_items_in.
l_order_schedules_in-itm_number = so_item-itm_number.
l_order_schedules_in-sched_line = '0001'.
l_order_schedules_in-req_qty = so_item-quantity.
APPEND l_order_schedules_in TO t_order_schedules_in.
l_order_schedules_inx-itm_number = so_item-itm_number.
l_order_schedules_inx-sched_line = so_item-sched_line.
l_order_schedules_inx-updateflag = 'X'.
l_order_schedules_inx-req_qty = 'X'.
APPEND l_order_schedules_inx TO t_order_schedules_inx.
ENDFORM. " ADD_ITEMS
*&---------------------------------------------------------------------*
*& Form ADD_HEADER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_ORDER_PARTNERS text
* <--P_L_ORDER_HEADER_IN text
* -->P_SO_HEADER text
*----------------------------------------------------------------------*
FORM add_header TABLES t_order_partners STRUCTURE bapiparnr
19. SAP Excel Integration
19
CHANGING l_order_header_in TYPE bapisdhd1
so_header TYPE zssoheader.
DATA l_order_partners LIKE bapiparnr.
MOVE-CORRESPONDING so_header TO l_order_header_in.
l_order_partners-partn_numb = so_header-partn_numb_sp.
l_order_partners-partn_role = 'AG'.
APPEND l_order_partners TO t_order_partners.
IF so_header-partn_numb_sh IS NOT INITIAL.
l_order_partners-partn_numb = so_header-partn_numb_sh.
l_order_partners-partn_role = 'WE'.
APPEND l_order_partners TO t_order_partners.
ENDIF.
ENDFORM. " ADD_HEADER
*&---------------------------------------------------------------------*
*& Form RETURN_OP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_RETURN text
* <--P_SD_DOC_NUMBER text
* <--P_E_INFO text
*----------------------------------------------------------------------*
FORM return_op TABLES return STRUCTURE bapiret2
CHANGING sd_doc_number
sd_po_number
e_info.
SHIFT sd_doc_number LEFT DELETING LEADING '0'.
DATA is_error TYPE boolean VALUE 0.
LOOP AT return.
IF return-type = 'E'.
is_error = 1.
CONCATENATE 'E:-' return-message
' (' sd_po_number ') '
INTO e_info.
EXIT.
ENDIF.
ENDLOOP.
IF is_error = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
CONCATENATE 'S:-Sales Order (' sd_doc_number ')'
' Created Successfully'
INTO e_info.
ENDIF.
ENDFORM. " RETURN_OP
20. SAP Excel Integration
20
Full Excel VBA Scripting
Sub Button1_Click()
'---------------------------------
' Declaration.
'---------------------------------
Dim LogonControl As SAPLogonCtrl.SAPLogonControl
Dim R3Connection As SAPLogonCtrl.Connection
Dim TableFactory As SAPTableFactory
Dim Functions As SAPFunctionsOCX.SAPFunctions
Dim objBAPIControl As Object
Dim oWB As Workbook
Dim oST As Worksheet
Set oWB = Application.ActiveWorkbook
Set oST = oWB.Worksheets(1)
'---------------------------------
' Initialize SAP ActiveX Control.
'---------------------------------
Set LogonControl = CreateObject("SAP.LogonControl.1")
Set R3Connection = LogonControl.NewConnection
Set objBAPIControl = CreateObject("SAP.Functions")
'--------------------
' Logon with prompt.
'--------------------
R3Connection.Client = "100" 'as per SAP Logon Pad
R3Connection.System = "SID" 'as per SAP Logon Pad
R3Connection.SystemNumber = "00" 'as per SAP Logon Pad
R3Connection.ApplicationServer = "XX.XX.XX.XX" 'as per SAP Logon Pad
R3Connection.User = "sapidx" 'as per SAP Logon Pad
R3Connection.Password = "sapid-passwdx" 'as per SAP Logon Pad
Application.StatusBar = "Start of Logging in"
SY_Subrc = R3Connection.Logon(0, SilentLogon)
If SY_Subrc <> True Then MsgBox "Logon failed": Exit Sub
Application.StatusBar = "Login Successful"
Set objBAPIControl.Connection = R3Connection
'---------------------------------
' Prepare a sales order.
'---------------------------------
Dim SO_Header As Object
21. SAP Excel Integration
21
Dim SO_Item1 As Object
Dim SO_Item2 As Object
Dim SO_Number As Object
Dim SO_Info As Object
Dim vRow, vCol As Integer
Set oBAPI = objBAPIControl.Add("ZZZ_SO_BAPI_CREATE_N")
Set SO_Header = oBAPI.Exports.Item("SO_HEADER")
Set SO_Item1 = oBAPI.Exports.Item("SO_ITEMS1")
Set SO_Item2 = oBAPI.Exports.Item("SO_ITEMS2")
Set SO_Number = oBAPI.Imports("SD_DOC_NUMBER")
Set SO_Info = oBAPI.Imports("E_INFO")
SO_Header.Value("DOC_TYPE") = "OR"
SO_Header.Value("SALES_ORG") = "3090"
SO_Header.Value("DISTR_CHAN") = "01"
SO_Header.Value("DIVISION") = "01"
SO_Header.Value("PURCH_NO_C") = Trim(oST.Cells(7, 4))
SO_Header.Value("PARTN_NUMB_SP") = Trim(oST.Cells(6, 4))
vRow = 10: vCol = 3
SO_Item1.Value("ITM_NUMBER") = Trim(oST.Cells(vRow, vCol + 0))
SO_Item1.Value("MATERIAL") = Trim(oST.Cells(vRow, vCol + 1))
SO_Item1.Value("QUANTITY") = Trim(oST.Cells(vRow, vCol + 2))
SO_Item1.Value("PLANT") = Trim(oST.Cells(vRow, vCol + 3))
SO_Item1.Value("SHORT_TEXT") = Trim(oST.Cells(vRow, vCol + 4))
vRow = 11: vCol = 3
SO_Item2.Value("ITM_NUMBER") = Trim(oST.Cells(vRow, vCol + 0))
SO_Item2.Value("MATERIAL") = Trim(oST.Cells(vRow, vCol + 1))
SO_Item2.Value("QUANTITY") = Trim(oST.Cells(vRow, vCol + 2))
SO_Item2.Value("PLANT") = Trim(oST.Cells(vRow, vCol + 3))
SO_Item2.Value("SHORT_TEXT") = Trim(oST.Cells(vRow, vCol + 4))
'---------------------------------
' Make the sales order.
'---------------------------------
Application.StatusBar = "Perform SAP Call"
SY_Subrc = oBAPI.Call
If SY_Subrc <> True Then MsgBox "Call failed!!": Exit Sub
If Left(SO_Info, 2) = "E:" Then MsgBox "Call failed: " & SO_Info: Exit Sub
MsgBox SO_Info
Application.StatusBar = "Perform SAP Call Successful"
Cells(4, 4).Value = SO_Number
22. SAP Excel Integration
22
Cells(4, 4).Interior.Color = vbGreen
'-----------------------------------
' Logoff SAP and close the control.
'-----------------------------------
R3Connection.Logoff
Set LogonControl = Nothing
Set objBAPIControl = Nothing
End Sub
23. SAP Excel Integration
23
Author Bio
Benedict Yong is a PMP/ITIL trained Project Consultant with 9+ years Finance domain experience (FICO,
COPA, BPC) and 3+ years of Logistics experiences (SD, MM, PS, CS). He holds four SAP® Functional
Certifications (Financial Accounting, Management Accounting, Sales, Procurement) and three Technical
Certifications (S/4 HANA Implementation Architect, S/4 Cloud Onboarding with SAP Activate, SAP
Business Intelligence 7.0).
He holds a Bachelor of Management and a Diploma in IT. He has worked in Banking,
Retail and Manufacturing industries, playing both in-house and external consultant
role.
He is situated in Singapore and is bilingual in English and Mandarin. He can be
contacted at benytx@gmail.com.
For people who are interested to have a holistic understanding of ERP, a PDF document will not be
enough. “ERP Made Simple” at Amazon might prove to be useful.
https://www.amazon.com/dp/B083C3X8YY
24. SAP Excel Integration
24
Reference
1. SAP Help - BAPI Framework
https://help.sap.com/doc/saphelp_46c/4.6C/en-
US/d8/44ca02ac3c11d189c60000e829fbbd/content.htm
2. SAP OSS – note 2256415 - Adaptation of RFC controls (Logon, Function, Table and BAPI) to use
SAP NetWeaver RFC Library
https://launchpad.support.sap.com/#/notes/2256415
3. SAP SDN – Common export parameter issues
https://blogs.sap.com/2014/04/27/activex-component-sapfunctions-with-export-parameter-string/
https://answers.sap.com/questions/529288/datatype-problem-with-sap-gui-75-pl5-unicode-activ.html
https://answers.sap.com/questions/10222185/activex-component-sapfunctions-with-export-
paramet.html