Chinaunix首页 | 论坛 | 博客
  • 博客访问: 203359
  • 博文数量: 54
  • 博客积分: 2056
  • 博客等级: 大尉
  • 技术积分: 568
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-25 12:07
文章分类

全部博文(54)

文章存档

2014年(1)

2013年(1)

2012年(1)

2011年(2)

2010年(1)

2009年(11)

2008年(28)

2007年(9)

我的朋友

分类:

2009-05-08 13:29:16

*&---------------------------------------------------------------------*
*& Report  BCALV_TEST_GRID_LAYOUT                                      *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*
report  bcalv_test_grid_layout.
types: g_ty_s_sflight type alv_t_t2.
constants: con_sflight type lvc_fname value 'ALV_T_T2'.
*----------------------------------------------------------------------*
* DATA                                                                 *
*----------------------------------------------------------------------*
include .
include .
type-pools: slis.
class cl_gui_resources definition load.
types: g_ty_t_icon  type standard table of icon,
       g_ty_t_icont type standard table of icont,
       begin of g_ty_s_test,
         select_amount           type i,
         vari_none               type char1,
         vari_save               type char1,
         vari_default            type char1,
         vari_layout             type disvariant-variant,
         vari_dark               type disvariant-variant,
         vari_dark_user          type syuname,
         layo_no_authcheck       type char1,
         bypassing_buffer        type char1,
         buffer_active           type char1,
         current_display         type i,
       end   of g_ty_s_test,
       begin of g_ty_s_outtab.
include type g_ty_s_sflight.
types:   checkbox             type char1,
         box                  type char1,
         count                type i,
         lights               type char1,
       end   of g_ty_s_outtab,
       g_ty_t_outtab type table of g_ty_s_outtab.
constants: con_true         type char1 value 'X',
           con_display_list type i value 1,
           con_display_grid type i value 2,
           con_display_full type i value 3,
           con_dark_on  type sy-ucomm value 'DARK_ON',
           con_dark_off type sy-ucomm value 'DARK_OFF',
           con_exit type sy-ucomm value 'EXIT',
           con_canc type sy-ucomm value 'CANC',
           con_back type sy-ucomm value 'BACK'.
data: g_okcode type sy-ucomm.
data: gs_test type g_ty_s_test.
data: g_repid type sy-repid.
data: gt_outtab            type g_ty_t_outtab,
      gr_container_d0100   type ref to cl_gui_custom_container,
      gr_grid_d0100        type ref to cl_gui_alv_grid.
*----------------------------------------------------------------------*
* SELECTION-SCREEN                                                     *
*----------------------------------------------------------------------*
selection-screen begin of block gen with frame.
parameters:
p_amount type i default 30.
selection-screen end of block gen.
selection-screen begin of block var with frame title text-var.
parameters:
p_var01 radiobutton group save, "BENUTZERSPEZ
p_var02 radiobutton group save, "BENUTZER蹷ERGREIF
p_var03 radiobutton group save, "ALLES
p_var04 radiobutton group save. "KEINE
selection-screen skip.
parameters:
p_var05 as checkbox. "KEINE VERWALTUNG
selection-screen skip.
parameters:
p_var06 as checkbox. "DEFAULT
selection-screen skip.
parameters:
p_var07 like disvariant-variant. "LAYOUT
selection-screen skip.
parameters:
p_var08 as checkbox. "NO AUTHORITY CHECK
selection-screen end of block var.
selection-screen begin of block drk with frame.
parameters:
p_drk01 like disvariant-variant, "LAYOUT DARK
p_drk02 like sy-uname. "USERNAME VARIANT DARK
selection-screen end of block drk.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN ON VALUE-REQUEST                                 *
*----------------------------------------------------------------------*
at selection-screen on value-request for p_var07.
  perform f01_f4_variant changing p_var07.
*----------------------------------------------------------------------*
* START-OF-SELECTION                                                   *
*----------------------------------------------------------------------*
start-of-selection.
  g_repid               = sy-repid.
  gs_test-select_amount = p_amount.
  case con_true.
    when p_var01.
      gs_test-vari_save = 'U'.
    when p_var02.
      gs_test-vari_save = 'X'.
    when p_var03.
      gs_test-vari_save = 'A'.
    when p_var04.
      gs_test-vari_save = ' '.
  endcase.
  gs_test-vari_none         = p_var05.
  gs_test-vari_default      = p_var06.
  gs_test-vari_layout       = p_var07.
  gs_test-layo_no_authcheck = p_var08.
  gs_test-vari_dark         = p_drk01.
  gs_test-vari_dark_user    = p_drk02.
  gs_test-bypassing_buffer = space.
  gs_test-buffer_active    = space.
*----------------------------------------------------------------------*
* END-OF-SELECTION                                                     *
*----------------------------------------------------------------------*
end-of-selection.
  call screen 100.
*&---------------------------------------------------------------------*
*&      Module  d0100_set_status  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module d0100_set_status output.
  perform d0100_set_status.
endmodule.                 " d0100_set_status  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  d0100_prepare_container  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module d0100_prepare_container output.
  perform d0100_prepare_container.
endmodule.                 " d0100_prepare_container  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  d0100_exit  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module d0100_exit input.
  perform d0100_exit.
endmodule.                 " d0100_exit  INPUT
*&---------------------------------------------------------------------*
*&      Module  d0100_fcode  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module d0100_fcode input.
  perform d0100_fcode.
endmodule.                 " d0100_fcode  INPUT
*&---------------------------------------------------------------------*
*&      Form  d0100_set_status
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form d0100_set_status .
  types: begin of l_ty_s_excl,
           func type syucomm,
         end   of l_ty_s_excl,
         l_ty_t_excl type standard table of l_ty_s_excl.
  data: lt_excl type l_ty_t_excl.
  set pf-status 'D0100' excluding lt_excl.
  set titlebar 'D0100'.
endform.                    " d0100_set_status
*&---------------------------------------------------------------------*
*&      Form  d0100_prepare_container
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form d0100_prepare_container .
  data: lt_fcat             type lvc_t_fcat,
        ls_layo             type lvc_s_layo,
        ls_vari             type disvariant,
        ls_prnt             type lvc_s_prnt,
        l_consistency_check type char1.
  gs_test-current_display = con_display_grid.
  if gr_container_d0100 is initial.
    if cl_gui_alv_grid=>offline( ) is initial.
      create object gr_container_d0100
                    exporting container_name = 'D0100_CONTAINER'.
    endif.
    create object gr_grid_d0100
                  exporting i_parent = gr_container_d0100.
    perform d0100_get_outtab.
    perform d0100_set_grid_vari using space changing ls_vari.
    perform d0100_set_grid_layo changing ls_layo.
    perform d0100_set_grid_fcat changing lt_fcat.
    ls_prnt-grpchgedit = con_true.
    call method gr_grid_d0100->set_table_for_first_display
      exporting
        i_buffer_active     = gs_test-buffer_active
        i_bypassing_buffer  = gs_test-bypassing_buffer
        i_consistency_check = l_consistency_check
        is_variant          = ls_vari
        i_save              = gs_test-vari_save
        i_default           = gs_test-vari_default
        is_layout           = ls_layo
        is_print            = ls_prnt
      changing
        it_outtab           = gt_outtab[]
        it_fieldcatalog     = lt_fcat.
    if gs_test-vari_dark ne space.
      perform d0100_set_grid_vari using con_true changing ls_vari.
      call method gr_grid_d0100->save_variant_dark
        exporting
          is_variant = ls_vari.
    endif.
  endif.
endform.                    " d0100_prepare_container
*&---------------------------------------------------------------------*
*&      Form  d0100_exit
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form d0100_exit .
  data: l_okcode like sy-ucomm.
  l_okcode = g_okcode.
  clear g_okcode.
  case l_okcode.
    when con_exit or con_back or con_canc.
      call method gr_grid_d0100->free.
      call method gr_container_d0100->free.
      call method cl_gui_cfw=>flush.
      clear gr_container_d0100.
      clear gr_grid_d0100.
      set screen 0.
      leave screen.
  endcase.
endform.                    " d0100_exit
*&---------------------------------------------------------------------*
*&      Form  d0100_fcode
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form d0100_fcode .
  data: l_okcode    like sy-ucomm,
        ls_selfield type slis_selfield.
  l_okcode = g_okcode.
  clear g_okcode.
  case l_okcode.
    when con_exit or con_back or con_canc.
      g_okcode = l_okcode.
      perform d0100_exit.
    when others.
      perform f01_alv_event_user_command using l_okcode
                                               ls_selfield.
  endcase.
endform.                    " d0100_fcode
*&---------------------------------------------------------------------*
*&      Form  d0100_set_grid_vari
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form d0100_set_grid_vari using i_dark
                         changing cs_vari type disvariant.
  if gs_test-vari_none ne space and i_dark eq space.
    exit.
  endif.
  cs_vari-report      = sy-repid.
  cs_vari-handle      = space.
  cs_vari-log_group   = space.
  cs_vari-username    = space.
  cs_vari-variant     = gs_test-vari_layout.
  cs_vari-text        = space.
  cs_vari-dependvars  = space.
  if i_dark eq con_true.
    cs_vari-variant     = gs_test-vari_dark.
    cs_vari-username    = gs_test-vari_dark_user.
    cs_vari-text        = cs_vari-variant.
  endif.
endform.                    " d0100_set_grid_vari
*&---------------------------------------------------------------------*
*&      Form  d0100_set_grid_layo
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form d0100_set_grid_layo  changing cs_layo type lvc_s_layo.
*... ALV-Control: Allgemeine Anzeigeoptionen
  cs_layo-stylefname  = space.
  cs_layo-graphics    = space.
  cs_layo-frontend    = space.
  cs_layo-template    = space.
*... ALV-Control: Gridcustomizing
  cs_layo-grid_title  = space.
  cs_layo-smalltitle  = space.
  cs_layo-cwidth_opt  = con_true.
  cs_layo-zebra       = space.
  cs_layo-no_colexpd  = space.
  cs_layo-no_hgridln  = space.
  cs_layo-no_vgridln  = space.
  cs_layo-no_rowmark  = space.
  cs_layo-no_headers  = space.
  cs_layo-no_merging  = space.
  cs_layo-no_toolbar  = space.
  cs_layo-sel_mode    = space.
  cs_layo-sgl_clk_hd  = space.
  cs_layo-box_fname   = 'BOX'.
*... ALV-Control: Summenoptionen
  cs_layo-totals_bef  = space.
  cs_layo-no_totline  = space.
  cs_layo-numc_total  = space.
  cs_layo-no_utsplit  = space.
*... ALV-Control: Exceptions
  cs_layo-excp_group  = space.
  cs_layo-excp_fname  = 'LIGHTS'.
  cs_layo-excp_rolln  = space.
  cs_layo-excp_conds  = space.
  cs_layo-excp_led    = space.
*... ALV-Control: Steuerung Interaktion
  cs_layo-detailinit  = space.
  cs_layo-detailtitl  = space.
  cs_layo-keyhot      = space.
  cs_layo-no_keyfix   = space.
  cs_layo-no_author   = gs_test-layo_no_authcheck.
  clear cs_layo-s_dragdrop.
*... ALV-Control: Farben
  cs_layo-info_fname  = space.
  cs_layo-ctab_fname  = space.
*... ALV-Control: Eingabef鋒igkeit
  cs_layo-edit        = space.
  cs_layo-edit_mode   = space.
  cs_layo-no_rowins   = space.
  cs_layo-no_rowmove  = space.
*... ALV-Control: Web-Optionen
  cs_layo-weblook     = space.
  cs_layo-webstyle    = space.
  cs_layo-webrows     = space.
  cs_layo-webxwidth   = space.
  cs_layo-webxheight  = space.
endform.                    " d0100_set_grid_layo
*&---------------------------------------------------------------------*
*&      Form  d0100_set_grid_fcat
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form d0100_set_grid_fcat changing ct_fcat type lvc_t_fcat.
  call function 'LVC_FIELDCATALOG_MERGE'
    exporting
      i_buffer_active        = gs_test-buffer_active
      i_structure_name       = con_sflight
      i_client_never_display = con_true
      i_bypassing_buffer     = gs_test-bypassing_buffer
    changing
      ct_fieldcat            = ct_fcat[]
    exceptions
      inconsistent_interface = 1
      program_error          = 2
      others                 = 3.
  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.                    " d0100_set_grid_fcat
*&---------------------------------------------------------------------*
*&      Form  d0100_get_outtab
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form d0100_get_outtab .
  field-symbols: type g_ty_s_outtab.
  data: l_excp_mod  type i,
        l_excp_div  type i,
        l_excp_amnt type i value 4,
        l_excp      type i.
  if gs_test-select_amount gt 0.
    select * from (con_sflight) into corresponding fields
               of table gt_outtab up to gs_test-select_amount rows.
  endif.
  gs_test-select_amount = sy-dbcnt.
  loop at gt_outtab assigning .
*... Exception
    l_excp_mod = sy-tabix mod l_excp_amnt.
    if l_excp_mod eq 0.
      l_excp_div = 1.
    else.
      l_excp_div = 0.
    endif.
    l_excp = ( l_excp_amnt * l_excp_div ) + l_excp_mod.
    if l_excp_amnt eq 4.
      subtract 1 from l_excp.
    endif.
    -lights = l_excp.
  endloop.
endform.                    " d0100_get_outtab
*&---------------------------------------------------------------------*
*&      Form  f01_f4_variant
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form f01_f4_variant changing c_variant type disvariant-variant.
  data: ls_variant type disvariant,
        l_exit     type char1.
  ls_variant-report = sy-repid.
  call function 'REUSE_ALV_VARIANT_F4'
       exporting
            is_variant          = ls_variant
            i_save              = 'A'
*           it_default_fieldcat =
       importing
            e_exit              = l_exit
            es_variant          = ls_variant
       exceptions
            not_found = 2.
  if sy-subrc = 2.
    message id sy-msgid type 'S' number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  else.
    if l_exit eq space.
      c_variant = ls_variant-variant.
    endif.
  endif.
endform.                    " f01_f4_variant
*---------------------------------------------------------------------*
*  FORM f01_alv_event_pf_status_set
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
form f01_alv_event_pf_status_set using rt_extab type slis_t_extab.
                                                            "#EC *
  set pf-status 'STANDARD' excluding rt_extab.
  set titlebar 'D0100'.
endform.                    "f01_alv_event_pf_status_set
*---------------------------------------------------------------------*
*  FORM f01_alv_event_user_command
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
form f01_alv_event_user_command using r_ucomm     like sy-ucomm
                                      rs_selfield type slis_selfield.
                                                            "#EC *
  data: ls_vari      type disvariant,
        ls_slis_layo type slis_layout_alv,
        lt_slis_fcat type slis_t_fieldcat_alv,
        lt_slis_sort type slis_t_sortinfo_alv,
        lt_slis_filt type slis_t_filter_alv,
        ls_slis_prnt type slis_print_alv,
        ls_lvc_layo  type lvc_s_layo,
        lt_lvc_fcat  type lvc_t_fcat,
        lt_lvc_sort  type lvc_t_sort,
        lt_lvc_filt  type lvc_t_filt,
        ls_lvc_prnt  type lvc_s_prnt.
  case r_ucomm.
    when con_dark_on or con_dark_off.
      data: l_active type char1.
      case r_ucomm.
        when con_dark_on.
          l_active = con_true.
        when con_dark_off.
          l_active = space.
      endcase.
      call method gr_grid_d0100->save_variant_dark
        exporting
          i_active = l_active.
    when others.
  endcase.
  check r_ucomm eq 'LIST' or
        r_ucomm eq 'FULLSCREEN' or
        r_ucomm eq 'GRID'.
  case gs_test-current_display.
    when con_display_list or con_display_full.
      case gs_test-current_display.
        when con_display_list.
          call function 'REUSE_ALV_LIST_LAYOUT_INFO_GET'
            importing
              es_layout     = ls_slis_layo
              et_fieldcat   = lt_slis_fcat
              et_sort       = lt_slis_sort
              et_filter     = lt_slis_filt
              es_variant    = ls_vari
            exceptions
              no_infos      = 1
              program_error = 2
              others        = 3.
          if sy-subrc <> 0.
            message id sy-msgid type sy-msgty number sy-msgno
                    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          endif.
        when con_display_full.
          call function 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
            importing
              es_layout     = ls_slis_layo
              et_fieldcat   = lt_slis_fcat
              et_sort       = lt_slis_sort
              et_filter     = lt_slis_filt
              es_variant    = ls_vari
              es_print      = ls_slis_prnt
            exceptions
              no_infos      = 1
              program_error = 2
              others        = 3.
          if sy-subrc <> 0.
            message id sy-msgid type sy-msgty number sy-msgno
                    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          endif.
      endcase.
      call function 'LVC_TRANSFER_FROM_SLIS'
        exporting
          it_fieldcat_alv = lt_slis_fcat
          it_sort_alv     = lt_slis_sort
          it_filter_alv   = lt_slis_filt
          is_layout_alv   = ls_slis_layo
        importing
          et_fieldcat_lvc = lt_lvc_fcat
          et_sort_lvc     = lt_lvc_sort
          et_filter_lvc   = lt_lvc_filt
          es_layout_lvc   = ls_lvc_layo
        tables
          it_data         = gt_outtab
        exceptions
          it_data_missing = 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.
    when con_display_grid.
      set screen 0.
      call method gr_grid_d0100->get_variant
        importing
          es_variant = ls_vari.
      call method gr_grid_d0100->get_frontend_layout
        importing
          es_layout = ls_lvc_layo.
      call method gr_grid_d0100->get_frontend_fieldcatalog
        importing
          et_fieldcatalog = lt_lvc_fcat.
      call method gr_grid_d0100->get_sort_criteria
        importing
          et_sort = lt_lvc_sort.
      call method gr_grid_d0100->get_frontend_print
        importing
          es_print = ls_lvc_prnt.
      call method gr_grid_d0100->get_filter_criteria
        importing
          et_filter = lt_lvc_filt.
      call function 'LVC_TRANSFER_TO_SLIS'
        exporting
          it_fieldcat_lvc         = lt_lvc_fcat
          it_sort_lvc             = lt_lvc_sort
          it_filter_lvc           = lt_lvc_filt
          is_layout_lvc           = ls_lvc_layo
        importing
          et_fieldcat_alv         = lt_slis_fcat
          et_sort_alv             = lt_slis_sort
          et_filter_alv           = lt_slis_filt
          es_layout_alv           = ls_slis_layo
        tables
          it_data                 = gt_outtab
        exceptions
          it_data_missing         = 1
          it_fieldcat_lvc_missing = 2
          others                  = 3.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
  endcase.
  case r_ucomm.
    when 'LIST'.
      gs_test-current_display = con_display_list.
      call function 'REUSE_ALV_LIST_DISPLAY'
        exporting
          i_bypassing_buffer       = gs_test-bypassing_buffer
          i_buffer_active          = gs_test-buffer_active
          i_callback_program       = g_repid
          i_callback_pf_status_set = 'F01_ALV_EVENT_PF_STATUS_SET'
          i_callback_user_command  = 'F01_ALV_EVENT_USER_COMMAND'
          is_layout                = ls_slis_layo
          it_fieldcat              = lt_slis_fcat
          it_sort                  = lt_slis_sort
          it_filter                = lt_slis_filt
          i_default                = gs_test-vari_default
          i_save                   = gs_test-vari_save
          is_variant               = ls_vari
          is_print                 = ls_slis_prnt
        tables
          t_outtab                 = gt_outtab
        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.
    when 'FULLSCREEN'.
      gs_test-current_display = con_display_full.
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_bypassing_buffer       = gs_test-bypassing_buffer
          i_buffer_active          = gs_test-buffer_active
          i_callback_program       = g_repid
          i_callback_pf_status_set = 'F01_ALV_EVENT_PF_STATUS_SET'
          i_callback_user_command  = 'F01_ALV_EVENT_USER_COMMAND'
          is_layout                = ls_slis_layo
          it_fieldcat              = lt_slis_fcat
          it_sort                  = lt_slis_sort
          it_filter                = lt_slis_filt
          i_default                = gs_test-vari_default
          i_save                   = gs_test-vari_save
          is_variant               = ls_vari
          is_print                 = ls_slis_prnt
        tables
          t_outtab                 = gt_outtab
        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.
    when 'GRID'.
      gs_test-current_display = con_display_grid.
      if gr_container_d0100 is initial.
        create object gr_container_d0100
                      exporting container_name = 'D0100_CONTAINER'.
        create object gr_grid_d0100
                      exporting i_parent = gr_container_d0100.
      endif.
      call method gr_grid_d0100->set_table_for_first_display
        exporting
          i_buffer_active    = gs_test-buffer_active
          i_bypassing_buffer = gs_test-bypassing_buffer
          is_variant         = ls_vari
          i_save             = gs_test-vari_save
          i_default          = gs_test-vari_default
          is_layout          = ls_lvc_layo
          is_print           = ls_lvc_prnt
        changing
          it_outtab          = gt_outtab[]
          it_fieldcatalog    = lt_lvc_fcat
          it_sort            = lt_lvc_sort
          it_filter          = lt_lvc_filt.
      call screen 100.
  endcase.
  rs_selfield-exit = con_true.
endform.                    "f01_alv_event_user_command
阅读(3766) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-06-04 13:58:53

BCALV_TEST_GRID_PRINT