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

RFC Function Module

Former Member
0 Likes
2,286

Hi Experts,

I am writing a select query in a rfc function module who's tablename is decided at runtime.After the selection i want to pass those entries from where the FM is being called.

I have wriiten the select query.To send the retrieved entries, I dont know how to declare a dynamic table in rfc FM. i.e in the TABLES parameter.

Could any one guide me how to do that please.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,824

you cannot use generic type in RFC FM so here is what you can do:

create an exporting parameter of type XSTRING.

apply transformation on you internal table in FM after you fetch data:


* Convert the dynamic data into XML format to be sent to RFC FM
  CALL TRANSFORMATION id_indent
     SOURCE itab = pv_table
     RESULT XML lv_xstring.

in the calling program do reverse transformation:


*  Convert xstring back into XML
    CALL TRANSFORMATION id_indent
      SOURCE XML i_xstring
      RESULT itab = <lt_table>.

10 REPLIES 10
Read only

Former Member
0 Likes
1,824

check this FM

RFC_READ_TABLE

this reads data from any table + with RFC connection + works with where clause as well

Read only

Former Member
0 Likes
1,824

Hi,

Use the following link for Dynamic SQL

<<linkfarm removed>>

Edited by: kishan P on Jan 17, 2012 6:29 PM

Read only

Former Member
0 Likes
1,825

you cannot use generic type in RFC FM so here is what you can do:

create an exporting parameter of type XSTRING.

apply transformation on you internal table in FM after you fetch data:


* Convert the dynamic data into XML format to be sent to RFC FM
  CALL TRANSFORMATION id_indent
     SOURCE itab = pv_table
     RESULT XML lv_xstring.

in the calling program do reverse transformation:


*  Convert xstring back into XML
    CALL TRANSFORMATION id_indent
      SOURCE XML i_xstring
      RESULT itab = <lt_table>.

Read only

0 Likes
1,824

Hi,

Thanks a lot for your reply. I also want to pass a dynamic table with entries to the rfc Fm how can i do that. Is there any way. Please guide on.

Read only

0 Likes
1,824

vadiv_maha wrote:

"Thanks a lot for your reply. I also want to pass a dynamic table with entries to the rfc Fm how can i do that. Is there any way. Please guide on."

I have given the steps in my previous post do you have any specific question on it?

Read only

0 Likes
1,824

Those steps are very clear.

But how do i pass a dynamic table entry to rfc Fm with entries. Could you help me on that please.

Read only

0 Likes
1,824

It cannot be passed as table you need to convert table data into XML and store the result in XSTRING format. to transform you dynamic table data in XML use call transformation, assume you data is in table pv_table:


* Convert the dynamic data into XML format to be sent to RFC FM
  CALL TRANSFORMATION id_indent
     SOURCE itab = pv_table
     RESULT XML lv_xstring.

once this tranformation is executed your data will reside in XSTRING type variable lv_xstring and you can pass it as you pass any other normal exporting parameter. parameter type should be given as XSTRING.

Edited by: Gaurav B. on Jan 17, 2012 2:22 PM

Read only

0 Likes
1,824

Hi thanks a lot for u r help my issue is resolved.

Read only

surajarafath
Contributor
0 Likes
1,824

This case is One difficult. I also received this requirement a week ago. After the search I found , you can refer FM HR_READ_INFOTYPE in that they have used dynamic table you can refer to that.

And I found one good code sample the link is below. You need to pass it as XML to achieve.

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f50dcd4e-0501-0010-3596-b686a7b51...

Read only

0 Likes
1,824

oh thanks a lot for u r response. will check it out.