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

select count

Former Member
0 Likes
503

Hi all,

how to count number of employ in several bukrs.

I have 25 bukrs , I need to display number of employs from every company separated in one report

eg. bukrs 2800 4539 emp

2300 342 emp.

I used pa0000 and pa0001.

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
0 Likes
454

Try this way


ranges : r_bukrs for t001-bukrs.
select * from t001 into table i_t001.
loop at i_t001w.
   move 'I' to r_bukrs-sign.
   move 'EQ' to r_bukrs-option.
   move i_t001-bukrs to r_bukrs-low.
   append r_bukrs.
endloop.

if not r_bukrs[] is initial.
  select count( distinct pa0001~pernr ) into i_noofemp
  from pa0001 inner join pa0000
  on pa0001~pernr = pa0000~pernr
  where pa0001~bukrs in r_bukrs.
endif.

a®

3 REPLIES 3
Read only

Former Member
0 Likes
454

Hi,

If you are using the LDB then use the collect statement to get the count.

If you are using the Select statement to get the Pernr 0000 and 0001 infotype data ..you need to loop and find the Count as per bukrs.

Incase LDB.

GET PERNR.

ITAB-bukrs = P0001-bukrs.
ITAB-COUNT = 1.
COLLECT ITAB.
Clear ITAB.

In case Select.

LOOP AT PA0001.
  ITAB-bukrs = P0001-bukrs.
  ITAB-COUNT = 1.
  COLLECT ITAB.
  Clear ITAB.
ENDLOOP.

Read only

former_member194669
Active Contributor
0 Likes
455

Try this way


ranges : r_bukrs for t001-bukrs.
select * from t001 into table i_t001.
loop at i_t001w.
   move 'I' to r_bukrs-sign.
   move 'EQ' to r_bukrs-option.
   move i_t001-bukrs to r_bukrs-low.
   append r_bukrs.
endloop.

if not r_bukrs[] is initial.
  select count( distinct pa0001~pernr ) into i_noofemp
  from pa0001 inner join pa0000
  on pa0001~pernr = pa0000~pernr
  where pa0001~bukrs in r_bukrs.
endif.

a®

Read only

Former Member
0 Likes
454

Very vague - do you want only active employees, all employees, something else?

Rob