단순한 ALV 프로그램 구현 시 Screen 을 사용하여 개발한 프로그램 이다.


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

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

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

 

1. 조회조건

 

(ALV)조회PRG(Screen사용)_20100321_v0.1.docx

사용자 삽입 이미지


2. 조회결과

 

사용자 삽입 이미지

 

 

 

* 프로그램 선언

REPORT  ZSDR6040S.

INCLUDE ZSDR6040STOP.

INCLUDE ZSDR6040SSCR.

INCLUDE ZSDR6040SALV.

INCLUDE ZSDR6040SEVT.

INCLUDE ZSDR6040SO01.

INCLUDE ZSDR6040SI01.

INCLUDE ZSDR6040SF01.

 

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

*&  Include           ZSDR6040S_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           ZSDR6040S_SCR

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

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.

 

*&--------------------------------------------------------------**&  Include           ZSDR6040S_ALV

*&--------------------------------------------------------------*CLASS: lcl_alv_grid_0100       DEFINITION DEFERRED.

 

*& 상수를 선언한다.

DATA: gc_container_0100   TYPE scrfname VALUE 'CONTAINER_0100'.

 

*& 변수를 선언한다.

DATA: gv_container        TYPE scrfname VALUE space.

 

*& Alv관련 구조체/IT 선언한다.

DATA: gs_scroll           TYPE lvc_s_stbl,

      gs_fieldcat         TYPE lvc_s_fcat.

 

*& 100화면

DATA: gs_grid_0100        TYPE REF TO lcl_alv_grid_0100,

      gt_sort_0100        TYPE lvc_t_sort,

      gs_layout_0100      TYPE lvc_s_layo,

      gs_variant_0100     TYPE disvariant,

      gt_exclude_0100     TYPE ui_functions,

      gt_fieldcat_0100    TYPE lvc_t_fcat,

      gs_container_0100   TYPE REF TO cl_gui_custom_container.

 

*&--------------------------------------------------------------**       CLASS lcl_alv_grid_0100  DEFINITION

*&--------------------------------------------------------------*CLASS lcl_alv_grid_0100 DEFINITION INHERITING FROM cl_gui_alv_grid.

  PUBLIC SECTION.

    METHODS: set_optimize_all_cols_0100,

             set_cursor_0100  IMPORTING row     TYPE i

                                        col     TYPE i,

             set_fixed_column_0100,

             set_row_resize_0100.

ENDCLASS.                    " lcl_alv_grid_0100 DEFINITION

 

*&--------------------------------------------------------------**       CLASS lcl_alv_grid_0100  IMPLEMENTATION

*&--------------------------------------------------------------*CLASS lcl_alv_grid_0100 IMPLEMENTATION.

  METHOD set_optimize_all_cols_0100.

    CALL METHOD me->optimize_all_cols

         EXPORTING

              include_header    = 1.

  ENDMETHOD.                    " set_optimize_all_cols_0100

*

  METHOD set_cursor_0100.

    CALL METHOD me->set_current_cell_base

         EXPORTING

              row              = row

              col              = col.

  ENDMETHOD.                    " set_cursor_0100

*

  METHOD set_fixed_column_0100.

    CALL METHOD me->set_fixed_cols

         EXPORTING

              cols            = 4.

  ENDMETHOD.                    " set_fixed_column_0100

*

  METHOD set_row_resize_0100.

    CALL METHOD me->set_resize_rows

         EXPORTING

              enable          = 1.

  ENDMETHOD.                    " set_row_resize_0100

ENDCLASS.                    " lcl_alv_grid_0100 IMPLEMENTATION

 

 

 

*&--------------------------------------------------------------**&  Include           ZSDR6040S_EVT

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

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

*&    START-OF-SELECTION

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

 

  PERFORM read_data_with_parameters.  "데이타 Select

 

 

*&--------------------------------------------------------------**&    END-OF-SELECTION

*&--------------------------------------------------------------*END-OF-SELECTION.

CALL SCREEN '0100'.

 
*&--------------------------------------------------------------****INCLUDE ZSDR6040SO01 .

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

 

module STATUS_0100 output.

  SET PF-STATUS '0100'.

  SET TITLEBAR '0100'.

 

endmodule.                 " STATUS_0100  OUTPUT

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

*&      Module  INIT_CONTAINER_0100  OUTPUT

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

module INIT_CONTAINER_0100 output.

  CHECK gs_container_0100 IS INITIAL.

 

  PERFORM create_init_0100.

endmodule.                 " INIT_CONTAINER_0100  OUTPUT

 

 

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

***INCLUDE ZSDR6040SI01 .

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

 

MODULE exit_0100 INPUT.

  CASE sy-ucomm.

    WHEN 'EXIT' OR 'BACK'.

      LEAVE TO SCREEN 0.

  ENDCASE.

ENDMODULE.                 " PRG_EXIT  INPUT

 

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

*&      Module  USER_COMMAND_0100  INPUT

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

 

MODULE user_command_0100 INPUT.

  CASE sy-ucomm.

 

    WHEN 'BTN'.  "BUTTON

 

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

 

  ENDCASE.

ENDMODULE.                 " USER_COMMAND_0100  INPUT

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

*&  Include           ZHWAN0030_F01

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

*&      Form  READ_DATA_WITH_PARAMETERS

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

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  CREATE_INIT_0100

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

 

FORM create_init_0100 .

  CLEAR: gs_layout_0100, gt_fieldcat_0100[], gt_exclude_0100[],

          gt_sort_0100[].

 

  CREATE OBJECT gs_container_0100

    EXPORTING

      container_name = gc_container_0100.

 

  CREATE OBJECT gs_grid_0100

    EXPORTING

      i_parent = gs_container_0100.

 

  gs_layout_0100-cwidth_opt = 'X'.

  gs_layout_0100-zebra = 'X'.

  gs_layout_0100-sel_mode = 'D'.

 

  gs_variant_0100-report = sy-repid.

 

  PERFORM build_fieldcat_0100.

  PERFORM exclude_tb_functions  CHANGING gt_exclude_0100.

 

  CALL METHOD gs_grid_0100->set_table_for_first_display

    EXPORTING

      is_layout            = gs_layout_0100

      it_toolbar_excluding = gt_exclude_0100

      is_variant           = gs_variant_0100

      i_save               = 'A'

    CHANGING

      it_fieldcatalog      = gt_fieldcat_0100

      it_sort              = gt_sort_0100

      it_outtab            = gt_data[].

 

  CALL METHOD gs_grid_0100->register_edit_event

    EXPORTING

      i_event_id = cl_gui_alv_grid=>mc_evt_modified.

 

  CALL METHOD gs_grid_0100->set_toolbar_interactive.

 

ENDFORM.                    " CREATE_INIT_0100

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

*&      Form  BUILD_FIELDCAT_0100

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

 

FORM build_fieldcat_0100 .

  DATA: ls_fcat             TYPE slis_fieldcat_alv,

        lt_fcat             TYPE slis_t_fieldcat_alv.

 

  CLEAR: lt_fcat[], gt_fieldcat_0100[].

 

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

      i_program_name         = sy-repid

      i_internal_tabname     = 'GS_DATA'

      i_inclname             = sy-repid

    CHANGING

      ct_fieldcat            = lt_fcat

    EXCEPTIONS

      inconsistent_interface = 1

      program_error          = 2

      OTHERS                 = 3.

 

  LOOP AT lt_fcat  INTO ls_fcat.

    CLEAR: gs_fieldcat.

    MOVE-CORRESPONDING ls_fcat  TO gs_fieldcat.

 

    CASE gs_fieldcat-fieldname.

 

      WHEN 'ITSM_NO'.

        gs_fieldcat-outputlen = '10'.

        ls_fcat-seltext_l = 'ITSMNO'.

      WHEN 'EXP_START_DATE'.

        gs_fieldcat-outputlen = '10'.

        ls_fcat-seltext_l = '시작예정일'.

      WHEN 'EXP_END_DATE'.

        gs_fieldcat-outputlen = '10'.

        ls_fcat-seltext_l = '종료예정일'.

      WHEN 'DEV_START_DATE'.

        gs_fieldcat-outputlen = '10'.

        ls_fcat-seltext_l = '개발착수일'.

      WHEN 'REQ_TEST_DATE'.

        gs_fieldcat-outputlen = '10'.

        ls_fcat-seltext_l = '테스트요청일'.

      WHEN OTHERS.

        DELETE lt_fcat INDEX sy-tabix.

        CONTINUE.

 

    ENDCASE.

 

    gs_fieldcat-scrtext_l = ls_fcat-seltext_l.

    gs_fieldcat-colddictxt = 'L'.

 

    APPEND gs_fieldcat  TO gt_fieldcat_0100.

  ENDLOOP.

 

ENDFORM.                    " BUILD_FIELDCAT_0100

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

*&      Form  EXCLUDE_TB_FUNCTIONS

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

FORM exclude_tb_functions  CHANGING pt_exclude  TYPE ui_functions.

  DATA: ls_exclude             TYPE ui_func.

 

  ls_exclude = cl_gui_alv_grid=>mc_fc_detail.

  APPEND ls_exclude TO pt_exclude.

 

*  ls_exclude = cl_gui_alv_grid=>mc_fc_find.

*  APPEND ls_exclude TO pt_exclude.

 

  ls_exclude = cl_gui_alv_grid=>mc_fc_check.

  APPEND ls_exclude TO pt_exclude.

 

*  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.

*  APPEND ls_exclude TO pt_exclude.

 

  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.

  APPEND ls_exclude TO pt_exclude.

 

*  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.

*  APPEND ls_exclude TO pt_exclude.

*

*  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.

*  APPEND ls_exclude TO pt_exclude.

 

  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.

  APPEND ls_exclude TO pt_exclude.

 

*  ls_exclude = cl_gui_alv_grid=>mc_fc_refresh.

*  APPEND ls_exclude TO pt_exclude.

*

*  ls_exclude = cl_gui_alv_grid=>mc_fc_sort_asc.

*  APPEND ls_exclude TO pt_exclude.

*

*  ls_exclude = cl_gui_alv_grid=>mc_fc_sort_dsc.

*  APPEND ls_exclude TO pt_exclude.

*

  ls_exclude = cl_gui_alv_grid=>mc_fc_print.

  APPEND ls_exclude TO pt_exclude.

 

  ls_exclude = cl_gui_alv_grid=>mc_fc_graph.

  APPEND ls_exclude TO pt_exclude.

 

  ls_exclude = cl_gui_alv_grid=>mc_fc_views.

  APPEND ls_exclude TO pt_exclude.

 

  ls_exclude = cl_gui_alv_grid=>mc_fc_subtot.

  APPEND ls_exclude TO pt_exclude.

 

  ls_exclude = cl_gui_alv_grid=>mc_mb_sum.

  APPEND ls_exclude TO pt_exclude.

 

*  ls_exclude = cl_gui_alv_grid=>mc_mb_export.

*  APPEND ls_exclude TO pt_exclude.

 

*  ls_exclude = cl_gui_alv_grid=>mc_mb_filter.

*  APPEND ls_exclude TO pt_exclude.

 

  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.

  APPEND ls_exclude TO pt_exclude.

 

  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.

  APPEND ls_exclude TO pt_exclude.

 

  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.

  APPEND ls_exclude TO pt_exclude.

 

  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.

  APPEND ls_exclude TO pt_exclude.

 

  ls_exclude = cl_gui_alv_grid=>mc_fc_info.

  APPEND ls_exclude TO pt_exclude.

 

 

ENDFORM.                    " EXCLUDE_TB_FUNCTIONS

 

 

 


Posted by SAP HANA .Brian

댓글을 달아 주세요

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

댓글을 달아 주세요