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 Tables parameter to RFC

former_member194669
Active Contributor
0 Likes
6,610

Hi All,

I have RFC enabled function module within that i need to pass a dynamic table content as a table. I know this is not possible. But anybody have any other solution ?

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
2,981

Hello

In a previous thread I provided a possible solution but I cannot find the thread anymore.

Thus, here is another sample coding which might be useful. The sample exploits the enormous versatilty of XML:


*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_READ_TABLE_RFC                                      *
*&                                                                     *
*&---------------------------------------------------------------------*
*& Dynamic Tables parameter to RFC.
*& https:||<a class="jive_macro jive_macro_message" href="" __jive_macro_name="message" modifiedtitle="true" __default_attr="4899728"></a>            *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  zus_sdn_read_table_rfc                                      .


DATA: gdo_data    TYPE REF TO data.

FIELD-SYMBOLS:
  <gt_itab>       TYPE table,
  <gs_record>     TYPE ANY.




PARAMETERS:
  p_table    TYPE tabname  DEFAULT 'E070'.




START-OF-SELECTION.

" Dynamically create itab
  CREATE DATA gdo_data TYPE TABLE OF (p_table).
  ASSIGN gdo_data->* TO <gt_itab>.


  CALL FUNCTION 'ZUS_SDN_CALL_READ_TABLE_RFC'
    EXPORTING
      id_tabname = p_table
    IMPORTING
      et_data    = <gt_itab>.


  LOOP AT <gt_itab> ASSIGNING <gs_record>.
    WRITE: / <gs_record>.
  ENDLOOP.


END-OF-SELECTION.

Here is the coding of fm ZUS_SDN_CALL_READ_TABLE_RFC:


FUNCTION zus_sdn_call_read_table_rfc.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(ID_TABNAME) TYPE  TABNAME
*"  EXPORTING
*"     REFERENCE(ET_DATA) TYPE  TABLE
*"----------------------------------------------------------------------

* define local data
  DATA: ld_xmlstring  TYPE xstring.


  CALL FUNCTION 'ZUS_SDN_READ_TABLE_RFC'
    DESTINATION 'NONE'  " simulate RFC call
    EXPORTING
      id_tabname         = id_tabname
    IMPORTING
      ed_xmlstring       = ld_xmlstring.
  .

  CALL TRANSFORMATION id
    SOURCE XML ld_xmlstring
    RESULT itab = et_data.

ENDFUNCTION.

And here the coding of fm ZUS_SDN_READ_TABLE_RFC:


FUNCTION zus_sdn_read_table_rfc.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(ID_TABNAME) TYPE  TABNAME
*"  EXPORTING
*"     VALUE(ED_XMLSTRING) TYPE  XSTRING
*"----------------------------------------------------------------------

* define local data
  DATA: ldo_data    TYPE REF TO data.

  FIELD-SYMBOLS:
    <lt_itab>       TYPE table.


" Dynamically create itab
  CREATE DATA ldo_data TYPE TABLE OF (id_tabname).
  ASSIGN ldo_data->* TO <lt_itab>.

  SELECT * FROM (id_tabname) INTO TABLE <lt_itab> UP TO 100 ROWS.


" NOTE: Using XSTRING instead of a simple STRING might be more safe
"       in a mixed Unicode/non-Unicode environment
  CALL TRANSFORMATION id
    SOURCE itab = <lt_itab>
    RESULT XML ed_xmlstring.

ENDFUNCTION.

Using class CL_ABAP_CONTAINER_UTILITIES you may run into trouble when you convert specific types.

For more details have a look at .

Regards

Uwe

Hi All,

I have RFC enabled function module within that i need to pass a dynamic table content as a table. I know this is not possible. But anybody have any other solution ?

10 REPLIES 10
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,981

Can you not type it in the TABLES tab with a type of STANDARD TABLE, this is then generic. Will it allow you to do that?

Regards,

Rich Heilman

Read only

0 Likes
2,981

No. as you said is correct. system not allowing as generic

any other suggestions. This is my requirement.

Client wants a common function module within that they pass a table and in return the table after calling cl_abap_container_utilities

just like passing values to EDID4-SDATA.

For example I am passing I_MARA contains the MARA table entries


  data : begin of i_vardata occurs 0,
           text(1000) type c.
  data : end of i_vardata.

  call method cl_abap_container_utilities=>fill_container_c
    exporting
      im_value               = i_mara
    importing
      ex_container           = i_vardata
    exceptions
      illegal_parameter_type = 1
      others                 = 2.

Read only

0 Likes
2,981

Maybe i got your requirement wrong, but RFC_READ_TABLE seems to provide exactly what you need. You can pass it a table name and if required even select criteria and in return you get the values of the table.

If for some reason you don't want to use this FM then you always could transfer a table of string with the values of each line separated by some delimiter.

Read only

0 Likes
2,981

If for some reason you don't want to use this FM then you always could transfer a table of string with the values of each line separated by some delimiter.

Daniel,

Out side of function module i cannot able to make table into a string because of Unicode issues. that's why i am planning to put that functionality inside this function module . ie I am passing a table and get back to me STRING table.

Read only

0 Likes
2,981

Hi,

Please check the code sample in following link, hope that can give you some lead.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f50dcd4e-0501-0010-3596-b686a7b5...

Regards

Eswar

Read only

0 Likes
2,981

Eswar,

I already seen this link. But this link will not suit for my requirement.

For i cannot able to make table into string table. I am planning to write a generic function module , within that i will pass table entries and in return i need a STRING table in Unicode environment.

Read only

0 Likes
2,981

How about considering FM's of Function Group TRUX ????

Though i have to say this is restricted to width of 4096.

Alternatively you might consider using field-symbols and appending the content field by field but i know this can become tedious.

Regards

Eswar

Read only

uwe_schieferstein
Active Contributor
0 Likes
2,982

Hello

In a previous thread I provided a possible solution but I cannot find the thread anymore.

Thus, here is another sample coding which might be useful. The sample exploits the enormous versatilty of XML:


*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_READ_TABLE_RFC                                      *
*&                                                                     *
*&---------------------------------------------------------------------*
*& Dynamic Tables parameter to RFC.
*& https:||<a class="jive_macro jive_macro_message" href="" __jive_macro_name="message" modifiedtitle="true" __default_attr="4899728"></a>            *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  zus_sdn_read_table_rfc                                      .


DATA: gdo_data    TYPE REF TO data.

FIELD-SYMBOLS:
  <gt_itab>       TYPE table,
  <gs_record>     TYPE ANY.




PARAMETERS:
  p_table    TYPE tabname  DEFAULT 'E070'.




START-OF-SELECTION.

" Dynamically create itab
  CREATE DATA gdo_data TYPE TABLE OF (p_table).
  ASSIGN gdo_data->* TO <gt_itab>.


  CALL FUNCTION 'ZUS_SDN_CALL_READ_TABLE_RFC'
    EXPORTING
      id_tabname = p_table
    IMPORTING
      et_data    = <gt_itab>.


  LOOP AT <gt_itab> ASSIGNING <gs_record>.
    WRITE: / <gs_record>.
  ENDLOOP.


END-OF-SELECTION.

Here is the coding of fm ZUS_SDN_CALL_READ_TABLE_RFC:


FUNCTION zus_sdn_call_read_table_rfc.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(ID_TABNAME) TYPE  TABNAME
*"  EXPORTING
*"     REFERENCE(ET_DATA) TYPE  TABLE
*"----------------------------------------------------------------------

* define local data
  DATA: ld_xmlstring  TYPE xstring.


  CALL FUNCTION 'ZUS_SDN_READ_TABLE_RFC'
    DESTINATION 'NONE'  " simulate RFC call
    EXPORTING
      id_tabname         = id_tabname
    IMPORTING
      ed_xmlstring       = ld_xmlstring.
  .

  CALL TRANSFORMATION id
    SOURCE XML ld_xmlstring
    RESULT itab = et_data.

ENDFUNCTION.

And here the coding of fm ZUS_SDN_READ_TABLE_RFC:


FUNCTION zus_sdn_read_table_rfc.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(ID_TABNAME) TYPE  TABNAME
*"  EXPORTING
*"     VALUE(ED_XMLSTRING) TYPE  XSTRING
*"----------------------------------------------------------------------

* define local data
  DATA: ldo_data    TYPE REF TO data.

  FIELD-SYMBOLS:
    <lt_itab>       TYPE table.


" Dynamically create itab
  CREATE DATA ldo_data TYPE TABLE OF (id_tabname).
  ASSIGN ldo_data->* TO <lt_itab>.

  SELECT * FROM (id_tabname) INTO TABLE <lt_itab> UP TO 100 ROWS.


" NOTE: Using XSTRING instead of a simple STRING might be more safe
"       in a mixed Unicode/non-Unicode environment
  CALL TRANSFORMATION id
    SOURCE itab = <lt_itab>
    RESULT XML ed_xmlstring.

ENDFUNCTION.

Using class CL_ABAP_CONTAINER_UTILITIES you may run into trouble when you convert specific types.

For more details have a look at .

Regards

Uwe

Read only

0 Likes
2,981

Thanks Uwe, Rich, Eswar

Got solution after analysing TRUX function group

Solved the problem .

Read only

0 Likes
2,981

Hi,

I too have the same requirement as you faced some years back. Could you please share with me what is the solution you tried out to resolve your issue.

Thanks in advance.