

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Using VBA macro to call an ABAP code
Please try using below script −
Dim sapConn As Object \Declaring a connection object Set sapConn = CreateObject("SAP.Functions") \Creating an ActiveX object sapConn.Connection.user = "username" sapConn.Connection.Password = "xxxx" sapConn.Connection.client = "client#" sapConn.Connection.ApplicationServer = "Application Server” sapConn.Connection.Language = "PT" If sapConn.Connection.Logon(0, True) <> True Then //Checking connection here MsgBox "Not able to login to SAP" Else MsgBox "Login Successful !!" End If Dim rfcAcctDocCheck As Object Dim oAcctHeader As Object Dim otAcctAR, otAcctGL, otAcctAP, otAcctAMT, otReturn As Object Set rfcAcctDocCheck = sapConn.Add("BAPI_ACC_DOCUMENT_CHECK") Set oAcctHeader = rfcAcctDocCheck.Exports("DOCUMENTHEADER") Set otAcctGL = rfcAcctDocCheck.Tables("ACCOUNTGL") Set otAcctAR = rfcAcctDocCheck.Tables("ACCOUNTRECEIVABLE") Set otAcctAP = rfcAcctDocCheck.Tables("ACCOUNTPAYABLE") Set otAcctAMT = rfcAcctDocCheck.Tables("CURRENCYAMOUNT") Set otReturn = rfcAcctDocCheck.Tables("RETURN") Dim qtLegs As Integer Dim dt, comp, tpDoc, docRef, tpAcct, acct, customer, vendor, _ curr, val, spLedger, ccenter, order As String Dim curLine As Integer For lin = 1 To UBound(reg) id = Format(tbPost.Cells(reg(lin).lin_ini, K_COL_ID), "0000000000") dt = getDate(tbPost.Cells(reg(lin).lin_ini, K_COL_DT)) comp = getCompanyCode(tbPost.Cells(reg(lin).lin_ini, K_COL_EMPR)) tpDoc = getDocumentType(tbPost.Cells(reg(lin).lin_ini, K_COL_TP_DOC)) docRef = tbPost.Cells(reg(lin).lin_ini, K_COL_DOC_REF) otAcctGL.freeTable otAcctAR.freeTable otAcctAP.freeTable otAcctAMT.freeTable oAcctHeader("USERNAME") = sapConn.Connection.user oAcctHeader("HEADER_TXT") = "Excel" oAcctHeader("COMP_CODE") = comp oAcctHeader("DOC_DATE") = dt oAcctHeader("PSTNG_DATE") = dt oAcctHeader("DOC_TYPE") = tpDoc oAcctHeader("REF_DOC_NO") = docRef otAcctAMT.Rows.Add otAcctAMT(otAcctAMT.Rows.Count, "ITEMNO_ACC") = Format(leg, "0000000000") otAcctAMT(otAcctAMT.Rows.Count, "CURRENCY") = curr otAcctAMT(otAcctAMT.Rows.Count, "AMT_BASE") = val Next If rfcAcctDocCheck.Call = False Then MsgBox rfcAcctDocCheck.Exception End If
- Related Questions & Answers
- Identify the program to edit an ABAP code
- Determining table or structure of an ABAP code
- Print screen using VBA in SAP
- Inserting rows in an empty table to test output of ABAP code
- Distinguish SAP ABAP code between clients
- Pseudo code to hide warning in SAP ABAP
- While changing Partner number, VBA code keeps running while interacting with SAP system
- Source code of ABAP reports without restriction
- Generating SAP ABAP code/ script from XML coming from an external application
- Sending an itab to SAP Spool using ABAP method
- Call screen on clicking the button in SAP ABAP
- Edit an ABAP Program using Transaction SE93, SE80
- How to pause an ABAP program?
- How to call RFC in SAP using an ETL job?
- How to send an error code using JSP to browser?
Advertisements