Saturday, December 18, 2010
As we can not see Appraisal tables(HRHAP*) data using SE16 transaction code, We can use the following program to check the program.

Standard program RHHAP_DISPLAY_DB is used to check Appraisal Document data.
REPORT  zappraisal_tables NO STANDARD PAGE HEADING .
"Declarations.
*&----------------------------------------------------------------------*
"variable
*&----------------------------------------------------------------------*
DATA:
    g_table TYPE ddobjname,
    i_table TYPE REF TO data.
TYPES:
    t_dfies TYPE dfies.
DATA:
    w_dfies TYPE t_dfies.
DATA:
    i_dfies TYPE STANDARD TABLE OF t_dfies.

"Field symbols
FIELD-SYMBOLS:
   <it_table> TYPE STANDARD TABLE.
" ALV Declarations
* Types Pools
TYPE-POOLS:
    slis.
" Types
TYPES:
    t_fieldcat_d       TYPE lvc_s_fcat,
    t_events           TYPE slis_alv_event,
    t_layout           TYPE slis_layout_alv.
" Workareas
DATA:
    w_fieldcat_d       TYPE t_fieldcat_d,
    w_events           TYPE t_events,
    w_layout           TYPE t_layout.
" Internal Tables
DATA:
    i_fieldcat_d       TYPE STANDARD TABLE OF t_fieldcat_d,
    i_events           TYPE STANDARD TABLE OF t_events.
*&----------------------------------------------------------------------*
" selection-screen
*&----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE f_title1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (15) text_003 FOR FIELD table.
PARAMETERS :table TYPE rsrd1-tbma_val OBLIGATORY.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 1.
PARAMETERS: alv_list RADIOBUTTON GROUP list USER-COMMAND list DEFAULT 'X'.
SELECTION-SCREEN COMMENT (20) text_001 FOR FIELD alv_list.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 1.
PARAMETERS : alv_grid RADIOBUTTON GROUP list.
SELECTION-SCREEN COMMENT (20) text_002 FOR FIELD alv_grid.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.
*&----------------------------------------------------------------------*
"Initialization
*&----------------------------------------------------------------------*

INITIALIZATION.

  f_title1 = 'Report Category'.
  text_001 = 'ALV List'.
  text_002 = 'ALV Grid'.
  text_003 = 'Table Name'.

*&----------------------------------------------------------------------*
  "Start-of-selection.
*&----------------------------------------------------------------------*

START-OF-SELECTION.

  " Get Table information given on Selection-screen.
  g_table = table.
  CALL FUNCTION 'DDIF_NAMETAB_GET'
    EXPORTING
      tabname   = g_table
    TABLES
      dfies_tab = i_dfies.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
    "Build fieldcatalog to create Dynamic Internal table
    LOOP AT i_dfies INTO w_dfies.
      w_fieldcat_d-fieldname   = w_dfies-fieldname.
      w_fieldcat_d-tabname     = table.
      w_fieldcat_d-ref_table   = table.
      APPEND w_fieldcat_d TO i_fieldcat_d.
      CLEAR  w_fieldcat_d.
    ENDLOOP.
    "Create Dynamic Internal table for the DB table given on Selection-screen.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
      EXPORTING
        it_fieldcatalog = i_fieldcat_d
      IMPORTING
        ep_table        = i_table.
    "Assign dynamic table to field-symbol
    ASSIGN i_table->* TO <it_table>.
    "Get Data from Database table .
    SELECT *
    FROM (table)
    INTO TABLE <it_table> UP TO 20 ROWS.
  ENDIF.
*&----------------------------------------------------------------------*
  "End-of-selection.
*&----------------------------------------------------------------------*

END-OF-SELECTION.
  "Build layout structure
  w_layout-zebra             = 'X'.
  w_layout-colwidth_optimize = 'X'.
  "Build events table
  w_events-name = 'TOP_OF_PAGE'.
  w_events-form = 'TOP_OF_PAGE'.
  APPEND w_events TO i_events.
  CLEAR  w_events.
  "Display data using ALV GRID
  PERFORM display_data.
*&---------------------------------------------------------------------*
*&      Form  display_data
*&---------------------------------------------------------------------*
FORM display_data .
  DATA:
  l_program   TYPE sy-repid,
  l_structure TYPE dd02l-tabname,
  l_function  TYPE rs38l-name.

  l_program = sy-repid.
  l_structure = table.
  IF alv_list = 'X'.
    l_function = 'REUSE_ALV_LIST_DISPLAY'.
  ELSEIF alv_grid = 'X'.
    l_function = 'REUSE_ALV_GRID_DISPLAY'.
  ENDIF.
  CALL FUNCTION l_function
    EXPORTING
      i_callback_program = l_program
      i_structure_name   = l_structure
      is_layout          = w_layout
      it_events          = i_events
    TABLES
      t_outtab           = <it_table>
    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_data
*&---------------------------------------------------------------------*
*&      Form  top_of_page
*&---------------------------------------------------------------------*
FORM top_of_page.
  DATA :
  i_header TYPE slis_t_listheader,
  w_header LIKE LINE OF i_header.

  w_header-typ = 'H'.
  CONCATENATE 'Table' ':' table INTO w_header-info.
  APPEND w_header TO i_header.
  CLEAR w_header.

  w_header-typ = 'H'.
  WRITE sy-datum TO w_header-info.
  APPEND w_header TO i_header.
  CLEAR w_header.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = i_header
      i_logo             = 'ENJOYSAP_LOGO'.

ENDFORM. "top_of_page



0 comments:

Post a Comment

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.