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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With