* Logged Changes In INFOTYPE Data *
* Also We Can Use STANDARD SAP Report Program RPUAUD00
REPORT ZHR_D213_AS08.
TABLES PERNR.
INFOTYPES:
0000,0001,0002,
0006,0008.
RANGES:R_PERNR
FOR PERNR-PERNR,
R_INFTY FOR P0008-INFTY.
DATA IT_LOG TYPE
PLDOC_KEY_TAB.
DATA WA_LOG TYPE
PLDOC_KEY.
DATA IT_INFTY_B
TYPE PRELP_TAB.
DATA WA_INFTY_B TYPE
PRELP.
DATA IT_INFTY_A
TYPE PRELP_TAB.
DATA WA_INFTY_A
TYPE PRELP.
DATA IT_FIELDS
LIKE HRINFTYLOG_FIELDS OCCURS 0 WITH HEADER LINE.
DATA:BEGIN OF
IT_FINAL OCCURS 0,
FNAME(6) TYPE C,
OLD(10)
TYPE C,
NEW(10)
TYPE C,
PERNR TYPE PERNR,
NACHN TYPE NACHN,
HIRE
TYPE PREL-BEGDA,
WERKS TYPE P0001-WERKS,
BTRTL TYPE P0001-BTRTL,
STRAS TYPE P0006-STRAS,
ORT01 TYPE P0006-ORT01,
ORT02 TYPE P0006-ORT02,
PSTLZ TYPE P0006-PSTLZ,
TRFAR TYPE P0008-TRFAR,
TRFGB TYPE P0008-TRFGB,
TRFGR TYPE P0008-TRFGR,
ANSAL TYPE P0008-ANSAL,
END OF IT_FINAL.
DATA: V_PERNR
TYPE PERNR,
V_NACHN TYPE NACHN,
V_HIRE
TYPE PREL-BEGDA,
V_WERKS TYPE P0001-WERKS,
V_BTRTL TYPE P0001-BTRTL,
V_STRAS TYPE P0006-STRAS,
V_ORT01 TYPE P0006-ORT01,
V_ORT02 TYPE P0006-ORT02,
V_PSTLZ TYPE P0006-PSTLZ,
V_TRFAR TYPE P0008-TRFAR,
V_TRFGB TYPE P0008-TRFGB,
V_TRFGR TYPE P0008-TRFGR,
V_ANSAL TYPE P0008-ANSAL.
DATA IT_HIFI TYPE
PHIFI OCCURS 0 WITH HEADER LINE.
DATA IT_UNAME
TYPE UNAME_RANGE OCCURS 0 WITH HEADER LINE.
PARAMETER P_FILE
TYPE STRING.
AT
SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL METHOD CL_RSAN_UT_FILES=>F4
EXPORTING
I_APPLSERV = SPACE
I_TITLE = SPACE
I_GUI_EXTENSION = '.TXT'
I_GUI_EXT_FILTER = SPACE
* I_GUI_INITIAL_DIRECTORY =
* I_APPLSERV_LOGICAL =
'X'
* I_APPLSERV_AL11 = 'X'
* IMPORTING
* E_CANCELED =
* E_LOGICAL_FILE =
* E_AL11_CHOSEN =
CHANGING
C_FILE_NAME = P_FILE
* EXCEPTIONS
* FAILED = 1
* others = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID
SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3
SY-MSGV4.
ENDIF.
START-OF-SELECTION.
GET PERNR.
RP-READ-ALL-TIME-ITY PN-BEGDA PN-ENDDA.
CALL FUNCTION 'RP_HIRE_FIRE'
EXPORTING
BEG = PN-BEGDA
END = PN-ENDDA
IMPORTING
* FIRE_DATE =
HIRE_DATE = V_HIRE
TABLES
PPHIFI = IT_HIFI
PP0000 = P0000
PP0001 = P0001
.
REFRESH R_PERNR[].
R_PERNR-SIGN = 'I'.
R_PERNR-OPTION = 'EQ'.
R_PERNR-LOW = PERNR-PERNR.
APPEND R_PERNR.
REFRESH R_INFTY.
R_INFTY-SIGN = 'I'.
R_INFTY-OPTION = 'EQ'.
R_INFTY-LOW = '0000'.
APPEND R_INFTY.
CLEAR R_INFTY.
R_INFTY-SIGN = 'I'.
R_INFTY-OPTION = 'EQ'.
R_INFTY-LOW = '0001'.
APPEND R_INFTY.
CLEAR R_INFTY.
R_INFTY-SIGN = 'I'.
R_INFTY-OPTION = 'EQ'.
R_INFTY-LOW = '0006'.
APPEND R_INFTY.
CLEAR
R_INFTY.
R_INFTY-SIGN = 'I'.
R_INFTY-OPTION = 'EQ'.
R_INFTY-LOW = '0008'.
APPEND R_INFTY.
CLEAR R_INFTY.
IT_UNAME-SIGN = 'I'.
IT_UNAME-OPTION = 'EQ'.
IT_UNAME-LOW = 'SAPUSER'.
APPEND IT_UNAME.
CLEAR IT_UNAME.
CALL FUNCTION 'HR_INFOTYPE_LOG_GET_LIST'
EXPORTING
TCLAS = 'A'
BEGDA = PN-BEGDA
ENDDA = PN-ENDDA
* AUTH_CHECK = 'X'
* USE_ARCHIVE = ' '
* IMPORTING
* SUBRC =
TABLES
PERNR_TAB = R_PERNR[]
INFTY_TAB = R_INFTY[]
INFTY_LOGG_KEY_TAB = IT_LOG
* DATUM_TAB =
UNAME_TAB = IT_UNAME
.
LOOP AT IT_LOG INTO WA_LOG.
CALL FUNCTION 'HR_INFOTYPE_LOG_GET_DETAIL'
EXPORTING
LOGGED_INFOTYPE = WA_LOG
* AUTH_CHECK = 'X'
* USE_ARCHIVE = ' '
* IMPORTING
* SUBRC =
TABLES
INFTY_TAB_BEFORE = IT_INFTY_B
INFTY_TAB_AFTER = IT_INFTY_A
FIELDS = IT_FIELDS
.
MOVE: PERNR-PERNR TO V_PERNR,
P0002-NACHN TO V_NACHN,
P0001-WERKS TO V_WERKS,
P0001-BTRTL TO V_BTRTL,
P0006-STRAS TO V_STRAS,
P0006-ORT01 TO V_ORT01,
P0006-ORT02 TO V_ORT02,
P0006-PSTLZ TO V_PSTLZ,
P0008-TRFAR TO V_TRFAR,
P0008-TRFGB TO V_TRFGB,
P0008-TRFGR TO V_TRFGR,
P0008-ANSAL TO V_ANSAL.
LOOP AT IT_FIELDS.
IF IT_FIELDS-FNAME = 'PERSK' OR
IT_FIELDS-FNAME = 'STAT2'
OR IT_FIELDS-FNAME = 'ORT01' OR
IT_FIELDS-FNAME = 'TRFGB'.
IF IT_FIELDS-OLDDT NE IT_FIELDS-NEWDT.
MOVE: IT_FIELDS-FNAME TO
IT_FINAL-FNAME,
IT_FIELDS-OLDDT TO
IT_FINAL-OLD,
IT_FIELDS-NEWDT TO
IT_FINAL-NEW,
V_PERNR TO IT_FINAL-PERNR,
V_NACHN TO IT_FINAL-NACHN,
V_HIRE TO IT_FINAL-HIRE,
V_WERKS TO IT_FINAL-WERKS,
V_BTRTL TO IT_FINAL-BTRTL,
V_STRAS TO IT_FINAL-STRAS,
V_ORT01 TO IT_FINAL-ORT01,
V_ORT02 TO IT_FINAL-ORT02,
V_PSTLZ TO IT_FINAL-PSTLZ,
V_TRFAR TO IT_FINAL-TRFAR,
V_TRFGB TO IT_FINAL-TRFGB,
V_TRFGR TO IT_FINAL-TRFGR,
V_ANSAL TO IT_FINAL-ANSAL.
APPEND IT_FINAL.
CLEAR IT_FINAL.
ENDIF.
ENDIF.
ENDLOOP.
ENDLOOP.
END-OF-SELECTION.
CALL METHOD
CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
EXPORTING
* BIN_FILESIZE =
FILENAME = P_FILE
FILETYPE
= 'ASC'
APPEND = SPACE
WRITE_FIELD_SEPARATOR = 'X'
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = SPACE
* WRITE_LF = 'X'
* COL_SELECT = SPACE
* COL_SELECT_MASK = SPACE
DAT_MODE = 'X'
* CONFIRM_OVERWRITE = SPACE
* NO_AUTH_CHECK = SPACE
* CODEPAGE = SPACE
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = SPACE
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = SPACE
* WK1_N_SIZE = SPACE
* WK1_T_FORMAT = SPACE
* WK1_T_SIZE = SPACE
* IMPORTING
* FILELENGTH =
CHANGING
DATA_TAB = IT_FINAL[]
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* NO_BATCH = 2
* GUI_REFUSE_FILETRANSFER = 3
* INVALID_TYPE = 4
* NO_AUTHORITY = 5
* UNKNOWN_ERROR = 6
* HEADER_NOT_ALLOWED = 7
* SEPARATOR_NOT_ALLOWED = 8
* FILESIZE_NOT_ALLOWED = 9
* HEADER_TOO_LONG = 10
* DP_ERROR_CREATE = 11
* DP_ERROR_SEND = 12
* DP_ERROR_WRITE = 13
* UNKNOWN_DP_ERROR = 14
* ACCESS_DENIED = 15
* DP_OUT_OF_MEMORY = 16
* DISK_FULL = 17
* DP_TIMEOUT
= 18
* FILE_NOT_FOUND = 19
* DATAPROVIDER_EXCEPTION = 20
* CONTROL_FLUSH_ERROR = 21
* NOT_SUPPORTED_BY_GUI = 22
* ERROR_NO_GUI = 23
* others = 24
.
IF SY-SUBRC <> 0.
* MESSAGE ID
SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3
SY-MSGV4.
ENDIF.