12-13-2007 11:58 AM
hi ,
i want to find total no of records for given a table( this table name is user will enter in selection screen ) based on year wise.
regards,
siva kumar
12-13-2007 12:11 PM
hi siva
using sy-index to find the num of records in table .
if itab-date is not initial.
sy-index = sy-index + 1 .
endif.
like this u follow
12-13-2007 12:25 PM
hi,
siva
use describe table tablename lines w_no.
note: The current number of table rows of the internal table itab is determined and is assigned to the data object lin.The data type i is expected for the data object.
try this u can get no of lines in tht internal table
or else.
select * from table
w_no = w_no + 1.
endselect.
write: / w_no.
it also works
plzzzzzzz reward if useful
feel free to ask any quiries my mail id is mutyalasunilkumar@gmail.com
12-13-2007 12:39 PM
user will give the table name in selection screen ,i want to display the total of records based on year wise.
suppose i am using the below code
PARAMETERS : p_table(10) TYPE c.
data:count type sy-dbcnt.
DATA: w_tabname TYPE w_tabname,
w_dref TYPE REF TO data,
w_grid TYPE REF TO cl_gui_alv_grid.
FIELD-SYMBOLS: <t_itab> TYPE ANY TABLE.
w_tabname = p_table.
CREATE DATA w_dref TYPE TABLE OF (w_tabname).
ASSIGN w_dref->* TO <t_itab>.
START-OF-SELECTION.
SELECT *
FROM (w_tabname)
INTO TABLE <t_itab>.
here in intertable <t_itab > i have to calculate the total no records based on year wise,,,,year wise....
12-13-2007 12:48 PM
SELECT *
FROM (w_tabname)
INTO TABLE <t_itab>.
so u hav all the records in an internal table suppose it_tab.
sort it_tab by date.
loop at it_tab.
cnt = cnt + 1.
at end of date.
write: date,cnt.
clear cnt.
endloop.
hope dis helps
endat.
12-13-2007 12:51 PM
suppose user will enter MSEG table here i have to consider mjahr field,
vbak means ERDAT field how i can do in runtime these selection.
12-13-2007 12:53 PM
hi siva
try like this
PARAMETERS : p_table(10) TYPE c.
data:count type sy-dbcnt.
DATA: w_tabname TYPE w_tabname,
w_dref TYPE REF TO data,
w_grid TYPE REF TO cl_gui_alv_grid.
FIELD-SYMBOLS: <t_itab> TYPE ANY TABLE.
w_tabname = p_table.
CREATE DATA w_dref TYPE TABLE OF (w_tabname).
ASSIGN w_dref->* TO <t_itab>.
START-OF-SELECTION.
SELECT *
FROM (w_tabname)
INTO TABLE <t_itab>.
sort <t_itab> ascending by (datefield) .
loop at <T_itab> into w_tabname.
count = count + 1 .
write : / count, w_tabname.
endloop.
12-13-2007 12:53 PM
hi Siva,
you can use the following statement in the program:
PARAMETERS : p_table TYPE tablename.
SELECT COUNT( * )
FROM (p_table)
WHERE ...
You wrote that you need this information year-wise, in WHERE you need some conditions for this. However in some tables there is field for year (like BKPF-GJAHR), or field for creation date (like BKPF-ERDAT), but it can vary table by table (usually ERDAT is OK), so there could be problems.
ec