Skip to Content
0
Former Member
Oct 21, 2008 at 10:59 AM

ALV Top of Page is not displaying

20 Views

Hi,

in this program TOP OF PAGE is displaying as empty

*-----------------------------------------------------------------------
* Tables
*-----------------------------------------------------------------------
TABLES:/irm/ipsipart.

*-----------------------------------------------------------------------
* Type pools
*-----------------------------------------------------------------------
TYPE-POOLS slis.
*-----------------------------------------------------------------------
* Types
*-----------------------------------------------------------------------
TYPES:BEGIN OF typ_ipsipart,
      depcode  TYPE /irm/ip_depcode,
      partid   TYPE /irm/ip_ktonr,
      endda    TYPE /irm/ip_pedat,
      begda    TYPE /irm/ip_pbdat,
      END OF typ_ipsipart.

TYPES:BEGIN OF typ_pa0000,
      pernr    TYPE persno,
      endda    TYPE endda,
      begda    TYPE begda,
      massn    TYPE massn,
      massg    TYPE massg,
      stat2    TYPE stat2,
      partid   TYPE /irm/ip_ktonr,
      END OF typ_pa0000.

TYPES:BEGIN OF typ_pa0001,
      pernr    TYPE persno,
      endda    TYPE endda,
      ename    TYPE ename,
      END OF typ_pa0001.

TYPES:BEGIN OF typ_pernr,
      pernr    TYPE persno,
      END OF typ_pernr.

TYPES:BEGIN OF typ_a942,
      zzpersnr TYPE persno,
      END OF typ_a942.

TYPES:BEGIN OF typ_a943,
      zzpersnr TYPE persno,
      END OF typ_a943.

TYPES:BEGIN OF typ_a976,
      zzpersnr TYPE persno,
      END OF typ_a976.

TYPES:BEGIN OF typ_final,
      pernr    TYPE persno,
      ename    TYPE ename,
      begda    TYPE begda,
      statx(9) TYPE c,
      mgtxt    TYPE mgtxt,
      depcode  TYPE /irm/ip_depcode,
      begda_c  TYPE /irm/ip_pbdat,
      endda_c  TYPE /irm/ip_pedat,
      END OF typ_final.

TYPES:BEGIN OF typ_t530t,
      massn    TYPE massn,
      massg    TYPE massg,
      mgtxt    TYPE mgtxt,
      END OF typ_t530t.
*-----------------------------------------------------------------------
* Internal Tables
*-----------------------------------------------------------------------
DATA:it_a942     TYPE TABLE OF typ_a942,
     it_a943     TYPE TABLE OF typ_a943,
     it_a976     TYPE TABLE OF typ_a976,
     it_pernr    TYPE TABLE OF typ_pernr,
     it_pa0000   TYPE TABLE OF typ_pa0000,
     it_pa0001   TYPE TABLE OF typ_pa0001,
     it_ipsipart TYPE TABLE OF typ_ipsipart,
     it_final    TYPE TABLE OF typ_final,
     it_t530t    TYPE TABLE OF typ_t530t.

*-----------------------------------------------------------------------
* Work areas
*-----------------------------------------------------------------------
DATA:wa_a942     TYPE typ_a942,
     wa_a943     TYPE typ_a943,
     wa_a976     TYPE typ_a976,
     wa_pernr    TYPE typ_pernr,
     wa_pa0000   TYPE typ_pa0000,
     wa_pa0001   TYPE typ_pa0001,
     wa_ipsipart TYPE typ_ipsipart,
     wa_final    TYPE typ_final,
     wa_t530t    TYPE typ_t530t.

*-----------------------------------------------------------------------
* Constants
*-----------------------------------------------------------------------
CONSTANTS:c_stat2 TYPE stat2 VALUE '0',
          c_statx(9) TYPE c  VALUE 'Withdrawn',
          c_endda TYPE endda VALUE '99991231',
          c_ptype TYPE /irm/ip_patype VALUE 'PE',
          c_kappl TYPE kappl VALUE 'V',
          c_ysam  TYPE kschl VALUE 'YSAM',
          c_ysdm  TYPE kschl VALUE 'YSDM',
          c_yssm  TYPE kschl VALUE 'YSSM',
          c_ysse  TYPE kschl VALUE 'YSSE',
          c_sprsl TYPE spras VALUE 'E'.

*-----------------------------------------------------------------------
* Variables
*-----------------------------------------------------------------------
DATA:v_begda TYPE begda,
     v_endda TYPE endda.
DATA:v_variant   LIKE disvariant,
     v_save(1)   TYPE c,
     v_repid TYPE sy-repid.
*-----------------------------------------------------------------------
* ALV Declaraion Part
*-----------------------------------------------------------------------
* FIELD CATALOG DECLARATION                                        *****
DATA:it_fcat TYPE slis_t_fieldcat_alv,
     wa_fcat TYPE slis_fieldcat_alv.
* ALV SORT INFORMATION                                             *****
DATA:wa_sort TYPE slis_sortinfo_alv,
     it_sort TYPE slis_t_sortinfo_alv.
*ALV LAYOUT INFORMATION                                            *****
DATA:wa_layout TYPE slis_layout_alv.
*ALV TOOLBAR EXCLUDING                                             *****
DATA:it_excluding TYPE slis_t_extab,
     wa_excluding TYPE slis_extab.
*-----------------------------------------------------------------------
* Selection Screen
*-----------------------------------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:s_pernr  FOR /irm/ipsipart-partid,
               s_date   FOR /irm/ipsipart-begda OBLIGATORY NO-EXTENSION,
               s_depcod FOR /irm/ipsipart-depcode.
SELECTION-SCREEN END OF BLOCK b1.

*-----------------------------------------------------------------------
* At Selection Screen
*-----------------------------------------------------------------------
AT SELECTION-SCREEN.
  IF NOT s_date-low IS INITIAL AND s_date-high IS NOT INITIAL.
    READ TABLE s_date INDEX 1.
    v_begda = s_date-low.
    v_endda = s_date-high.
  ENDIF.

  IF s_date-low IS INITIAL AND s_date-high IS NOT INITIAL.
    READ TABLE s_date INDEX 1.
    v_begda = s_date-high.
    v_endda = s_date-high.
  ENDIF.

  IF s_date-low IS NOT INITIAL AND s_date-high IS INITIAL.
    READ TABLE s_date INDEX 1.
    v_begda = s_date-low.
    v_endda = s_date-low.
  ENDIF.

*-----------------------------------------------------------------------
* Start of selection
*-----------------------------------------------------------------------
START-OF-SELECTION.
  break vkreddy1x.
  PERFORM get_data.
  PERFORM move_data_to_finalitab.
  IF NOT it_final[] IS INITIAL.
    PERFORM field_catalog TABLES it_final
                          USING it_fcat[]
                                wa_fcat.
    PERFORM alv_sort_info USING it_sort[]
                                wa_sort.
    PERFORM alv_layout_build USING wa_layout.
    PERFORM alv_toolbar_excluding USING it_excluding[]
                                        wa_excluding.
    PERFORM load-variant     USING v_variant v_repid v_save.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program     = v_repid
        i_callback_top_of_page = 'TOP_OF_PAGE'
        is_layout              = wa_layout
        it_fieldcat            = it_fcat
        it_excluding           = it_excluding
        it_sort                = it_sort
        i_save                 = v_save
        is_variant             = v_variant
      TABLES
        t_outtab               = it_final
      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.
  ELSE.
    PERFORM info_msg.
  ENDIF.
*&---------------------------------------------------------------------*
*&      Form  GET_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_data .
  SELECT zzpersnr FROM a942 INTO TABLE it_a942 WHERE kappl  = c_kappl
                                               AND   kschl  = c_ysdm
                                               AND   datbi >= v_begda
                                               AND   datab <= v_endda.
  IF sy-subrc EQ 0.
    SORT it_a942 BY zzpersnr.
    DELETE ADJACENT DUPLICATES FROM it_a942 COMPARING zzpersnr.
    LOOP AT it_a942 INTO wa_a942.
      MOVE wa_a942-zzpersnr TO wa_pernr-pernr.
      APPEND wa_pernr TO it_pernr.
      CLEAR:wa_pernr,wa_a942.
    ENDLOOP.
  ENDIF.
  SELECT zzpersnr FROM a943 INTO TABLE it_a943 WHERE kappl  = c_kappl
                                               AND  ( kschl = c_ysam
                                                   OR kschl = c_ysse )
                                               AND   datbi >= v_begda
                                               AND   datab <= v_endda.
  IF sy-subrc EQ 0.
    SORT it_a943 BY zzpersnr.
    DELETE ADJACENT DUPLICATES FROM it_a943 COMPARING zzpersnr.
    LOOP AT it_a943 INTO wa_a943.
      MOVE wa_a943-zzpersnr TO wa_pernr-pernr.
      APPEND wa_pernr TO it_pernr.
      CLEAR:wa_pernr,wa_a943.
    ENDLOOP.
  ENDIF.
  SELECT zzpersnr FROM a976 INTO TABLE it_a976 WHERE kappl  = c_kappl
                                               AND   kschl  = c_yssm
                                               AND   datbi >= v_begda
                                               AND   datab <= v_endda.
  IF sy-subrc EQ 0.
    SORT it_a976 BY zzpersnr.
    DELETE ADJACENT DUPLICATES FROM it_a976 COMPARING zzpersnr.
    LOOP AT it_a976 INTO wa_a976.
      MOVE wa_a976-zzpersnr TO wa_pernr-pernr.
      APPEND wa_pernr TO it_pernr.
      CLEAR:wa_pernr,wa_a976.
    ENDLOOP.
  ENDIF.

  SORT it_pernr BY pernr.
  DELETE ADJACENT DUPLICATES FROM it_pernr COMPARING pernr.

  IF NOT it_pernr[] IS INITIAL.
    SELECT pernr endda begda massn massg stat2 FROM pa0000
                                               INTO TABLE it_pa0000
                                               FOR ALL ENTRIES IN it_pernr
                                               WHERE pernr = it_pernr-pernr
                                               AND endda >= v_begda
                                               AND begda <= v_endda
                                               AND stat2 = c_stat2.
  ENDIF.

  LOOP AT it_pa0000 INTO wa_pa0000.
    wa_pa0000-partid = wa_pa0000-pernr.
    MODIFY TABLE it_pa0000 FROM wa_pa0000 .
  ENDLOOP.
  IF NOT it_pa0000[] IS INITIAL.
    SELECT depcode partid endda begda FROM /irm/ipsipart
                            INTO CORRESPONDING FIELDS OF TABLE it_ipsipart
                            FOR ALL ENTRIES IN it_pa0000
                            WHERE nrart = c_ptype
                                       AND partid = it_pa0000-partid
                                       AND endda >= it_pa0000-begda
                                       AND begda <= it_pa0000-endda.
    SELECT pernr ename FROM pa0001 INTO TABLE it_pa0001
                                   FOR ALL ENTRIES IN it_pa0000
                                   WHERE pernr = it_pa0000-pernr
                                   AND endda   = c_endda.

    SELECT mgtxt FROM t530t INTO TABLE it_t530t
                            FOR ALL ENTRIES IN it_pa0000
                            WHERE sprsl = c_sprsl
                            AND massn = it_pa0000-massn
                            AND massg   = it_pa0000-massg.

  ENDIF.
ENDFORM.                    " GET_DATA
*&---------------------------------------------------------------------*
*&      Form  MOVE_DATA_TO_ITAB
*&---------------------------------------------------------------------*
FORM move_data_to_finalitab .
  LOOP AT it_pa0000 INTO wa_pa0000.
    MOVE wa_pa0000-pernr TO wa_final-pernr.
    MOVE wa_pa0000-begda TO wa_final-begda.
    IF wa_pa0000-stat2 = c_stat2.
      MOVE c_statx TO wa_final-statx.
    ENDIF.
    READ TABLE it_pa0001 INTO wa_pa0001 WITH KEY pernr = wa_pa0000-pernr.
    IF sy-subrc EQ 0.
      MOVE wa_pa0001-ename TO wa_final-ename.
    ENDIF.
    READ TABLE it_t530t INTO wa_t530t WITH KEY massn = wa_pa0000-massn
                                               massg = wa_pa0000-massg.
    IF sy-subrc EQ 0.
      MOVE wa_t530t-mgtxt TO wa_final-mgtxt.
    ENDIF.
    READ TABLE it_ipsipart INTO wa_ipsipart WITH KEY
                                               partid = wa_pa0000-partid.
    IF sy-subrc EQ 0.
      MOVE wa_ipsipart-depcode TO wa_final-depcode.
      MOVE wa_ipsipart-begda TO wa_final-begda_c.
      MOVE wa_ipsipart-endda TO wa_final-endda_c.
    ENDIF.
    APPEND wa_ipsipart TO it_ipsipart.
    CLEAR wa_ipsipart.
  ENDLOOP.
ENDFORM.                    " MOVE_DATA_TO_ITAB
*&---------------------------------------------------------------------*
*&      Form  FIELD_CATALOG
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM field_catalog TABLES p_it_final  LIKE it_final
                   USING  p_it_fcat   TYPE slis_t_fieldcat_alv
                          p_wa_fcat   TYPE slis_fieldcat_alv.
  CLEAR p_wa_fcat.
  p_wa_fcat-col_pos   = '1'.
  p_wa_fcat-tabname   = p_it_final.
  p_wa_fcat-fieldname = 'PERNR'.
  p_wa_fcat-key       = 'X'.
  p_wa_fcat-seltext_l = 'Personnel Number'.
  p_wa_fcat-seltext_m = 'Personnel No.'.
  p_wa_fcat-seltext_s = 'Pers.No.'.
  APPEND p_wa_fcat TO p_it_fcat.

  CLEAR p_wa_fcat.
  p_wa_fcat-col_pos   = '2'.
  p_wa_fcat-tabname   = p_it_final.
  p_wa_fcat-fieldname = 'ENAME'.
  p_wa_fcat-key       = 'X'.
  p_wa_fcat-seltext_l = 'Employee Name'.
  p_wa_fcat-seltext_m = 'Emp Name'.
  p_wa_fcat-seltext_s = 'Name'.
  APPEND p_wa_fcat TO p_it_fcat.

  CLEAR p_wa_fcat.
  p_wa_fcat-col_pos   = '3'.
  p_wa_fcat-tabname   = p_it_final.
  p_wa_fcat-fieldname = 'BEGDA'.
  p_wa_fcat-key       = ' '.
  p_wa_fcat-seltext_l = 'Termination start date'.
  p_wa_fcat-seltext_m = 'Term start date'.
  p_wa_fcat-seltext_s = 'Term start date'.
  APPEND p_wa_fcat TO p_it_fcat.

  CLEAR p_wa_fcat.
  p_wa_fcat-col_pos   = '4'.
  p_wa_fcat-tabname   = p_it_final.
  p_wa_fcat-fieldname = 'MGTXT'.
  p_wa_fcat-seltext_l = 'Reason f.action text'.
  p_wa_fcat-seltext_m = 'Reason for action'.
  p_wa_fcat-seltext_s = 'Act.reason'.
  APPEND p_wa_fcat TO p_it_fcat.

  CLEAR p_wa_fcat.
  p_wa_fcat-col_pos   = '5'.
  p_wa_fcat-tabname   = p_it_final.
  p_wa_fcat-fieldname = 'STATX'.
  p_wa_fcat-seltext_l = 'Employment status text'.
  p_wa_fcat-seltext_m = 'Employment status'.
  p_wa_fcat-seltext_s = 'Employment status'.
  APPEND p_wa_fcat TO p_it_fcat.

  CLEAR p_wa_fcat.
  p_wa_fcat-col_pos   = '6'.
  p_wa_fcat-tabname   = p_it_final.
  p_wa_fcat-fieldname = 'DEPCODE'.
  p_wa_fcat-seltext_l = 'Deployment Code'.
  p_wa_fcat-seltext_m = 'Deployment Code'.
  p_wa_fcat-seltext_s = 'Dep. Code'.
  APPEND p_wa_fcat TO p_it_fcat.

  CLEAR p_wa_fcat.
  p_wa_fcat-col_pos   = '7'.
  p_wa_fcat-tabname   = p_it_final.
  p_wa_fcat-fieldname = 'BEGDA_C'.
  p_wa_fcat-seltext_l = 'Participation Start Date'.
  p_wa_fcat-seltext_m = 'Participation Start'.
  p_wa_fcat-seltext_s = 'Start Date'.
  APPEND p_wa_fcat TO p_it_fcat.

  CLEAR p_wa_fcat.
  p_wa_fcat-col_pos   = '8'.
  p_wa_fcat-tabname   = p_it_final.
  p_wa_fcat-fieldname = 'ENDDA_C'.
  p_wa_fcat-seltext_l = 'Participation End Date'.
  p_wa_fcat-seltext_m = 'Participation End'.
  p_wa_fcat-seltext_s = 'End Date'.
  APPEND p_wa_fcat TO p_it_fcat.

ENDFORM.                    " FIELD_CATALOG
*&---------------------------------------------------------------------*
*&      Form  ALV_SORT_INFO
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_IT_SORT[]  text
*      -->P_WA_SORT  text
*----------------------------------------------------------------------*
FORM alv_sort_info  USING   p_it_sort TYPE slis_t_sortinfo_alv
                            p_wa_sort TYPE slis_sortinfo_alv .

  p_wa_sort-fieldname = 'PERNR'.
  p_wa_sort-up = 'X'.
  APPEND p_wa_sort TO p_it_sort.

ENDFORM.                    " ALV_SORT_INFO

*&---------------------------------------------------------------------*
*&      Form  ALV_LAYOUT_BUILD
*&---------------------------------------------------------------------*
FORM alv_layout_build  CHANGING p_wa_layout TYPE slis_layout_alv.

  p_wa_layout-no_input          = 'X'.
  p_wa_layout-colwidth_optimize = 'X'.

ENDFORM.                    " ALV_LAYOUT_BUILD

*&---------------------------------------------------------------------*
*&      Form  ALV_TOOLBAR_EXCLUDING
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM alv_toolbar_excluding  USING   p_it_excluding TYPE slis_t_extab
                                    p_wa_excluding TYPE slis_extab.
  p_wa_excluding-fcode = '&GRAPH'.
  APPEND p_wa_excluding TO p_it_excluding.

  p_wa_excluding-fcode = '&ABC'.
  APPEND p_wa_excluding TO p_it_excluding.

  p_wa_excluding-fcode = '%SL'.
  APPEND p_wa_excluding TO p_it_excluding.

ENDFORM.                    " ALV_TOOLBAR_EXCLUDING

*&---------------------------------------------------------------------*
*&      Form  LOAD-VARIANT
*&---------------------------------------------------------------------*

FORM load-variant  USING    p_v_variant STRUCTURE disvariant
                            p_v_repid
                            p_v_save.
  CLEAR p_v_variant.
  p_v_variant-report = p_v_repid.
  p_v_save = 'A'.

ENDFORM.                    " LOAD-VARIANT

*&---------------------------------------------------------------------*
*&      Form  info_msg
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM info_msg .
  MESSAGE i016(rp) WITH 'No Data Selected for the Selection Criteria'.
ENDFORM.                    "info_msg

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

  DATA:it_listhead TYPE slis_t_listheader.
  DATA:wa_listhead TYPE slis_listheader.

  wa_listhead-typ = 'H'.
  wa_listhead-info = 'Withdrawn Employees Still Active on Commission Plan'.
  APPEND wa_listhead TO it_listhead.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = it_listhead.

ENDFORM.                    "top_of_page