‎2008 Jun 27 11:41 AM
hi
i wrote normal function module not remote enabled.
and i want call it asynchronously in the same system to achieve parallel processing.
how to do this?
‎2008 Jun 27 11:48 AM
Hi Marat,
Check below syntax and F1 help. I think u have to define ur FM as RFC. There is no difference in functionality as far as considered with in ur system by making the FM as RFC.
CALL FUNCTION funcion name IN BACKGROUND TASK.
Additions:
1. ... AS SEPARATE UNIT
2. ... DESTINATION dest
3. ... EXPORTING p1 = f1 ... pn = fn
4. ... TABLES p1 = itab1 ... pn = itabn
Effect
Flags the function module func to be run asynchronously. It is not executed at once, but the data passed with EXPORTING or TABLES is placed in a database table and the next COMMIT WORK executes it in another work process.
Note
This variant applies only as of Release 3.0, so both the client system and the server system must be Release 3.0 or higher.
Note
qRFC with Outbound Queue
This is an extension of tRFC. The tRFC is serialized using queues, ensuring that the sequence of LUWs required by the application is observed when the calls are sent.
For further information about qRFC, refer to the Serialized RFC: qRFC With Outbound Queue section of the SAP Library.
Addition 1
... AS SEPARATE UNIT
Effect
Executes the function module in a separate LUW under a new transaction ID.
Addition 2
... DESTINATION dest
Effect
Executes the function module externally as a Remote Function Call (RFC); dest can be a literal or a variable.
Depending on the specified destination, the function module is executed either in another R/3 System or as a C-implemented function module. Externally callable function modules must be flagged as such in the Function Builder (of the target system).
Since each destination defines its own program context, further calls to the same or different function modules with the same destination can access the local memory (global data) of these function modules.
Note
Note that a database commit occurs at each Remote Function Call (RFC). Consequently, you may not use Remote Function Calls between pairs of statements that open and close a database cursor (such as SELECT ... ENDSELECT).
Addition 3
... EXPORTING p1 = f1 ... pn = fn
Effect
EXPORTING passes values of fields and field strings from the calling program to the function module. In the function module, formal parameters are defined as import parameters. Default values must be assigned to all import parameters of the function module in the interface definition.
Addition 4
... TABLES p1 = itab1 ... pn = itabn
Effect
TABLES passes references to internal tables. All table parameters of the function module must contain values.
Notes
If several function module calls with the same destination are specified before COMMIT WORK, these normally form an LUW in the target system. Calls with the addition 1 are an exception to this rule - they each have their own LUW.
You cannot specify type 2 destinations (R/3 - R/2 connections).
(See Technical details and Administration transaction.)
Example
REPORT RS41503F.
/* This program performs a transactional RFC.
TABLES: SCUSTOM.
SELECT-OPTIONS: CUSTID FOR SCUSTOM-ID DEFAULT 1 TO 2.
PARAMETERS: DEST LIKE RFCDES-RFCDEST DEFAULT 'NONE',
MODE DEFAULT 'N',
TIME LIKE SY-UZEIT DEFAULT SY-UZEIT.
DATA: CUSTITAB TYPE TABLE OF CUST415,
TAMESS TYPE TABLE OF T100,
WA_CUSTITAB TYPE CUST415.
SELECT ID NAME TELEPHONE INTO CORRESPONDING FIELDS OF TABLE CUSTITAB
FROM SCUSTOM WHERE ID IN CUSTID ORDER BY ID.
PERFORM READ_CUSTITAB.
EDITOR-CALL FOR CUSTITAB TITLE 'Editor for table CUSTITAB'.
PERFORM READ_CUSTITAB.
CALL FUNCTION 'TRAIN415_RFC_CALLTRANSACTION'
IN BACKGROUND TASK
DESTINATION DEST
EXPORTING
TAMODE = MODE
TABLES
CUSTTAB = CUSTITAB.
CALL FUNCTION 'START_OF_BACKGROUNDTASK'
EXPORTING
STARTDATE = SY-DATUM
STARTTIME = TIME
EXCEPTIONS
OTHERS = 1.
IF SY-SUBRC = 1.
EXIT.
ENDIF.
COMMIT WORK.
CALL TRANSACTION 'SM58'.
----
FORM READ_CUSTITAB *
----
FORM READ_CUSTITAB.
WRITE: / 'System ID:', SY-SYSID.
SKIP.
LOOP AT CUSTITAB into WA_CUSTITAB
WRITE: / WA_CUSTITAB-ID, WA_CUSTITAB-NAME,
WA_CUSTITAB-TELEPHONE.
ENDLOOP.
ULINE.
ENDFORM.
Note
Authorization check
If the instance profile parameter 'auth/rfc_authority_check' is set (=1), the system automatically checks the RFC authorization. This is based on the function group of the function module that you are calling. If the authorization check fails, a runtime error is triggered. You can check the authorization in advance using the function module AUTHORITY_CHECK_RFC. If the RFC communication is within a single system and user context (that is, same client and same user ID), there is no authorization check. For further information, refer to the RFC authorization concept.
Note
If errors occur, you can refer to Typical RFC problems and solutions
Note
Runtime errors:
CALL_FUNCTION_NO_RECEIVER:
Data received for an unknown CPI-C connection.
CALL_FUNCTION_DEST_TYPE:
Destination type not allowed.
CALL_FUNCTION_NO_DEST:
Specified destination does not exist.
CALL_FUNCTION_NO_LB_DEST:
Specified destination (in load distribution mode) does not exist.
CALL_FUNCTION_TABINFO:
Data error (info internal table) in a Remote Function Call.
CALL_BACK_ENTRY_NOT_FOUND:
The called function module is not released for use in RFC.
CALL_FUNCTION_FIELD_NOT_FOUND:
The function parameter that you passed is not recognized on the recipient side.
RFC_NO_AUTHORITY:
The user does not have RFC authorization.
CALL_FUNCTION_SINGLE_LOGIN_REJ:
No authorization to log on as a trusted system. The error codes have the following meanings:
0) Valid security key but wrong logon data 1) Calling system is not a trusted system, or security key is invalid 2) User either does not have RFC authorization (authorization object S_RFCACL), or logged on as one of the protected users 'DDIC' or 'SAP*' 3) Timestamp of the logon data is invalid
CALL_FUNCTION_DESTINATION_NO_T:
Missing communication type (I for internal connection, 3 for R/3) in an asynchronous RFC
CALL_FUNCTION_NOT_REMOTE:
The function module called is not flagged as "RFC supported"
CALL_FUNCTION_REMOTE_ERROR:
An error occurred during the Remote Function Call. This has been logged in the target system.
CALL_FUNCTION_SIGNON_INCOMPL:
The logon data for the user is incomplete.
CALL_FUNCTION_SIGNON_INTRUDER:
You cannot log onto a target system using an internal call.
CALL_FUNCTION_SIGNON_INVALID:
External RFC without a valid user name.
CALL_FUNCTION_SIGNON_REJECTED:
Attempt to log onto a target system without a valid user name. The error code can have the following meanings:
1) Wrong password or invalid user ID
2) User locked
3) Too many logon attempts
4) Error in authorization buffer (internal error)
5) No external user check
6) Invalid user type
7) Validity period of user has expired
CALL_FUNCTION_SYSCALL_ONLY:
RFC without a valid user name only allowed when calling system function modules. For the meaning of the error codes, refer to CALL_FUNCTION_SINGLE_LOGIN_REJ.
CALL_FUNCTION_TABLE_NO_MEMORY:
No memory available for a table to be imported
CALL_FUNCTION_TASK_IN_USE:
Asynchronous RFC only: Task name already in use.
CALL_FUNCTION_TASK_YET_OPEN:
Asynchronous RFC only: The specified task is already open.
CALL_FUNCTION_SNC_ERROR:
Error reading the SNC information for the destination.
CALL_RPERF_SLOGIN_READ_ERROR:
No valid trusted system entry for the calling system.
CALL_RPERF_SLOGIN_AUTH_ERROR:
No trusted authorization for the RFC caller and trusted system.
Thanks,
Vinod.
Edited by: Vinod Reddy Vemuru on Jun 27, 2008 4:19 PM
‎2008 Jun 27 11:47 AM
for calling the function module asynchronously......the fm should be remote enabled other wise it will show the error that destination failure..so it is not possible to call it asynchronously with out remote enabled
‎2008 Jun 27 11:48 AM
Hi Marat,
Check below syntax and F1 help. I think u have to define ur FM as RFC. There is no difference in functionality as far as considered with in ur system by making the FM as RFC.
CALL FUNCTION funcion name IN BACKGROUND TASK.
Additions:
1. ... AS SEPARATE UNIT
2. ... DESTINATION dest
3. ... EXPORTING p1 = f1 ... pn = fn
4. ... TABLES p1 = itab1 ... pn = itabn
Effect
Flags the function module func to be run asynchronously. It is not executed at once, but the data passed with EXPORTING or TABLES is placed in a database table and the next COMMIT WORK executes it in another work process.
Note
This variant applies only as of Release 3.0, so both the client system and the server system must be Release 3.0 or higher.
Note
qRFC with Outbound Queue
This is an extension of tRFC. The tRFC is serialized using queues, ensuring that the sequence of LUWs required by the application is observed when the calls are sent.
For further information about qRFC, refer to the Serialized RFC: qRFC With Outbound Queue section of the SAP Library.
Addition 1
... AS SEPARATE UNIT
Effect
Executes the function module in a separate LUW under a new transaction ID.
Addition 2
... DESTINATION dest
Effect
Executes the function module externally as a Remote Function Call (RFC); dest can be a literal or a variable.
Depending on the specified destination, the function module is executed either in another R/3 System or as a C-implemented function module. Externally callable function modules must be flagged as such in the Function Builder (of the target system).
Since each destination defines its own program context, further calls to the same or different function modules with the same destination can access the local memory (global data) of these function modules.
Note
Note that a database commit occurs at each Remote Function Call (RFC). Consequently, you may not use Remote Function Calls between pairs of statements that open and close a database cursor (such as SELECT ... ENDSELECT).
Addition 3
... EXPORTING p1 = f1 ... pn = fn
Effect
EXPORTING passes values of fields and field strings from the calling program to the function module. In the function module, formal parameters are defined as import parameters. Default values must be assigned to all import parameters of the function module in the interface definition.
Addition 4
... TABLES p1 = itab1 ... pn = itabn
Effect
TABLES passes references to internal tables. All table parameters of the function module must contain values.
Notes
If several function module calls with the same destination are specified before COMMIT WORK, these normally form an LUW in the target system. Calls with the addition 1 are an exception to this rule - they each have their own LUW.
You cannot specify type 2 destinations (R/3 - R/2 connections).
(See Technical details and Administration transaction.)
Example
REPORT RS41503F.
/* This program performs a transactional RFC.
TABLES: SCUSTOM.
SELECT-OPTIONS: CUSTID FOR SCUSTOM-ID DEFAULT 1 TO 2.
PARAMETERS: DEST LIKE RFCDES-RFCDEST DEFAULT 'NONE',
MODE DEFAULT 'N',
TIME LIKE SY-UZEIT DEFAULT SY-UZEIT.
DATA: CUSTITAB TYPE TABLE OF CUST415,
TAMESS TYPE TABLE OF T100,
WA_CUSTITAB TYPE CUST415.
SELECT ID NAME TELEPHONE INTO CORRESPONDING FIELDS OF TABLE CUSTITAB
FROM SCUSTOM WHERE ID IN CUSTID ORDER BY ID.
PERFORM READ_CUSTITAB.
EDITOR-CALL FOR CUSTITAB TITLE 'Editor for table CUSTITAB'.
PERFORM READ_CUSTITAB.
CALL FUNCTION 'TRAIN415_RFC_CALLTRANSACTION'
IN BACKGROUND TASK
DESTINATION DEST
EXPORTING
TAMODE = MODE
TABLES
CUSTTAB = CUSTITAB.
CALL FUNCTION 'START_OF_BACKGROUNDTASK'
EXPORTING
STARTDATE = SY-DATUM
STARTTIME = TIME
EXCEPTIONS
OTHERS = 1.
IF SY-SUBRC = 1.
EXIT.
ENDIF.
COMMIT WORK.
CALL TRANSACTION 'SM58'.
----
FORM READ_CUSTITAB *
----
FORM READ_CUSTITAB.
WRITE: / 'System ID:', SY-SYSID.
SKIP.
LOOP AT CUSTITAB into WA_CUSTITAB
WRITE: / WA_CUSTITAB-ID, WA_CUSTITAB-NAME,
WA_CUSTITAB-TELEPHONE.
ENDLOOP.
ULINE.
ENDFORM.
Note
Authorization check
If the instance profile parameter 'auth/rfc_authority_check' is set (=1), the system automatically checks the RFC authorization. This is based on the function group of the function module that you are calling. If the authorization check fails, a runtime error is triggered. You can check the authorization in advance using the function module AUTHORITY_CHECK_RFC. If the RFC communication is within a single system and user context (that is, same client and same user ID), there is no authorization check. For further information, refer to the RFC authorization concept.
Note
If errors occur, you can refer to Typical RFC problems and solutions
Note
Runtime errors:
CALL_FUNCTION_NO_RECEIVER:
Data received for an unknown CPI-C connection.
CALL_FUNCTION_DEST_TYPE:
Destination type not allowed.
CALL_FUNCTION_NO_DEST:
Specified destination does not exist.
CALL_FUNCTION_NO_LB_DEST:
Specified destination (in load distribution mode) does not exist.
CALL_FUNCTION_TABINFO:
Data error (info internal table) in a Remote Function Call.
CALL_BACK_ENTRY_NOT_FOUND:
The called function module is not released for use in RFC.
CALL_FUNCTION_FIELD_NOT_FOUND:
The function parameter that you passed is not recognized on the recipient side.
RFC_NO_AUTHORITY:
The user does not have RFC authorization.
CALL_FUNCTION_SINGLE_LOGIN_REJ:
No authorization to log on as a trusted system. The error codes have the following meanings:
0) Valid security key but wrong logon data 1) Calling system is not a trusted system, or security key is invalid 2) User either does not have RFC authorization (authorization object S_RFCACL), or logged on as one of the protected users 'DDIC' or 'SAP*' 3) Timestamp of the logon data is invalid
CALL_FUNCTION_DESTINATION_NO_T:
Missing communication type (I for internal connection, 3 for R/3) in an asynchronous RFC
CALL_FUNCTION_NOT_REMOTE:
The function module called is not flagged as "RFC supported"
CALL_FUNCTION_REMOTE_ERROR:
An error occurred during the Remote Function Call. This has been logged in the target system.
CALL_FUNCTION_SIGNON_INCOMPL:
The logon data for the user is incomplete.
CALL_FUNCTION_SIGNON_INTRUDER:
You cannot log onto a target system using an internal call.
CALL_FUNCTION_SIGNON_INVALID:
External RFC without a valid user name.
CALL_FUNCTION_SIGNON_REJECTED:
Attempt to log onto a target system without a valid user name. The error code can have the following meanings:
1) Wrong password or invalid user ID
2) User locked
3) Too many logon attempts
4) Error in authorization buffer (internal error)
5) No external user check
6) Invalid user type
7) Validity period of user has expired
CALL_FUNCTION_SYSCALL_ONLY:
RFC without a valid user name only allowed when calling system function modules. For the meaning of the error codes, refer to CALL_FUNCTION_SINGLE_LOGIN_REJ.
CALL_FUNCTION_TABLE_NO_MEMORY:
No memory available for a table to be imported
CALL_FUNCTION_TASK_IN_USE:
Asynchronous RFC only: Task name already in use.
CALL_FUNCTION_TASK_YET_OPEN:
Asynchronous RFC only: The specified task is already open.
CALL_FUNCTION_SNC_ERROR:
Error reading the SNC information for the destination.
CALL_RPERF_SLOGIN_READ_ERROR:
No valid trusted system entry for the calling system.
CALL_RPERF_SLOGIN_AUTH_ERROR:
No trusted authorization for the RFC caller and trusted system.
Thanks,
Vinod.
Edited by: Vinod Reddy Vemuru on Jun 27, 2008 4:19 PM
‎2008 Jun 27 11:49 AM
You need to make the FM as RFC. otherwise it will not be processed asynchronously.
refer the documet for further help
check under this
Prerequisites for Parallel Processinghttp://help.sap.com/saphelp_nw04/helpdata/en/22/0425c6488911d189490000e829fbbd/content.htm
‎2008 Jun 27 11:53 AM
Hi Marat
greetings.
check the following.....may be of yr help.
To be able to call a function module in an update work process, you must flag it in the Function Builder. When you create the function module, set the Process Type attribute to one of the following values:
Update with immediate start
Set this option for high priority ("V1") functions that run in a shared (SAP LUW). These functions can be restarted by the update task in case of errors.
Update w. imm. start, no restart
Set this option for high priority ("V1") functions that run in a shared (SAP LUW). These functions may not be restarted by the update task.
Update with delayed start
Set this option for low priority ("V2") functions that run in their own update transactions. These functions can be restarted by the update task in case of errors.
reward points,if helpful
prashant tiwari
‎2008 Jun 27 11:55 AM
In your main program that calls this Function Module
use FM 'ENQUEUE_ES_PROG' to lock the program
use FM 'SPBT_INITIALIZE' to initialise the paralell processing.
Call your function module
get the time management records
call function 'ZGET_Data'
starting new task w_task1
destination in group p_srvgrp
performing come_back on end of task
exporting
p_pernr = i_pa0000-pernr............
Your function module will need to be remote enabled and start immediatly.
use FM DEQUEUE_ES_PROG to release the program
Hopefully this helps.
‎2008 Jun 27 11:56 AM
In your main program that calls this Function Module
use FM 'ENQUEUE_ES_PROG' to lock the program
use FM 'SPBT_INITIALIZE' to initialise the paralell processing.
Call your function module
get the time management records
call function 'ZGET_Data'
starting new task w_task1
destination in group p_srvgrp
performing come_back on end of task
exporting
p_pernr = i_pa0000-pernr............
Your function module will need to be remote enabled and start immediatly.
use FM DEQUEUE_ES_PROG to release the program
Hopefully this helps.