Like USR02, USGRP_USER has a validity range. When selecting from USR02, you have to treat an empty validity date field as beginning (or end) of time.
SELECT usgrp_user~bname usgrp_user~from_dat usgrp_user~to_dat usr02~gltgv usr02~gltgb INTO TABLE userids FROM usgrp_user INNER JOIN usr02 ON usr02~bname EQ usgrp_user~bname WHERE usergroup EQ c_deputy_user_group * AND ( from_dat LE sy-datum OR from_dat EQ '00000000' ) * AND ( to_dat GE sy-datum OR to_dat EQ '00000000' ) AND ( gltgv LE sy-datum OR gltgv EQ '00000000' ) AND ( gltgb GE sy-datum OR gltgb EQ '00000000' ).<br>
I've a bunch of valid users, with valid groups - some with the dates set, some not. At the moment, I'm looping through userids, after the select.
LOOP AT userids ASSIGNING <userid>. CHECK ( <userid>-from_date LE sy-datum OR <userid>-from_date IS INITIAL ) AND ( <userid>-to_date GE sy-datum OR <userid>-to_date IS INITIAL ).Now, if I uncomment lines 2 and 3 of the WHERE clause, I'd expect not to need that CHECK. But then the SELECT gets no data...