‎2011 Jun 07 3:53 PM
Hey experts,
I cannot call a r/3 table out of a local variable.
DATA: lv_test LIKE smoftables-r3tabname.
SELECT r3tabname FROM smoftables INTO lv_test WHERE objname = 'DNL_CUST_BASIS'.
WRITE /. Write /. Write /. Write lv_test.
ENDSELECT.
So I loop the r/3 table name into lv_test, but here comes my problem : I'd like to display the content of the original database table whose name was saved in lv_test. Is there any way to do so?
Thanks in advance!
‎2011 Jun 07 4:10 PM
Hi,
This can be done and some coding has to be done. Please search in SCN for creating dynamic internal table based on a dbtable name and retrieving the contents . You may find lot of threads. You can also check my reply here for a similar kind of question
‎2011 Jun 07 4:17 PM
Paul,
I am not sure that I follow your needs. Can you explain further?
‎2011 Jun 07 4:26 PM
If multiple records exist where objname = 'DNL...:" then you could use a simple Flag b/c you are using a SELECT... ENDSELECT. Bear in mind that Select... endselect is not a recommended code technique.
Something like below:
data: lv_First(1) value 'Y'.
Select ....
if lv_First = 'Y'.
write out the tab name
lv_First = 'N'.
endif.
EndSelect
Also - bear in mind that without an ORDER BY clause - that your OpenSQL could produce different results.
‎2011 Jun 07 4:33 PM
Funny how the same kinds of question pop up in clusters. See this thread, started today.
‎2011 Jun 08 12:36 PM
Hm I think you didnt quite get me.
lv_test is of the type r3table, there exist 8 of them (r3 database tables) within the adapter object "dnl_cust_basis".
For each loop of the select..endselect-statement I want to display one of them.
This is just a testing program because I need that functionality somewhere else.
‎2011 Jun 08 3:55 PM
Paul,
In that case, go with code like this:
DATA: lv_test LIKE smoftables-r3tabname.
data: lt_test type table of smoftables-r3tabname.
SELECT r3tabname INTO table lt_test
FROM smoftables
WHERE objname = 'DNL_CUST_BASIS'.
loop at lt_test into lv_test.
skip 3.
write: / lv_test.
endloop.
‎2011 Jun 08 3:57 PM
Again though - if order IS important - then an ORDER BY will be required.
A RDBMS does not gaurantee any ordering of the returned results. You must tell the RDBMS using an ORDER BY clause if that is necessary to meet your requirements.
‎2011 Jun 08 8:22 PM
Hi Paul,
Did you check th link which I referred ?
Your question was
I'd like to display the content of the original database table whose name was saved in lv_test.
You have the solution in the link i referred.
Keshav