cancel
Showing results for 
Search instead for 
Did you mean: 

Netweaver Gateway Function Imports and RFCs

Former Member
0 Kudos

Hi - I am trying to use a Function Import to return a table of name value pairs using an RFC. The call takes a single paramter.
It should be pretty straight forward except I am getting the error "Name or password is incorrect (repeat logon)" off the RFC.

On the same service I have created a regular GetEntity(Read) operation calling the same RFC and using the same destination and it works.
Obviously the data is useless but it proves that the service is configured correctly to make the call.

Any ideas?

method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~EXECUTE_ACTION.

DATA lo_dp_facade TYPE REF TO /iwbep/if_mgw_dp_facade.
data LV_DESTINATION type RFCDEST.
data LV_EXC_MSG type /IWBEP/MGW_BOP_RFC_EXCEP_TEXT.
data LV_SUBRC type SYST-SUBRC.

DATA: ls_parameter  TYPE /iwbep/s_mgw_name_value_pair,
        lv_userid    TYPE string,
        ls_entity     TYPE  ZCL_ZFOH_READ_SETTINGS_MPC=>TS_SETTINGS,
        lt_entityset  TYPE ZCL_ZFOH_READ_SETTINGS_MPC=>TT_SETTINGS.

TYPES: BEGIN OF s_param,
        mandt type string,
        name type string,
        value type string,
      END OF s_param.

DATA: t_param type standard table of s_param.
DATA  ls_param like line of t_param.

  IF iv_action_name = 'GetSettings'. " Check what action is being requested
    IF it_parameter IS NOT INITIAL.

* Read Function import parameter value

      READ TAbLE it_parameter INTO ls_parameter WITH KEY name = 'UserId'.

      IF sy-subrc = 0.

        lv_userid = ls_parameter-value.

      ENDIF.

      IF lv_userid IS NOT INITIAL.

        lo_dp_facade = /iwbep/if_mgw_conv_srv_runtime~get_dp_facade( ).
        lv_destination = /iwbep/cl_sb_gen_dpc_rt_util=>get_rfc_destination( io_dp_facade = lo_dp_facade ).

        call function 'Z_FOH_READ_SETTINGS_ODATA' destination lv_destination
        exporting
          IV_USER_ID   =   lv_userid
        importing
          EV_SETTINGS   =   t_param
          exceptions
          system_failure         = 1000 message lv_exc_msg
          communication_failure  = 1001 message lv_exc_msg
          others = 1002.
        lv_subrc = sy-subrc.

*-------------------------------------------------------------
*  Map the RFC response to the caller interface - Only mapped attributes
*-------------------------------------------------------------
*-------------------------------------------------------------
* Error and exception handling
*-------------------------------------------------------------
IF lv_subrc <> 0.
* Execute the RFC exception handling process
  me->/iwbep/if_sb_dpc_comm_services~rfc_exception_handling(
    EXPORTING
      iv_subrc            = lv_subrc
      iv_exp_message_text = lv_exc_msg ).
ENDIF.

        LOOP AT t_param into ls_param .
          ls_entity-NAME  = ls_param-name.
          ls_entity-VALUE = ls_param-value.
          APPEND ls_entity TO lt_entityset.

        ENDLOOP.

* Call methos copy_data_to_ref and export entity set data

        copy_data_to_ref( EXPORTING is_data = lt_entityset

                CHANGING cr_data = er_data ).

      ENDIF.

    ENDIF.

  ENDIF.

  endmethod.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I have solved this issue.

If I add the Function Import to an existing service where an RFC has been successfully mapped to a GetEntity Ready then it works.

I initially added the Function Import to a fresh service and then added a test GetEntity call and the Function Import still did not work.

Hopefully this saves somebody else some time. Thanks for help Ashwin.

Answers (1)

Answers (1)

AshwinDutt
Active Contributor
0 Kudos

Hello Ricky,

Does the call is coming inside Execute_Action method ? Are you able to debug ?

Are you testing from the browser or GW_Client ?

Regards,

Ashwin

Former Member
0 Kudos

Yes the call is coming to the Execute_Action method when debugging. I have been testing from the GW_client.

AshwinDutt
Active Contributor
0 Kudos

Then in that case i would suggest you to check if FM is returning any data on passing User ID as input.

Please check if any exception is returned by FM.

Looks like error is because when FM is called with an RFC Destination, Authentication is failing which you need to check.

Former Member
0 Kudos

The FM works when I test it directly in the target system.

When the same FM is called from GetEntity I can see in debugging that the data is also coming back correctly.

It is strange though - that when I called the same FM from the Execute_Action then I get the mentioned error message. I have checked that the correct destination is given to the function call.

AshwinDutt
Active Contributor
0 Kudos

That error is coming as part of Excetion returned by FM ?

Former Member
0 Kudos

No it is from gateway side.