abap--一个简单类浏览器的代码(等有空继续完善)

REPORT ZBrowse_Class_tool.

type-pools:
    SEOO,
    SEOR,
    slis,
    SEOS.
tables:
    sscrfields.
types: begin of t_attr,
     CLSNAME type SEOCLSNAME,
     CMPNAME type SEOCMPNAME,
     DESCRIPT type SEODESCR,
*Private,Protected,Public
     EXPOSURE type SEOEXPOSE,
     SEOEXPOF1I type SEOEXPOF1I,
*Instance Attribute,Static Attribute,Constant
     ATTDECLTYP type SEOATTDECL,
     SEOATTDF1I type SEOATTDF1I,
*ReadOnly
     ATTRDONLY type SEORDONLY,
*Attribute reference (LIKE),Type reference (TYPE),Object (TYPE),Object reference (TYPE REF TO),See coding
     TYPTYPE type SEOTYPTYPE,
     SEOTYPTF1I type SEOTYPTF1I,
*Initial value
     ATTVALUE type SEOVALUE,
     level   type i,
     lights type i,
     color(4)  type c,
     tabcolor  type slis_t_specialcol_alv,
   end of t_attr.

types: begin of t_meth,
     CLSNAME type SEOCLSNAME,
     CMPNAME type SEOCMPNAME,
     DESCRIPT type SEODESCR,
*Private,Protected,Public
     EXPOSURE type SEOEXPOSE,
     SEOEXPOF1I type SEOEXPOF1I,
*Instance,Static
     MTDDECLTYP type SEOMTDDECL,
     SEOATTDF1I type SEOATTDF1I,
     level   type i,
     lights type i,
     color(4)  type c,
     tabcolor  type slis_t_specialcol_alv,
   end of t_meth.

types: begin of t_event,
     CLSNAME type SEOCLSNAME,
     CMPNAME type SEOCMPNAME,
     DESCRIPT type SEODESCR,
*Private,Protected,Public
     EXPOSURE type SEOEXPOSE,
     SEOEXPOF1I type SEOEXPOF1I,
*Instance,Static
     EVTDECLTYP type SEOEVTDECL,
     SEOEVTDF1I type SEOEVTDF1I,
     level   type i,
     lights type i,
     color(4)  type c,
     tabcolor  type slis_t_specialcol_alv,
   end of t_event.

data: gt_classkey type seoclskey.
data: NOT_ACTIVE TYPE  SEOX_BOOLEAN.
field-symbols: <gt_outtab> type standard table.
data: i_gettype type i value 1.
data: gt_field   type slis_t_fieldcat_alv,
      gt_sort       type slis_t_sortinfo_alv.
data  gt_layout type slis_layout_alv.
data:
   g_wa_attr type t_attr,
   gt_attr type standard table of t_attr,
   g_wa_event type t_event,
   gt_event type standard table of t_event,
   g_wa_meth type t_meth,
   gt_meth type standard table of t_meth.

parameters p_CLS like  SEOCLASS-CLSNAME obligatory default 'CL_GUI_ALV_GRID'.

SELECTION-SCREEN: FUNCTION KEY 1,
                  FUNCTION KEY 2,
                  FUNCTION KEY 3.

load-of-program.
  sscrfields-functxt_01 = 'Methods'.
  sscrfields-functxt_02 = 'Attributes'.
  sscrfields-functxt_03 = 'Events'.

INITIALIZATION.

AT SELECTION-SCREEN OUTPUT.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_CLS.
  gt_classkey-clsname =  p_CLS.
  call function 'F4_DD_ALLTYPES'
    EXPORTING
      object               = gt_classkey-clsname
      suppress_selection   = 'X'
      display_only         = ' '
      only_types_for_clifs = 'X'
    IMPORTING
      result               = p_CLS.

AT SELECTION-SCREEN.
* check class existence
  gt_classkey-CLSNAME = p_CLS.
  call function 'SEO_CLASS_EXISTENCE_CHECK'
    EXPORTING
      clskey        = gt_classkey
    IMPORTING
      not_active    = not_active
    EXCEPTIONS
      not_specified = 1
      not_existing  = 2
      is_interface  = 3
      no_text       = 4
      inconsistent  = 5
      others        = 6.
  if sy-subrc ne 0.
    message 'The % is not existent.' TYPE 'E'.
  endif.
  CASE sscrfields-ucomm.
    WHEN 'FC01'.
*trigge  start-of-SELECTION event
      sscrfields-ucomm = 'ONLI'.
      i_gettype = 1.
    WHEN 'FC02'.
*trigge  start-of-SELECTION event
      sscrfields-ucomm = 'ONLI'.
      i_gettype = 2.
    WHEN 'FC03'.
*trigge  start-of-SELECTION event
      sscrfields-ucomm = 'ONLI'.
      i_gettype = 3.
    when others.
      i_gettype = 2.
  ENDCASE.

start-of-SELECTION.
  case i_gettype.
    when 1.
      perform get_meth.
    when 2.
      perform get_att.
    when 3.
      perform get_event.
  endcase.

END-OF-SELECTION.
  call function 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program      = sy-repid
      i_callback_user_command = 'USER_COMMAND'
      it_fieldcat             = gt_field[]
      is_layout               = gt_layout
      it_sort                 = gt_sort[]
    TABLES
      t_outtab                = <gt_outtab>.

*&---------------------------------------------------------------------*
*&      Form  user_command
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
form user_command using r_ucomm like sy-ucomm
                  rs_selfield type slis_selfield.
  data:
    bdcdata_wa  type bdcdata,
    bdcdata_tab type standard table of bdcdata with default key.

  case r_ucomm.
    when '&IC1'.                       "doubleclick
      clear bdcdata_wa.
      bdcdata_wa-program  = 'SAPLSEOD'.
      bdcdata_wa-dynpro   = '1000'.
      bdcdata_wa-dynbegin = 'X'.
      append bdcdata_wa to bdcdata_tab.

      clear bdcdata_wa.
      bdcdata_wa-fnam = 'BDC_CURSOR'.
      bdcdata_wa-fval = 'SEOCLASS-CLSNAME'.
      append bdcdata_wa to bdcdata_tab.

      clear bdcdata_wa.
      bdcdata_wa-fnam = 'BDC_OKCODE'.
      bdcdata_wa-fval = '=CIDI'.
      append bdcdata_wa to bdcdata_tab.

      clear bdcdata_wa.
      bdcdata_wa-fnam = 'SEOCLASS-CLSNAME'.
      bdcdata_wa-fval = p_cls.
      append bdcdata_wa to bdcdata_tab.
      call transaction 'SE24' using bdcdata_tab mode 'E'.
      clear r_ucomm.
  endcase.
endform.                    "USER_COMMAND

*&---------------------------------------------------------------------*
*&      Form  get_attfield
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_att .
  data: classkey type seoclskey,
        superclskey type seoclsref,
        constructor_exists_in_class type seox_boolean,
        rede       type seor_redefinitions_r,
        it_rede    type seor_redefinitions_r,
        wa_redes   type seoredef,
        it_atts    type seoo_attributes_r,
        atts       type seoo_attributes_r,
        i_level    type i.
  i_level = 0.
  call function 'SEO_CLASS_TYPEINFO_GET'
    EXPORTING
      clskey        = gt_classkey
      version       = '1'
      state         = seoc_state_model_and_impl
    IMPORTING
      attributes    = it_atts
      REDEFINITIONS = it_rede
    EXCEPTIONS
      not_existing  = 1
      is_interface  = 2
      others        = 3.
  if sy-subrc = 0.
    perform addattr using it_atts it_rede i_level.
    classkey  = gt_classkey.
    do.
      clear superclskey.
      call function 'SEO_CLASS_GET'
        EXPORTING
          clskey        = classkey
          version       = '1'
          state         = seoc_state_model_and_impl
        IMPORTING
          superclass    = superclskey
        EXCEPTIONS
          error_message = 1
          others        = 1.
      if sy-subrc = 1 or superclskey is initial.
        exit.
      endif.
      classkey  = superclskey.
      i_level = i_level + 1.
      refresh: atts.
      call function 'SEO_CLASS_TYPEINFO_GET'
        EXPORTING
          clskey        = classkey
          version       = '1'
          state         = seoc_state_model_and_impl
        IMPORTING
          attributes    = atts
          REDEFINITIONS = rede.
      delete atts where exposure = seoc_exposure_private.
      loop at it_rede into wa_redes.
        delete atts where CMPNAME = wa_redes-mtdname.
      endloop.
      perform addattr using atts rede i_level.
      it_rede[] = rede[].
    enddo.
    perform sub_field_des_d using   '' '' 'LEVEL'       '' '' ''  '' '' 'Class Level'  '2' '' 'X' '' gt_field[].
    perform sub_field_des_d using   '' '' 'SEOEXPOF1I'       '' 'X' 'X' '' '' 'Visiblity'  '10' '' '' '' gt_field[].
    perform sub_field_des_d using   '' '' 'CMPNAME'       '' 'X' 'X' '' '' 'Attribute name'  '30' '' '' '' gt_field[].
    perform sub_field_des_d using   '' '' 'CLSNAME'       '' '' '' '' '' 'Class name'  '30' '' '' '' gt_field[].
    perform sub_field_des_d using   '' '' 'DESCRIPT'       '' '' '' '' '' 'Description'  '60' '' '' '' gt_field[].
    perform sub_field_des_d using   '' '' 'SEOATTDF1I'       '' '' ''  '' '' 'Attribute Level'  '15' '' '' '' gt_field[].
    perform sub_field_des_d using   '' '' 'ATTRDONLY'       '' '' '' '' '' 'ReadOnly'  '1' '' '' '' gt_field[].
    perform sub_field_des_d using   '' '' 'SEOTYPTF1I'       '' '' '' '' '' 'Typing'  '10' '' '' '' gt_field[].
    perform sub_field_des_d using   '' '' 'ATTVALUE'       '' '' '' '' '' 'Initial Value'  '20' '' '' '' gt_field[].
    gt_layout-lights_fieldname  = 'LIGHTS'.
    gt_layout-info_fieldname = 'COLOR'.
    refresh gt_sort.
    clear gt_sort.
    perform sub_field_sort using:
       'SEOEXPOF1I' '' '1' '' 'X' gt_sort[],
       'LEVEL' '' '2' 'X' '' gt_sort[],
       'CMPNAME' '' '3' 'X' '' gt_sort[],
       'CLSNAME' '' '4' 'X' '' gt_sort[].
  endif.
  assign gt_attr to <gt_outtab>.
ENDFORM.                    " get_attfield
*&---------------------------------------------------------------------*
*&      Form  addattr
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_IT_ATTRS[]  text
*      -->P_I_LEVEL  text
*----------------------------------------------------------------------*
FORM addattr  USING  P_IT_ATTRS  type  seoo_attributes_r
                     p_rede      type  seor_redefinitions_r
                     P_LEVEL     type  i.
  data:  wa_atts    type seoo_attribute_r.
  loop at   P_IT_ATTRS into wa_atts.
    move-corresponding wa_atts to g_wa_attr.
    g_wa_attr-level = P_LEVEL.
*Private,Protected,Public
    case g_wa_attr-EXPOSURE.
      when 0.
        g_wa_attr-SEOEXPOF1I = 'Private'.
        g_wa_attr-lights = 1.
      when 1.
        g_wa_attr-SEOEXPOF1I = 'Protected'.
        g_wa_attr-lights = 2.
      when 2.
        g_wa_attr-SEOEXPOF1I = 'Public'.
        g_wa_attr-lights = 3.
    endcase.
*Instance Attribute,Static Attribute,Constant
    case g_wa_attr-ATTDECLTYP.
      when 0.
        g_wa_attr-SEOATTDF1I = 'Instance'.
        g_wa_attr-color      = ''.
      when 1.
        g_wa_attr-SEOATTDF1I = 'Static'.
        g_wa_attr-color      = 'C510'.
      when 2.
        g_wa_attr-SEOATTDF1I = 'Constant'.
        g_wa_attr-color      = 'C510'.
        continue."Do not display constant attributes
    endcase.
*Attribute reference (LIKE),Type reference (TYPE),Object (TYPE),Object reference (TYPE REF TO),See coding
*     TYPTYPE type SEOTYPTYPE,
*     SEOTYPTF1I type SEOTYPTF1I,
*      case g_wa_attr-TYPTYPE.
*        when 0.
*          g_wa_attr-SEOTYPTF1I = 'Like'.
*          g_wa_attr-color      = ''.
*        when 1.
*          g_wa_attr-SEOTYPTF1I = 'Type'.
*          g_wa_attr-color      = 'C510'.
*        when 2.
*          g_wa_attr-SEOTYPTF1I = 'Type'.
*        when 3.
*          g_wa_attr-SEOTYPTF1I = 'Type Ref To'.
*      endcase.
    append g_wa_attr to gt_attr.
  endloop.
ENDFORM.                    " addattr
*&---------------------------------------------------------------------*
*&      Form  get_meth
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_meth .
  data: classkey type seoclskey,
        superclskey type seoclsref,
        constructor_exists_in_class type seox_boolean,
        rede       type seor_redefinitions_r,
        it_rede    type seor_redefinitions_r,
        wa_redes   type seoredef,
        it_meth type  seoo_methods_r,
        meth type  seoo_methods_r,
        i_level    type i.
  i_level = 0.
  call function 'SEO_CLASS_TYPEINFO_GET'
    EXPORTING
      clskey        = gt_classkey
      version       = '1'
      state         = seoc_state_model_and_impl
    IMPORTING
      METHODS       = it_meth
      REDEFINITIONS = it_rede
    EXCEPTIONS
      not_existing  = 1
      is_interface  = 2
      others        = 3.
  if sy-subrc = 0.
    perform addmeth using it_meth it_rede i_level.
    classkey  = gt_classkey.
    do.
      clear superclskey.
      call function 'SEO_CLASS_GET'
        EXPORTING
          clskey        = classkey
          version       = '1'
          state         = seoc_state_model_and_impl
        IMPORTING
          superclass    = superclskey
        EXCEPTIONS
          error_message = 1
          others        = 1.
      if sy-subrc = 1 or superclskey is initial.
        exit.
      endif.
      classkey  = superclskey.
      i_level   = i_level + 1.
      refresh:  meth.
      call function 'SEO_CLASS_TYPEINFO_GET'
        EXPORTING
          clskey        = classkey
          version       = '1'
          state         = seoc_state_model_and_impl
        IMPORTING
          METHODS       = meth
          REDEFINITIONS = rede.
      delete meth where exposure = seoc_exposure_private.
      loop at it_rede into wa_redes.
        delete meth where CMPNAME = wa_redes-mtdname.
      endloop.
      perform addmeth using meth rede i_level.
      it_rede[] = rede[].
    enddo.
    perform sub_field_des_d using   '' '' 'LEVEL'       '' '' ''  '' '' 'Class Level'  '2' '' 'X' '' gt_field[].
    perform sub_field_des_d using   '' '' 'SEOEXPOF1I'       '' 'X' 'X' '' '' 'Visiblity'  '10' '' '' '' gt_field[].
    perform sub_field_des_d using   '' '' 'CMPNAME'       '' 'X' 'X' '' '' 'Method name'  '30' '' '' '' gt_field[].
    perform sub_field_des_d using   '' '' 'CLSNAME'       '' '' '' '' '' 'Class name'  '30' '' '' '' gt_field[].
    perform sub_field_des_d using   '' '' 'DESCRIPT'       '' '' '' '' '' 'Description'  '60' '' '' '' gt_field[].
    perform sub_field_des_d using   '' '' 'SEOATTDF1I'       '' '' ''  '' '' 'Method Level'  '15' '' '' '' gt_field[].
    gt_layout-lights_fieldname  = 'LIGHTS'.
    gt_layout-info_fieldname = 'COLOR'.
    refresh gt_sort.
    clear gt_sort.
    perform sub_field_sort using:
       'SEOEXPOF1I' '' '1' '' 'X' gt_sort[],
       'LEVEL' '' '2' 'X' '' gt_sort[],
       'CMPNAME' '' '3' 'X' '' gt_sort[],
       'CLSNAME' '' '4' 'X' '' gt_sort[].
  endif.
  assign gt_meth to <gt_outtab>.
ENDFORM.                    " get_meth
*&---------------------------------------------------------------------*
*&      Form  addattr
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_IT_ATTRS[]  text
*      -->P_I_LEVEL  text
*----------------------------------------------------------------------*
FORM addmeth  USING  P_IT_meth  type  seoo_methods_r
                     p_rede      type  seor_redefinitions_r
                     P_LEVEL     type  i.
  data   wa_meth type seoo_method_r.
  loop at P_IT_meth into wa_meth.
    move-corresponding wa_meth to g_wa_meth.
    g_wa_meth-level = P_LEVEL.
*Private,Protected,Public
    case g_wa_meth-EXPOSURE.
      when 0.
        g_wa_meth-SEOEXPOF1I = 'Private'.
        g_wa_meth-lights = 1.
      when 1.
        g_wa_meth-SEOEXPOF1I = 'Protected'.
        g_wa_meth-lights = 2.
      when 2.
        g_wa_meth-SEOEXPOF1I = 'Public'.
        g_wa_meth-lights = 3.
    endcase.
*Instance Attribute,Static Attribute,Constant
    case g_wa_meth-MTDDECLTYP.
      when 0.
        g_wa_meth-SEOATTDF1I = 'Instance'.
        g_wa_meth-color      = ''.
      when 1.
        g_wa_meth-SEOATTDF1I = 'Static'.
        g_wa_meth-color      = 'C510'.
      when 2.
        g_wa_meth-SEOATTDF1I = 'Constant'.
        g_wa_meth-color      = 'C510'.
        continue."Do not display constant attributes
    endcase.
    append g_wa_meth to gt_meth.
  endloop.
ENDFORM.                    " addmeth
*&---------------------------------------------------------------------*
*&      Form  get_meth
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_event .
  data: classkey type seoclskey,
        superclskey type seoclsref,
        constructor_exists_in_class type seox_boolean,
        rede       type seor_redefinitions_r,
        it_rede    type seor_redefinitions_r,
        wa_redes   type seoredef,
        it_event   type  seoo_events_r,
        event      type  seoo_events_r,
        i_level    type i.
  i_level = 0.
  call function 'SEO_CLASS_TYPEINFO_GET'
    EXPORTING
      clskey        = gt_classkey
      version       = '1'
      state         = seoc_state_model_and_impl
    IMPORTING
      EVENTS        = it_event
      REDEFINITIONS = it_rede
    EXCEPTIONS
      not_existing  = 1
      is_interface  = 2
      others        = 3.
  if sy-subrc = 0.
    perform addevent using it_event it_rede i_level.
    classkey  = gt_classkey.
    do.
      clear superclskey.
      call function 'SEO_CLASS_GET'
        EXPORTING
          clskey        = classkey
          version       = '1'
          state         = seoc_state_model_and_impl
        IMPORTING
          superclass    = superclskey
        EXCEPTIONS
          error_message = 1
          others        = 1.
      if sy-subrc = 1 or superclskey is initial.
        exit.
      endif.
      classkey  = superclskey.
      i_level   = i_level + 1.
      refresh:  event.
      call function 'SEO_CLASS_TYPEINFO_GET'
        EXPORTING
          clskey        = classkey
          version       = '1'
          state         = seoc_state_model_and_impl
        IMPORTING
          eventS        = event
          REDEFINITIONS = rede.
      delete event where exposure = seoc_exposure_private.
      loop at it_rede into wa_redes.
        delete event where CMPNAME = wa_redes-mtdname.
      endloop.
      perform addevent using event rede i_level.
      it_rede[] = rede[].
    enddo.
    perform sub_field_des_d using   '' '' 'LEVEL'       '' '' ''  '' '' 'Class Level'  '2' '' 'X' '' gt_field[].
    perform sub_field_des_d using   '' '' 'SEOEXPOF1I'       '' 'X' 'X' '' '' 'Visiblity'  '10' '' '' '' gt_field[].
    perform sub_field_des_d using   '' '' 'CMPNAME'       '' 'X' 'X' '' '' 'Event name'  '30' '' '' '' gt_field[].
    perform sub_field_des_d using   '' '' 'CLSNAME'       '' '' '' '' '' 'Class name'  '30' '' '' '' gt_field[].
    perform sub_field_des_d using   '' '' 'DESCRIPT'       '' '' '' '' '' 'Description'  '60' '' '' '' gt_field[].
    perform sub_field_des_d using   '' '' 'SEOEVTDF1I'       '' '' ''  '' '' 'Event Level'  '15' '' '' '' gt_field[].
    gt_layout-lights_fieldname  = 'LIGHTS'.
    gt_layout-info_fieldname = 'COLOR'.
    refresh gt_sort.
    clear gt_sort.
    perform sub_field_sort using:
       'SEOEXPOF1I' '' '1' '' 'X' gt_sort[],
       'LEVEL' '' '2' 'X' '' gt_sort[],
       'CMPNAME' '' '3' 'X' '' gt_sort[],
       'CLSNAME' '' '4' 'X' '' gt_sort[].
  endif.
  assign gt_event to <gt_outtab>.
ENDFORM.                    " get_event
*&---------------------------------------------------------------------*
*&      Form  addattr
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_IT_ATTRS[]  text
*      -->P_I_LEVEL  text
*----------------------------------------------------------------------*
FORM addevent  USING  P_IT_event  type  seoo_events_r
                     p_rede      type  seor_redefinitions_r
                     P_LEVEL     type  i.
  data   wa_event type seoo_event_r.
  loop at P_IT_event into wa_event.
    move-corresponding wa_event to g_wa_event.
    g_wa_event-level = P_LEVEL.
*Private,Protected,Public
    case g_wa_event-EXPOSURE.
      when 0.
        g_wa_event-SEOEXPOF1I = 'Private'.
        g_wa_event-lights = 1.
      when 1.
        g_wa_event-SEOEXPOF1I = 'Protected'.
        g_wa_event-lights = 2.
      when 2.
        g_wa_event-SEOEXPOF1I = 'Public'.
        g_wa_event-lights = 3.
    endcase.
*Instance Attribute,Static Attribute,Constant
    case g_wa_event-EVTDECLTYP.
      when 0.
        g_wa_event-SEOEVTDF1I = 'Instance'.
        g_wa_event-color      = ''.
      when 1.
        g_wa_event-SEOEVTDF1I = 'Static'.
        g_wa_event-color      = 'C510'.
      when 2.
        g_wa_event-SEOEVTDF1I = 'Constant'.
        g_wa_event-color      = 'C510'.
        continue."Do not display constant attributes
    endcase.
    append g_wa_event to gt_event.
  endloop.
ENDFORM.                    " addevent
*----------------------------------------------------------------------*
* Form         : SUB_FIELD_DES_D
*----------------------------------------------------------------------*
*      Description:  Set the fields which will be displayed
*----------------------------------------------------------------------*
*      im_ref_FIELD---must upper case                                 *
*      im_ref_TABLE---internal table name                             *
*      im_FIELDname---must upper case                                 *
*      im_TABname  ---internal table name                             *
*      im_KEY      ---column with key-color AND frozen                *
*      im_CHECKBOX ---the column is checkbox                          *
*      im_dosum    ---total,if total, the field must be sumed         *
*      im_SELTEX_L ---column Long description of title                *
*      im_outputlen---column output length
*      IM_dec--?????
*      re_field : ????????
*----------------------------------------------------------------------*
* Modification Log:                                                    *
* Date        Programmer     Correction Number                         *
*----------------------------------------------------------------------*
form sub_field_des_d using im_ref_field type c
                         im_ref_table type c
                         im_fieldname type c
                         im_tabname type c
                         im_key type c
                         im_fix type c
                         im_checkbox type c
                         im_dosum type c
                         im_seltex_l type c
                         im_outputlen type i
                         im_zero type c
                         im_out  type c
                         im_dec  type c
                         re_field type slis_t_fieldcat_alv.
  data: wa_fieldcat type slis_fieldcat_alv.
  clear wa_fieldcat.
  wa_fieldcat-ref_fieldname = im_ref_field.
  wa_fieldcat-ref_tabname = im_ref_table.
  wa_fieldcat-fieldname = im_fieldname.
  wa_fieldcat-tabname   = im_tabname.
  wa_fieldcat-key       = im_key.
  wa_fieldcat-fix_column = IM_fix.
  wa_fieldcat-checkbox  = im_checkbox.
  wa_fieldcat-do_sum     = im_dosum.
  wa_fieldcat-no_zero     = im_zero.
  wa_fieldcat-no_out     = im_out.
  wa_fieldcat-seltext_l = im_seltex_l.
  wa_fieldcat-seltext_m = im_seltex_l.
  wa_fieldcat-seltext_s = im_seltex_l.
  wa_fieldcat-outputlen = im_outputlen.
  wa_fieldcat-decimals_out = im_dec.
*  wa_fieldcat-col_pos   = IM_colpos.
  append wa_fieldcat to re_field.
endform.                    "SUB_FIELD_DES

*&---------------------------------------------------------------------*
*&      Form  sub_field_sort
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->IM_FIELDNAME  text
*      -->IM_TABNAME    text
*      -->IM_SPOS       text
*      -->IM_UP         text
*      -->IM_SUBTOT     text
*      -->RE_SORT       text
*----------------------------------------------------------------------*
form sub_field_sort using im_fieldname type c
                          im_tabname type c
                          im_spos type i
                          im_up type c
                          im_subtot type c
                          re_sort type slis_t_sortinfo_alv.
  data: wa_sort     type slis_sortinfo_alv.
  clear wa_sort .
  wa_sort-fieldname = im_fieldname.  "The field will be sorted
  wa_sort-tabname   = im_tabname.    "internal table name
  wa_sort-spos      = im_spos.       "Sort sequence
  wa_sort-up        = im_up.         "Ascending,down-Descending
  wa_sort-subtot    = im_subtot.
  append wa_sort to re_sort.
endform.                    "SUB_FIELD_SORT 

posted on 2007-12-14 11:57  毛小娃  阅读(162)  评论(0编辑  收藏  举报

导航