‎2010 Oct 01 1:56 AM
Hi there!
Abapers, I'm needing some help here with RFCs.
My destinations (SM59):
ERP_100 ERP_120 ERP_130 PI_200 PI_300
I have to call a function in PI from ERP. I'm doing in this way:
CALL FUNCTION 'pi_function_module' DESTINATION 'PI_200' ...It's working. But the destination can not be hard coded. With the program in ERP_100 (DEV) and ERP_120 (QAS) the destination is PI_200 (PI DEV) and with the program in ERP_130 (PRD) the destination is PI_300 (PI PRD).
How can I handle this?
Thanks in advance!
Best regards,
Charles
‎2010 Oct 01 3:17 AM
Hi Charles,
I quote the last post by Micky Oestreich - "This solely depends on the naming conventions you are using. Since the name of the RFC destination is arbitrary, there is 'no' way of determining the name of the destination."
So, your design approach could either be by building a customizing table where you maintain the destination values or use a 'CASE' statement in your code before calling the remote function module....something like:
DATA:
lv_own_system TYPE logsys,
lv_rfcdest TYPE rfcdest.
CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
IMPORTING
own_logical_system = lv_own_system
EXCEPTIONS
own_logical_system_not_defined = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CASE lv_own_system.
WHEN 'ERP_100' or 'ERP_120'.
lv_rfcdest = 'PI_200'.
WHEN 'ERP_130'.
lv_rfcdest = 'PI_300'.
WHEN OTHERS.
ENDCASE.
"Now call the remote function
CALL FUNCTION 'pi_function_module' DESTINATION lv_rfcdest ...
Hope this helps,
Cheers,
Sougata.
‎2010 Oct 01 2:32 AM
Use variable instead of hard coded string with type rfcdest.
Cheers
‎2010 Oct 01 2:49 AM
Martin, I know I need to use a variable of the type rfcdest-rfcdest.
But the problem is to get the value automatically. I was thinking of something to bring me that value, maybe a function that returns the destination for the actual environment.
Thanks for try to help. If you have any other idea let me know.
Best regards,
Charles
‎2010 Oct 01 3:13 AM
Hi,
it depends on your logic. For example you can create a custom table where you will store correct RFC destination. You will have to maintain it in each system. Another approach could be to derive RFC destination from system ID. Something like
IF sy-sysid EQ 'PRD'.
dest = 'XXX'.
ELSE.
dest = 'YYY'.
ENDIF.
Obviously, a solution with table is more flexible.
Cheers
‎2010 Oct 01 3:17 AM
Hi Charles,
I quote the last post by Micky Oestreich - "This solely depends on the naming conventions you are using. Since the name of the RFC destination is arbitrary, there is 'no' way of determining the name of the destination."
So, your design approach could either be by building a customizing table where you maintain the destination values or use a 'CASE' statement in your code before calling the remote function module....something like:
DATA:
lv_own_system TYPE logsys,
lv_rfcdest TYPE rfcdest.
CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
IMPORTING
own_logical_system = lv_own_system
EXCEPTIONS
own_logical_system_not_defined = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CASE lv_own_system.
WHEN 'ERP_100' or 'ERP_120'.
lv_rfcdest = 'PI_200'.
WHEN 'ERP_130'.
lv_rfcdest = 'PI_300'.
WHEN OTHERS.
ENDCASE.
"Now call the remote function
CALL FUNCTION 'pi_function_module' DESTINATION lv_rfcdest ...
Hope this helps,
Cheers,
Sougata.
‎2010 Oct 01 3:33 AM
Thank you Martin Voros and Sougata.
I was just thinking in 'custom table' but wondering a better way to do this. I'll probably go with the table solution.
Best regards,
Charles