2014 Jul 07 12:14 PM
Hi experts,
I have a requirement to display highest qualification based on subtypes .
lets say
Z3-Graduation
Z5- Diploma
Z4- PG
Z7-Others
here PG ( subtype - z4) is the highest qualification for some employee, for some "Graduation (z3) is highest qualification.
could anybody give me some idea to write the logic.
i'm having the data in internal table.
Thanks in Advance.
Regards
satish
2014 Jul 07 3:59 PM
DATA: qual_for_employee.
LOOP AT itab INTO workarea.
CASE workarea.
WHEN 'Z3'.
qual_for_employee = workarea.
WHEN 'Z5'.
IF qual_for_employee = 'Z3'.
ELSE.
qual_for_employee = workarea.
ENDIF.
WHEN 'Z4'.
IF qual_for_employee = 'Z3'.
ELSEIF qual_for_employee = 'Z5'.
ELSE.
qual_for_employee = workarea.
ENDIF.
WHEN 'Z7'.
IF qual_for_employee = 'Z3'.
ELSEIF qual_for_employee = 'Z5'.
ELSEIF qual_for_employee = 'Z4'.
ELSE.
qual_for_employee = workarea.
ENDIF.
ENDCASE.
ENDLOOP.
2014 Jul 07 12:27 PM
Dear Satish,
Best soltion is to have an internal table fill like this:
Employee group - Highest qualification
A Z3
B Z3
C Z4
Then use 2 loops together and write your condition in 2nd loop in "Where" clause
2014 Jul 07 12:30 PM
Hi Satish,
store the itab to temporary itab.
sort temporary itab by descending. and
delete adjacent duplicates.
try this .
Regards,
Venkat.
2014 Jul 07 12:40 PM
hi ramesh,
thanks for the prompt reply, i guess the logic u have given will not work as subgroups are in random order. if i sort my itab in desc, following is my result set as itab is having 4 records
Z7-Others
Z5- Diploma
Z4- PG
Z3-Graduation
but my requirement is to get highest qualification. here z4 - PG is the highest qualification.
regards
satish
2014 Jul 07 1:50 PM
Hi satish,
Check this code,
data: BEGIN OF itab OCCURS 0,
name(30) TYPE c,
id(02) TYPE c,
des(30) TYPE c,
Ini(01) TYPE c,
END OF itab,
wa LIKE LINE OF itab.
START-OF-SELECTION.
wa-name = 'Ram'.
wa-id = 'z7'.
wa-des = 'Others'.
APPEND wa to itab. CLEAR wa.
wa-name = 'Ram'.
wa-id = 'z2'.
wa-des = 'Diploma'.
APPEND wa to itab. CLEAR wa.
wa-name = 'Ram'.
wa-id = 'z4'.
wa-des = 'PG'.
APPEND wa to itab. CLEAR wa.
wa-name = 'Ram'.
wa-id = 'z8'.
wa-des = 'Graduation'.
APPEND wa to itab. CLEAR wa.
loop at itab INTO wa.
wa-ini = wa-des(01).
if wa-ini EQ 'O'.
wa-ini = 'A'.
ENDIF.
MODIFY itab FROM wa.
ENDLOOP.
sort itab by name ini DESCENDING.
READ TABLE itab INTO wa INDEX 1.
write:/ wa-name,
wa-des.
Regards,
Venkat.
2014 Jul 07 3:59 PM
DATA: qual_for_employee.
LOOP AT itab INTO workarea.
CASE workarea.
WHEN 'Z3'.
qual_for_employee = workarea.
WHEN 'Z5'.
IF qual_for_employee = 'Z3'.
ELSE.
qual_for_employee = workarea.
ENDIF.
WHEN 'Z4'.
IF qual_for_employee = 'Z3'.
ELSEIF qual_for_employee = 'Z5'.
ELSE.
qual_for_employee = workarea.
ENDIF.
WHEN 'Z7'.
IF qual_for_employee = 'Z3'.
ELSEIF qual_for_employee = 'Z5'.
ELSEIF qual_for_employee = 'Z4'.
ELSE.
qual_for_employee = workarea.
ENDIF.
ENDCASE.
ENDLOOP.
2014 Jul 08 6:48 AM
Hi Anthony,
Thank you very much for your helpful reply to achieve my requirement. thanks a lot.
regards
satish
2014 Jul 08 6:51 AM