Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

how to detect function module is exist in remote system without ABAP dump

Former Member
0 Likes
4,373

Hi all,

Please advise is there any way to verify a function module is exist in remote system whithout ABAP dump?

By using the following method we can have ABAP dump if the specified FM is not yet available on the destination.

CALL FUNCTION 'Z_xxx_xxxx' DESTINATION rfcdestination

Thank you.

1 ACCEPTED SOLUTION
Read only

Sougata
Active Contributor
0 Likes
2,284

Hi Reetha,

The way I handled this situation is as follows:

1. I created a Static Public Method called CHECK_FUNC_EXIST in one of the existing Z utility Class

method check_func_exist.

  data: lv_rfcdest type rfcdest.

  if iv_rfcdest is not initial.
    lv_rfcdest = iv_rfcdest.
  else.
    lv_rfcdest = co_none.       "----> 'NONE'
  endif.

  call function 'FUNCTION_EXISTS'          "<------- Note that this FM is also Remote Enabled
    destination lv_rfcdest
    exporting
      funcname           = iv_func_name
    exceptions
      function_not_exist = 1
      others             = 2.

  check sy-subrc = 0.
  rv_exist = lcl_gc=>gc_true.       "-----> 'X'

endmethod.

2. Then, before calling the Remote Function in my application (within another Method) , I used the above Method first to validate before the actual remote function call.

method derive_fbt_year_period.

  data: lv_crmrfcdest type rfcdest.

* get the CRM RFC destination name
  lv_crmrfcdest = get_crm_rfc_dest( ).   

* check the function module exists in the remote system
  if check_func_exist(                                              "<----- The Method above
        iv_func_name = co_fbt_rfc_func_name
        iv_rfcdest   = lv_crmrfcdest ) is initial.
    message e104(zf_enhancements) with iv_transaction_date
      raising fbt_year_not_found.
  endif.

* call the remote function to get the FBT year, Date From, Date To
  call function co_fbt_rfc_func_name
    destination lv_crmrfcdest
    exporting
      iv_date      = iv_transaction_date
    importing
      ev_fbt_year  = ev_fbt_gjahr
      ev_date_from = ev_date_from
      ev_date_to   = ev_date_to
      ev_days_held = ev_days_held
    exceptions
      not_found    = 1
      others       = 2.

  if sy-subrc <> 0.
    message e104(zf_enhancements) with iv_transaction_date
      raising fbt_year_not_found.
  endif.

  check ev_fbt_monat is requested.

* using the "Date From" imported from the RFC, derive the FBT period
  ev_fbt_monat = derive_fbt_period( iv_transaction_date = iv_transaction_date
                                    iv_date_from        = ev_date_from ).

endmethod.

I'm hoping you could use this or a similar approach to solve your issue.

Hope this helps.

Cheers,

Sougata.

4 REPLIES 4
Read only

Former Member
0 Likes
2,284

Hi,

The FM you have provided CALL FUNCTION 'Z_xxx_xxxx' DESTINATION rfcdestination, is a custom function module which would be available in your project, if you want to avoid dump by calling the same FM, you can modify the FM by creating a exception and throwing this exception instead of dump if the FM does not exist in remote system.

Regards,

Raghavendra

Read only

Former Member
0 Likes
2,284

Hello,

There is no standard way of doing it but workaround for this problem would be as follows:

1. Create Z function module Z_GET_RFC_FUNCTION_LIST.You may choose name as you like.

2. In this function module you can write select statament for selecting data from table TFDIR.

3. Select statement will select FUNCNAME and FMODE from TFDIR table.

4. Retrun list of all the required function module using tables parameter.

Now you need to deploy this function module on all the SAP system in landscape so that

before every remote call you can check if that function module exist in remote system using Z function module.

Hope this helps!

Thanks,

Augustin.

Read only

Sougata
Active Contributor
0 Likes
2,285

Hi Reetha,

The way I handled this situation is as follows:

1. I created a Static Public Method called CHECK_FUNC_EXIST in one of the existing Z utility Class

method check_func_exist.

  data: lv_rfcdest type rfcdest.

  if iv_rfcdest is not initial.
    lv_rfcdest = iv_rfcdest.
  else.
    lv_rfcdest = co_none.       "----> 'NONE'
  endif.

  call function 'FUNCTION_EXISTS'          "<------- Note that this FM is also Remote Enabled
    destination lv_rfcdest
    exporting
      funcname           = iv_func_name
    exceptions
      function_not_exist = 1
      others             = 2.

  check sy-subrc = 0.
  rv_exist = lcl_gc=>gc_true.       "-----> 'X'

endmethod.

2. Then, before calling the Remote Function in my application (within another Method) , I used the above Method first to validate before the actual remote function call.

method derive_fbt_year_period.

  data: lv_crmrfcdest type rfcdest.

* get the CRM RFC destination name
  lv_crmrfcdest = get_crm_rfc_dest( ).   

* check the function module exists in the remote system
  if check_func_exist(                                              "<----- The Method above
        iv_func_name = co_fbt_rfc_func_name
        iv_rfcdest   = lv_crmrfcdest ) is initial.
    message e104(zf_enhancements) with iv_transaction_date
      raising fbt_year_not_found.
  endif.

* call the remote function to get the FBT year, Date From, Date To
  call function co_fbt_rfc_func_name
    destination lv_crmrfcdest
    exporting
      iv_date      = iv_transaction_date
    importing
      ev_fbt_year  = ev_fbt_gjahr
      ev_date_from = ev_date_from
      ev_date_to   = ev_date_to
      ev_days_held = ev_days_held
    exceptions
      not_found    = 1
      others       = 2.

  if sy-subrc <> 0.
    message e104(zf_enhancements) with iv_transaction_date
      raising fbt_year_not_found.
  endif.

  check ev_fbt_monat is requested.

* using the "Date From" imported from the RFC, derive the FBT period
  ev_fbt_monat = derive_fbt_period( iv_transaction_date = iv_transaction_date
                                    iv_date_from        = ev_date_from ).

endmethod.

I'm hoping you could use this or a similar approach to solve your issue.

Hope this helps.

Cheers,

Sougata.

Read only

Former Member
0 Likes
2,284

thanks all for the idea.