‎2007 Dec 14 10:46 AM
Hi,
Can any one please provide me a sample step by step code to call RFC FM and display values in excel sheet by using VBA. I'm very new to this, so can you also provide any more information to VBA will be very useful for me.
Thanks,
Kannan
‎2007 Dec 15 10:38 AM
Hi,
Here are the steps.
SM59 Transaction is used for Connection Establishment with Destination.
When you establish a connection to a client through a destination, the HTTP connection must first be entered in transaction SM59.
There are two types of HTTP connection in transaction SM59: Call transaction SM59 to display the different RFC destinations.
The HTTP connection to the external server (connection type G) and the HTTP connection to the R/3 system (connection type H) are different only in their logon procedures. Their technical settings are the same. To display the technical settings, double-click a connection.
You can choose from three tabs. Under Technical Settings, you can specify the following:
· Target Host: The host to which you want to connect.
Note that if you are using HTTPS as a protocol, you have to specify the full host name (with domain).
· Service No.: Here, you specify the port. The destination host must of course be configured in such a way that the specified port understands the corresponding protocol (HTTP or HTTPS). See Parameterizing the ICM and the ICM Server Cache.
· Path Prefix: At the time when the connection to this destination is initiated, the system inserts this sub-path before ~request_uri.
· HTTP Proxy Options: Here, you can configure a proxy for HTTP connections: You can determine the proxy host and service, as well as users and passwords for the HTTP connection.
The tab page Logon/Security will be different depending on whether you have selected a HTTP connection to an external server (connection type G) or a HTTP connection to an R/3 system (connection type H).
HTTP Connection to an External Server (Connection Type G)
Choose the connection you want to use. You can choose from the following logon procedures:
· No Logon: The server program does not request a user or password.
· Basic Authentication: The server program requests a user and password. Basic Authentication is a standard HTTP method for authenticating users. When a user logs on to the target system, he or she provides a user ID and password as authentication. This information is then sent in a header variable as a Base 64-encoded string to the server, through the HTTP connection.
· SSL Client Certificate: If you use client certificates for authentication, the client authentication is performed through the Secure Sockets Layer (SSL) protocol. In this case, you must also select the SSL Client PSE of the SAP Web AS that contains the relevant certificate for the authentication. The target system must handle the issuer of the SAP Web AS client certificate as a trusted system.
Under Logon/Security, you can also activate SSL to ensure that HTTPS is the protocol used (if you select SSL, make sure that the correct port is entered under Technical Settings). In the security transaction STRUST you can determine which type of SSL client is used. (Getting Started with the Trust Manager, Trust Manager).
The field Authorization for Destination has been implemented as an additional level of protection. We recommend that you specify a user and password for the RFC destination.
HTTP Connection to an R/3 System (Connection Type H)
Here, you can specify more settings for authentication in the target system.
The settings under Technical Settings and Special Options are the same as for connection type G. Under Logon/Security, the connection type H has additional logon procedures. As with external servers, you can activate and deactivate SSL and specify an authorization.
Because the target system is an SAP system, you can set the client and language for the logon as well as the user name and password. If you check Current User, you have to specify the password.
The following authentication procedures are available: Basic Authentication, SAP Standard, and SAP Trusted System, and SSL Client Certificate.
· HTTP Basic Authentication: Logon with user and password
· SAP Standard: This procedure uses an RFC logon procedure. The RFC Single Sign-On (SSO) procedure is valid within the one system. The same SAP user (client, language, and user name) is used for logon.
· SAP Trusted System: Trusted RFC logon to a different SAP system (see Trusted System: Maintaining Trust Relationships Between SAP Systems)).
· SSL Client Certificate: The SSL protocol enables you to use client certificates for the logon.
Type G/H (SM59)
Timeout:
When sending a HTTP request, you can use this parameter to specify the maximum response time for the connection.
HTTP Setting:
You can use the HTTP version to specify the protocol version of the HTTP request (HTTP 1.0 or 1.1).
Compression:
You can use this option to activate the gzip compression for the request body. This can only be activated in HTTP Version 1.1.
Compressed Response:
In the standard setting, the SAP Web Application Server sends the Accept Encoding field as a header field with the value gzip, if the application server can handle this compression. This notifies the partner that the caller can handle gzip decompression, and that the partner can send compressed data. If you want to prevent a compressed response being sent, choose the option No.
HTTP Cookie:
You can use this option to control the way received cookies are handled.
You can specify the following for cookies:
· Accept them automatically
· Reject them automatically
· Accept or reject them in a prompt
· Use a handler for the event IF_HTTP_CLIENT~EVENTKIND_HANDLE_COOKIE to process the cookies in the program.
· In the next section, you can read about the parallelization of requests.
Please check this online document.
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESDE2/BCFESDE2.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESDE5/BCFESDE5.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESRFC/BCFESRFC.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESDE4/BCFESDE4.pdf
Reward points if found helpful
Cheers,
Chandra Sekhar.
‎2007 Dec 15 11:18 AM
Dear Kannan,
Calling Remote Functions Locally
If you want to call a function module, which is registered as being remote in an SAP system, in the same SAP system, you have two options for making this call:
·As a remote call
·As a local call
The CALL FUNCTION statement and the parameter handling is different for both cases.
Remote Call:
·CALL FUNCTION...DESTINATION = 'NONE'
This is a remote call, even though DESTINATION = 'NONE' means that the remote function will run in the same system as the caller. As a remote call, the function module runs in its own roll area, and parameter values are handled as for other remote calls (described in Parameter Handling in Remote Calls.)
CALL FUNCTION Remotefunction
DESTINATION NONE
EXPORTING
F1 = a1
F2 = a2
TABLES
t1 = ITAB
EXCEPTIONS
...
Local Call:
This is a local call, even though the function module is registered as remote. The module does not run in a separate roll area, and is essentially like a normal function call. Parameter transfer is handled as for normal function modules. In particular, if the call leaves some EXPORTING parameters unspecified, it terminates abnormally.
CALL FUNCTION Remotefunction
EXPORTING
F1 = a1
F2 = a2
TABLES
t1 = ITAB
EXCEPTIONS
...
And regarding displaying values in excel sheet by using VBA, refer to the following link:
Displaying values in MS Excel using VBA.
Best Regards,
Rajesh
Please award points if found helpful.