Jen Mer
Jen Mer

Reputation: 101

Best practice instead of hard-coded RFC destinations?

is there a good way to use not hardcoded RFC destinations?

Right now our solution is to check which system is used and then assign the destination to a variable

IF cl_role EQ 'P'.
      p_dest = 'ESW300'.
   ELSE.
      p_dest = 'EAW300'.
   ENDIF.

which we use when calling our destination function.

CALL FUNCTION 'XYZ' DESTINATION p_dest

Is there a good way to not use the hardcoded destinations?

Thank you for the help!

Upvotes: 4

Views: 4480

Answers (2)

SAP Pro
SAP Pro

Reputation: 427

RFC destinations are already an abstraction of the endpoint so I would not recommend to abstract it yet again. For that reason I would suggest using the same name across systems as a leading practice and not change them to be instance specific.

Otherwise I would suggest instead of hard-coding that you determine the RFC destination dynamically if you really want to use different RFC destination names across systems (I would not). If you look at some SAP standard programs they use specific format to determine the expected RFC destination name for example <hostname>_<systemname>_<system number> is used by SolMan but there are many examples if you look at the standard RFC destinations you can find.

I would also recommend as a best practice that any hard coded values never be populated inline as your example shows but in a header constant.

I realize you were probably only trying to focus on your question but for others reading this.

Upvotes: 4

Sandra Rossi
Sandra Rossi

Reputation: 13639

I saw every company creating its own custom table containing the RFC destinations (maintained differently in every SAP system by administrators; eventually it can be custom entries in the standard table TVARVC), but nobody published anything about it. Eventually this blog post but it's a very complex solution, only documented, but no code provided.

An easier (and adequate?) way is to create a Logical System (transaction code BD54) for every system, and assign a RFC destination (transaction code BD97).

In your program, do this kind of thing:

SELECT SINGLE rfcdest
    FROM tblsysdest
    WHERE logsys = 'CRM' 
    INTO @DATA(crm_system).

CALL FUNCTION 'RFC_PING' DESTINATION crm_system
    EXCEPTIONS OTHERS = 1.

PS: prefer to abstract things, like creating a global class with one method GET_CRM_SYSTEM instead of hardcoding the SELECT in every program.

Upvotes: 3

Related Questions