SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Employee data



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> HR
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Fri Apr 11, 2008 11:36 pm    Post subject: Employee data Reply with quote

Code:
REPORT z_employee_data.

TYPE-POOLS: SLIS.

TABLES:pa0002,pa0008.

data:begin of it_pa0002 occurs 0,
checkbox,
pernr like pa0002-pernr,
begda like pa0002-begda,
endda like pa0002-endda,
vorna like pa0002-vorna,
nachn like pa0002-nachn,
end of it_pa0002.

data:begin of it_pa00021 occurs 0,
pernr like pa0002-pernr,
begda like pa0002-begda,
endda like pa0002-endda,
vorna like pa0002-vorna,
nachn like pa0002-nachn,
expand TYPE xfeld value 'X',
end of it_pa00021.

data:begin of it_pa0008 occurs 0,
pernr like pa0008-pernr,
begda like pa0008-begda,
endda like pa0008-endda,
ANSAL like pa0008-ANSAL,
LGA01 like pa0008-LGA01,
BET01 LIKE PA0008-BET01,
end of it_pa0008.

DATA: IT_FIELD_CAT TYPE SLIS_T_FIELDCAT_ALV,
IT_FIELD_CAT1 TYPE SLIS_T_FIELDCAT_ALV,
IT_LAYOUT1 TYPE SLIS_LAYOUT_ALV,
WA_FIELD_CAT TYPE SLIS_FIELDCAT_ALV,
WA_FIELD_CAT1 TYPE SLIS_FIELDCAT_ALV,
IT_LAYOUT TYPE SLIS_LAYOUT_ALV,
IT_EVENTS TYPE SLIS_T_EVENT,
WA_EVENTS TYPE SLIS_ALV_EVENT,
IT_HEADER TYPE SLIS_T_LISTHEADER,
WA_HEADER TYPE SLIS_LISTHEADER,
wa_keyinfo TYPE slis_keyinfo_alv.

CONSTANTS:c VALUE 'X'.

SELECT-OPTIONS: S_pernr FOR pa0002-pernr.

START-OF-SELECTION.
SET PF-STATUS 'DATA' .
PERFORM GET_DATA.

PERFORM BUILD_FIELD_CAT.

PERFORM GET_EVENTS.

PERFORM DISPLAY_DATA.

*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM GET_DATA .

SELECT pernr
begda
endda
vorna
nachn
FROM pa0002
INTO CORRESPONDING FIELDS OF TABLE IT_pa0002
WHERE pernr IN S_pernr.

ENDFORM. " get_data
*&---------------------------------------------------------------------*
*& Form build_field_cat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM BUILD_FIELD_CAT .

wa_field_cat-tabname = 'PA0002'.
WA_FIELD_CAT-FIELDNAME = 'CHECKBOX'.
wa_field_cat-ref_tabname = 'IT_PA0002'.
WA_FIELD_CAT-REPTEXT_DDIC = 'Check Box'.
APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
CLEAR WA_FIELD_CAT.

wa_field_cat-tabname = 'PA0002'.
WA_FIELD_CAT-FIELDNAME = 'PERNR'.
wa_field_cat-ref_tabname = 'IT_PA0002'.
WA_FIELD_CAT-REPTEXT_DDIC = 'Personnel no'.
APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
CLEAR WA_FIELD_CAT.

wa_field_cat-tabname = 'PA0002'.
WA_FIELD_CAT-FIELDNAME = 'BEGDA'.
wa_field_cat-ref_tabname = 'IT_PA0002'.
WA_FIELD_CAT-REPTEXT_DDIC = 'Start date'.
APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
CLEAR WA_FIELD_CAT.

wa_field_cat-tabname = 'PA0002'.
WA_FIELD_CAT-FIELDNAME = 'ENDDA'.
wa_field_cat-ref_tabname = 'IT_PA0002'.
WA_FIELD_CAT-REPTEXT_DDIC = 'End date'.
APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
CLEAR WA_FIELD_CAT.

wa_field_cat-tabname = 'PA0002'.
WA_FIELD_CAT-FIELDNAME = 'VORNA'.
wa_field_cat-ref_tabname = 'IT_PA0002'.
WA_FIELD_CAT-REPTEXT_DDIC = 'First name'.
APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
CLEAR WA_FIELD_CAT.

wa_field_cat-tabname = 'PA0002'.
WA_FIELD_CAT-FIELDNAME = 'NACHN'.
wa_field_cat-ref_tabname = 'IT_PA0002'.
WA_FIELD_CAT-REPTEXT_DDIC = 'Last name'.
APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
CLEAR WA_FIELD_CAT.

wa_field_cat1-tabname = 'PA0002'.
WA_FIELD_CAT1-FIELDNAME = 'PERNR'.
wa_field_cat1-ref_tabname = 'IT_PA00021'.
WA_FIELD_CAT1-REPTEXT_DDIC = 'Personnel no'.
APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
CLEAR WA_FIELD_CAT1.

wa_field_cat1-tabname = 'PA0002'.
WA_FIELD_CAT1-FIELDNAME = 'BEGDA'.
wa_field_cat1-ref_tabname = 'IT_PA00021'.
WA_FIELD_CAT1-REPTEXT_DDIC = 'Start date'.
APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
CLEAR WA_FIELD_CAT1.

wa_field_cat1-tabname = 'PA0002'.
WA_FIELD_CAT1-FIELDNAME = 'ENDDA'.
wa_field_cat1-ref_tabname = 'IT_PA00021'.
WA_FIELD_CAT1-REPTEXT_DDIC = 'End date'.
APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
CLEAR WA_FIELD_CAT1.

wa_field_cat1-tabname = 'PA0002'.
WA_FIELD_CAT1-FIELDNAME = 'VORNA'.
wa_field_cat1-ref_tabname = 'IT_PA00021'.
WA_FIELD_CAT1-REPTEXT_DDIC = 'First name'.
APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
CLEAR WA_FIELD_CAT.

wa_field_cat1-tabname = 'PA0002'.
WA_FIELD_CAT1-FIELDNAME = 'NACHN'.
wa_field_cat1-ref_tabname = 'IT_PA00021'.
WA_FIELD_CAT1-REPTEXT_DDIC = 'Last name'.
APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
CLEAR WA_FIELD_CAT1.

wa_field_cat1-tabname = 'PA0008'.
wa_field_cat1-fieldname = 'PERNR'.
wa_field_cat-ref_tabname = 'IT_PA0008'.
wa_field_cat1-REPTEXT_DDIC = 'personnelno'.
APPEND wa_field_cat1 TO it_field_cat1.
CLEAR WA_FIELD_CAT1.

wa_field_cat1-tabname = 'PA0008'.
wa_field_cat1-fieldname = 'BEGDA'.
wa_field_cat-ref_tabname = 'IT_PA0008'.
wa_field_cat1-REPTEXT_DDIC = 'begindate'.
APPEND wa_field_cat1 TO it_field_cat1.
CLEAR WA_FIELD_CAT1.

wa_field_cat1-tabname = 'PA0008'.
wa_field_cat1-fieldname = 'ENDDA'.
wa_field_cat-ref_tabname = 'IT_PA0008'.
wa_field_cat1-REPTEXT_DDIC = 'enddate'.
APPEND wa_field_cat1 TO it_field_cat1.
CLEAR WA_FIELD_CAT1.

wa_field_cat1-tabname = 'PA0008'.
wa_field_cat1-fieldname = 'ANSAL'.
wa_field_cat-ref_tabname = 'IT_PA0008'.
wa_field_cat1-REPTEXT_DDIC = 'annualsalary'.
APPEND wa_field_cat1 TO it_field_cat1.
CLEAR WA_FIELD_CAT1.

wa_field_cat1-tabname = 'PA0008'.
wa_field_cat1-fieldname = 'LGA01'.
wa_field_cat-ref_tabname = 'IT_PA0008'.
wa_field_cat1-REPTEXT_DDIC = 'wagetype'.
APPEND wa_field_cat1 TO it_field_cat1.
CLEAR WA_FIELD_CAT1.

wa_field_cat1-tabname = 'PA0008'.
wa_field_cat1-fieldname = 'BET01'.
wa_field_cat-ref_tabname = 'IT_PA0008'.

wa_field_cat1-REPTEXT_DDIC = 'Amount'.
APPEND wa_field_cat1 TO it_field_cat1.
CLEAR WA_FIELD_CAT1.

ENDFORM. " build_field_cat

*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM DISPLAY_DATA .

it_layout-box_fieldname = 'CHECKBOX'.
it_layout-EDIT = 'X'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FIELD_CAT
IS_LAYOUT = IT_LAYOUT
IT_EVENTS = IT_EVENTS
TABLES
T_OUTTAB = IT_pa0002.

ENDFORM. " display_data

*&---------------------------------------------------------------------*
*& Form get_events
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM GET_EVENTS .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
IMPORTING
ET_EVENTS = IT_EVENTS .

READ TABLE IT_EVENTS INTO WA_EVENTS
WITH KEY NAME = SLIS_EV_TOP_OF_PAGE.
IF SY-SUBRC = 0.
WA_EVENTS-FORM = 'TOP_OF_PAGE'.
MODIFY IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX.
ENDIF.

ENDFORM. " get_events

*&---------------------------------------------------------------------*
*& Form top_of_page
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM TOP_OF_PAGE.

WA_HEADER-TYP = 'H'.
WA_HEADER-INFO = 'EMPLOYEE DATA'.
APPEND WA_HEADER TO IT_HEADER.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_HEADER
.
ENDFORM. "top_of_page
*&---------------------------------------------------------------------*
*& Form GUI_SET
*&---------------------------------------------------------------------*
FORM GUI_SET USING RT_EXTAB TYPE SLIS_T_EXTAB .

SET PF-STATUS 'DATA' .

ENDFORM. "GUI_SET
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*

FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
R_SELFIELD TYPE SLIS_SELFIELD.

DATA:V_PERNR LIKE PA0002-PERNR.

CASE R_UCOMM.
WHEN 'DET'.
DATA: V_FLAG.
clear : v_flag.

LOOP AT IT_PA0002.
if it_PA0002-checkbox = 'X'.
v_flag = 'X'.
v_pernr = IT_PA0002-PERNR.

SELECT PERNR
BEGDA
ENDDA
VORNA
NACHN
FROM PA0002
INTO CORRESPONDING FIELDS OF TABLE IT_PA00021
WHERE PERNR = V_PERNR.
SORT IT_PA00021 BY PERNR.
DELETE ADJACENT DUPLICATES FROM IT_PA00021 COMPARING PERNR.
READ TABLE IT_PA00021 INDEX 1.

SELECT PERNR
BEGDA
ENDDA
ANSAL
LGA01
BET01
FROM PA0008
INTO TABLE IT_PA0008
FOR ALL ENTRIES IN IT_PA00021
WHERE PERNR = IT_PA00021-PERNR.

if not it_PA0008[] Is initial.
SORT IT_PA0008 BY PERNR.
READ TABLE IT_PA0008 INDEX 1.
endif.
endif.

it_layout1-group_change_edit = c.
it_layout1-colwidth_optimize = c.
it_layout1-zebra = c.
it_layout1-detail_popup = c.
it_layout1-get_selinfos = c.

it_layout-expand_fieldname = 'EXPAND'.

wa_keyinfo-header01 = 'PERNR'.
wa_keyinfo-item01 = 'PERNR'.

IF NOT V_FLAG IS INITIAL.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = IT_LAYOUT1
IT_FIELDCAT = IT_FIELD_CAT1
I_TABNAME_HEADER = 'PA0002'
I_TABNAME_ITEM = 'PA0008'
IS_KEYINFO = wa_keyinfo
TABLES
T_OUTTAB_HEADER = IT_PA00021
T_OUTTAB_ITEM = IT_PA0008.
ENDIF.
CLEAR: IT_PA00021,IT_PA0002,IT_PA0008.
ENDLOOP.

WHEN 'BACK'.
EXIT.
ENDCASE.

ENDFORM. "USER_COMMAND
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> HR All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.