Application Development 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: 

How do I create structures for RFC call parameters at runtime ?

Former Member
0 Kudos

Hi,

I have a RFC module that takes one table type and returns complex structure. Can I create these parameters at runtime and pass it to the function (looking at the signature of the RFC).

So that if the structure elements of the RFC changes in the other system, the module would still work on the parent system.

Thanks,

Mahidhar

1 ACCEPTED SOLUTION

Clemenss
Active Contributor
0 Kudos

Hi Mahidhar,

yes, why not. Starting release 46C you can create structures dynamically, starting with 47 you can create tables.

Make sure that the structure is defined in your source system.

sample:

field-symbols:

<any> type any,

<anytab> type any table.

Data:

l_ref type ref to data.

create data l_ref type ([strucname]).

assign l_ref->* to <any>.

create data l_ref type table of ([strucname]).

assign l_ref->* to <anytab>.

Now use <any> as the dynamically created structure and <anytab> as the dynamically created internal table.

Regards,

Clemens

3 REPLIES 3

Former Member
0 Kudos

Hi,

As long as you have something in the DB to refer to you can create a structure dynamically at runtime.

CREATE DATA var type (STR).

STR is the name of the structure in SE11.

After that you can assigne values using fields symbols and ASSIGN COMPONENT xxx of STR XXX to <FS>.

Regards,

Ravi

Note : Please mark the helpful answers

Former Member
0 Kudos

Hi madhikar,

1.

For this purpose,

in my program,

there is an INDEPENDENT FORM

whose inputs are

TABLE NAME / STRUCTURE NAME

and from those, it consructs dynamic table.

2. Here is the program.

the dynamic table name will be

<DYNTABLE>.

3. U can use this program (FORM in this program)

to generate any kind of internal table

by specifying TABLE NAME .

4.

REPORT abc.

*----


COMPULSORY

FIELD-SYMBOLS: <dyntable> TYPE ANY TABLE.

FIELD-SYMBOLS: <dynline> TYPE ANY.

DATA: lt TYPE lvc_t_fcat.

DATA: ls TYPE lvc_s_fcat.

FIELD-SYMBOLS: <fld> TYPE ANY.

DATA : fldname(50) TYPE c.

*----


parameters : iname LIKE dd02l-tabname.

*----


START-OF-SELECTION.

*----


PERFORM

PERFORM mydyntable USING lt.

BREAK-POINT.

*----


  • INDEPENDENT FORM

*----


FORM mydyntable USING ptabname.

*----


Create Dyn Table From FC

FIELD-SYMBOLS: <fs_data> TYPE REF TO data.

FIELD-SYMBOLS: <fs_1>.

FIELD-SYMBOLS: <fs_2> TYPE ANY TABLE.

DATA: lt_data TYPE REF TO data.

data : lt TYPE lvc_t_fcat .

DATA : ddfields LIKE ddfield OCCURS 0 WITH HEADER LINE.

*----


CALL FUNCTION 'DD_NAMETAB_TO_DDFIELDS'

EXPORTING

tabname = iname

TABLES

ddfields = ddfields.

.

*----


CONSTRUCT FIELD LIST

LOOP AT ddfields.

ls-fieldname = ddfields-fieldname.

APPEND ls TO lt.

ENDLOOP.

ASSIGN lt_data TO <fs_data>.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = lt

IMPORTING

ep_table = <fs_data>

EXCEPTIONS

generate_subpool_dir_full = 1

OTHERS = 2.

IF sy-subrc <> 0.

ENDIF.

*----


Assign Dyn Table To Field Sumbol

ASSIGN <fs_data>->* TO <fs_1>.

ASSIGN <fs_1> TO <fs_2>.

ASSIGN <fs_1> TO <dyntable>.

ENDFORM. "MYDYNTABLE

regards,

amit m.

Clemenss
Active Contributor
0 Kudos

Hi Mahidhar,

yes, why not. Starting release 46C you can create structures dynamically, starting with 47 you can create tables.

Make sure that the structure is defined in your source system.

sample:

field-symbols:

<any> type any,

<anytab> type any table.

Data:

l_ref type ref to data.

create data l_ref type ([strucname]).

assign l_ref->* to <any>.

create data l_ref type table of ([strucname]).

assign l_ref->* to <anytab>.

Now use <any> as the dynamically created structure and <anytab> as the dynamically created internal table.

Regards,

Clemens