Application Development and Automation 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: 
Read only

Count With Condition

Former Member
0 Likes
1,075

Hi to All,

This is Satheesh Charles, Newly join to this Forum.

I want to count number of female patient under some condition,

If Month = JAN & patient_gender = F i have to count all the F value.

How to perform this operation ?. pls suggest.

1 ACCEPTED SOLUTION
Read only

sarbajitm
Contributor
0 Likes
1,042

Various way

1)You can use Select Count(*) from tabname into cnt where your where condition

where cnt is of type integer i.e. i.

2)you can use sy-dbcnt after your select statement..

Now its upto you which one you use.

Regards.

Sarbajit.

8 REPLIES 8
Read only

Former Member
0 Likes
1,042

Use a COUNTER with the IF statement.

Read only

0 Likes
1,042

Are you mean by using count option

Read only

sarbajitm
Contributor
0 Likes
1,043

Various way

1)You can use Select Count(*) from tabname into cnt where your where condition

where cnt is of type integer i.e. i.

2)you can use sy-dbcnt after your select statement..

Now its upto you which one you use.

Regards.

Sarbajit.

Read only

Former Member
0 Likes
1,042

HI,

DATA: g_fcount type I.

IF Month = JAN AND patient_gender = 'F'.
 g_fcount = g_fcount + 1.
ENDIF.

Read only

0 Likes
1,042

Thanks for your valuable answer, But i have to perform this operaion in crystal report not in DB

Read only

siddhesh_pathak4
Contributor
0 Likes
1,042

Hello,

You can use the SAP provided library function, COUNT,

refer the URL,

[http://help.sap.com/saphelp_nw04/helpdata/en/48/b4e443c0ca11d2a97100a0c9449261/frameset.htm]

Read only

Former Member
0 Likes
1,042

Dear Sateesh

Welcome to the forum.

if u have that values in an internal table u can do as follows

let us assume that the internal table is ITAB

and it has the following fields at minimum

month " field names are self explanatory

gender

declare another internal table as below

data : begin of itab_new occurs 0,

month(3) type c, -


>" same field names as in ITAB

gender(1) type c,

count type i,

end of itab_new.

loop at ITAB.

clear : itab_new.

move-corresponding ITAB to ITAB_NEW. (this will work if the field names are exactly same in both

ITAB_NEW-COUNT = 1. the tables)

collect ITAB_NEW.

endloop.

if u want only 'F' the use WHERE addition in LOOP , like

LOOP AT ITAB_NEW WHERE GENDER = 'F'.

Regards

Prabumanoharan

Read only

0 Likes
1,042

Thank you prabhu,

How ever i have to perform this operation with CRYSTAL REPORTS formula coloum