Retrieve comment texts from cluster table for SAP infotype 19


*......................................................................*
*: Report  ZIT0019_TXT                                                :*
*: Author  SAPdev.co.uk                                               :*
*:.....................................................................*
*: Description :                                                      :*
*:.............:                                                      :*
*: Retrieves comment text for infotype 0019 form PCL1 cluster table   :*
*:                                                                    :*
*: Please visit www.SAP Development for further info                     :*
*:....................................................................:*
REPORT  zp191rep_txt.                                               .
NODES: pernr.
INFOTYPES: 0019.
TYPE-POOLS: slis.
*---------------------------------------------------------------------*
*        Daten zu Cluster TX (Infotyptexte)                           *
*---------------------------------------------------------------------*
INCLUDE RPC1TX00.
*INCLUDE rpcitx00.
*INCLUDE rpcitd00.
TYPES: BEGIN OF t_reptab,
  pernr TYPE pernr-pernr,
  subty TYPE p0019-subty,
  termn TYPE p0019-termn,
  text  LIKE ptext-line,
 END OF t_reptab.
DATA: it_reptab TYPE STANDARD TABLE OF t_reptab INITIAL SIZE 0,
      wa_reptab TYPE t_reptab.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
      gd_tab_group TYPE slis_t_sp_group_alv,
      gd_layout    TYPE slis_layout_alv,
      gd_repid     LIKE sy-repid,
      it_sortcat   TYPE slis_sortinfo_alv OCCURS 1,
      wa_sort LIKE LINE OF it_sortcat.
SELECTION-SCREEN BEGIN OF BLOCK subtyp WITH FRAME TITLE text-001.
SELECT-OPTIONS: so_sub FOR p0019-subty.
SELECTION-SCREEN END OF BLOCK subtyp.
************************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
GET pernr.
*rp_provide_from_last p0019 space pn-begda pn-endda.
  PROVIDE * FROM p0019 BETWEEN pn-begda AND pn-endda.
    CHECK p0019-subty IN so_sub.
    MOVE-CORRESPONDING p0019 TO tx-key.
    tx-key-infty = '0019'.
    rp-imp-c1-tx.
    IF sy-subrc = 0.
      LOOP AT ptext.
        MOVE-CORRESPONDING p0019 TO wa_reptab.
        wa_reptab-text = ptext-line.
        APPEND wa_reptab TO it_reptab.
        CLEAR: wa_reptab.
      ENDLOOP.
    ENDIF.
  ENDPROVIDE.
  SORT it_reptab BY pernr subty.
************************************************************************
*END-OF-SELECTION.
END-OF-SELECTION.
  PERFORM build_fieldcatalog.
  PERFORM build_layout.
  PERFORM build_sortcat.
  PERFORM display_alv_report.
*&---------------------------------------------------------------------*
*&      Form  BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*       Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
FORM build_fieldcatalog.
  fieldcatalog-fieldname   = 'PERNR'.
  fieldcatalog-seltext_m   = 'Personnel Num'.
  fieldcatalog-col_pos     = 0.
  fieldcatalog-outputlen   = 10.
  fieldcatalog-emphasize   = 'X'.
  fieldcatalog-key         = 'X'.
*  fieldcatalog-do_sum      = 'X'.
*  fieldcatalog-no_zero     = 'X'.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  fieldcatalog-fieldname   = 'SUBTY'.
  fieldcatalog-seltext_m   = 'Sub Type'.
  fieldcatalog-col_pos     = 1.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  fieldcatalog-fieldname   = 'TERMN'.
  fieldcatalog-seltext_m   = 'Sub Type'.
  fieldcatalog-col_pos     = 1.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
  fieldcatalog-fieldname   = 'TEXT'.
  fieldcatalog-seltext_m   = 'Text'.
  fieldcatalog-col_pos     = 2.
  APPEND fieldcatalog TO fieldcatalog.
  CLEAR  fieldcatalog.
ENDFORM.                    " BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*&      Form  BUILD_LAYOUT
*&---------------------------------------------------------------------*
*       Build layout for ALV grid report
*----------------------------------------------------------------------*
FORM build_layout.
  gd_layout-no_input          = 'X'.
  gd_layout-colwidth_optimize = 'X'.
  gd_layout-totals_text       = 'Totals'(201).
*  gd_layout-totals_only        = 'X'.
*  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
*                                         "click(press f2)
*  gd_layout-zebra             = 'X'.
*  gd_layout-group_change_edit = 'X'.
*  gd_layout-header_text       = 'helllllo'.
ENDFORM.                    " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
*       Display report using ALV grid
*----------------------------------------------------------------------*
FORM display_alv_report.
  gd_repid = sy-repid.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            i_callback_program      = gd_repid
*            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
*            i_callback_user_command = 'USER_COMMAND'
*            i_grid_title           = outtext
            is_layout               = gd_layout
            it_fieldcat             = fieldcatalog[]
            it_sort                 = it_sortcat
*            it_special_groups       = gd_tabgroup
*            IT_EVENTS                = GT_XEVENTS
            i_save                  = 'X'
*            is_variant              = z_template
       TABLES
            t_outtab                = it_reptab
       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.                    " DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
*&      Form  build_sortcat
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM build_sortcat .
  wa_sort-spos      = 1.
  wa_sort-fieldname = 'PERNR'.
*  gd_sortcat-tabname
  APPEND wa_sort TO it_sortcat.
  wa_sort-spos      = 2.
  wa_sort-fieldname = 'SUBTY'.
*  gd_sortcat-tabname
  APPEND wa_sort TO it_sortcat.
  wa_sort-spos      = 3.
  wa_sort-fieldname = 'TERMN'.
*  gd_sortcat-tabname
  APPEND wa_sort TO it_sortcat.
ENDFORM.                    " build_sortcat

Related Articles

Payroll results (ABAP)
Display organisational structure
SAP HR infotypes
GET PERNR LAST and GET PAYROL
Retrieve multiple contracts for HR personnel and include in locical database selection/report
SAP HR Development help - ABAP code and information on various areas of HR development in SAP
ABAP code to retrieve Absence type text(AWART) from SAP table
ABAP to retrieve country grouping for personnel with SAP
Deleting an SAP HR Infotype
SAP HR Infotype selection
Creating a New SAP Infotype using transaction PM01 and PPCI
SAP Function module to call ABAP report from managers desktop(MDT)
SAP User Exits to Add functionality to the PBO and PAI of HR infotypes
Create SAP HR report category for logical database selection within ABAP report
SAP HR Selection Screen example
Retrieve SAP personal work schedule
SAP HR Infotype Development Information, ABP and step by step instructions
Enhancing an Infotype - Add, change or modify fields of and SAP infotype
SAP Personal absence calander for SSP/SMP
ABAP Program to retrieve and display sickpay(SSP, SMP etc) with SAP
SAP Personal absence calendar (NCALE) using transaction PC00_M08_CLPC
Accessing NCALE data via the Results Log when running a payroll
Program to retrieve sickpay values
Processing the SAP HR Organisation unit
SAP HR Payroll results ( transaction code: PC_PAYRESULT)
Payroll results (ABAP)
Display Payroll results using SAP transaction PC_PAYRESULT