Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8526

Re: How can i get tablename ande fieldname dynamically

$
0
0

In your syntax FIELD is not evaluated, but SQL look for a field with name FIELD in the database table...

 

Sample to try

" Some work area
 DATA: cnt TYPE i,       fieldname TYPE fieldname VALUE 'ERVOL',       tabname TYPE tabname VALUE 'MARA',       text TYPE string,       dmax TYPE REF TO data,       dsum TYPE REF TO data.
 FIELD-SYMBOLS: <max> TYPE ANY,                <sum> TYPE ANY.
 * Create fields adequate to reveive aggegated values in SQL statement
 CONCATENATE tabname '-' fieldname INTO text.
 CREATE DATA dmax TYPE (text).
 ASSIGN dmax->* TO <max>.
 CREATE DATA dsum TYPE (text).
 ASSIGN dsum->* TO <sum>.
 * Execute SQL request (will only pass once in loop, required as Abap doesn't know we use aggregates)
 CONCATENATE 'COUNT( ' fieldname ' ) MAX( ' fieldname ' ) SUM( ' fieldname ')'   INTO text RESPECTING BLANKS.
 SELECT (text) INTO (cnt,<max>,<sum>) FROM (tabname).
 ENDSELECT.


Regards,

Raymond


Viewing all articles
Browse latest Browse all 8526

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>