History of Corrections in Infotype

How to see the history of all changes in the infotypes, e.g. someone is changing the bank details in 0006. How is it possible to see the change? Is there any protocol or table where changes are stored?

Answers:

You can see the change log in audit reports. 

RPUAUD00 program will give you the changes made by different people to a particular infotype.  If you double click on any particular entry it will show you the actual changes made to that infotype.

or

SAP Audit Log report is available for viewing the changes- 

S_AHR_61016380 -  Logged Changes in Infotype Data 

For this you'll have to enable the logging.

or

Use this customized program (by Latha).

REPORT ZINFOTYPE_CHANGE_HISTORY NO STANDARD PAGE HEADING.

TABLES: pa0000.

************************************************************************
*                         Selection Screen                             *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK main WITH FRAME TITLE text-001 .
SELECT-OPTIONS: soaedat FOR pa0000-aedtm OBLIGATORY NO-EXTENSION,
                sopernr for pa0000-pernr.
SELECTION-SCREEN END OF BLOCK main.

************************************************************************
*                          Types Defined                               *
************************************************************************
TYPES:  BEGIN OF ty_tables, " Type for All HR Master Table Name and Description
        tabname LIKE dd02l-tabname,
        ddtext LIKE dd02t-ddtext,
        END OF ty_tables.

TYPES:  BEGIN OF ty_mas. " Type for HR Master Data Change
INCLUDE: STRUCTURE pakey,
         TYPE ty_tables.
TYPES:  ename LIKE pa0001-ename,
        aedtm LIKE pa0000-aedtm,
        uname LIKE pa0000-uname,
        END OF ty_mas.

TYPES:  BEGIN OF ty_pa0001, " Type for Ename and Plans
        pernr LIKE pa0001-pernr,
        ename LIKE pa0001-ename,
        END OF ty_pa0001.

************************************************************************
*                    Declaration of Variables                          *
************************************************************************
DATA: it_tables TYPE STANDARD TABLE OF ty_tables WITH HEADER LINE,
      wa_tables TYPE ty_tables,
      it_mas    TYPE STANDARD TABLE OF ty_mas WITH HEADER LINE,
      wa1_mas   TYPE ty_mas,
      wa2_mas   TYPE ty_mas,
      it_pa0001 TYPE SORTED TABLE OF ty_pa0001 WITH HEADER LINE WITH UNIQUE KEY pernr,
      wa_pa0001 TYPE ty_pa0001,
      str_date  TYPE string,
      str_len   TYPE i,
      date_low  TYPE c LENGTH 10,
      date_high TYPE c LENGTH 10,
      flag      TYPE c LENGTH 1.

************************************************************************
*                           FIELD-SYMBOLS                              *
************************************************************************
FIELD-SYMBOLS: <wa_mas_c> TYPE ty_mas.
 

************************************************************************
*                    Declaration of RANGES                             *
************************************************************************
data: rg_pernr like RANGE OF pa0000-pernr WITH HEADER LINE.
 

************************************************************************
*                        START-OF-SELECTION                            *
************************************************************************
START-OF-SELECTION.

*  Format Date to Display on the Screen Top of Page
  CLEAR: date_low, date_high.
  WRITE: soaedat-low TO date_low, soaedat-high TO date_high.
  IF soaedat-high <> '00000000' .
    CONCATENATE 'Date: From' date_low 'to' date_high INTO str_date SEPARATED BY space.
  ELSE.
    CONCATENATE 'Date:' date_low INTO str_date SEPARATED BY space.
  ENDIF.

*  Select All the Table Name and Description Start from PA
  SELECT dd02l~tabname dd02t~ddtext
    INTO CORRESPONDING FIELDS OF TABLE it_tables
    FROM dd02l LEFT OUTER JOIN dd02t ON ( dd02l~tabname = dd02t~tabname AND dd02t~ddlanguage = 'E' )
    WHERE dd02l~tabname LIKE 'PA%'.

*  Now Delete all other Tables name Because we Need name from PA0000 to PA9999 we are dealing with all Infotypes 0000 to 9999
  LOOP AT it_tables INTO wa_tables.
    IF wa_tables-tabname+2(4) CO '0123456789' AND STRLEN( wa_tables-tabname ) = 6 .
    ELSE.
      DELETE it_tables INDEX sy-tabix.
    ENDIF.
  ENDLOOP.

  SORT it_tables BY tabname.

**  Get all the Changed Data and Append it to Internal Table and also Append pernrs to a Range for further USE
  rg_pernr-sign = 'I'. rg_pernr-option = 'EQ'.
  LOOP AT it_tables into wa_tables.
    SELECT pernr subty objps sprps endda begda seqnr aedtm uname
      APPENDING CORRESPONDING FIELDS OF TABLE it_mas
      FROM (wa_tables-tabname)
      WHERE aedtm IN soaedat
        and pernr in sopernr.
    IF sy-subrc = 0.
      LOOP AT it_mas ASSIGNING <wa_mas_c> WHERE tabname is INITIAL.
        <wa_mas_c>-tabname = wa_tables-tabname.
        <wa_mas_c>-ddtext = wa_tables-ddtext.
        rg_pernr-low = <wa_mas_c>-pernr.
        append rg_pernr.
      ENDLOOP.
    ENDIF.
  ENDLOOP.

*  Delete all duplicate pernrs because we Need Distinct For this First Sort by low
  SORT rg_pernr BY low.
  DELETE ADJACENT DUPLICATES FROM rg_pernr COMPARING low.

  IF rg_pernr[] is not INITIAL.
*  Select Ename and Plans from PA0001 for all pernr in Range
    SELECT mandt PERNR SUBTY OBJPS SPRPS ENDDA BEGDA SEQNR ename " We need only Pernr and Ename but because me using FOR ALL ENTRIES IN so talking all Key Fields
       FROM pa0001
      INTO CORRESPONDING FIELDS OF TABLE it_pa0001
      FOR ALL ENTRIES IN rg_pernr
      WHERE pernr = rg_pernr-low
        and endda = '99991231'.
*  Now Place Names against every pernr
    LOOP AT it_mas ASSIGNING <wa_mas_c> .
      READ TABLE it_pa0001 WITH TABLE KEY pernr = <wa_mas_c>-pernr.
      IF sy-subrc = 0.
        <wa_mas_c>-ename = it_pa0001-ename.
      ENDIF.
    ENDLOOP.
  endif.

  IF it_mas[] is INITIAL.
    MESSAGE: 'No Change History Found' TYPE 'I'.
  ENDIF.

  SORT: it_mas BY pernr tabname aedtm begda.

*  Now Write the Master Internal Table on the Screen in the Specific Format
  LOOP AT it_mas INTO wa1_mas.

*    Uncomment this code if want to see Table Description between ( )
**    Here we only need the infotype name not Prefix Before Table Description So Get only Text in " (  ) "
*    SEARCH wa1_mas-ddtext FOR '('.
*    IF sy-subrc EQ 0.
*      str_len = 60 - sy-fdpos.
*      wa1_mas-ddtext = wa1_mas-ddtext+sy-fdpos(str_len).
*    ELSE.
*      CLEAR: wa1_mas-ddtext.
*    ENDIF.

    wa2_mas = wa1_mas.

    AT NEW pernr.
      WRITE: 1(140) sy-uline,
             /1 '|',
             2(12) wa2_mas-pernr CENTERED HOTSPOT ON,
             14(1) '|',
             15(30) wa2_mas-ename HOTSPOT ON,
             45(1) '|',
             46(60) wa2_mas-ddtext HOTSPOT ON,
             106(1) '|',
             107(20) wa2_mas-uname CENTERED HOTSPOT ON,
             127(1) '|',
             128(12) wa2_mas-aedtm CENTERED HOTSPOT ON.
      HIDE : wa2_mas.
      WRITE:  140(1) '|',
        /1(140) sy-uline.
      flag = 'X'.
    ENDAT.
    IF flag EQ 'X'.
      flag = ''.
    ELSE.
      WRITE: /1 '|',
             45(1) '|',
             46(60) wa2_mas-ddtext HOTSPOT ON,
             106(1) '|',
             107(20) wa2_mas-uname CENTERED HOTSPOT ON,
             127(1) '|',
             128(12) wa2_mas-aedtm CENTERED HOTSPOT ON,
             140(1) '|'.
      HIDE : wa2_mas.
      WRITE: /1 '|',
             45(96) sy-uline.
    ENDIF.

    AT END OF pernr.
      WRITE: 1(140) sy-uline.
    ENDAT.
  ENDLOOP.

************************************************************************
*                           AT LINE-SELECTION                          *
************************************************************************
AT LINE-SELECTION.

  DATA: it_ref TYPE REF TO data.
  DATA: lvc_title TYPE lvc_title.

*  Creation of Dynamic Internal Table
  CREATE DATA it_ref TYPE STANDARD TABLE OF (wa2_mas-tabname).
  FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE.
  ASSIGN it_ref->* TO <itab>.

*  Selection of Changed Data
  SELECT * FROM (wa2_mas-tabname)
    INTO CORRESPONDING FIELDS OF TABLE <itab>
    WHERE pernr = wa2_mas-pernr
    AND aedtm <= wa2_mas-aedtm.
  IF sy-subrc = 0.
*  Show ALV for select records
    PERFORM show_alv.
  ENDIF.
 

************************************************************************
*                    AT SELECTION-SCREEN OUTPUT                        *
************************************************************************
AT SELECTION-SCREEN OUTPUT.
  IF soaedat[] IS INITIAL.
    soaedat-high = sy-datum.
    APPEND soaedat TO soaedat.
  ENDIF.

************************************************************************
*                           INITIALIZATION                             *
************************************************************************
INITIALIZATION.

************************************************************************
*                             TOP-OF-PAGE                              *
************************************************************************
TOP-OF-PAGE.
  WRITE: 1(140) sy-uline,
         /1 '|',
         2(139) 'HR: Master Data Change' CENTERED COLOR 1,
         140(1) '|' ,
         /1 '|',
         2(139) str_date CENTERED COLOR 1,
         140(1) '|' .
  WRITE: /1(140) sy-uline,
         /1 '|',
         2(12) 'Personal No.' CENTERED  COLOR 1,
         14(1) '|',
         15(30) 'Name of Employee' CENTERED  COLOR 1,
         45(1) '|',
         46(60) 'Changed Category' CENTERED  COLOR 1,
         106(1) '|',
         107(20) 'Changed By' CENTERED  COLOR 1,
         127(1) '|',
         128(12) 'Changed On' CENTERED  COLOR 1,
         140(1) '|',
         /1(140) sy-uline.

************************************************************************
*                               FORMs                                  *
************************************************************************
*&---------------------------------------------------------------------*
*&      Form  show_alv
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM show_alv.
  TYPE-POOLS: SLIS.
  DATA: wa_layout TYPE slis_layout_alv.
  DATA: it_sort TYPE slis_t_sortinfo_alv,
        wa_sort TYPE slis_sortinfo_alv.

  CONCATENATE wa2_mas-tabname+2(4) '=>' wa2_mas-ddtext into lvc_title SEPARATED BY space.

*  For Sorting
  CLEAR wa_sort.
  wa_sort-fieldname = 'AEDTM'.
  wa_sort-up = 'X'.
  APPEND wa_sort TO it_sort.

*  for Layout
  wa_layout-zebra = 'X'.
  wa_layout-colwidth_optimize = 'X'.

*  Display ALV
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = sy-cprog
      I_STRUCTURE_NAME   = wa2_mas-tabname
      i_grid_title       = lvc_title
      is_layout          = wa_layout
      it_sort            = it_sort
      i_default          = 'X'
      i_save             = 'X'
    TABLES
      t_outtab           = <itab>
    EXCEPTIONS
      PROGRAM_ERROR      = 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.

ENDFORM.                    "show_alv

SAP HR

Read Also
Steps To Create Different Types of Absence Quotas

SAP HR Reference Books:
SAP Human Resource Certification, Interview Questions and Configuration Reference Books

Back to:
SAP HR (Human Resources) Hints and Tips

Return to :-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.