2011 Dec 13 5:08 PM
Hi,
I am having a requirement where I should fetch the records count in a table, since there are close to 50 tables I have written below code, which is working fine with out WHERE clause, but going to short dump if I use a where clause.
IF NOT p_sel_opt IS INITIAL.
LOOP AT p_sel_opt INTO wa_sel_opt .
ASSIGN wa_sel_opt-low TO <fval>.
ASSIGN p_fieldname TO <field>.
IF <field> IS ASSIGNED AND <fval> IS ASSIGNED.
SELECT COUNT(*) FROM (p_tabname) WHERE <FIELD> = <fval> .
IF sy-subrc = 0.
wa_fi_bukrs-bukrs = <fval>.
wa_fi_bukrs-table = p_tabname.
wa_fi_bukrs-count = sy-dbcnt.
APPEND wa_fi_bukrs TO it_fi_bukrs.
CLEAR wa_fi_bukrs.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.Reason it is giving is
<field>is not availble in the data base tables . what can I do to the above query for that to work.
Thanks,
Varun
Hi,
I am having a requirement where I should fetch the records count in a table, since there are close to 50 tables I have written below code, which is working fine with out WHERE clause, but going to short dump if I use a where clause.
IF NOT p_sel_opt IS INITIAL.
LOOP AT p_sel_opt INTO wa_sel_opt .
ASSIGN wa_sel_opt-low TO <fval>.
ASSIGN p_fieldname TO <field>.
IF <field> IS ASSIGNED AND <fval> IS ASSIGNED.
SELECT COUNT(*) FROM (p_tabname) WHERE <FIELD> = <fval> .
IF sy-subrc = 0.
wa_fi_bukrs-bukrs = <fval>.
wa_fi_bukrs-table = p_tabname.
wa_fi_bukrs-count = sy-dbcnt.
APPEND wa_fi_bukrs TO it_fi_bukrs.
CLEAR wa_fi_bukrs.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.Reason it is giving is
<field>is not availble in the data base tables . what can I do to the above query for that to work.
Thanks,
Varun
2011 Dec 13 5:31 PM
replace <field> with (<field>) ok?
but, its better if you construct your where clause.. i dont know the above will work or not.
like
concatenate <FIELD> ' = ' <fval> into s1 separated by space.
and pass where (s1).
check the FM RFC_READ_TABLE. you will get a proper picture
Edited by: Soumyaprakash Mishra on Dec 13, 2011 11:02 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |