2018년 10월 30일 화요일

템플릿 - Z*PROGRAM ID* _C01

*&---------------------------------------------------------------------*
*& Include          ZEVR0010C01
*&---------------------------------------------------------------------*
*******************************
* LOCAL CLASSES: DEFINITION
*******************************
* 클래스 정의
CLASS lcl_def_receiver DEFINITION.

  PUBLIC SECTION.

    METHODS: handle_top_of_page
               FOR EVENT top_of_page OF cl_gui_alv_grid
               IMPORTING e_dyndoc_id table_index.

    METHODS : handle_toolbar
                 FOR EVENT toolbar OF cl_gui_alv_grid
                 IMPORTING sender
                           e_object
                           e_interactive.

    METHODS : handle_user_command
                 FOR EVENT user_command OF cl_gui_alv_grid
                 IMPORTING sender e_ucomm.

    METHODS : handle_data_changed
                 FOR EVENT data_changed OF cl_gui_alv_grid
                 IMPORTING sender er_data_changed.

    METHODS : handle_after_user_command
                     FOR EVENT after_user_command OF cl_gui_alv_grid.

    METHODS : handle_data_changed_finished
                 FOR EVENT data_changed_finished OF cl_gui_alv_grid
                 IMPORTING sender e_modified
                           et_good_cells.

    METHODS : handle_hotspot_click
                 FOR EVENT hotspot_click OF cl_gui_alv_grid
                 IMPORTING sender e_row_id
                           e_column_id.

    METHODS : handle_double_click
                 FOR EVENT double_click OF cl_gui_alv_grid
                 IMPORTING sender
                           e_row
                           e_column
                           es_row_no.

    METHODS: handle_on_f4 FOR EVENT onf4 OF cl_gui_alv_grid
       IMPORTING sender
                 e_fieldname
                 e_fieldvalue
                 es_row_no
                 er_event_data
                 et_bad_cells
                 e_display.

ENDCLASS.  " LCL_DEF_RECEIVER
*******************************
* LOCAL CLASSES: IMPLEMENTATION
*******************************
* 클래스 구현
CLASS lcl_def_receiver IMPLEMENTATION.

  METHOD handle_top_of_page.
*    PERFORM top_of_page USING e_dyndoc_id table_index.

  ENDMETHOD.                    "HANDLE_TOP_OF_PAGE

  METHOD handle_toolbar.
    IF sender = go_alv1.
*      PERFORM TOOBAR_PART USING SENDER E_OBJECT E_INTERACTIVE.
    ENDIF.
  ENDMETHOD.                    "handle_toolbar

*----------------------------------------------------------------------*
*       CLASS LCL_EVENT_RECEIVER IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
  METHOD handle_after_user_command.
*    PERFORM AFTER_USER_COMMAND.
  ENDMETHOD.                    "HANDLE_AFTER_USER_COMMAND

  METHOD handle_user_command.
    IF sender = go_alv1.
      PERFORM user_command_part USING e_ucomm.
    ENDIF.
  ENDMETHOD.                    "handle_user_command

  METHOD handle_data_changed.
    IF sender = go_alv1.
      PERFORM data_changed USING er_data_changed.
    ENDIF.
  ENDMETHOD.                    "handle_data_changed

  METHOD handle_data_changed_finished.
    IF sender = go_alv1.
      PERFORM data_changed_finished USING e_modified et_good_cells.
    ENDIF.
  ENDMETHOD.                    "handle_data_changed_finished

  METHOD handle_hotspot_click.
    IF sender = go_alv1.
      PERFORM hotspot_click USING e_row_id e_column_id.
    ENDIF.
  ENDMETHOD.                    "handle_hotspot_click

  METHOD handle_double_click.
    IF sender = go_alv1.
      PERFORM double_click USING e_row e_column es_row_no.
    ENDIF.
  ENDMETHOD.                    "handle_double_click

  METHOD handle_on_f4.
    PERFORM on_f4 USING sender
                        e_fieldname
                        e_fieldvalue
                        es_row_no
                        er_event_data
                        et_bad_cells
                        e_display.
  ENDMETHOD.                    "handle_on_f4

ENDCLASS.  " LCL_DEF_RECEIVER
*&---------------------------------------------------------------------*
*&      FORM  TOOBAR_PART
*&---------------------------------------------------------------------*
*       TOOBAR_PART
*----------------------------------------------------------------------*
FORM toobar_part USING sender
                       p_c_object TYPE REF TO cl_alv_event_toolbar_set
                       p_interactive.

*  PERFORM TOOBAR_PART_100 USING P_C_OBJECT P_INTERACTIVE.

ENDFORM.                    " TOOBAR_PART

*&---------------------------------------------------------------------*
*&      FORM  USER_COMMAND_PART
*&---------------------------------------------------------------------*
*       TEXT
*----------------------------------------------------------------------*
*      -->P_E_UCOMM  TEXT
*----------------------------------------------------------------------*
FORM user_command_part  USING p_ucomm.

  IF p_ucomm EQ 'SUB'.
    PERFORM get_selected_row USING go_alv1.
    PERFORM user_command.
  ENDIF.

ENDFORM.                    " USER_COMMAND_PART

*&---------------------------------------------------------------------*
*&      FORM  DATA_CHANGED
*&---------------------------------------------------------------------*
*       TEXT
*----------------------------------------------------------------------*
*      -->P_ER_DATA_CHANGED  TEXT
*----------------------------------------------------------------------*
FORM data_changed USING p_c_data_changed
                          TYPE REF TO cl_alv_changed_data_protocol.

ENDFORM.                    " DATA_CHANGED

*&---------------------------------------------------------------------*
*&      Form  F_OUT_MESSAGE_PROC
*&---------------------------------------------------------------------*
*       에러처리를 한다.
*----------------------------------------------------------------------*
*      -->P_DATA_CHANGED  text
*      -->P_MODF_FIELD    text
*----------------------------------------------------------------------*
FORM f_out_message_proc
        USING p_data_changed TYPE REF TO cl_alv_changed_data_protocol
              p_modf_field   TYPE lvc_s_modi
              ps_msg TYPE t_msg.


*  CALL METHOD P_DATA_CHANGED->ADD_PROTOCOL_ENTRY

*    EXPORTING

*      I_MSGID     = PS_MSG-MSGID

*      I_MSGTY     = PS_MSG-MSGTY

*      I_MSGNO     = PS_MSG-MSGNO

*      I_MSGV1     = PS_MSG-MSG1

*      I_MSGV2     = PS_MSG-MSG2

*      I_MSGV3     = PS_MSG-MSG3

*      I_MSGV4     = PS_MSG-MSG4

*      I_FIELDNAME = P_MODF_FIELD-FIELDNAME

*      I_ROW_ID    = P_MODF_FIELD-ROW_ID.

ENDFORM.                    " F_OUT_MESSAGE_PROC

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

*&      FORM  DATA_CHANGED_FINISHED

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

*       TEXT

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

*      -->P_E_MODIFIED  TEXT

*      -->P_ET_GOOD_CELLS  TEXT

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

FORM data_changed_finished  USING  p_e_modified

                                   et_good_cells. " TYPE LVC_T_MODI



ENDFORM.                    " DATA_CHANGED_FINISHED

*&---------------------------------------------------------------------*
*&      FORM  HOTSPOT_CLICK
*&---------------------------------------------------------------------*
*       TEXT
*----------------------------------------------------------------------*
*      -->P_E_ROW_ID  TEXT
*      -->P_E_COLUMN_ID  TEXT
*----------------------------------------------------------------------*
FORM hotspot_click  USING   p_row_id
                            p_column_id.

  IF p_column_id EQ 'BELNR'.
    IF p_sel01 EQ 'X'.
      CLEAR gs_card.
      READ TABLE gt_card INTO gs_card INDEX p_row_id.
      CHECK sy-subrc EQ 0.

    ELSEIF p_sel02 EQ 'X'.
      CLEAR gs_dti.
      READ TABLE gt_dti INTO gs_dti INDEX p_row_id.
      CHECK sy-subrc EQ 0.

    ELSEIF p_sel03 EQ 'X'.
      CLEAR gs_etc.
      READ TABLE gt_etc INTO gs_etc INDEX p_row_id.
      CHECK sy-subrc EQ 0.

    ENDIF.
  ENDIF.

ENDFORM.                    " HOTSPOT_CLICK

*&---------------------------------------------------------------------*
*&      FORM  DOUBLE_CLICK
*&---------------------------------------------------------------------*
*       TEXT
*----------------------------------------------------------------------*
*      -->P_E_ROW  TEXT
*      -->P_E_COLUMN  TEXT
*      -->P_ES_ROW_NO  TEXT
*----------------------------------------------------------------------*
FORM double_click  USING  p_row TYPE lvc_s_row
                          p_column
                          p_s_row_no.

  RANGES : lr_cardno FOR ztficd10-zcardno,
           lr_mail   FOR zdti_header-zbyre,
           lr_supno  FOR zdti_header-supno,
           lr_pernr  FOR usr02-bname.

  CHECK p_row-index NE 0.

  IF p_sel01 EQ 'X'.
    CLEAR gs_card.
    READ TABLE gt_card INTO gs_card INDEX p_row-index.
    add_range_eq_space : lr_cardno  gs_card-zcardno.
  ELSEIF p_sel02 EQ 'X'.
    CLEAR gs_dti.
    READ TABLE gt_dti INTO gs_dti INDEX p_row-index.
    add_range_eq_space : lr_mail    gs_dti-email,
                         lr_supno   gs_dti-supno.
  ELSEIF p_sel03 EQ 'X'.
    CLEAR gs_etc.
    READ TABLE gt_etc INTO gs_etc INDEX p_row-index.
    add_range_eq_space : lr_pernr   gs_etc-empno.
  ENDIF.

  SUBMIT zevr0020 USING SELECTION-SCREEN 1000
               WITH p_bukrs  EQ p_bukrs
               WITH s_budat  IN s_budat
               WITH p_sel01  EQ p_sel01
               WITH p_sel02  EQ p_sel02
               WITH p_sel03  EQ p_sel03
               WITH p_tot    EQ p_tot
               WITH p_fi     EQ p_fi
               WITH p_tr     EQ p_tr
               WITH s_cardno IN lr_cardno
               WITH s_mail   IN lr_mail
               WITH s_supno  IN lr_supno
               WITH s_pernr  IN lr_pernr
               AND RETURN.

ENDFORM.                    " DOUBLE_CLICK

*&---------------------------------------------------------------------*
*&      Form  ON_F4
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_SENDER  text
*      -->P_E_FIELDNAME  text
*      -->P_E_FIELDVALUE  text
*      -->P_ES_ROW_NO  text
*      -->P_ER_EVENT_DATA  text
*      -->P_ET_BAD_CELLS  text
*      -->P_E_DISPLAY  text
*----------------------------------------------------------------------*
FORM on_f4  USING    p_c_sender     TYPE REF TO cl_gui_alv_grid
                     p_fieldname    TYPE lvc_fname
                     p_fieldvalue   TYPE lvc_value
                     p_s_row_no     TYPE lvc_s_roid
                     p_c_event_data TYPE REF TO cl_alv_event_data
                     p_t_bad_cells  TYPE lvc_t_modi
                     p_display      TYPE char01.

*  PERFORM ON_F4_100 USING P_C_SENDER
*                          P_FIELDNAME
*                          P_FIELDVALUE
*                          P_S_ROW_NO
*                          P_C_EVENT_DATA
*                          P_T_BAD_CELLS
*                          P_DISPLAY.

ENDFORM.                                                    " ON_F4

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

*&      Form  ON_F4_100

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

*       text

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

*      -->P_P_C_SENDER  text

*      -->P_P_FIELDNAME  text

*      -->P_P_FIELDVALUE  text

*      -->P_P_S_ROW_NO  text

*      -->P_P_C_EVENT_DATA  text

*      -->P_P_T_BAD_CELLS  text

*      -->P_P_DISPLAY  text

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

*FORM ON_F4_100  USING    P_C_SENDER        TYPE REF TO CL_GUI_ALV_GRID

*                         P_FIELDNAME   TYPE LVC_FNAME

*                         P_FIELDVALUE  TYPE LVC_VALUE

*                         P_S_ROW_NO     TYPE LVC_S_ROID

*                         P_C_EVENT_DATA TYPE REF TO CL_ALV_EVENT_DATA

*                         P_T_BAD_CELLS  TYPE LVC_T_MODI

*                         P_DISPLAY     TYPE CHAR01.

*

*  DATA : LT_RETURN   LIKE DDSHRETVAL OCCURS 0 WITH HEADER LINE.

*  DATA : LS_LVC_MODI TYPE LVC_S_MODI.

*

*  FIELD-SYMBOLS : <FS_DATA> TYPE LVC_T_MODI.

*  CLEAR : P_DISPLAY .

*

*  CASE P_FIELDNAME.

*    WHEN 'MEINS'.

*  ENDCASE.

*

*ENDFORM.                                                    " ON_F4_100

*&---------------------------------------------------------------------*
*&      Form  SET_ALV_LIST
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_LCL_GRID  text
*      -->P_0062   text
*      -->P_0063   text
*----------------------------------------------------------------------*
FORM display_alv_list USING pv_alv_grid  TYPE REF TO lcl_def_grid
                            p_tname
                            p_cnt.

* 로컬변수선언
  DATA : lv_table LIKE feld-name.

  FIELD-SYMBOLS : <table>   TYPE STANDARD TABLE,
                  <ft_fcat> TYPE STANDARD TABLE,
                  <ft_sort> TYPE STANDARD TABLE,
                  <ft_func> TYPE STANDARD TABLE,
                  <fs_layo> TYPE any.

  DATA : l_subrc LIKE sy-subrc.
  DATA : l_fieldname LIKE dd03l-fieldname.


  CONCATENATE p_tname '[]' INTO lv_table.
  ASSIGN (lv_table) TO <table>.

*-- TOOLBAR ASSIGN
  CONCATENATE 'GT_UI_FUNCTIONS' p_cnt INTO lv_table.
  ASSIGN (lv_table) TO <ft_func>.

*-- FIELDCAT ASSIGN
  CONCATENATE 'GT_LVC_FCAT' p_cnt '[]' INTO lv_table.
  ASSIGN (lv_table) TO <ft_fcat>.

*-- GT_LVC_SORT ASSIGN
  CONCATENATE 'GT_LVC_SORT' p_cnt '[]' INTO lv_table.
  ASSIGN (lv_table) TO <ft_sort>.

  PERFORM check_sort_parameter USING <ft_fcat>[] <ft_sort>[]
    CHANGING l_fieldname l_subrc.

  IF l_subrc NE 0.
    CONCATENATE l_fieldname ` : `
    `Not Exist SORT Field` INTO l_fieldname.
    MESSAGE s000 DISPLAY LIKE 'E' WITH l_fieldname.
    EXIT.
  ENDIF.

  CONCATENATE 'GS_LVC_LAYO' p_cnt INTO lv_table.
  ASSIGN (lv_table) TO <fs_layo>.

  SORT <table>.

  CHECK NOT pv_alv_grid IS INITIAL.

*  gv_consistency_check = 'X'.

  CALL METHOD pv_alv_grid->set_table_for_first_display
    EXPORTING
      is_variant                    = gs_variant
      i_save                        = 'A'
      i_default                     = 'X'
      is_layout                     = <fs_layo>
      i_consistency_check           = gv_consistency_check
      it_toolbar_excluding          = <ft_func>
    CHANGING
      it_outtab                     = <table>
      it_fieldcatalog               = <ft_fcat>
      it_sort                       = <ft_sort>
    EXCEPTIONS
      invalid_parameter_combination = 1
      program_error                 = 2
      too_many_lines                = 3
    OTHERS                          = 4.

  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.                    " SET_ALV_LIST

*&---------------------------------------------------------------------*
*&      Form  SET_FIELDCATALOG_MERGE_X01
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_C_STRUC  text
*      <--P_GT_LVC_FCAT1  text
*----------------------------------------------------------------------*
FORM set_fcat_ddic_x01
  USING p_strnam LIKE dd02l-tabname
  CHANGING p_t_lvc_fcat TYPE lvc_t_fcat.

  DATA : ls_lvc_fcat TYPE lvc_s_fcat.
  DATA : lt_dd03t TYPE TABLE OF dd03t WITH HEADER LINE.


  CLEAR:   p_t_lvc_fcat, p_t_lvc_fcat[], ls_lvc_fcat.

  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name       = p_strnam
      i_bypassing_buffer     = 'X'
    CHANGING
      ct_fieldcat            = p_t_lvc_fcat
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.

*-- 사용자 정의 구조 추가
*  PERFORM FILL_FIELD_CATALOGS TABLES P_T_LVC_FCAT USING:
*          'S' 'FIELDNAME'     'STATUS',
*          ' ' 'KEY'           'X',
*          ' ' 'JUST'          'C',
*          ' ' 'OUTPUTLEN'     '3',
*          ' ' 'ICON'          'X',
*          ' ' 'COL_POS'       '1',
*          ' ' 'REF_TABLE'     'ICON',
*          ' ' 'REF_FIELD'     'ID',
*          'E' 'SCRTEXT_L'     'STATUS',
*
*          'S' 'FIELDNAME'     'MESSAGE',
*          ' ' 'JUST'          'L',
*          ' ' 'OUTPUTLEN'     '60',
*          ' ' 'COL_POS'       '90',
*          ' ' 'DATATYPE'      'CHAR',
*          ' ' 'INTLEN'        '255',
*          'E' 'SCRTEXT_L'     'MESSAGE'.

  LOOP AT p_t_lvc_fcat INTO ls_lvc_fcat.
*-- 숫자는 오른쪽 정렬
    IF ls_lvc_fcat-datatype EQ 'DEC' OR ls_lvc_fcat-datatype CP 'INT+'
    OR ls_lvc_fcat-datatype EQ 'QUAN' OR ls_lvc_fcat-datatype EQ 'CURR'.
      ls_lvc_fcat-just = 'R'.
    ENDIF.

**-- 필드별 속성 재정의
*    PERFORM FCAT_SCR_0100_X01 USING P_STRNAM
*                         CHANGING LS_LVC_FCAT.

*- 필드 텍스트 넣기
    IF ls_lvc_fcat-scrtext_l IS NOT INITIAL.
      ls_lvc_fcat-coltext = ls_lvc_fcat-scrtext_l.
    ELSE.
      ls_lvc_fcat-coltext = ls_lvc_fcat-reptext.
    ENDIF.

    ls_lvc_fcat-seltext = ls_lvc_fcat-coltext.

    MODIFY p_t_lvc_fcat FROM ls_lvc_fcat.
  ENDLOOP.

ENDFORM.                    " SET_FIELDCATALOG_MERGE_X01

*&---------------------------------------------------------------------*
*&      Form  FILL_FIELD_CATALOGS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_T_LVC_FCAT  text
*      -->P_GUB         text
*      -->P_FNAME       text
*      -->P_VALUE       text
*----------------------------------------------------------------------*
FORM fill_field_catalogs  TABLES p_t_lvc_fcat TYPE lvc_t_fcat
                           USING p_gub  p_fname  p_value.

  IF p_gub = 'S'.
    CLEAR gs_lvc_fcat.
  ENDIF.

  DATA l_fname(40).
  FIELD-SYMBOLS <fs> TYPE any.

  CONCATENATE 'GS_LVC_FCAT-' p_fname INTO l_fname.
  ASSIGN (l_fname) TO <fs>.
  <fs> = p_value.

  IF p_gub = 'E'.
    APPEND gs_lvc_fcat TO p_t_lvc_fcat.
  ENDIF.

ENDFORM.                    " FILL_FIELD_CATALOGS

*&---------------------------------------------------------------------*
*&      Form  FILL_FCAT_X01
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_&1  text
*      -->P_&2  text
*      -->P_&3  text
*      -->P_P_SFCAT  text
*      -->P_P_TFCAT  text
*      -->P_P_RFCAT  text
*----------------------------------------------------------------------*
FORM fill_fcat  USING p_gub p_fname p_con
      p_sfcat TYPE lvc_s_fcat
      p_tfcat TYPE lvc_t_fcat
      p_ref_fcat TYPE lvc_t_fcat.

  DATA : ls_fcat TYPE lvc_s_fcat.


  CLEAR : ls_fcat.

  IF   p_gub =  'S'. " 시작에서 담고 계속 돌면서..''E'를 만났을 때 APPEND해준다.
    CLEAR p_sfcat.
    READ  TABLE p_ref_fcat INTO ls_fcat
         WITH KEY fieldname  = p_fname.

    MOVE-CORRESPONDING ls_fcat TO p_sfcat.

    p_sfcat-fieldname  = p_fname.
    "gt_fieldcat_h와 gs_fieldcat에서 Name이 다른 Field 정보를 넘겨준다.
    p_sfcat-scrtext_l  = ls_fcat-scrtext_l.
    p_sfcat-scrtext_m  = ls_fcat-scrtext_m.
    p_sfcat-scrtext_s  = ls_fcat-scrtext_s.
    p_sfcat-reptext    = ls_fcat-reptext.
    p_sfcat-colddictxt = ls_fcat-colddictxt.
    p_sfcat-ref_field  = ls_fcat-ref_field.
    p_sfcat-ref_table  = ls_fcat-ref_table.
    p_sfcat-roundfield = ls_fcat-roundfield.
    p_sfcat-decmlfield = ls_fcat-decmlfield.
    p_sfcat-decimals   = ls_fcat-decimals.
    EXIT.
  ENDIF.


  DATA : l_col(40).

  FIELD-SYMBOLS : <fs>.

  CONCATENATE 'GS_LVC_FCAT-' p_fname INTO l_col.
  ASSIGN (l_col) TO <fs>.
  MOVE p_con TO <fs>.

  IF p_gub = 'E'.
    IF p_sfcat-datatype  = 'CURR'.
      IF    p_sfcat-cfieldname IS INITIAL
        AND p_sfcat-currency   IS INITIAL.
        READ TABLE p_ref_fcat INTO ls_fcat
              WITH KEY datatype  = 'CUKY'.
        IF sy-subrc EQ 0.
          p_sfcat-cfieldname = ls_fcat-fieldname.
        ELSE.
          p_sfcat-currency  = 'KRW'.
        ENDIF.
      ENDIF.
    ENDIF.

    IF p_sfcat-datatype = 'QUAN'.
      IF p_sfcat-qfieldname IS INITIAL.
        READ TABLE p_ref_fcat INTO ls_fcat
          WITH KEY datatype = 'UNIT'.
        IF sy-subrc EQ 0.
          p_sfcat-qfieldname = ls_fcat-fieldname.
        ENDIF.
      ENDIF.
    ENDIF.

    gv_alv_colpos = gv_alv_colpos + 1.

    p_sfcat-col_pos = gv_alv_colpos.

    IF p_sfcat-outputlen IS INITIAL.
      p_sfcat-outputlen = ls_fcat-intlen + 2.
    ENDIF.

    " 숫자형은 오른쪽 정렬.
    IF p_sfcat-datatype EQ 'DEC' OR p_sfcat-datatype CP 'INT+'
    OR p_sfcat-datatype EQ 'QUAN' OR p_sfcat-datatype EQ 'CURR'.
      p_sfcat-just = 'R'.
    ENDIF.

    p_sfcat-seltext = p_sfcat-coltext.

    APPEND p_sfcat TO p_tfcat.

    CLEAR : p_sfcat.
  ENDIF.

ENDFORM.                    " FILL_FCAT_X01



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

*&      Form  GET_LIKEITAB_FACT

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

*       text

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

*      -->P_P_ITAB_NAME  text

*      -->P_P_STRUCTURE_NAME  text

*      -->P_P_RFCAT  text

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

FORM get_likeitab_fact  USING p_likeitab_name

                                 p_ddic_fcat TYPE lvc_t_fcat.



  DATA : lt_table LIKE dd02l-tabname OCCURS 0 WITH HEADER LINE.

  DATA : lt_fieldcat   TYPE slis_t_fieldcat_alv.

  DATA : lt_alv_cat   TYPE TABLE OF lvc_s_fcat.

  DATA : l_alv_cat TYPE lvc_s_fcat.



  CLEAR : p_ddic_fcat[], p_ddic_fcat.

  CLEAR : lt_table[], lt_table.

  CLEAR : lt_fieldcat[], lt_fieldcat.

  CLEAR : lt_alv_cat[], lt_alv_cat.



*  "Internal Table을 참조하여 Field Catalog 정보를 구성한다.

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

      i_program_name         = sy-repid

      i_internal_tabname     = p_likeitab_name

      i_inclname             = sy-repid

*     I_STRUCTURE_NAME       = P_STRUCTURE_NAME

      i_bypassing_buffer     = 'X'

*     I_BUFFER_ACTIVE        = 'X'

    CHANGING

      ct_fieldcat            = lt_fieldcat[]

    EXCEPTIONS

      inconsistent_interface = 1

      program_error          = 2.



  CALL FUNCTION 'LVC_TRANSFER_FROM_SLIS'

    EXPORTING

      it_fieldcat_alv = lt_fieldcat

    IMPORTING

      et_fieldcat_lvc = lt_alv_cat

    TABLES

      it_data         = lt_table[].



  CALL FUNCTION 'LVC_FIELDCAT_COMPLETE'

    CHANGING

      ct_fieldcat = lt_alv_cat.



  CLEAR : p_ddic_fcat, p_ddic_fcat[].



  LOOP AT lt_alv_cat INTO l_alv_cat WHERE no_out =  'X'.

    CLEAR : l_alv_cat-no_out.

    MODIFY lt_alv_cat FROM l_alv_cat INDEX sy-tabix.

  ENDLOOP.



  p_ddic_fcat[] = lt_alv_cat[].

  CLEAR : lt_alv_cat, lt_alv_cat[].



ENDFORM.                    " GET_LIKEITAB_FACT

*&---------------------------------------------------------------------*
*&      Form  SET_TOP_OF_PAGE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_GO_CONTAINER_TOP1  text
*      -->P_GO_ALV1  text
*      -->P_GO_DD_DOCUMENT1  text
*      -->P_GO_HTML_VIEW1  text
*----------------------------------------------------------------------*
FORM set_top_of_page    USING
        p_top_cont TYPE REF TO cl_gui_container
        p_grid TYPE REF TO lcl_def_grid
        p_doc TYPE REF TO cl_dd_document
        p_html TYPE REF TO cl_gui_html_viewer.


  DATA : dl_length  TYPE i.                           " Length
  DATA : dl_background_id TYPE sdydo_key VALUE 'ALV_BACKGROUND'.
  DATA : l_alv_grid TYPE sdydo_attribute VALUE 'CL_GUI_ALV_GRID'.

  IF p_doc IS INITIAL.
    CREATE OBJECT p_doc
      EXPORTING
        style = l_alv_grid.
  ENDIF.

  CALL METHOD p_doc->initialize_document.
  CALL METHOD p_grid->list_processing_events
    EXPORTING
      i_event_name = 'TOP_OF_PAGE'
      i_dyndoc_id  = p_doc.

*CREATING HTML CONTROL
  IF p_html IS INITIAL.
    CREATE OBJECT p_html
      EXPORTING
        parent = p_top_cont.
  ENDIF.

* REUSE_ALV_GRID_COMMENTARY_SET
  CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'
    EXPORTING
      document = p_doc
      bottom   = space
    IMPORTING
      length   = dl_length.

* GET TOP->HTML_TABLE READY
  CALL METHOD p_doc->merge_document.

* Set wallpaper
  CALL METHOD p_doc->set_document_background
    EXPORTING
      picture_id = dl_background_id.

  PERFORM set_top_of_page_text USING p_doc.

* Connect TOP document to HTML-Control
  p_doc->html_control = p_html.

* Display TOP document
  CALL METHOD p_doc->display_document
    EXPORTING
      reuse_control      = 'X'
      parent             = p_top_cont
    EXCEPTIONS
      html_display_error = 1.

ENDFORM.                    " SET_TOP_OF_PAGE

*&---------------------------------------------------------------------*
*&      Form  SET_TOP_OF_PAGE_TEXT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM set_top_of_page_text USING
      p_doc TYPE REF TO cl_dd_document.

  LOOP AT gt_top_of_page_txt.
    CALL METHOD p_doc->add_text
      EXPORTING
        text         = gt_top_of_page_txt-top_text
        sap_fontsize = gt_top_of_page_txt-fontsize
        sap_color    = gt_top_of_page_txt-color.
    CALL METHOD p_doc->new_line.
  ENDLOOP.

ENDFORM.                    " SET_TOP_OF_PAGE_TEXT

댓글 없음:

댓글 쓰기