11-07-2014 4:31 AM
I need all your help on the below issue.
I need to automate a screen flow in abap (SM59).
Inside the Transaction SM59, i have to change the RFC destination SAPOSS Msg server first and then check whether the Connection Test succeeds or fails by clicking the Connection test button.
Please suggest me on how to go about this.
Should this be done via bdc by doing a step by step recording in shdb?
I am attaching a screenshot. Forget the Japanese characters. The tcode is SM59.
11-13-2014 2:20 AM
I found the below source code somewhere which does test RFC connection programatically.
REPORT ZSAPN_CHECK_RFC.
DATA : WA_RFCDES TYPE RFCDES.
PARAMETERS P_RFC TYPE STRING.
START-OF-SELECTION.
SELECT SINGLE * FROM RFCDES INTO WA_RFCDES WHERE RFCDEST = P_RFC.
IF WA_RFCDES IS NOT INITIAL.
CALL FUNCTION 'RFC_PING' DESTINATION P_RFC.
IF SY-SUBRC EQ 0.
MESSAGE 'RFC connection is perfect' TYPE 'S'.
ELSE.
MESSAGE 'RFC is not working' TYPE 'E'.
ENDIF.
ELSE.
MESSAGE 'RFC destination dosent exist' TYPE 'E'.
ENDIF.
But I want to test it based on the RFCOPTIONS and not based on the RFCDEST in the table RFCDES.
In case of RFCOPTIONS in the table the value in the Msg Server is noy directly saved in the field. Instead it is saved with some prefixes like shown in the picture below. Can someone suggest how to remove the prefixes in the server options programatically? Also is it always the same prefix?
Awaiting your reply. Thanks.
11-07-2014 4:42 AM
Awesome screenshots! I would love to work on a Japanese system like that
have you tried looking for BAPIs / FMS to achieve the same as that screenflow.
I know there is one for testing the RFC connection. Much easier that trying to build a BDC.
cheers
Paul
11-07-2014 5:11 AM
Thanks Paul.
I tried to to look up a few like RSRFCPIN report and RFCPING fm.
The RFCPING fm is totally empty. I would want a fm which can take the Message server address as a parameter and return me a success if the connection succeeds.
I also learnt abt a table called RFCDES but it seems have only the destination name and conn type.
Any other ideas would be highly appreciated.
Thanks.
11-07-2014 5:19 AM
Hi,
RFC_PING is empty because it doesn't have to do anything. You just call it and see what the result is, to determine if the connection is up.
CALL FUNCTION 'RFC_PING'
DESTINATION P_TRFC
EXCEPTIONS
COMMUNICATION_FAILURE = 1 MESSAGE ST_ERRORS-MSGTXT
SYSTEM_FAILURE = 2 MESSAGE ST_ERRORS-MSGTXT
OTHERS = 3.
IF SY-SUBRC NE 0. (..)
cheers
Paul
11-07-2014 5:29 AM
Hi,
Check the Function Group CRFC, you should be able to find a FM for your use..
RFC_MODIFY*
Regards,
Shobha
11-07-2014 6:12 AM
Thank you shobha. I had a look at the RFC_MODIFY set of FMs and its quite unnerving to find out which one takes the Msg Server as a param. There are way too many importing params with unclear (to me) names. Are you aware of any specific FM that i can use? I am quite a newbie to abap pgming and have a lot more to learn but very little time.
Thanks.
11-07-2014 6:29 AM
It is the IP address of the SAP router. are they under a different name probably?
04-25-2023 6:20 PM
11-13-2014 2:20 AM
I found the below source code somewhere which does test RFC connection programatically.
REPORT ZSAPN_CHECK_RFC.
DATA : WA_RFCDES TYPE RFCDES.
PARAMETERS P_RFC TYPE STRING.
START-OF-SELECTION.
SELECT SINGLE * FROM RFCDES INTO WA_RFCDES WHERE RFCDEST = P_RFC.
IF WA_RFCDES IS NOT INITIAL.
CALL FUNCTION 'RFC_PING' DESTINATION P_RFC.
IF SY-SUBRC EQ 0.
MESSAGE 'RFC connection is perfect' TYPE 'S'.
ELSE.
MESSAGE 'RFC is not working' TYPE 'E'.
ENDIF.
ELSE.
MESSAGE 'RFC destination dosent exist' TYPE 'E'.
ENDIF.
But I want to test it based on the RFCOPTIONS and not based on the RFCDEST in the table RFCDES.
In case of RFCOPTIONS in the table the value in the Msg Server is noy directly saved in the field. Instead it is saved with some prefixes like shown in the picture below. Can someone suggest how to remove the prefixes in the server options programatically? Also is it always the same prefix?
Awaiting your reply. Thanks.
11-13-2014 5:46 AM
Hi,
I don‘t know if it help you. Try to check FM RFC_HOST_TO_IP.
The prefix depends on the setting in the tab "Technical setting" and the connection type.
you can remove the prefix for example like in the following code:
REPORT ZTEST.
DATA: gs_rfcdes TYPE rfcdes,
gt_table TYPE TABLE OF string,
gs_table LIKE LINE OF gt_table,
gv_host TYPE RFCDISPLAY-RFCHOST,
gv_ip TYPE RFCDISPLAY-RFCHOST.
START-OF-SELECTION.
SELECT SINGLE * FROM rfcdes into gs_rfcdes
WHERE rfcdest = 'SAPOSS'.
SPLIT gs_rfcdes at ',' into TABLE gt_table.
IF sy-subrc = 0.
LOOP AT gt_table INTO gs_table.
CASE gs_table(2).
WHEN 'H='.
gv_host = gs_table+2.
ENDCASE.
ENDLOOP.
CALL FUNCTION 'RFC_HOST_TO_IP'
EXPORTING
RFCHOST = gv_host
IMPORTING
RFCIP = gv_ip
EXCEPTIONS
HOST_TO_IP_CONVERSION_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ELSE.
* Implement ohter steps.
ENDIF.
ENDIF.
11-13-2014 8:00 AM
Thanks a lot Karel.
Since I am doing a Test RFC connection, I may not need the 'RFC_HOST_TO_IP', I am using RFC_PING instead.
By the way, are you aware of any FM which tests the connection based on the IP address instead of the destination name?
Thanks again.
11-26-2014 11:18 AM
11-13-2014 4:13 AM