cancel
Showing results for 
Search instead for 
Did you mean: 

Odata Service Creation with RFC

0 Kudos

Hello Folks,

I have an RFC which has one input parameter and exporting a nested structure,

The nested structure has four fields and two structures in it as the fifth and the sixth field.

Example :

---------------------------------------------

field1

field2

field3

field4

structure1 (which has 4 fields in it)

structure2 (which has five fields in it)

--------------------------------------------------------------------

The nested structure in the export parameter will have multiple values.

The importing parameter is not a part of the output structure.

For example, I will input the systemid in importing parameter and I will get the Personnel number against it and multiple entries related to that Pernr in the output structure.

So far the RFC is working fine.

Now i want to create an OData service to utilize this RFC.

In the service query, i'll simply pass the sys ID as input and should get the output structure.

No association or navigation would be required.

My questions are:

1) What is the best way to implement this without any complexity ( I found most of the examples with association and quite complex) ?

2) I have tried by importing from RFC and mapping individual data fields.

But how do I map the input parameter (sysid) as I dont have the same (sysid) in output structure ?

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member185414
Active Contributor
0 Kudos

I can suggest two ways.

1. Option 1 - Have a navigation from parent entity (with key as systemid - your input parameter) to child entity(key as system id and any other suitable field). Then implement the Expanded_Entity method(assuming you are needing data for one systemid at a time)

2. Option 2 - Have a flat entity which has two properties - SystemId and String. In this string property pass the entire exporting structure in JSON format and communicate the same to consumption API (may be SAPUI5). In the consumer function, the string property(in JSON format) can be parsed easily to derive the data.

0 Kudos

Hello Ankit,

Unfortunately I don't have any parent or child entity set.

former_member185414
Active Contributor
0 Kudos

What about option 2 then

0 Kudos

We can import the DDIC structure() under data model and then in DPC_EXT and under get_entityset we can call the RFC and fetch the desired value but for that we can either add sysid in DDIC structure or we need to create a new structure with sysid and pernr as two fields to fetch the values.

0 Kudos

Hello Urvashi ,

If I add the SYSID in the structure, the how would I use it as an importing parameter ??

0 Kudos

Hi Subhajit,

We have sysid in the structure we can get the sysid details in ls_sysid and that we can pass in the RFC and fetch the details.

TRY.

CALL METHOD super->method
EXPORTING
iv_entity_name = iv_entity_name
iv_entity_set_name = iv_entity_set_name
iv_source_name = iv_source_name
it_filter_select_options = it_filter_select_options
is_paging = is_paging
it_key_tab = it_key_tab
it_navigation_path = it_navigation_path
it_order = it_order
iv_filter_string = iv_filter_string
iv_search_string = iv_search_string
io_tech_request_context = io_tech_request_context
IMPORTING
et_entityset = et_entityset
es_response_context = es_response_context.
CATCH /iwbep/cx_mgw_busi_exception .
CATCH /iwbep/cx_mgw_tech_exception .
ENDTRY.

LOOP AT it_filter_select_options INTO ls_filter.

IF ls_filter-property = 'SYSID'.
READ TABLE ls_filter-select_options INTO ls_select INDEX 1.
IF sy-subrc IS INITIAL.
ls_sysid = ls_select-low.
ENDIF.
ENDIF.

ENDLOOP.