2008 Feb 18 9:16 PM
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 ?
a®
2008 Feb 19 4:23 AM
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 ?
a®
2008 Feb 18 9:26 PM
2008 Feb 18 9:49 PM
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.
a®
2008 Feb 19 12:29 AM
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.
2008 Feb 19 3:05 AM
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.
a®
2008 Feb 19 3:29 AM
Hi,
Please check the code sample in following link, hope that can give you some lead.
Regards
Eswar
2008 Feb 19 3:42 AM
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.
a®
2008 Feb 19 3:54 AM
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
2008 Feb 19 4:23 AM
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
2008 Feb 19 1:12 PM
Thanks Uwe, Rich, Eswar
Got solution after analysing TRUX function group
Solved the problem .
a®
2012 Jan 17 12:27 PM
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.