2006 Jun 12 8:48 AM
Hi,
In an ARFC how we will define a return subroutine?
call function 'Z_RFC_EXEC'
starting new task g_task_name
destination in group us_srvgrp
performing <b>task_return</b> on end of taskdo we have to define the subroutine task_return in the main program ? if so how to build it ?
Could we put an ARFC inside an OPEN CURSOR and CLOSE CURSOR ?
rgds,
abhilash
2006 Jun 12 8:59 AM
Hi abhilash,
1 do we have to define the subroutine task_return in the main program ? if so how to build it ?
Yes, in your se38 program itself.
in this manner.
<b>FORM task_return USING TASKNAME</b>
2. This code may help u (just copy paste_
3.
report abc.
DATA: INFO LIKE RFCSI,
Result of the RFC_SYSTEM_INFO function
MSG(80) VALUE SPACE,
Exception handling
RET_SUBRC like SY-SUBRC.
SY-SUBRC handling
CALL FUNCTION 'RFC_SYSTEM_INFO'
STARTING NEW TASK 'INFO'
PERFORMING RETURN_INFO ON END OF TASK
EXCEPTIONS
COMMUNICATION_FAILURE = 1 MESSAGE MSG
SYSTEM_FAILURE = 2 MESSAGE MSG.
IF SY-SUBRC = 0.
WRITE: 'Wait for response'.
ELSE.
WRITE MSG.
ENDIF.
...
AT USER-COMMAND.
Return from the form routine RETURN_INFO using SET USER-COMMAND
IF SY-UCOMM = 'OKCD'.
IF RET_SUBRC = 0.
WRITE: 'Destination =', INFO-RFCDEST.
ELSE.
WRITE MSG.
ENDIF.
ENDIF.
...
*----
*
*----
FORM RETURN_INFO USING TASKNAME.
RECEIVE RESULTS FROM FUNCTION 'RFC_SYSTEM_INFO'
IMPORTING RFCSI_EXPORT = INFO
EXCEPTIONS
COMMUNICATION_FAILURE = 1 MESSAGE MSG
SYSTEM_FAILURE = 2 MESSAGE MSG.
RET_SUBRC = SY-SUBRC. "Setn RET_SUBRC
SET USER-COMMAND 'OKCD'. "Set OK_CODE
ENDFORM. "RETURN_INFO
regards,
amit m.
Hi,
In an ARFC how we will define a return subroutine?
call function 'Z_RFC_EXEC'
starting new task g_task_name
destination in group us_srvgrp
performing <b>task_return</b> on end of taskdo we have to define the subroutine task_return in the main program ? if so how to build it ?
Could we put an ARFC inside an OPEN CURSOR and CLOSE CURSOR ?
rgds,
abhilash
2006 Jun 12 8:59 AM
Hi abhilash,
1 do we have to define the subroutine task_return in the main program ? if so how to build it ?
Yes, in your se38 program itself.
in this manner.
<b>FORM task_return USING TASKNAME</b>
2. This code may help u (just copy paste_
3.
report abc.
DATA: INFO LIKE RFCSI,
Result of the RFC_SYSTEM_INFO function
MSG(80) VALUE SPACE,
Exception handling
RET_SUBRC like SY-SUBRC.
SY-SUBRC handling
CALL FUNCTION 'RFC_SYSTEM_INFO'
STARTING NEW TASK 'INFO'
PERFORMING RETURN_INFO ON END OF TASK
EXCEPTIONS
COMMUNICATION_FAILURE = 1 MESSAGE MSG
SYSTEM_FAILURE = 2 MESSAGE MSG.
IF SY-SUBRC = 0.
WRITE: 'Wait for response'.
ELSE.
WRITE MSG.
ENDIF.
...
AT USER-COMMAND.
Return from the form routine RETURN_INFO using SET USER-COMMAND
IF SY-UCOMM = 'OKCD'.
IF RET_SUBRC = 0.
WRITE: 'Destination =', INFO-RFCDEST.
ELSE.
WRITE MSG.
ENDIF.
ENDIF.
...
*----
*
*----
FORM RETURN_INFO USING TASKNAME.
RECEIVE RESULTS FROM FUNCTION 'RFC_SYSTEM_INFO'
IMPORTING RFCSI_EXPORT = INFO
EXCEPTIONS
COMMUNICATION_FAILURE = 1 MESSAGE MSG
SYSTEM_FAILURE = 2 MESSAGE MSG.
RET_SUBRC = SY-SUBRC. "Setn RET_SUBRC
SET USER-COMMAND 'OKCD'. "Set OK_CODE
ENDFORM. "RETURN_INFO
regards,
amit m.
2006 Jun 12 1:24 PM
hi amit,
Thanks..
i am making a function module to an ARFC.I have to import an Itab from FM.
So where in the form task_return should i mention the Itab.?
How can we get the internal table in the program ?
regards,
abhilash
2006 Jun 12 1:38 PM
Hi again,
Simple.
(We have to just take care in callback FORM )
1. First of all declare a blank internal table,
which u will pass to the FM.
2. Suppose :
a) your TASK_RETURN is the call back form name
b) T001 is the TABLES which is returned
c) T001 is also the name of the internal table
3.
FORM RETURN_INFO USING TASKNAME.
<b> RECEIVE RESULTS FROM FUNCTION 'ZAM_FM02'
TABLES T001 = T001.</b>
ENDFORM.
regards,
amit m.
2006 Jun 12 1:47 PM
Hi again,
1. Taking your same requirement,
2. suppose
a) a new FM which simply populates and returns TABLES T001 (company master)
b) the FM Name is ZAM_FM02
3. After creating the above FM,
just copy paste the code below.
(in the break-point, u will be able
to see the records in T001 internal table)
4.
report abc.
*----
data : t001 like table of t001 with header line.
DATA: INFO LIKE RFCSI,
MSG(80) VALUE SPACE,
RET_SUBRC like SY-SUBRC.
CALL FUNCTION 'ZAM_FM02'
STARTING NEW TASK 'INFO'
PERFORMING RETURN_INFO ON END OF TASK
TABLES
T001 = t001
EXCEPTIONS
COMMUNICATION_FAILURE = 1 MESSAGE MSG
SYSTEM_FAILURE = 2 MESSAGE MSG.
*----
IF SY-SUBRC = 0.
WRITE: 'Wait for response'.
ELSE.
WRITE MSG.
ENDIF.
*----
*
*----
FORM RETURN_INFO USING TASKNAME.
BREAK-POINT.
RECEIVE RESULTS FROM FUNCTION 'ZAM_FM02'
TABLES T001 = T001.
BREAK-POINT. "<----
HERE
ENDFORM. "RETURN_INFO
regards,
amit m.
2006 Jun 12 2:02 PM
hi amit,
here is my FM
CALL FUNCTION 'ORDER_CHANGE_FOR_ACTIVITY'
STARTING NEW TASK taskname
PERFORMING return_info ON END OF TASK
EXPORTING
flg_lkz = set_loek
flg_lvm = set_loev
* INTERVALL = ' '
selid = selid
testrun = pa_testl
init_tables = 'X'
maxnumber = pa_wpoc
called_as_rfc = 'X'
export_msg_to_memory = ' '
TABLES
caufv_tab = gt_caufv
table_of_messages = mess_tab
EXCEPTIONS
nothing_to_do = 1
wrong_selid = 2
OTHERS = 3
.and my form is
FORM return_info USING taskname.
RECEIVE RESULTS FROM FUNCTION 'ORDER_CHANGE_FOR_ACTIVITY'
TABLES
table_of_messages = mess_tab.
ENDFORM. "RETURN_INFOin this case program gets hanged at the end of the FM
what went wrong ?
regards
abhilash
2006 Jun 12 2:20 PM
Hi again,
1. are u able to execute this FM,
normally,
(ie. without any extension of new task)
2. The FM logic might be slow. just check out .
regards,
amit m.
2006 Jun 12 2:25 PM
hi amit,
i can run this FM normally. even in aRFC mode also it was runnig, but soon i added the
PERFORMING return_info ON END OF TASKand the corresponding Subroutine, it is getting hanged until i stop the transaction.
regds
abhilash
2006 Jun 12 2:50 PM
Use wait until...statement after the arfc function call to keep the program waiting for the return_info to get executed.
Regards
Sridhar
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |