Wednesday, 26 November 2014

what is RFC?


What is RFC?


For business applications, it is necessary to communicate and exchange information (in pre-defined formats) with other systems.Hence, there are well defined mechanisms to enable this communication. SAP has also provided us with such mechanism called RFC, which stands for 'Remote Function Call'.
 

RFC is a SAP protocol to handle communications between systems to simplify the related programming. It is the process of calling a function module which is residing in a different machine from the caller program. RFCs can be used to call a different program in the same machine as well, but usually it is used when 'calling' and 'called' function modules/ programs are running on separate machines.
 

In SAP, RFC Interface system is used for setting-up RFC connections between different SAP systems, and also between an SAP and an external (non-SAP) system.
 

Must Know Details About RFC

  • SAP Uses CPIC (Common Programming Interface for Communication) Protocol to transfer data between Systems. It is SAP Specific protocol. Remote Function Call (RFC) is a communications interface based on CPI-C, but with more functions and easier for application programmers to use
  • The RFC library functions support the C programming language and Visual Basic (on Windows platforms)
  • RFC connections can always be used across the entire system.This means that an RFC connection you have defined in client 000 can also be used from client 100 (without any difference).
  • RFC is the protocol for calling special subroutines (function modules) over the network. Function modules are comparable with C functions or PASCAL procedures. They have a defined interface through which data, tables and return codes can be exchanged. Function modules are managed in the R/3 System in their own function library, called the Function Builder.
  • The Function Builder (transaction SM37) provides application programmers with a useful environment for programming, documenting and testing function modules that can be called locally as well as remotely. The R/3 System automatically generates the additional code (RFC stub) needed for remote calls.
  • You maintain the parameters for RFC connections using transaction SM59. The R/3 System is also delivered with an RFC-SDK (Software Development Kit) that uses extensive C libraries to allow external programs to be connected to the R/3 System.
  • The only difference between a remote call of a function module to another server and a local call is a special parameter (destination) that specifies the target server on which the program is to be executed.

The RFC Advantages:


RFC helps to reduce the efforts of programmers, by letting them avoid the re-development of modules and methods at remote systems. It is capable enough to:
  • Convert the data into the format understandable by the remote (target) system.
  • Convert the data into the format understandable by the remote (target) system.
  • Call up certain routines which are necessary to start communication with remote system.
  • Handle errors that might occur in the process of communication.

Types of RFC:



Synchronous


requires both the systems (client and server) to be available at the time of communication or data transfer. It is the most common type and is required when result is required immediately after the execution of sRFC.

sRFC is a means of communication between systems where acknowledgements are required. The resources of the Source System wait at the target system and ensure that they deliver the message/data with ACKD. The Data is consistent and reliable for communication.

The issue is if the target system is not available, the source system resources wait until target system is available. This may lead to the Processes of source system to go into Sleep/RFC/CPIC Mode at target systems and hence blocks these resources.

Used for
  • For communication between systems
  • For communication between SAP Web Application Server to SAP GUI

Asynchronous

It is communication between systems where acknowledgements are not required (it is similar to post card delivery).It doesn't require both the systems to be available at the time of execution and the result is not immediately required to be sent back to calling system.
The Source System resource does not waitfor the target system as they deliver the message/data without waiting for any acknowledgement. It is not reliable for communication sincedata may be lost if the target system is not available. Used for -
  • For communication between systems
  • For parallel processing

Transactional

 It is a special form of aRFC. Transactional RFC ensures transaction-like handling of processing steps that were originally autonomous.
Transactional RFC is an asynchronous communication method that executes the called function module in the RFC server only once, even if the data is sent multiple times due to some network issue. The remote system need not be available at the time when the RFC client program is executing a tRFC. The tRFC component stores the called RFC function, together with the corresponding data, in the SAP database under a unique transaction ID (TID). tRFC is similar to aRFC as it does not wait at the target system (Similar to a registered post). If the system is not available, it will write the Data into aRFC Tables with a transaction ID (SM58) which is picked by the scheduler RSARFCSE (which runs for every 60 seconds). Used For-
  • Extension of Asynchronous RFC
  • For secure communication between systems

Queued

 
Queued RFC is an extension of tRFC. It also ensures that individual steps are processed in sequence.
To guarantee that multiple LUWs (Logical Unit of Work/ Transaction) are processed in the order specified by the application. tRFC can be serialized using queues (inbound and outbound queues). Hence the name queued RFC (qRFC). Used For-
  • Extension of the Transactional RFC
  • For a defined processing sequence
  • Implementation of qRFC is recommended if you want to guarantee that several transactions are processed in a predefined order.

Types of RFC Connections – SM59



Type 3 - entries specify connection between ABAP systems. Here, we must specify the host name / IP address. You can, however, specify logon information if desired. This is applicable for both type of RFCs, between ABAP systems and external calls to ABAP systems
Type I - entries specify ABAP systems connected to the same data base as the current system. These entries are pre-defined and cannot be modified. Example entry name: ws0015_K18_24
  • ws0015=host name
  • K18=system name (data base name)
  • 24=TCP-service name
  Type T - destinations are connections to external programs that use the RFC API to receive RFCs. The activation type can be either Start orRegistration. If it is Start, you must specify the host name and the pathname of the program to be started.

how to configure and test RFC?

How to Configure and Test RFC.

This tutorial is divided into 4 sections
  1. Setup a RFC connection
  2. Trusted RFC connection
  3. Testing a RFC connection
  4. Error Resolution

Procedure to setup an RFC connection:

Enter Transaction Code SM59


In the SM59 screen, you can navigate through already created RFCs connection with the help of option tree, which is a menu based method to organize all the connections on the basis of categories.
 

Click the  'CREATE' button. In the next screen , Enter -
  • RFC Destination – Name of Destination (could be Target System ID or anything relevant)
  • Connection Type – here we choose one of the types (as explained previously) of RFC connections as per requirements.
  • Description – This is a short informative description, probably to explain the purpose of connection.

After you'SAVE'the connection, the system will take you to 'Technical Settings' tab, where we provide the following information:
  • Target Host– Here we provide the complete hostname or IP address of the target system.
  • System Number – This is the system number of the target SAP system.
  • Click Save

In the 'Logon and Security'  Tab, Enter Target System information
  • Language – As per the target system's language
  • Client – In SAP we never logon to a system, there has to be a particular client always, therefore we need to specify client number here for correct execution.
  • User ID and Password – preferably not to be your own login ID, there should be some generic ID so that the connection should not be affected by constantly changing end-user IDs or passwords. Mostly, a user of type 'System' or 'Communication' is used here. Please note that this is the User ID for the target system and not the source system where we are creating this connection.

Click Save. RFC connection is ready for use
Note: By default a connection is defined as aRFC. To define a connection as tRFC or qRFC go to Menu Bar -> Destination aRFC options / tRFC options ; provide inputs as per requirements. To define qRFC , use the special options tab.

Trusted RFC connection


There is an option to make the RFC connection as 'Trusted'. Once selected, the calling (trusted) system doesn't require a password to connect with target (trusting) system.

Following are the advantages for using trusted channels:
  • Cross-system Single-Sign-On facility
  • Password does not need to be sent across the network
  • Timeout mechanism for the logon data prevents misuse.
  • Prevents the mishandling of logon data because of the time-out mechanism.
  • User-specific logon details of the calling/trusted system is checked.
The RFC users must have the required authorizations in the trusting system (authorization object S_RFCACL).Trusted connections are mostly used to connect SAP Solution Manager Systems with other SAP systems (satellites)

Testing the RFC Connection

After the RFCs are created (or sometimes in case of already existing RFCs) we need to test, whether the connection is established successfully or not.
 

As shown above we go to SM59 to choose the RFC connection to be tested and then we expand drop down menu - "Utilities->Test->…". We have three options:

Connection test -> This attempts to make a connection with remote system and hence validates IP address / Hostname and other connection details. If both systems are not able to connect, it throws an error. On success it displays the table with response times. This test is just to check if the calling system is able to reach the remote system.
 


Authorization Test -> It is used to validate the User ID and Password (provided under 'logon and security' tab for the target system) and also the authorizations that are provided. If test is successful, then same screen will appear as shown above for the connection test.

Unicode Test -> It is to check if the Target system is a Unicode or not.

Remote Logon –>This is also a kind of connection test, in which a new session of the target system is opened, and we need to specify a login ID and Password (if not already mentioned under 'Logon and Security' tab). If the user is of type 'Dialog' then a dialog session is created. To justify the successful connection test, output will be the response times for the communication packets, else error message will appear.
 



What went wrong?

If somehow the RFC connection is not established successfully, we can check the logs (to analyze the issue) at OS level in the 'WORK' director. There we can find the log files with the naming convention as "dev_rfc<sequence no.>" and the error description can be read from such files.
 

client create copy and delete at os level

Client created at os level.
1. Create a control file named as createclient.CTL and save some text in this file like...

Client create
Client= client number
Select*

And save this file in bin  directory.
Full path use/sap/trans/bin

2. Execute this file in command prompt using command

R3trans -w createclient.log -u1 createclient.ctl

Client will created by default in T000 table.

To check client create process run command
Tail -f  createclient.CTL

Delete client at os  level :


1. Create a control file named as delclient.CTL and save some text in this file like...

Client delete
Client= client number
Select*

And save this file in bin  directory.
Full path use/sap/trans/bin

2. Execute this file in command prompt using command

R3trans -w delclient.log -u1 delclient.ctl

Client will be deleted from the table T000.

To check client delete process run the command
Tail -f  createclient.CTLCTL

Client copy through os level :



1. Create a control file named as copyclient.CTL and save someCreate client in this file like...

Client copy
Source Client= client numbernumber
Target client= client number
Select * from moff where mandt= client no

And save this file in bin  directory.
Full path use/sap/trans/bin

2. Execute this file in command prompt using command

R3trans -w clientcopy.log -u1 clientcopy.ctl

Client will be copied from source to target.

To check client copy process run command
Tail -f  client copy.CTL

Tuesday, 25 November 2014

how to create client in sap

What is the Client?


The Client is a 'Customer'. We can say that each customer maps to one client. Within one SAP instance, a number of Clients can be created. No need to install separate software's for each and every customer.It provides isolation ,one client cannot see the data of other client.

As depicted above 100 and 200 clients exist under one roof. We can create a number of clients in SAP Application (from 000 to 999)

What does client contain?
  1. Application Data- Application data is the data that are stored in the database tables.
  2. Customizing Data - Customizing data is data created by customers when they customize their systems
  3. User Master Record- A user master record defines the authorizations assigned to a user. Basis consultants are responsible for maintaining the user master record and assigning authorizations.

Advantages of Client concept :-
  1. Clients enable SAP SAS providers to install a small number of SAP Systems, but still cater to a large number of customers.
  2. Costs are not only saved by sharing hardware and software but multiple customers also use the same application solution, including administration and support.
  3. Clients help establish your SAP landscape. For instance , you can have a client for the development team , a client for a test team and a production client.

SAP comes with three "standard clients" :-
  1. 000
  2. 001
  3. 066

000 Client :- We can find this client in the system as soon as we install SAP r/3 software. This is called master client. Client 000 contains a simple organizational structure of a test company and includes parameters for all applications, standard settings, and configurations for the control of standard transactions and examples to be used in many different profiles of the business applications. It contains client independent data.

001 Client :- This client is a copy of the 000 client including the test company. This client's settings are client-independent if it is configured or customized. People normally use 001 client to create a new client.

066 Client :- This client is called early watch client. The SAP earlywatch alert is a diagnosis service, for solution monitoring of SAP and non-SAP systems in the SAP Solution Manager. Alert may contain Performance issue, average response time, current system load, Database administration,etc..

How to create a new client ?


Theoretically we can create clients from 000 to 999.But maintenance of such a large number of clients becomes a challenge.

Step 1) Execute T-Code SCC4

Step 2) . It will bring you to the initial screen of SAP clients.

Click New Entry to make a new SAP Client

Step 3)
  1. Enter basic details as given below.
  • Client number & description
  • City to which client Belongs (etc, NY-New York)
  • Logical system may be <SID>CLNT<Client Number>
  • Std Currency may be (etc EUR)
  • Client roles may be Customizing,Demo,Training/Education,Production,etc..
  1. Enter your client specific data and set permission for the clients as per your requirement
  2. Save
  3. Press F3 to come back to SCC4

Step 4) New client will be there in the list.Here we have created client 100.

client copy

Client Copy


We can generate a blank client with SCC4.But how to fill the data in the client ?"Answer is the client copy."

Client copy means "transferring client specific data" within same instance(SID) or between different instances(SID).

Client copy can be performed with three different methods -
  1. Local client copy.
  2. Remote client copy.
  3. Client Import/Export.
Below brief details are given about client copy methods.

Local Client Copy :- This method is used to copy client within the same instance (SID).It is done by T-code SCCL.
ClientCopysameSID

Remote Client Copy-This method is used to copy client between different instances(SID).It is performed by T-code SCC9.
ClientCopyDifferentSID

Client Import/Export:- This method is used to copy client between different instances(SID).It is performed by T-code SCC8


Client Copy Pre-steps


To avoid data inconsistencies there are few pre-steps to be performed before starting client copy:-

1) Disconnect and lock business users(SU10).You can end the session of active users in the system through SM04. Once all users are logged out , check that no cancelled or pending update requests exists in the system.

 2) Suspend all background jobs
  • Execute SE38 as given below.


  • Fill program name with "BTCTRNS1" as above figure.
  •  Press Execute.


3)  For a local copy , system must have enough space in the database or tablespace .
For remote copy, target system must have enough space in the database or tablespace. Check space using Tx DB02.



4) To avoid inconsistencies during client copy users should not be allowed to work in source client.

5) rdisp/max_wprun_time parameter should be changed to 2000 second as a SAP recommendation . Although you use parallel processes and schedule job in background , dialog processes will be used.

Local Client Copy

Local client copy is performed using Tcode SCCL. 
Scenario:-
  • Source Instance & client := DKM-000
  • Target Instance & client := DKM-202

Step 1) Create an entry for your new target client using SCC4 . In our scenario, we will create client 202 in DKM system.Log on to this newly created target client (DKM-202) with user SAP* and default password pass.

Step 2) Excute T-code SCCL.


Step 3)
  • Select your desired profile
  • Enter Source client.
  • Enter Description



Step 4) By default Client Copy is executed as a single process. Single process will take a lot of time.We will distribute workload of single process to parallel(multiple) processes which will reduce time in copying a client.
  1. Select Goto from menubar.
  2. Select Parallel Process.Parallel processes are used to exploit the capacity of database better



Step 5) Always execute long running processes in background mode rather than foreground/dialog mode. Infact, some  processes run more quickly in background.


Step 6) The client copy logs are available in SCC3 . Status - "Successfully Completed" means client copy is completed.

Remote Client Copy:-

This technique uses Remote function call. You can view RFC from SM59. This technique depends on the network ,so network connectivity must be strong enough.

Scenario:-
Source Instance & client := BD1-101
Target Instance & client := DKM-202
Step 1) Log on to the target system. Here we will log on to DKM system. Create a new target client entry(202) using SCC4. Log on to this new target client with user SAP* and default password "pass".Here we will log on to DKM-200 system.

Step 2) Execute Transaction Code SCC9.

Step 3) Fill the basic details as per your requirement.

Step 4) Select Parallel Process.Parallel processes are used to exploit the capacity of database better.

Step 5) Schedule the client copy in background

Step 6) The client copy logs are available in SCC3 as given below.

 


Client Import/Export

For large database it is recommended to use client import/export instead of remote client copy.
Scenario:-
Source Instance & client := PKT-300
Target Instance & client := DKM-202
This technique always starts with client export step.

Note:- You must have enough space in the /usr/sap/trans_SID file system to perform the client export.

How to export client?;

Step 1) Log on to the target system(DKM). Create an entry for your new target client using SCC4 .Log on to the source system / source client(PKT).

Step 2)Before you import a Client you need to export.Export is nothing but transferring data files and co-files from source system's database to target system's import buffer.Execute T-code SCC8.

 Step 3) 
  • Select profile
  • Choose target system.


Step 4) Schedule the export in background

Step 5) Once the job is executed  data files and co-files of profiles from PKT system's database are transferred to DKM system's import buffer.Once we will import request in DKM only then it will be reflected in database of DKM system.

Depending on the chosen export profile there can be up to 3 transport requests created :
  • Request PKTKO00151 will hold the cross client data,
  • Request  PKTKT00151 will hold the client dependent data,
  • Request  PKTKX00151 will also hold some client dependent data.

How to import the client? 

Step 1) Log on to the newly created target client(DKM-202) using SAP* and password pass.

Step 2) Start the STMS_IMPORT transaction

As shown below , import queue will open

Step 2) Select the transport requests generated by client export .Import theses transport requests on the target client.

The transport requests should be imported in the following sequence :
  1. Request PKTKO00151
  2. Request  PKTKT00151
  3. Request  PKTKX00151
The system automatically detects these are client export transport requests and automatically performs the import of the 3 requests.
The import logs can be seen in STMS_IMPORT.

Step 3) Post import phase:- 
Once the import is done, execute SCC7  to perform the post client import actions,

Schedule the post import job in background.
Step 4. Run t code SCC3 to checks client copy logs.

how to delete client in sap

Client delete :
1. Login R3 syatem with
Client000
User sap*
Password PASS

2. Run t coPASSSCC5.



Step 2)  Click on "delete in background" to run client deletion as background job.You can also check option "Delete entry from T000" table.


Table "T000"  contains clients' entry which we have created in SCC4.


Step 3) Check status of  client deletion process using  SM50.


Workprocess overview will open. "BGD" denotes background workprocess.


deleted Once complete. Client will be deleteddeleted
Client deletion post steps:
1 run SE16 and delete the entry from the table T000 .
2. In br tools run sapreorg to free the memory of deleting client.