2006 Dec 14 11:05 PM
I want to query a table and get the SUM ( fieldx) without any where clause. However, the fieldx should be dynamic.
Select SUM ( Gross_Wt ) from table. I want the Gross_Wt field to be dynamic.
Any sugestions.
I want to query a table and get the SUM ( fieldx) without any where clause. However, the fieldx should be dynamic.
Select SUM ( Gross_Wt ) from table. I want the Gross_Wt field to be dynamic.
Any sugestions.
2006 Dec 14 11:09 PM
Try using Field symbols.
Select SUM ( <FS_Gross_Wt> ) from table.
- guru
2006 Dec 14 11:13 PM
2006 Dec 14 11:14 PM
Welcome to SDN,
You can try like this
DATA : v_field(40) like c VALUE 'SUM(<FIELD NAME>)',
v_var TYPE p.
SELECT v_field FROM <TABLE> INTO v_var.
Just this blog you will get more idea
/people/alvaro.tejadagalindo/blog/2006/12/13/dynamic-inner-join-function-module
Regards
Kathirvel
2006 Dec 14 11:21 PM
Karthir, I tried your code, its not working either. Thanks & Regards.
2006 Dec 14 11:27 PM
Plz try this
DATA : v_field(40) like c VALUE 'SUM( <FIELD NAME> )',
v_var TYPE p.
SELECT v_field FROM <TABLE> INTO v_var GROUP BY <key Field>.
Regards
Kathirvel
2006 Dec 14 11:57 PM
Solved the problem
strtemp1 = 'SUM( '.
strtemp2 = ' )'.
CONCATENATE strtemp1 l_kfname strtemp2
INTO strsumfld SEPARATED BY space.
SELECT SINGLE ( strsumfld )
FROM (l_etblname)
INTO l_ecubetotal.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |