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: 

Counting of values in the internal table.

Former Member
0 Kudos

Hi experts,

kindly give the logic.

i have 2 internal table, i_itab and itab2 and itab3. itab consists of different categorie form table "pa0233" say A,B,C.

ITAB2 consists of gender frm pa0002 say F or M. itab3 contains no.of trainees.i have requirement to see for a particular categorie say A for which how many f has belongs to ... ie. my output should get.

categorie gender no.of. trainees(total no. of trainees belongs to particular categorie for particular gender)

A - f - 7

B - f - 9

A - m - 16

B - m - 21

Thanks,

Priya.

Edited by: Priyadharshini Veluswamy on Sep 17, 2008 9:03 AM

5 REPLIES 5

Former Member
0 Kudos

use



select count * from <table> where .....

Former Member
0 Kudos

hi,

Could u give brief explaination.

Thanks,

priya.

Former Member
0 Kudos

Use

DESCRIBE TABLE mytab LINES myvar.

for get the registers in an internal table

Former Member
0 Kudos

hi ,

u can use :

select COUNT( DISTINCT col )

or

| COUNT( * )

or

| count(*) } ... .

Description:

COUNT( DISTINCT col ) Determines the number of different values in the column col in the resulting set or in the current group.

COUNT( * ) (or count(*)) Determines the number of rows in the resulting set or in the current group. No column label is specified in this case.

hope it will help you

thanks and regards

rahul sharma

Edited by: RAHUL SHARMA on Sep 17, 2008 11:56 AM

Edited by: RAHUL SHARMA on Sep 17, 2008 11:57 AM

Edited by: RAHUL SHARMA on Sep 17, 2008 11:58 AM

Former Member
0 Kudos

Hi,

Please find the code below I have framed it, as per my understanding of your requirement. Hope you will get valuable help to sove your problem from code below.

REPORT Z_COMP.

data: begin of itab1 occurs 0,

f1 type c,

f2 type c,

end of itab1.

data: begin of itab2 occurs 0,

f1 type c,

sex type c,

end of itab2.

data: v_count1 type i,

v_count2 type i.

data: begin of itab3 occurs 0,

f1 type c,

sex type c,

count type i,

end of itab3.

itab1-f1 = 'A'.

itab1-f2 = 'Z'.

append itab1.

clear itab1.

itab1-f1 = 'B'.

itab1-f2 = 'Z'.

append itab1.

clear itab1.

itab1-f1 = 'C'.

itab1-f2 = 'Z'.

append itab1.

clear itab1.

**************************************************************

itab2-f1 = 'A'.

itab2-sex = 'M'.

append itab2.

clear itab2.

itab2-f1 = 'A'.

itab2-sex = 'F'.

append itab2.

clear itab2.

itab2-f1 = 'A'.

itab2-sex = 'F'.

append itab2.

clear itab2.

itab2-f1 = 'B'.

itab2-sex = 'M'.

append itab2.

clear itab2.

itab2-f1 = 'B'.

itab2-sex = 'F'.

append itab2.

clear itab2.

itab2-f1 = 'B'.

itab2-sex = 'F'.

append itab2.

clear itab2.

itab2-f1 = 'C'.

itab2-sex = 'M'.

append itab2.

clear itab2.

itab2-f1 = 'C'.

itab2-sex = 'F'.

append itab2.

clear itab2.

************************************************************

loop at itab1.

clear v_count1.

clear v_count2.

AT NEW F1.

loop at itab2 where f1 eq itab1-f1.

if itab2-sex = 'F'.

v_count1 = v_count1 + 1.

else.

v_count2 = v_count2 + 1.

endif.

endloop.

itab3-f1 = itab1-f1.

itab3-sex = 'F'.

itab3-count = v_count1.

append itab3.

itab3-f1 = itab1-f1.

itab3-sex = 'M'.

itab3-count = v_count2.

append itab3.

ENDAT.

ENDLOOP.

loop at itab3.

write:/ itab3-f1,

itab3-sex,

itab3-count.

endloop.

With best wishes,

Murthy.