The coding for this is :
REPORT zservice .
*----------------------------------------------------------*
* tables
*----------------------------------------------------------*
TABLES: pernr,
pa0002,
pa0001.
*----------------------------------------------------------*
* info types
*----------------------------------------------------------*
INFOTYPES: 0002,
0001.
*----------------------------------------------------------*
* variables
*----------------------------------------------------------*
DATA: v_age TYPE d,
v_service TYPE d,
v_currentdate TYPE d,
v_currentdate1 TYPE d,
v_years TYPE d,
v_enddate TYPE d .
DATA:service TYPE char2 ,
diff TYPE char2 .
*----------------------------------------------------------*
* internal tables
*----------------------------------------------------------*
DATA: BEGIN OF itab OCCURS 0,
pernr LIKE pa0002-pernr,
begda LIKE pa0002-begda,
endda LIKE pa0002-endda,
nachn LIKE pa0002-nachn,
vorna LIKE pa0002-vorna,
gbdat LIKE pa0002-gbdat,
age TYPE d,
END OF itab.
DATA: BEGIN OF itab1 OCCURS 0,
pernr LIKE pa0001-pernr,
begda LIKE pa0001-begda,
endda LIKE pa0001-endda,
serv TYPE d,
END OF itab1 .
*----------------------------------------------------------*
* selection screen
*----------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:s_pernr FOR pa0002-pernr .
SELECT-OPTIONS: s_serv FOR service OBLIGATORY.
SELECTION-SCREEN END OF BLOCK block1.
*----------------------------------------------------------*
* start of selection
*----------------------------------------------------------*
START-OF-SELECTION .
IF s_serv-high IS INITIAL.
diff = s_serv-low .
CONCATENATE '00' diff '0101' INTO v_currentdate.
ELSE.
diff = s_serv-high - s_serv-low .
CONCATENATE '00' s_serv-low '0101' INTO v_currentdate.
ENDIF.
PERFORM get_data1.
PERFORM get_data2.
*----------------------------------------------------------*
* tables
*----------------------------------------------------------*
END-OF-SELECTION.
IF itab[] IS INITIAL.
WRITE:/ 'NO EMPLOYEE WITH',
v_currentdate+2(2),
'YEARS OF SERVICE' COLOR 7 .
ENDIF.
PERFORM display_emplist.
*&---------------------------------------------------------------------*
*& Form get_data1
*----------------------------------------------------------------------*
FORM get_data1 .
diff = s_serv-high - s_serv-low .
CONCATENATE '00' s_serv-low '0101' INTO v_currentdate.
ENDIF.
PERFORM get_data1.
PERFORM get_data2.
*----------------------------------------------------------*
* tables
*----------------------------------------------------------*
END-OF-SELECTION.
IF itab[] IS INITIAL.
WRITE:/ 'NO EMPLOYEE WITH',
v_currentdate+2(2),
'YEARS OF SERVICE' COLOR 7 .
ENDIF.
PERFORM display_emplist.
*&---------------------------------------------------------------------*
*& Form get_data1
*----------------------------------------------------------------------*
FORM get_data1 .
SELECT pernr
begda
endda
vorna
nachn
gbdat
FROM pa0002
INTO CORRESPONDING FIELDS OF TABLE itab
WHERE pernr IN s_pernr
AND begda LE sy-datum
AND endda GE sy-datum .
LOOP AT itab .
itab-age = sy-datum - itab-gbdat .
MODIFY itab TRANSPORTING age .
ENDLOOP .
ENDFORM.
*&---------------------------------------------------------------------*
*& Form display_emplist
*----------------------------------------------------------------------*
FORM display_emplist .
LOOP AT itab1 .
READ TABLE itab WITH KEY pernr = itab1-pernr .
IF s_serv-high IS INITIAL .
IF itab1-serv+2(2) EQ s_serv-low .
IF itab1-serv+2(2) EQ s_serv-low .
WRITE:/1 itab-pernr,
15 itab1-begda ,
30 itab1-endda ,
45 itab-nachn,
65 itab-vorna,
85 itab-gbdat,
98 itab-age+2(2),
109 itab1-serv+2(2) .
15 itab1-begda ,
30 itab1-endda ,
45 itab-nachn,
65 itab-vorna,
85 itab-gbdat,
98 itab-age+2(2),
109 itab1-serv+2(2) .
ENDIF.
ELSE.
IF itab1-serv+2(2) GE s_serv-low AND itab1-serv+2(2) LE s_serv-high.
WRITE:/1 itab-pernr,
15 itab1-begda ,
30 itab1-endda ,
45 itab-nachn,
65 itab-vorna,
85 itab-gbdat,
98 itab-age+2(2),
109 itab1-serv+2(2) .
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form get_data2
*----------------------------------------------------------------------*
FORM get_data2 .
SELECT pernr
begda
endda
FROM pa0001
INTO CORRESPONDING FIELDS OF TABLE itab1
FOR ALL ENTRIES IN itab
WHERE pernr = itab-pernr
AND begda LE sy-datum
AND endda GE sy-datum .
LOOP AT itab1 .
v_enddate = itab1-endda .
v_years = sy-datum - itab1-begda.
IF v_years GE v_currentdate AND v_enddate GE '99991231' .
itab1-serv = v_years .
MODIFY itab1 TRANSPORTING serv .
ENDIF .
ELSE.
IF itab1-serv+2(2) GE s_serv-low AND itab1-serv+2(2) LE s_serv-high.
WRITE:/1 itab-pernr,
15 itab1-begda ,
30 itab1-endda ,
45 itab-nachn,
65 itab-vorna,
85 itab-gbdat,
98 itab-age+2(2),
109 itab1-serv+2(2) .
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form get_data2
*----------------------------------------------------------------------*
FORM get_data2 .
SELECT pernr
begda
endda
FROM pa0001
INTO CORRESPONDING FIELDS OF TABLE itab1
FOR ALL ENTRIES IN itab
WHERE pernr = itab-pernr
AND begda LE sy-datum
AND endda GE sy-datum .
LOOP AT itab1 .
v_enddate = itab1-endda .
v_years = sy-datum - itab1-begda.
IF v_years GE v_currentdate AND v_enddate GE '99991231' .
itab1-serv = v_years .
MODIFY itab1 TRANSPORTING serv .
ENDIF .
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form top of page
*----------------------------------------------------------------------*
TOP-OF-PAGE.
WRITE:/ 'Personnel no',
15 'join date' ,
30 'last date ',
45 'LAST NAME',
65 'FIRST NAME',
85 'DOB',
98 'EMP AGE',
109 'EMP SERVICE' .
ULINE.
ALSO READ:
- BADI HRECM00_BDG0001 - Upload Initial Budgets From Excel Sheet.
- Get Employee Picture In Selection Screen.
- Unified Access to All HR Infotypes.
- F4(Value On Request) For Organization Unit In HR Report Program.
- Employee Pay Scale Report Program.
.....Back To Sub-Index On HR ABAP.
.....Back To MAIN INDEX.
No comments:
Post a Comment