ALV 단순 조회용 프로그램
스크린을 사용하지 않은 단순 조회용 프로그램이다.


*&--------------------------------------------------------------*

*& 기능 : 조회, 버튼기능

*&--------------------------------------------------------------*

 

1.조회조건

 

사용자 삽입 이미지

 

2. 실행결과

 

사용자 삽입 이미지

* 프로그램 선언

REPORT  ZSDR6040.

INCLUDE ZSDR6040TOP.              " Global Data

INCLUDE ZSDR6040SCR.              " SELECTION-SCREEN

INCLUDE ZSDR6040ALV.              " ALV

INCLUDE ZSDR6040EVT.              " EVENT

INCLUDE ZSDR6040F01.              " FORM-Routines

 

*&------------------------------------------------------------*

*&  Include           ZSDR6040_TOP   (TOP 구문)

*&------------------------------------------------------------*

 

TYPE-POOLS : slis .

 

INCLUDE <icon>.

INCLUDE <color>.

 

TABLES: ztsd6000, ztsd6001.

 

 

DATA: BEGIN OF gs_data ,

        itsm_no        LIKE ztsd6000-itsm_no ,

        exp_start_date LIKE ztsd6000-exp_start_date,

        exp_end_date   LIKE ztsd6000-exp_end_date,

        dev_start_date LIKE ztsd6000-dev_start_date,

        req_test_date  LIKE ztsd6000-req_test_date,

      END OF gs_data.

 

DATA: gt_data  LIKE gs_data  OCCURS 0 WITH HEADER LINE.

 

 

 

 

 

*&-----------------------------------------------------------*

*&  Include           ZSDR6040_SCR   (SELECTION-SCREEN)

*&-----------------------------------------------------------*

 

SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-001.

 

PARAMETERS pa_code LIKE ztsd6000-hq_code OBLIGATORY.  "본부코드

 

 

SELECT-OPTIONS: so_no FOR ztsd6000-itsm_no,  "ITSM NO

                so_erdat FOR ztsd6000-erdat. "생성일

 

SELECTION-SCREEN  END  OF  BLOCK  b01.

 

  

*--------------------------------------------------------------*

*   GLOBAL VARIABLE Definition for ALV GRID

*   설명 : ALV 구현시 반드시 기술

*--------------------------------------------------------------*

DATA: gt_listheader       TYPE slis_t_listheader      ,

      gt_field            TYPE slis_t_fieldcat_alv    WITH HEADER LINE,

      gt_event            TYPE slis_t_event           WITH HEADER LINE,

      gs_layout           TYPE slis_layout_alv        ,

      gt_fieldgroups      TYPE slis_t_sp_group_alv    ,

      gt_sort             TYPE slis_t_sortinfo_alv    WITH HEADER LINE,

      gt_filtered_entries TYPE slis_t_filtered_entries,

      gt_filter           TYPE slis_t_filter_alv      ,

      gt_extab            TYPE slis_t_extab           ,

      gt_top_of_page      TYPE slis_t_listheader      WITH HEADER LINE.

 

 

 

 

 

*&-------------------------------------------------------------*

*&  Include           ZSDR6040_EVT  (EVENT 구문)

*&--------------------------------------------------------------*

 

*****************

INITIALIZATION.

*****************

  PERFORM set_init_parameters.  "Default 셋팅

 

*********************

START-OF-SELECTION.

*********************

  PERFORM read_data_with_parameters.  "데이타 Select

 

*******************

END-OF-SELECTION.

*******************

  PERFORM alv_basic.

  PERFORM alv_header.

  PERFORM alv_field.

  PERFORM alv_sort.

PERFORM alv_display.

 

 

*&------------------------------------------------------------*

*&  Include           ZSDR6040_F01  (Form )

*&------------------------------------------------------------*

FORM read_data_with_parameters .

 

  CLEAR: gt_data, gt_data[].

 

  SELECT  *

    INTO CORRESPONDING FIELDS OF TABLE gt_data

    FROM ztsd6000

   WHERE itsm_no IN so_no   "ITSM_NO.

   AND   erdat IN so_erdat

   AND   hq_code = pa_code.

 

 

ENDFORM.                    " READ_DATA_WITH_PARAMETERS

*&------------------------------------------------------------*

*&      Form  SET_INIT_PARAMETERS

*&------------------------------------------------------------*

FORM set_init_parameters .

 

ENDFORM.                    " SET_INIT_PARAMETERS

*&---------------------------------------------------------------*

*&      Form  ALV_BASIC

*&---------------------------------------------------------------*

FORM alv_basic .

  CLEAR: gs_layout, gt_event, gt_event[].

 

  gs_layout-zebra             = 'X'.

  gs_layout-colwidth_optimize = 'X'.

 

  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    IMPORTING

      et_events = gt_event[].

 

  LOOP AT gt_event.

 

    IF gt_event-name = 'PF_STATUS_SET'.

      gt_event-form = 'PF_STATUS_SET'.

    ENDIF.

 

    IF gt_event-name = 'TOP_OF_PAGE'.

      gt_event-form = 'TOP_OF_PAGE'.

    ENDIF.

 

    IF gt_event-name = 'USER_COMMAND'.

      gt_event-form = 'USER_COMMAND'.

    ENDIF.

 

    MODIFY gt_event.

 

  ENDLOOP.

ENDFORM.                    " ALV_BASIC

*&-------------------------------------------------------------*

*&      Form  ALV_FIELD

*&-------------------------------------------------------------*

FORM alv_field .

  CLEAR: gt_field, gt_field[].

* alv 에 조회할 필드를 정의한다.

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

      i_program_name     = sy-repid

      i_internal_tabname = 'GS_DATA'

      i_inclname         = sy-repid

    CHANGING

      ct_fieldcat        = gt_field[].

 

* --field catalog 필드명을 정의한다.

  LOOP AT gt_field.

 

    IF gt_field-fieldname = 'ITSM_NO'.

      gt_field-seltext_l = 'ITSM_NO'.

      gt_field-ddictxt   = 'L'.

    ENDIF.

 

    MODIFY gt_field.

 

  ENDLOOP.

 

ENDFORM.                    " ALV_FIELD

*&-------------------------------------------------------------*

*&      Form  ALV_DISPLAY

*&-------------------------------------------------------------*

FORM alv_display .

 

* alv display catalog 정의한다/.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

      i_callback_program = sy-repid

      is_layout          = gs_layout

      it_fieldcat        = gt_field[]

      it_sort            = gt_sort[]

      it_events          = gt_event[]

    TABLES

      t_outtab           = gt_data.

 

ENDFORM.                    " ALV_DISPLAY

 

 

*&---------------------------------------------------------------*

*&      Form  PF_STATUS_SET

*&---------------------------------------------------------------*

FORM pf_status_set USING p_rt_extab TYPE slis_t_extab.

 

  SET PF-STATUS '1000'.

  SET TITLEBAR  '1000'.

 

ENDFORM.                    " PF_STATUS_SET

 

*&------------------------------------------------------------*

*&      Form  TOP_OF_PAGE

*&------------------------------------------------------------*

FORM top_of_page.

 

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

      it_list_commentary = gt_top_of_page[].

 

ENDFORM.                    " TOP_OF_PAGE

 

*&------------------------------------------------------------*

*&      Form  USER_COMMAND

*&------------------------------------------------------------*

FORM user_command USING p_ucomm    LIKE sy-ucomm

                        p_selfield TYPE slis_selfield.

 

  CASE p_ucomm.

 

    WHEN '&IC1'.    "Double Click, Hotspot Click

 

      MESSAGE i000(zmm001) WITH p_selfield-fieldname

                                ':'

                                p_selfield-value.

 

    WHEN 'BUTTON'.  "Toolbar Button Click

 

      MESSAGE i000(zmm001) WITH 'Toolbar Button Click!'.

 

  ENDCASE.

 

ENDFORM.                    " USER_COMMAND

 

*&------------------------------------------------------------*

*&      Form  ALV_HEADER

*&-------------------------------------------------------------*

FORM alv_header .

 

  DATA: l_total_cnt TYPE string,

        l_total_cnt2 TYPE string.

  CLEAR: gt_top_of_page, gt_top_of_page[].

 

* 조회된 레코드 수를 count 한다. (DESCRIBE TABLE ~ LINES))

  DESCRIBE TABLE gt_data LINES l_total_cnt.

* 변수의 값과 문자를 합친다. (CONCATENATE)

  CONCATENATE l_total_cnt ' 건' INTO l_total_cnt2.

 

  gt_top_of_page-typ  = 'S'.

  gt_top_of_page-key  = '총 레코드 수:'.

  gt_top_of_page-info = l_total_cnt2.

 

  APPEND gt_top_of_page.

 

ENDFORM.                    " ALV_HEADER

 

*&-------------------------------------------------------------*

*&      Form  ALV_SORT

*&----

(ALV)조회PRG_20100320_v0.1.docx

---------------------------------------------------------*

FORM alv_sort .

 

  CLEAR: gt_sort, gt_sort[].

 

  gt_sort-fieldname = 'ITSM_NO'.  "ITSM_NO

  gt_sort-spos      = '1'.

  gt_sort-up        = 'X'.

 

  APPEND gt_sort.

 

ENDFORM.                    " ALV_SORT

 


 

Posted by SAP HANA .Brian

댓글을 달아 주세요