Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return dynamically-typed table rows via RFC?

I need to return the rows of some tables via RFC, and the names of these tables are not known before the execution.

I have this statement which gets executed in a loop:

  SELECT *
    up to iv_max_count rows
    into table <lt_result>
    FROM (iv_table_name) AS ltab
    WHERE (SQL_WHERE).

How can I concatenate the <lt_result> results to one list/table and return this via RFC?

Of course all tables can have different structures. Creating one big table which holds all rows does not help.

like image 312
guettli Avatar asked Jul 18 '26 02:07

guettli


1 Answers

You can't return an arbitrary structure or structures in an RFC, they have to be predefined.

The best way I can think of to do this is to mimic the way SAP handles idocs in the database. Your table would need a minimum of two fields, the first would be a descriptor field telling the caller what the table structure is, and the second field would be a very long character type field with all the data concatenated together, either fixed width or delimited. This way, you could pass data from multiple tables in the same return structure.

If your calling program really knows nothing about SAP data sets, you would probably also need to grab metadata from table DD02l.

like image 92
Bryan Cain Avatar answered Jul 20 '26 14:07

Bryan Cain