We have added search box. Key in SAP issue keyword to search
TopBottom

Announcement: wanna exchange links? contact me at sapchatroom@gmail.com.

[sap-dev] BAPIs of BO GeneralLedger: Export to Excel

Posted by Admin at
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

Question from Tom82 on Sep 19 at 5:58 AM
Dear all,

I am currently trying to write a VBA code in Excel in order to extract financial data from our SAP system to Excel. For this I wrote the below stated code. I would like to use the BAPI GetGLAccountPeriodBalances from the business object GeneralLedger. But I do not know how to fill the cells in Excel with the data. There is always an error when I try to fill the Excel cells with the data from the export parameters (almost at the end of the code). Could anyone of you please tell me how I can extract the period balance from the GL Account to Excel? Thank you in advance!

Tom82

Sub RetrieveSAPData()

'Declaration of objects and variables

Dim oBAPICtrl As Object
Dim oGeneralLedger As Object
Dim oCompanyCode As Variant
Dim oGLAccount As Variant
Dim oFiscalYear As Variant
Dim oCurrencyType As Variant
Dim oReturn As Object
Dim oAccountBalances As Object

'creation of the BAPI ActiveX Control object

Set oBAPICtrl = CreateObject("SAP.BAPI.1")


'SAP Logon

oBAPICtrl.Connection.Logon

If oBAPICtrl.Connection.Logon(1, False) = True Then
MsgBox ("SAP Logon erfolgreich")
Else: MsgBox ("SAP Logon fehlgeschlagen")
End If

'creation of SAP business object GeneralLedger

Set oGeneralLedger = oBAPICtrl.GetSAPObject("GeneralLedger")

'declaration of the export parameters

Set oReturn = oBAPICtrl.DimAs(oGeneralLedger, "GetGLAccountPeriodBalances", "Return")
Set oAccountBalances = oBAPICtrl.DimAs(oGeneralLedger, "GetGLAccountPeriodBalances", "AccountBalances")

'data for the import parameters

oCompanyCode = Range("F1")
oGLAccount = Range("F2")
oFiscalYear = Range("F3")
oCurrencyType = Range("F4")

'Calling the BAPI

oGeneralLedger.GetGLAccountPeriodBalances CompanyCode:=oCompanyCode, GLacct:=oGLAccount, _
Fiscalyear:=oFiscalYear, CurrencyType:=oCurrencyType, Return:=oReturn, AccountBalances:=oAccountBalances

'write the data from export parameters to the Excel sheet
Range("F8").Value = oReturn
Range("F9").Value = oAccountBalances

'SAP Logoff

oBAPICtrl.Connection.Logoff


End Sub
 
Reply to this email to post your response.
 
__.____._
Manage Settings | Unsubscribe | Create FAQ | Send Feedback
  
Copyright © 2013 Ziff Davis, Inc. and message author.
Ziff Davis, Inc. 28 E 28th Street New York, NY 10016
Tom82  
 
View this online
Ask a new question
 
In the Spotlight
Have a technical question? Need to find IT solutions? Ask your peers in the Toolbox for IT community.

_.____.__

0 comments:

Post a Comment

T r a n s l a t e to your language