Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Total no of records based on year wise

Former Member
0 Kudos

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

7 REPLIES 7

Former Member
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

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....

0 Kudos

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.

0 Kudos

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.

0 Kudos

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.

JozsefSzikszai
Active Contributor
0 Kudos

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