Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to test RFC destination via Pyrfc (SAP ABAP) #241

Closed
atomhippo opened this issue Sep 22, 2021 · 8 comments
Closed

How to test RFC destination via Pyrfc (SAP ABAP) #241

atomhippo opened this issue Sep 22, 2021 · 8 comments
Assignees
Labels

Comments

@atomhippo
Copy link

Hi Pyrfc experts,

I am a sap basis guy, and I would like to build some automation code to execute system check after service windows for an ABAP systems.
One step of the manual check is to make connection test in SM59 of the ABAP system to the rfc destinations e.g. "SMPCLNT001"

Is it possible to perform that with Pyrfc? or any other automated / command line method?

BTW I saw some ABAP code with below line:
CALL FUNCTION 'RFC_PING' DESTINATION DEST

Is that possible to convert this line to Python?
I have tried:
result = conn.call('RFC_PING', DESTINATION = 'SMPCLNT001')
But it gives error that “DESTINATION” is not a known parameter.

Many thanks in advance.

Best Regards
Karl
SAP Basis

@bsrdjan bsrdjan self-assigned this Sep 29, 2021
@bsrdjan
Copy link
Member

bsrdjan commented Sep 29, 2021

Hello Karl,

sorry the late response, I was on vacation.

The error message is correct because the RFC_PING does not have parameters and it works with already opened connection to one backend system.

There is no fully automated solution working out of the box to check connections with multiple systems/destinations. The standard function module RFC_TEST_EXTERNAL will only test if another destination is maintained in ABAP system and will not test the connection to that destination.

To test multiple destinations you can create a custom ABAP function module for that purpose. It will call RFC_PING in another destination, like this:

FUNCTION z_test_destination.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(IV_DEST) TYPE  RFCDEST
*"  EXPORTING
*"     VALUE(RETCODE) TYPE  SYST-SUBRC
*"----------------------------------------------------------------------

  CALL FUNCTION 'RFC_PING' DESTINATION iv_dest
    EXCEPTIONS
      system_failure        = 1
      communication_failure = 2.

  RETCODE = sy-subrc.

ENDFUNCTION.

From Python you can open the connection to that system and call the custom function module with the destination parameter:

result = conn.call('z_test_destination', iv_dest='SMPCLNT001')

Hope this help solving the problem.

@atomhippo
Copy link
Author

Hi Srdjan,

Thank you for the solution.

BTW, is there any way we can do in python script so that we don't have to create the function module in customer's ABAP system?
Or maybe the ping can be performed with OS command?

Many thanks!

Best Regards
Karl

@bsrdjan
Copy link
Member

bsrdjan commented Sep 30, 2021

Hello Karl,

there is a SAP command line utility niping, for ABAP system connectivity and other tests.

The installation and usage are described in SAP Note 500235 - Network Diagnosis with NIPING.

Hope this helps further.

Kind regards,
Srdjan

@jfilak
Copy link

jfilak commented Sep 30, 2021

Hi Karl,

do I get it right that you want to test if RFC destionations listed in SM59 are working properly - i.e. you want to test if an ABAP system has RFC connectivity to other configured ABAP systems?

Kind regards,
Jakub

BTW: The link posted by Srdjan has doubled URL, so it does not open corrrectly. The correct URL is https://launchpad.support.sap.com/#/notes/500235

@bsrdjan
Copy link
Member

bsrdjan commented Sep 30, 2021

Thanks, fixed the url

@atomhippo
Copy link
Author

@bsrdjan
Thank you Srdjan for your inspiration! I've found below 2 FM which support my need very well:
/SDF/RFC_CHECK
/SDF/HTTP_CHECK

Both are remote-Enabled function modules, and can output ping result of given destination name.

Best Regards
Karl

@atomhippo
Copy link
Author

@jfilak Hi Jakub, yes you are right.
Now I have found the solution.

Best Regards
Karl

@bsrdjan
Copy link
Member

bsrdjan commented Oct 6, 2021

Thank you @atomhippo for finding and sharing the solution, I was not aware of these function modules.

@bsrdjan bsrdjan closed this as completed Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants