SAP and VBA (Visual Basic for Applications)

New Site Address: http://abap.mirrorz.com



Home

Definitions
OK Code Values
Other Useful Tips
SAP and ABAP Links
SAP Functions
SAP Reports
SAP Tables
Source Code
Transaction Codes

Site Map (Index)

ABAP Keyword Help


SAP and VBA (Visual Basic for Applications)

These Excel files contain a macro that will retrieve data from an SAP system. Feel free to use the macro however you feel. There is no warranty that this macro will work for you. The original macro was developed and tested using a 3.1H system, and the 4.6 version was provided by Clayton Mergen.

"
The Excel macro to extract data from SAP has been updated (the 4.6 version)
	
If you are having trouble getting the excel examples to work, the following notes from 
Yoherman may help.

To Make your excel work with SAP RFC :       
1. For Windows 95/OSR2 you must install Winsock Ver. 2 
     Download from Microsoft if you don't have it       
2. You must have DLL file :        
     a. Microsoft Foundation Class 4.2 : MFC42.dll  > Owner : Microsoft     
     b. Microsoft Visual C++ Runtime Library : MSVCIRT.dll,and
	MSVCP60.dll
	 Owner : Microsoft                  
     c. SAP RFC library : LIBRFC32.dll                  
3. You must have SAP ActiveX and register :            
     a. WDTAOCX.ocx                 
     b. WDTLOG.ocx                  
     c. WDTFUNCS.ocx                
All file tested and work  at 3.1I and 4.6X    
3.1 Version of Excel macro -
4.6D version of excel worksheet and macro -

The following files provide a Microsoft Access example of retrieving data from SAP. This code was developed by Pierre Johansson, with some input by me, and is based on the Excel code above.

Access code as a text file -
Access Database with code -

Here is an example of a call transaction using Excel, and calling transaction SE16.

Please look at the notes below for some other comments. As it stands, the transaction call is not useful, other than as an example. For example, the excel sample that I have attached calls SE16 to display KNA1. The list that is created (of customers) is not returned to excel. All that is returned to excel is a message indicating the success or failure of the transaction.

NOTE: This example makes a call to SE16, to display table KNA1. All that is returned from the CALL TRANSACTION is the message that appears on the botton line of the SAP screen (if you were doing the transaction from SAP).

NOTE: The results of the transaction are not shown. The transaction is executed, and the message result is returned. This means that this is not suitable for calling transactions that return data that you want to use.

If you want to see the results of a transaction (ie the transaction runs a report) you should do it some other way. A possible way would be to write an RFC enabled function in SAP that would take a report and its parameters as input, and it would send back an internal table with the results of the report.

Performing a Call Transaction via Excel (tested with 4.6D) -

New Site Address: http://abap.mirrorz.com


Send any hints or tips to ABAP Hints & Tips .
All submissions will be recognized along with the tip.

Get a cool web address
Free subdomains from
ShortURL.com