메뉴 건너뛰기

SAP 한국 커뮤니티

REPORT z19_010

sapjoy 2007.04.07 00:10 조회 수 : 2843

REPORT  z19_010.


DATA: g_alv_tree         TYPE REF TO cl_gui_alv_tree,
      g_custom_container TYPE REF TO cl_gui_custom_container.


DATA: gt_sflight      TYPE sflight OCCURS 0,      "Output-Table
      ok_code LIKE sy-ucomm,
      save_ok LIKE sy-ucomm,           "OK-Code
      g_max TYPE i VALUE 255.


END-OF-SELECTION.


  CALL SCREEN 100.


*&---------------------------------------------------------------------*
*&      Module  PBO  OUTPUT
*&---------------------------------------------------------------------*
*       process before output
*----------------------------------------------------------------------*
MODULE pbo OUTPUT.


  SET PF-STATUS 'MAIN100'.
  SET TITLEBAR 'MAINTITLE'.


  IF g_alv_tree IS INITIAL.
    PERFORM init_tree.


    CALL METHOD cl_gui_cfw=>flush
      EXCEPTIONS
        cntl_system_error = 1
        cntl_error        = 2.
    IF sy-subrc NE 0.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = 'Automation Queue failure'(801)
          txt1  = 'Internal error:'(802)
          txt2  = 'A method in the automation queue'(803)
          txt3  = 'caused a failure.'(804).
    ENDIF.
  ENDIF.


ENDMODULE.                             " PBO  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  PAI  INPUT
*&---------------------------------------------------------------------*
*       process after input
*----------------------------------------------------------------------*
MODULE pai INPUT.
  save_ok = ok_code.
  CLEAR ok_code.


  CASE save_ok.
    WHEN 'EXIT' OR 'BACK' OR 'CANC'.
      PERFORM exit_program.


    WHEN OTHERS.
* §6. Call dispatch to process toolbar functions
      CALL METHOD cl_gui_cfw=>dispatch.


  ENDCASE.


  CALL METHOD cl_gui_cfw=>flush.
ENDMODULE.                             " PAI  INPUT


*&---------------------------------------------------------------------*
*&      Form  init_tree
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM init_tree.
* §1b. Create ALV Tree Control and corresponding Container.


* create container for alv-tree
  DATA: l_tree_container_name(30) TYPE c.


  l_tree_container_name = 'CCONTAINER1'.


  CREATE OBJECT g_custom_container
     EXPORTING
           container_name = l_tree_container_name
     EXCEPTIONS
           cntl_error                  = 1
           cntl_system_error           = 2
           create_error                = 3
           lifetime_error              = 4
           lifetime_dynpro_dynpro_link = 5.
  IF sy-subrc <> 0.
    MESSAGE x208(00) WITH 'ERROR'(100).
  ENDIF.


* create tree control
  CREATE OBJECT g_alv_tree
    EXPORTING
        parent              = g_custom_container
        node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple
        item_selection      = 'X'
        no_html_header      = 'X'
        no_toolbar          = ''
    EXCEPTIONS
        cntl_error                   = 1
        cntl_system_error            = 2
        create_error                 = 3
        lifetime_error               = 4
        illegal_node_selection_mode  = 5
        failed                       = 6
        illegal_column_name          = 7.
  IF sy-subrc <> 0.
    MESSAGE x208(00) WITH 'ERROR'.                          "#EC NOTEXT
  ENDIF.


 


  DATA l_hierarchy_header TYPE treev_hhdr.
  PERFORM build_hierarchy_header CHANGING l_hierarchy_header.


  CALL METHOD g_alv_tree->set_table_for_first_display
    EXPORTING
      i_structure_name    = 'SFLIGHT'
      is_hierarchy_header = l_hierarchy_header
    CHANGING
      it_outtab           = gt_sflight. "table must be empty !



  PERFORM create_hierarchy.


  CALL METHOD g_alv_tree->frontend_update.



ENDFORM.                               " init_tree
*&---------------------------------------------------------------------*
*&      Form  build_hierarchy_header
*&---------------------------------------------------------------------*
*       build hierarchy-header-information
*----------------------------------------------------------------------*
*      -->P_L_HIERARCHY_HEADER  strucxture for hierarchy-header
*----------------------------------------------------------------------*
FORM build_hierarchy_header CHANGING
                               p_hierarchy_header TYPE treev_hhdr.


  p_hierarchy_header-heading = 'Month/Carrier/Date'(300).
  p_hierarchy_header-tooltip = 'Flights in a month'(400).
  p_hierarchy_header-width = 30.
  p_hierarchy_header-width_pix = ' '.


ENDFORM.                               " build_hierarchy_header
*&---------------------------------------------------------------------*
*&      Form  exit_program
*&---------------------------------------------------------------------*
*       free object and leave program
*----------------------------------------------------------------------*
FORM exit_program.


  CALL METHOD g_custom_container->free.
  LEAVE PROGRAM.


ENDFORM.                               " exit_program
*&---------------------------------------------------------------------*
*&      Form  create_hierarchy
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM create_hierarchy.


  DATA: ls_sflight TYPE sflight,
        lt_sflight TYPE sflight OCCURS 0,
        l_carrid LIKE sflight-carrid,
        l_carrid_last LIKE sflight-carrid.


  DATA: l_node_key TYPE lvc_nkey,
        l_node_key2 TYPE lvc_nkey,
        l_node_key3 TYPE lvc_nkey,
        l_node_text TYPE lvc_value,
        l_relat_key TYPE lvc_nkey,
        l_first_flg TYPE c.


  SELECT * FROM sflight INTO TABLE lt_sflight UP TO g_max ROWS.


* 1. root node
  l_relat_key = ''.
  l_node_text = 'AIRPLANE'.
  CALL METHOD g_alv_tree->add_node
    EXPORTING
      i_relat_node_key = l_relat_key
      i_relationship   = 6" cl_gui_column_tree=>relat_last_child
      i_node_text      = l_node_text
*      is_outtab_line   = ls_sflight
    IMPORTING
      e_new_node_key   = l_node_key.


  SORT lt_sflight BY  carrid fldate.


  LOOP AT lt_sflight INTO ls_sflight.
    AT NEW carrid.
      l_relat_key = l_node_key.
      l_node_text = ls_sflight-carrid.
      l_first_flg = 'X'.
      CALL METHOD g_alv_tree->add_node
        EXPORTING
          i_relat_node_key = l_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = l_node_text
*      is_outtab_line   = ls_sflight
        IMPORTING
          e_new_node_key   = l_node_key2.
    ENDAT.


    IF l_first_flg = 'X'.
      l_relat_key = l_node_key2.
      l_node_text = ls_sflight-fldate.
      l_first_flg = 'X'.
      CALL METHOD g_alv_tree->add_node
        EXPORTING
          i_relat_node_key = l_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = l_node_text
          is_outtab_line   = ls_sflight
        IMPORTING
          e_new_node_key   = l_node_key3.
    ENDIF.


    AT END OF carrid.
      CLEAR l_first_flg.
    ENDAT.


  ENDLOOP.


ENDFORM.                               " create_hierarchy

번호 제목 글쓴이 날짜 조회 수
111 REPORT Z05_022 sapjoy 2007.05.28 2136
110 REPORT Z05_021 sapjoy 2007.05.28 2087
109 REPORT Z05_011 sapjoy 2007.05.28 2066
108 REPORT Z05_011 sapjoy 2007.05.28 2159
107 REPORT Z05_002 sapjoy 2007.05.22 2172
106 REPORT z03_026 sapjoy 2007.05.16 2313
105 REPORT Z03_020 sapjoy 2007.05.15 2170
104 TYPE-POOL ztgrp [1] sapjoy 2007.05.15 2700
103 REPORT Z03_010 [2] sapjoy 2007.05.15 2664
102 REPORT Z03_002 [4] sapjoy 2007.05.11 2581
101 REPORT Z03_004 sapjoy 2007.05.11 2433
100 REPORT Z03_003 [7] sapjoy 2007.05.11 2879
99 INCLUDE Z16_001I01 sapjoy 2007.04.27 2892
98 Include Z16_001TOP sapjoy 2007.04.27 2601
97 PROGRAM z16_001 sapjoy 2007.04.27 2952
96 REPORT z20_002 [2] sapjoy 2007.04.16 3096
95 REPORT z20_001 sapjoy 2007.04.13 2499
94 REPORT z18_027 sapjoy 2007.04.10 2315
» REPORT z19_010 [2] sapjoy 2007.04.07 2843
92 REPORT z19_004 sapjoy 2007.03.28 3238