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

Dynamic table for RFC function

Former Member
0 Likes
3,831

Hello,

Currently I am building a function group that retrieves information from a local database and a remote database. For the remote database I call a RFC function with the DESTINATION parameter. Now I would like to use a ANY TABLE for the TABLES parameter since the structure of that parameter does not exist in our system:

FIELD-SYMBOLS: <lit_table> TYPE ANY TABLE.

CALL FUNCTION 'BAPI_ZGETAGRDET'

DESTINATION 'XYZCLNT160'

EXPORTING

iv_datum = pa_date

iv_gpart = '1'

TABLES

et_table = <lit_table>.

This gives the error that its not ASSIGNED yet, is it even possible to call a function like this? Or do I need to copy the structure van the remote system to the local system and declare it staticly.

Any help is welcome and I'll reward point ofcourse.

1 ACCEPTED SOLUTION
Read only

Laxmana_Appana_
Active Contributor
0 Likes
2,063

Hi,

Check these FM 's: RFC_READ_TABLE

RFC_GET_TABLE_ENTRIES

i think these will work for your requirement.

Regards

Appana

3 REPLIES 3
Read only

Former Member
0 Likes
2,063

Hi ,

If your FM is RFC enabled you can't declare a generic type. that is the problem when you try to use the FM and try to pass a dynamic table name to get the data from the remote system.

Hope this helps.

Regards,

kinshuk

Read only

Laxmana_Appana_
Active Contributor
0 Likes
2,064

Hi,

Check these FM 's: RFC_READ_TABLE

RFC_GET_TABLE_ENTRIES

i think these will work for your requirement.

Regards

Appana

Read only

Former Member
0 Likes
2,063

I have done it:

FIELD-SYMBOLS: <lwa_tabname> TYPE rfc_fields,

<lit_aanstelling> TYPE table.

DATA: lit_nametab TYPE TABLE OF rfc_fields,

lob_data TYPE REF TO data,

lit_fieldcat TYPE lvc_t_fcat,

lwa_fieldcat TYPE lvc_s_fcat.

CALL FUNCTION 'RFC_GET_STRUCTURE_DEFINITION'

DESTINATION 'N01CLNT160'

EXPORTING

tabname = 'ZCS_INTERM_AGR_DET_AANST'

TABLES

fields = lit_nametab

EXCEPTIONS

table_not_active = 1

OTHERS = 2.

IF sy-subrc <> 0.

*

ENDIF.

LOOP AT lit_nametab ASSIGNING <lwa_tabname>.

MOVE <lwa_tabname>-fieldname TO lwa_fieldcat-fieldname.

MOVE <lwa_tabname>-exid TO lwa_fieldcat-inttype.

MOVE <lwa_tabname>-intlength TO lwa_fieldcat-outputlen.

APPEND lwa_fieldcat TO lit_fieldcat.

ENDLOOP.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = lit_fieldcat

IMPORTING

ep_table = lob_data.

ASSIGN lob_data->* TO <lit_aanstelling>.

It doesn't seem efficient copy data from table1 to table2 but it works...