head item alv LIST

*&---------------------------------------------------------------------*
*& Report  BCALV_TEST_HIERSEQ_LIST                                     *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*
report  bcalv_test_hierseq_list.

types: g_ty_t_carrid  type standard table of alv_tab,
       g_ty_t_connid  type standard table of alv_chck,
       g_ty_t_curr    type standard table of alv_cur,
       g_ty_s_sflight type alv_t_t2,
       g_ty_s_carrid  type alv_tab,
*>>keyinfo external sort
       begin of g_ty_s_connid.
         include type alv_chck.
         types: carrid_master type g_ty_s_sflight-carrid,
       end of g_ty_s_connid,
*<<keyinfo external sort
       g_ty_s_curr    type alv_cur.

constants: con_sflight type lvc_fname value 'ALV_T_T2',
           con_scarr   type lvc_fname value 'ALV_TAB',
           con_spfli   type lvc_fname value 'ALV_CHCK',
           con_scurx   type lvc_fname value 'ALV_CUR'.

*----------------------------------------------------------------------*
* DATA                                                                 *
*----------------------------------------------------------------------*
tables: sscrfields.   " for processing the FCODEs in Selektion screens

include <icon>.
include <symbol>.

type-pools: slis.

class lcl_events_d1001 definition deferred.

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_plane,
         carrid    type g_ty_s_sflight-carrid,
         connid    type g_ty_s_sflight-connid,
         planetype type g_ty_s_sflight-planetype,
         seatsmax  type g_ty_s_sflight-seatsmax,
       end   of g_ty_s_plane,
       g_ty_t_plane type sorted table of g_ty_s_plane
                         with unique key carrid connid,

       begin of g_ty_s_fcat_curr,
         fieldname  type lvc_fname,
         table      type lvc_fname,
         cfieldname type lvc_fname,
         currency   type lvc_s_fcat-currency,
       end   of g_ty_s_fcat_curr,
       g_ty_t_fcat_curr type sorted table of g_ty_s_fcat_curr
                             with unique key fieldname,

       begin of g_ty_s_fname,
         field type lvc_fname,
         table type lvc_fname,
       end   of g_ty_s_fname,
       g_ty_t_fname type standard table of g_ty_s_fname,

       begin of g_ty_s_sort.
include type slis_sortinfo_alv.
types:   handle_drdn  type lvc_s_drop-handle,
       end   of g_ty_s_sort,
       g_ty_t_sort type sorted table of g_ty_s_sort
                        with unique key spos fieldname,

       begin of g_ty_s_tests,
         select_amount_master     type i,
         select_amount_slave      type i,
         only_db_info             type char1,
         db_short                 type char1,
         excp_display             type char1,
         excp_condense            type char1,
         layo_title               type lvc_s_layo-grid_title,
         layo_zebra               type char1,
         layo_no_vert_lines       type char1,
         layo_no_horiz_lines      type char1,
         layo_cell_merge          type char1,
         layo_count               type char1,
         layo_box                 type char1,
         layo_no_colhead          type char1,
         layo_column_optimize     type char1,
         layo_keys_hotspot        type char1,
         layo_no_keyfix           type char1,
         layo_no_hotspot          type char1,
         layo_hotspot_rows        type i occurs 0,
         layo_hotspot_columns     type g_ty_s_fname occurs 0,
         layo_no_scrolling        type char1,
         layo_no_authcheck        type char1,
         layo_no_min_linesize     type char1,
         layo_min_linesize        type sylinsz,
         layo_max_linesize        type sylinsz,
         layo_group_change_edit   type char1,
         layo_get_selinfo         type char1,
         layo_confirmation_prompt type char1,
         layo_f2code              type syucomm,
         layo_reprep              type char1,
         layo_expand_field        type char1,
         layo_expand_all          type char1,
         sum_before               type char1,
         sum_no_sumline           type char1,
         sum_no_sumchoice         type char1,
         sum_numc                 type char1,
         sum_no_unitsplit         type char1,
         sum_totals_only          type char1,
         sum_totals_text          type symsgli,
         sum_no_subtotals         type char1,
         sum_no_subchoice         type char1,
         sum_subtotals_text       type symsgli,
         vari_none                type char1,
         vari_save                type char1,
         vari_default             type char1,
         vari_layout              type disvariant-variant,
         prnt_print               type char1,
         prnt_reserve_lines       type lvc_s_prnt-reservelns,
         prnt_no_listinfo         type char1,
         prnt_no_selinfo          type char1,
         prnt_with_title          type char1,
         prnt_footline            type lvc_s_prnt-footline,
         prnt_printinfo           type char1,
         prnt_no_coverpage        type char1,
         prnt_no_new_page         type char1,
         prnt_no_change_print_params type char1,
         prnt_no_hierseq_item     type char1,
         color_rows               type i occurs 0,
         color_fields_column      type g_ty_s_fname occurs 0,
         color_fields_cell        type g_ty_s_fname occurs 0,
         fcat_no_out_fields       type g_ty_s_fname occurs 0,
         fcat_tech_fields         type g_ty_s_fname occurs 0,
         fcat_fix_column_fields   type g_ty_s_fname occurs 0,
         fcat_do_sum_fields       type g_ty_s_fname occurs 0,
         fcat_no_sum_fields       type g_ty_s_fname occurs 0,
         fcat_curr_fields         type g_ty_t_fcat_curr,
         curr_amount              type i,
         curr_space               type char1,
         t_sort                   type g_ty_t_sort,
         buffer_active            type char1,
         bypassing_buffer         type char1,
         current_display          type i,
       end   of g_ty_s_tests,

       begin of g_ty_s_master.
include type g_ty_s_connid.
types:   box                  type char1,
         lights               type char1,
         checkbox             type char1,
         hotspot              type char1,
         expand               type char1,
         color(4)             type c,
         tabcolor             type slis_t_specialcol_alv,

         price                type g_ty_s_sflight-price,
         currency             type g_ty_s_sflight-currency,
         price_head           type g_ty_s_sflight-price,
         currency_head        type g_ty_s_sflight-currency,

         char(10)             type c,
         string               type string,
         int1                 type int1,
         int2                 type int2,
         int4                 type i,
         numc(10)             type n,
         dec(10)              type p decimals 2,
         fltp                 type f,
         dats                 type d,
         tims                 type t,
         icon                 type icon-id,
         icon_qinfo           type icon-name,
         symbol               type icon-id,
       end   of g_ty_s_master,
       g_ty_t_master type standard table of g_ty_s_master,

       begin of g_ty_s_slave.
include type g_ty_s_sflight.
types:   box                  type char1,
         lights               type char1,
         checkbox             type char1,
         hotspot              type char1,
         expand               type char1,
         color(4)             type c,
         tabcolor             type slis_t_specialcol_alv,

         price_item           type g_ty_s_sflight-price,
         currency_item        type g_ty_s_sflight-currency,

         char(10)             type c,
         string               type string,
         int1                 type int1,
         int2                 type int2,
         int4                 type i,
         numc(10)             type n,
         dec(10)              type p decimals 2,
         fltp                 type f,
         dats                 type d,
         tims                 type t,
         icon                 type icon-id,
         icon_qinfo           type icon-name,
         symbol               type icon-id,
       end   of g_ty_s_slave,
       g_ty_t_slave type standard table of g_ty_s_slave.

constants: con_true         type char1 value 'X',

           con_ok   type sy-ucomm value 'OK',
           con_exit type sy-ucomm value 'EXIT',
           con_canc type sy-ucomm value 'CANC',
           con_back type sy-ucomm value 'BACK'.

data: gt_master   type g_ty_t_master,
      gt_slave    type g_ty_t_slave,
      gs_test     type g_ty_s_tests.

data: gt_sort type standard table of g_ty_s_sort.

data: g_repid type sy-repid.

data: g_field     type lvc_s_fcat-fieldname,
      g_int_field type i,
      g_dummy     type lvc_s_fcat-fieldname,
      gs_field    type g_ty_s_fname.

data: gr_container_d1001   type ref to cl_gui_custom_container,
      gr_grid_d1001        type ref to cl_gui_alv_grid,
      gr_events_d1001      type ref to lcl_events_d1001.

data: g_okcode type sy-ucomm.

*---------------------------------------------------------------------*
*       CLASS lcl_events_d1001 DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
class lcl_events_d1001 definition.
  public section.
    methods:
    onf4                 for event onf4
                         of cl_gui_alv_grid
                         importing e_fieldname
                                   e_fieldvalue
                                   es_row_no
                                   er_event_data
                                   et_bad_cells
                                   e_display,

    data_changed         for event data_changed
                         of cl_gui_alv_grid
                         importing er_data_changed
                                   e_onf4
                                   e_onf4_before
                                   e_onf4_after,

    data_changed_finished
                         for event data_changed_finished
                         of cl_gui_alv_grid.

endclass.                    "lcl_events_d1001 DEFINITION

*---------------------------------------------------------------------*
*       CLASS lcl_events_d1001 IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
class lcl_events_d1001 implementation.
  method onf4.
    perform d1001_event_onf4 using e_fieldname
                                   e_fieldvalue
                                   es_row_no
                                   er_event_data
                                   et_bad_cells
                                   e_display.
  endmethod.                                                "onf4

  method data_changed.
    perform d1001_event_data_changed using er_data_changed
                                           e_onf4
                                           e_onf4_before
                                           e_onf4_after.
  endmethod.                    "data_changed

  method data_changed_finished.
    perform d1001_event_data_changed_finis.
  endmethod.                    "data_changed_finished
endclass.                    "lcl_events_d1001 IMPLEMENTATION

*---------------------------------------------------------------------*
*       CLASS random DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
class random definition.
  public section.
    types:
      value(16) type p decimals 0,
      numcv(15) type n.
    constants:
      max type random=>value value 4294967295.
    class-methods:
*   computes a random natural number from the set {0, ..., random=>max}.
      number returning value(rval) type random=>value,
*   computes a random character from the set {A-Za-z0-9}
      c returning value(rval) type char01,
*   computes a random string consisting of "len" random characters
      string importing len type i
             returning value(rval) type string,
*   computes a date
      dats returning value(rval) type d,
*   computes a time
      time returning value(rval) type t,
*   computes a random numc from the set {low, ..., high}
      numc importing low type random=>numcv high type random=>numcv
        returning value(rval) type random=>numcv,
*   computes a random integer from the set {low, ..., high}
      i importing low type i high type i
        returning value(rval) type i,
*   computes a random integer from the set {low, ..., high}
      int2 importing low type int2 high type int2
           returning value(rval) type int2,
*   computes a random integer from the set {low, ..., high}
      int1 importing low type int1 high type int1
           returning value(rval) type int1,
*   computes a random float from the interval [low ; high]
      f importing low type f high type f
        returning value(rval) type f,
*   computes a random character from the set {A-F0-9}
      hex returning value(rval) type char01,
*   computes a random character from the set {0-1}
      x returning value(rval) type char01,
*   method "random=>class_constructor"
      class_constructor.

  private section.
    class-data:
*   precomputed maximal index (= string length - 1) of "random=>chars"
*   or of "random=>x_data".
      charsmax type i,
      xmax type i,
*   random number seed value.
*   (Used in method "random=>number".)
      seed type random=>value.

    constants:
*   characters for class-method "random=>hex"
      hex_data(100) type c value 'ABCDEF' &
                                 '0123456789',
*   characters for class-method "random=>x"
      x_data(100) type c value '01',
*   characters for class-metshod "random=>c"
      chars(100) type c value 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' &
                              'abcdefghijklmnopqrstuvwxyz' &
                              '0123456789'.

endclass.                    "random DEFINITION

*---------------------------------------------------------------------*
*       CLASS random IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
class random implementation.
* implementation of the methods for randomizing the values
  method x.
    data: ri type i.
    ri = random=>i( low = 0  high = random=>xmax ).
    move x_data+ri(1) to rval.
  endmethod.                    "x

  method hex.
    data: ri type i.
    ri = random=>i( low = 0  high = random=>charsmax ).
    move hex_data+ri(1) to rval.
  endmethod.                    "hex

  method number.
    constants:
      a(3) type p  value 67301,        " Coefficient
      c(1) type p  value 1,            " Increment
      m(6) type p  value 4294967296.   " Modulus 2**32
    random=>seed = ( a * random=>seed + c ) mod m.
    rval = random=>seed.
  endmethod.                    "number

  method c.
    data:
      ri type i.
    ri = random=>i( low = 0  high = random=>charsmax ).
    move chars+ri(1) to rval.
  endmethod.                    "c

  method string.
    data:
      char(1) type c.
    clear rval.
    do len times.
      char = random=>c( ).
      concatenate rval char into rval.
    enddo.
  endmethod.                    "string

  method dats.
    data: l_date      type sy-datum,
          l_day(2)    type n,
          l_month(2)  type n,
          l_year(4)   type n,
          l_value     type random=>numcv,
          l_low       type random=>numcv,
          l_high      type random=>numcv.

    l_year  = sy-datum+0(4).
    l_low   = l_year - 5.
    l_high  = l_year + 5.
    l_value = random=>numc( low = l_low high = l_high ).
    l_year  = l_value+11(4).

    l_value = random=>numc( low = 1 high = 12 ).
    l_month = l_value+13(2).
    case l_month.
      when 2.
        l_high = 28.
      when 4 or 6 or 9 or 11.
        l_high = 30.
      when others.
        l_high = 31.
    endcase.

    l_value = random=>numc( low = 1 high = l_high ).
    l_day   = l_value+13(2).

    l_date+0(4) = l_year.
    l_date+4(2) = l_month.
    l_date+6(2) = l_day.

    rval = l_date.
  endmethod.                    "dats

  method time.
    data: l_time      type t,
          l_hour(2)   type n,
          l_min(2)    type n,
          l_sec(2)    type n,
          l_value     type random=>numcv.

    l_value = random=>numc( low = 0 high = 60 ).
    l_sec   = l_value+13(2).

    l_value = random=>numc( low = 0 high = 60 ).
    l_min   = l_value+13(2).

    l_value = random=>numc( low = 1 high = 24 ).
    l_hour  = l_value+13(2).

    l_time+0(2) = l_hour.
    l_time+2(2) = l_min.
    l_time+4(2) = l_sec.

    rval = l_time.
  endmethod. "time

  method numc.
*   Go from {0,...,random=>max} to {low,...,high} with ABAP rounding
    data: l_dec(16)   type p,
          l_char(16)  type c.

    l_dec = ( ( high - low + 1 ) * random=>number( ) ) / random=>max
           + '0.5'.
    subtract 1 from l_dec.
    add low to l_dec.

    data: lr_type_descr  type ref to cl_abap_typedescr,
          lr_elem_descr  type ref to cl_abap_elemdescr.

    lr_type_descr =
             cl_abap_typedescr=>describe_by_data( rval ).
    lr_elem_descr ?= lr_type_descr.

    l_char = l_dec.
    shift l_char left deleting leading space.
    rval = l_char+0(lr_elem_descr->output_length).
  endmethod.                    "i

  method i.
*   Go from {0,...,random=>max} to {low,...,high} with ABAP rounding
    data: l_dec(16)   type p,
          l_char(16)  type c.

    l_dec = ( ( high - low + 1 ) * random=>number( ) ) / random=>max
           + '0.5'.
    subtract 1 from l_dec.
    add low to l_dec.

    data: lr_type_descr  type ref to cl_abap_typedescr,
          lr_elem_descr  type ref to cl_abap_elemdescr.

    lr_type_descr =
             cl_abap_typedescr=>describe_by_data( rval ).
    lr_elem_descr ?= lr_type_descr.

    l_char = l_dec.
    shift l_char left deleting leading space.
    rval = l_char+0(lr_elem_descr->output_length).
  endmethod.                    "i

  method int2.
*   Go from {0,...,random=>max} to {low,...,high} with ABAP rounding
    data: l_dec(16)   type p,
          l_char(16)  type c.

    l_dec = ( ( high - low + 1 ) * random=>number( ) ) / random=>max
           + '0.5'.
    subtract 1 from l_dec.
    add low to l_dec.

    data: lr_type_descr  type ref to cl_abap_typedescr,
          lr_elem_descr  type ref to cl_abap_elemdescr.

    lr_type_descr =
             cl_abap_typedescr=>describe_by_data( rval ).
    lr_elem_descr ?= lr_type_descr.

    l_char = l_dec.
    shift l_char left deleting leading space.
    rval = l_char+0(lr_elem_descr->output_length).
  endmethod.                    "i

  method int1.
*   Go from {0,...,random=>max} to {low,...,high} with ABAP rounding
    data: l_dec(16)   type p,
          l_char(16)  type c.

    l_dec = ( ( high - low + 1 ) * random=>number( ) ) / random=>max
           + '0.5'.
    subtract 1 from l_dec.
    add low to l_dec.

    data: lr_type_descr  type ref to cl_abap_typedescr,
          lr_elem_descr  type ref to cl_abap_elemdescr.

    lr_type_descr =
             cl_abap_typedescr=>describe_by_data( rval ).
    lr_elem_descr ?= lr_type_descr.

    l_char = l_dec.
    shift l_char left deleting leading space.
    rval = l_char+0(lr_elem_descr->output_length).
  endmethod.                    "i

  method f.
*   Go from {0,...,random=>max} to [low;high]
    rval = ( ( high - low ) * random=>number( ) ) / random=>max
           + low.
  endmethod.                    "f

  method class_constructor.
    charsmax = strlen( chars ) - 1.
    xmax = strlen( x_data ) - 1.
    seed = 1.
  endmethod.                    "class_constructor

endclass.                    "random IMPLEMENTATION

*----------------------------------------------------------------------*
* SELECTION-SCREEN                                                     *
*----------------------------------------------------------------------*
selection-screen begin of block gen with frame.
parameters:
p_amount type i default 30,
p_amouns type i default 30,
p_dbinfo as checkbox,
p_dbshrt as checkbox.
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üBERGREIF
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 hsq with frame title text-hsq.
parameters:
p_exp01 as checkbox, " EXPAND FIELD
p_exp02 as checkbox. " EXPAND ALL
selection-screen end of block hsq.

selection-screen begin of block tit with frame title text-tit.
parameters:
p_tit01 type lvc_s_layo-grid_title default text-p01. "TITLE
selection-screen end of block tit.

selection-screen begin of block lay with frame title text-lay.
parameters:
p_lay01 as checkbox. "ZEBRA

selection-screen skip.

parameters:
p_lay02 as checkbox, "NO HORIZONTAL LINES
p_lay03 as checkbox. "NO VERTICAL LINES

selection-screen skip.

parameters:
p_lay04 as checkbox. "NO SCROLLING

selection-screen skip.

parameters:
p_lay06 type syucomm,                                       "F2CODE
p_lay07 as checkbox. "CONFIRMATION PROMPT
selection-screen end of block lay.

selection-screen begin of block spa with frame title text-spa.
parameters:
p_spa01 as checkbox, "BOX
p_spa02 as checkbox, "COUNT FELD
p_spa03 as checkbox, "NO COLUMN HEADERS
p_spa04 as checkbox. "COLUMN OPTIMIZE

selection-screen begin of block hot with frame title text-hot.
parameters:
p_hot01 as checkbox. "NO HOTSPOT
parameters:
p_hot02 as checkbox. "Hotspot auf Zeilenebene
select-options:
p_hotf02 for g_int_field no intervals default 1.
parameters:
p_hot03 as checkbox.
select-options:
p_hotf03 for g_field no intervals.
selection-screen end of block hot.

selection-screen begin of block mrg with frame title text-mrg.
parameters:
p_mrg01 radiobutton group mrge, "Default
p_mrg02 radiobutton group mrge, "kein Merge
p_mrg03 radiobutton group mrge. "Merge
selection-screen end of block mrg.

selection-screen begin of block out with frame title text-out.
parameters:
p_out01 as checkbox.
select-options:
p_outf01 for g_field no intervals.
selection-screen end of block out.

selection-screen begin of block tec with frame title text-tec.
parameters:
p_tec01 as checkbox.
select-options:
p_tecf01 for g_field no intervals.
selection-screen end of block tec.

selection-screen begin of block fix with frame title text-fix.
parameters:
p_fix01 as checkbox.
select-options:
p_fixf01 for g_field no intervals.
selection-screen end of block fix.

selection-screen begin of block cur with frame title text-cur.
parameters:
p_curanz type i,
p_curspc as checkbox default space.

selection-screen skip.

select-options:
p_curf00 for g_field no intervals.
parameters:
p_cur01 radiobutton group cur default 'X',
p_curf01 type lvc_s_fcat-fieldname.
parameters:
p_cur02 radiobutton group cur,
p_curf02 type g_ty_s_sflight-currency.
selection-screen end of block cur.

selection-screen begin of block sort with frame title text-srt.
selection-screen pushbutton /1(20) text-pb1 user-command pb01.
selection-screen end   of block sort.
selection-screen end of block spa.

selection-screen begin of block key with frame title text-key.
parameters:
p_key01 as checkbox, "KEYFELDER ALS HOTSPOT
p_key02 as checkbox. "NO KEY FIXIERUNG
selection-screen end of block key.

selection-screen begin of block exp with frame title text-exp.
parameters:
p_excp01 as checkbox, "EXCEPTION
p_excp_c as checkbox. "EXCEPTION CONDENSE
selection-screen end of block exp.

selection-screen begin of block sum with frame title text-sum.
parameters:
p_sum01 as checkbox, "SUM BEFORE
p_sum02 as checkbox, "NUMC
p_sum03 as checkbox, "NO UNITSPLIT
p_sum04 as checkbox, "TOTALS ONLY
p_sum05 as checkbox, "NO SUMCHOICE
p_sum06 as checkbox, "NO SUMLINE
p_sum07 type sy-msgli, "TOTALS TEXT
p_sum08 as checkbox, "NO SUBCHOICE
p_sum09 as checkbox, "NO SUBTOTALS
p_sum10 type sy-msgli. "SUBTOTALS TEXT

selection-screen begin of block dos with frame title text-dos.
parameters:
p_dos01 as checkbox.
select-options:
p_dosf01 for g_field no intervals.
selection-screen end of block dos.

selection-screen begin of block nos with frame title text-nos.
parameters:
p_nos01 as checkbox.
select-options:
p_nosf01 for g_field no intervals.
selection-screen end of block nos.
selection-screen end of block sum.

selection-screen begin of block col with frame title text-col.
parameters:
p_col01 as checkbox.
select-options:
p_colf01 for g_int_field no intervals default 1.
parameters:
p_col02 as checkbox.
select-options:
p_colf02 for g_field no intervals.
parameters:
p_col03 as checkbox.
select-options:
p_colf03 for g_field no intervals.
selection-screen end of block col.

selection-screen begin of block prn with frame title text-prn.
parameters:
p_lpr01 as checkbox default 'X'. "GROUP CHANGE EDIT

selection-screen skip.

parameters:
p_lpr02 as checkbox. "GET SELINFO

selection-screen skip.

parameters:
p_lpr03 as checkbox, "NO MIN LINESIZE
p_lpr04 type sylinsz, "MIN LINESIZE
p_lpr05 type sylinsz. "MAX LINESIZE

selection-screen skip.

parameters:
p_prn01 as checkbox, "PRINT
p_prn02 type lvc_s_prnt-reservelns, "RESERVE LINES
p_prn03 as checkbox, "NO LISTINFO
p_prn04 as checkbox, "NO SELINFO
p_prn05 as checkbox, "TITEL
p_prn06 type lvc_s_prnt-footline, "FOOTLINE
p_prn07 as checkbox, "PRINT INFO
p_prn08 as checkbox, "NO COVERPAGE
p_prn09 as checkbox, "NO NEW PAGE
p_prn10 as checkbox, "NO CHANGE PRINT PARAMS
p_prn11 as checkbox. "no_print_hierseq_item
selection-screen end of block prn.

selection-screen begin of block rep with frame title text-rep.
parameters:
p_rep01 as checkbox. "REPREP
selection-screen end of block rep.

selection-screen begin of block keys with frame title text-inf.
parameters:
p_skey01 as checkbox, "is_keyinfo different keys
p_skey02 as checkbox. "fields only filled in Masterarea
*already implemented FLDATE
selection-screen end of block keys.

*----------------------------------------------------------------------*
* INITIALIZATION                                                       *
*----------------------------------------------------------------------*
initialization.
  perform f01_f4_field using 'SUM' space changing p_dosf01-low
                                                  p_dosf01-high.
  p_dosf01-option = 'EQ'.
  p_dosf01-sign   = 'I'.
  append p_dosf01.

  perform f01_f4_field using 'SUM' space changing p_nosf01-low
                                                  p_nosf01-high.
  p_nosf01-option = 'EQ'.
  p_nosf01-sign   = 'I'.
  append p_nosf01.

  perform f01_f4_field using 'KEY' space changing p_outf01-low
                                                  p_outf01-high.
  p_outf01-option = 'EQ'.
  p_outf01-sign   = 'I'.
  append p_outf01.

  perform f01_f4_field using space space changing p_tecf01-low
                                                  p_tecf01-high.
  p_tecf01-option = 'EQ'.
  p_tecf01-sign   = 'I'.
  append p_tecf01.

  perform f01_f4_field using space space changing p_fixf01-low
                                                  p_fixf01-high.
  p_fixf01-option = 'EQ'.
  p_fixf01-sign   = 'I'.
  append p_fixf01.

  perform f01_f4_field using 'CURR' space changing p_curf00-low
                                                   p_curf00-high.
  p_curf00-option = 'EQ'.
  p_curf00-sign   = 'I'.
  append p_curf00.

  perform f01_f4_field using 'CUKY' space changing p_curf01
                                                   p_curf00-high.

  perform f01_f4_field using space space changing p_hotf03-low
                                                  p_hotf03-high.
  p_hotf03-option = 'EQ'.
  p_hotf03-sign   = 'I'.
  append p_hotf03.

  perform f01_f4_field using space space changing p_colf02-low
                                                  p_colf02-high.
  p_colf02-option = 'EQ'.
  p_colf02-sign   = 'I'.
  append p_colf02.

  perform f01_f4_field using space space changing p_colf03-low
                                                  p_colf03-high.
  p_colf03-option = 'EQ'.
  p_colf03-sign   = 'I'.
  append p_colf03.

*----------------------------------------------------------------------*
* AT SELECTION-SCREEN                                                  *
*----------------------------------------------------------------------*
at selection-screen.
  case sscrfields-ucomm.
    when 'PB01'.
      call screen 1001 starting at 1 1 ending at 80 20.
  endcase.

*----------------------------------------------------------------------*
* AT SELECTION-SCREEN ON VALUE-REQUEST                                 *
*----------------------------------------------------------------------*
at selection-screen on value-request for p_var07.
  perform f01_f4_variant changing p_var07.

at selection-screen on value-request for p_dosf01-low.
  perform f01_f4_field using 'SUM' 'X'
                       changing p_dosf01-low p_dosf01-high.

at selection-screen on value-request for p_nosf01-low.
  perform f01_f4_field using 'SUM' 'X'
                       changing p_nosf01-low p_nosf01-high.

at selection-screen on value-request for p_outf01-low.
  perform f01_f4_field using 'KEY' 'X'
                       changing p_outf01-low p_outf01-high.

at selection-screen on value-request for p_tecf01-low.
  perform f01_f4_field using space 'X'
                       changing p_tecf01-low p_tecf01-high.

at selection-screen on value-request for p_fixf01-low.
  perform f01_f4_field using space 'X'
                       changing p_fixf01-low p_fixf01-low.

at selection-screen on value-request for p_curf00-low.
  perform f01_f4_field using 'CURR' 'X'
                       changing p_curf00-low p_curf00-high.

at selection-screen on value-request for p_curf01.
  perform f01_f4_field using 'CUKY' 'X'
                       changing p_curf01 g_dummy.

at selection-screen on value-request for p_hotf03-low.
  perform f01_f4_field using space 'X'
                       changing p_hotf03-low p_hotf03-high.

at selection-screen on value-request for p_colf02-low.
  perform f01_f4_field using space 'X'
                       changing p_colf02-low p_colf02-high.

at selection-screen on value-request for p_colf03-low.
  perform f01_f4_field using space 'X'
                       changing p_colf03-low p_colf03-high.

at selection-screen on value-request for p_lay06.
  perform f01_f4_fcode using space
                             space
                    changing p_lay06.

*----------------------------------------------------------------------*
* START-OF-SELECTION                                                   *
*----------------------------------------------------------------------*
start-of-selection.
  g_repid                    = sy-repid.

  gs_test-select_amount_master = p_amount.
  gs_test-select_amount_slave  = p_amouns.

  gs_test-only_db_info  = p_dbinfo.
  gs_test-db_short      = p_dbshrt.

  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-layo_expand_field        = p_exp01.
  gs_test-layo_expand_all          = p_exp02.

  gs_test-layo_title               = p_tit01.

  gs_test-layo_zebra               = p_lay01.
  gs_test-layo_no_horiz_lines      = p_lay02.
  gs_test-layo_no_vert_lines       = p_lay03.
  gs_test-layo_no_scrolling        = p_lay04.
  gs_test-layo_f2code              = p_lay06.
  gs_test-layo_confirmation_prompt = p_lay07.

  gs_test-layo_box                 = p_spa01.
  gs_test-layo_count               = p_spa02.
  gs_test-layo_no_colhead          = p_spa03.
  gs_test-layo_column_optimize     = p_spa04.

  gs_test-layo_no_hotspot          = p_hot01.
  if p_hot02 eq con_true.
    loop at p_hotf02.
      if not p_hotf02-low is initial.
        append p_hotf02-low to gs_test-layo_hotspot_rows.
      endif.
    endloop.
  endif.

  if p_hot03 eq con_true.
    loop at p_hotf03.
      if not p_hotf03-low is initial.
        gs_field-field = p_hotf03-low.
        gs_field-table = p_hotf03-high+3.
        if gs_field-table eq space.
          gs_field-table = 'GT_MASTER'.
        endif.
        append gs_field to gs_test-layo_hotspot_columns.
      endif.
    endloop.
  endif.

  case con_true.
    when p_mrg01.
      gs_test-layo_cell_merge          = space.
    when p_mrg02.
      gs_test-layo_cell_merge          = 'N'.
    when p_mrg03.
      gs_test-layo_cell_merge          = 'Y'.
  endcase.

  if p_out01 eq con_true.
    loop at p_outf01.
      if not p_outf01-low is initial.
        gs_field-field = p_outf01-low.
        gs_field-table = p_outf01-high+3.
        if gs_field-table eq space.
          gs_field-table = 'GT_MASTER'.
        endif.
        append gs_field to gs_test-fcat_no_out_fields.
      endif.
    endloop.
  endif.

  if p_tec01 eq con_true.
    loop at p_tecf01.
      if not p_tecf01-low is initial.
        gs_field-field = p_tecf01-low.
        gs_field-table = p_tecf01-high+3.
        if gs_field-table eq space.
          gs_field-table = 'GT_MASTER'.
        endif.
        append gs_field to gs_test-fcat_tech_fields.
      endif.
    endloop.
  endif.

  if p_fix01 eq con_true.
    loop at p_fixf01.
      if not p_fixf01-low is initial.
        gs_field-field = p_fixf01-low.
        gs_field-table = p_fixf01-high+3.
        if gs_field-table eq space.
          gs_field-table = 'GT_MASTER'.
        endif.
        append gs_field to gs_test-fcat_fix_column_fields.
      endif.
    endloop.
  endif.

  gs_test-curr_amount = p_curanz.
  gs_test-curr_space  = p_curspc.
  if p_cur01 eq con_true or p_cur02 eq con_true.
    data: ls_fcat_curr type g_ty_s_fcat_curr.

    loop at p_curf00.
      clear ls_fcat_curr.
      if not p_curf00-low is initial.
        ls_fcat_curr-fieldname = p_curf00-low.
        ls_fcat_curr-table     = p_curf00-high+3.
        if ls_fcat_curr-table eq space.
          ls_fcat_curr-table = 'GT_MASTER'.
        endif.
        case con_true.
          when p_cur01.
            ls_fcat_curr-cfieldname = p_curf01.
          when p_cur02.
            ls_fcat_curr-currency   = p_curf02.
        endcase.
        append ls_fcat_curr to gs_test-fcat_curr_fields.
      endif.
    endloop.
  endif.

  gs_test-layo_keys_hotspot        = p_key01.
  gs_test-layo_no_keyfix           = p_key02.

  gs_test-excp_display             = p_excp01.
  gs_test-excp_condense            = p_excp_c.

  gs_test-sum_before               = p_sum01.
  gs_test-sum_numc                 = p_sum02.
  gs_test-sum_no_unitsplit         = p_sum03.
  gs_test-sum_totals_only          = p_sum04.
  gs_test-sum_no_sumchoice         = p_sum05.
  gs_test-sum_no_sumline           = p_sum06.
  gs_test-sum_totals_text          = p_sum07.
  gs_test-sum_no_subchoice         = p_sum08.
  gs_test-sum_no_subtotals         = p_sum09.
  gs_test-sum_subtotals_text       = p_sum10.

  if p_dos01 eq con_true.
    loop at p_dosf01.
      if not p_dosf01-low is initial.
        gs_field-field = p_dosf01-low.
        gs_field-table = p_dosf01-high+3.
        if gs_field-table eq space.
          gs_field-table = 'GT_MASTER'.
        endif.
        append gs_field to gs_test-fcat_do_sum_fields.
      endif.
    endloop.
  endif.

  if p_nos01 eq con_true.
    loop at p_nosf01.
      if not p_nosf01-low is initial.
        gs_field-field = p_nosf01-low.
        gs_field-table = p_nosf01-high+3.
        if gs_field-table eq space.
          gs_field-table = 'GT_MASTER'.
        endif.
        append gs_field to gs_test-fcat_no_sum_fields.
      endif.
    endloop.
  endif.

  gs_test-layo_group_change_edit   = p_lpr01.
  gs_test-layo_get_selinfo         = p_lpr02.
  gs_test-layo_no_min_linesize     = p_lpr03.
  gs_test-layo_min_linesize        = p_lpr04.
  gs_test-layo_max_linesize        = p_lpr05.

  gs_test-prnt_print                  = p_prn01.
  gs_test-prnt_reserve_lines          = p_prn02.
  gs_test-prnt_no_listinfo            = p_prn03.
  gs_test-prnt_no_selinfo             = p_prn04.
  gs_test-prnt_with_title             = p_prn05.
  gs_test-prnt_footline               = p_prn06.
  gs_test-prnt_printinfo              = p_prn07.
  gs_test-prnt_no_coverpage           = p_prn08.
  gs_test-prnt_no_new_page            = p_prn09.
  gs_test-prnt_no_change_print_params = p_prn10.
  gs_test-prnt_no_hierseq_item        = p_prn11.

  gs_test-layo_reprep              = p_rep01.

  if p_col01 eq con_true.
    loop at p_colf01.
      if not p_colf01-low is initial.
        append p_colf01-low to gs_test-color_rows.
      endif.
    endloop.
  endif.
  if p_col02 eq con_true.
    loop at p_colf02.
      if not p_colf02-low is initial.
        gs_field-field = p_colf02-low.
        gs_field-table = p_colf02-high+3.
        if gs_field-table eq space.
          gs_field-table = 'GT_MASTER'.
        endif.
        append gs_field to gs_test-color_fields_column.
      endif.
    endloop.
  endif.
  if p_col03 eq con_true.
    loop at p_colf03.
      if not p_colf03-low is initial.
        gs_field-field = p_colf03-low.
        gs_field-table = p_colf03-high+3.
        if gs_field-table eq space.
          gs_field-table = 'GT_MASTER'.
        endif.
        append gs_field to gs_test-color_fields_cell.
      endif.
    endloop.
  endif.

  gs_test-buffer_active            = space.
  gs_test-bypassing_buffer         = space.

*----------------------------------------------------------------------*
* END-OF-SELECTION                                                     *
*----------------------------------------------------------------------*
end-of-selection.
  perform f01_call_list.

*&---------------------------------------------------------------------*
*&      Form  f01_call_list
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form f01_call_list.

  data: ls_vari      type disvariant,
        ls_layo      type slis_layout_alv,
        lt_fcat      type slis_t_fieldcat_alv,
        lt_sort      type slis_t_sortinfo_alv,
        ls_prnt      type slis_print_alv,
        lt_qinf      type slis_t_qinfo_alv,
        ls_keyinfo   type slis_keyinfo_alv.

  perform f01_get_outtab.

  perform f01_set_vari changing ls_vari.
  perform f01_set_layo changing ls_layo.
  perform f01_set_fcat changing lt_fcat.
  perform f01_set_prnt changing ls_prnt.
  perform f01_set_color changing lt_fcat
                                 ls_layo.
  perform f01_set_hotspot changing lt_fcat
                                   ls_layo.
  perform f01_set_keyinfo changing ls_keyinfo.

  lt_sort[] = gs_test-t_sort[].

  call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
    exporting
*     I_INTERFACE_CHECK              = ' '
      i_callback_program             = g_repid
*     I_CALLBACK_PF_STATUS_SET       = ' '
*     I_CALLBACK_USER_COMMAND        = ' '
      is_layout                      = ls_layo
      it_fieldcat                    = lt_fcat
*     IT_EXCLUDING                   =
*     it_special_groups              =
      it_sort                        = lt_sort
*     IT_FILTER                      =
*     IS_SEL_HIDE                    =
*     I_SCREEN_START_COLUMN          = 0
*     I_SCREEN_START_LINE            = 0
*     I_SCREEN_END_COLUMN            = 0
*     I_SCREEN_END_LINE              = 0
      i_default                      = gs_test-vari_default
      i_save                         = gs_test-vari_save
      is_variant                     = ls_vari
*     it_events                      =
*     it_event_exit                  =
      i_tabname_header               = 'GT_MASTER'
      i_tabname_item                 = 'GT_SLAVE'
*     I_STRUCTURE_NAME_HEADER        =
*     I_STRUCTURE_NAME_ITEM          =
      is_keyinfo                     = ls_keyinfo
      is_print                       = ls_prnt
      it_except_qinfo                = lt_qinf
*     IS_REPREP_ID                   =
*   IMPORTING
*     E_EXIT_CAUSED_BY_CALLER        =
*     ES_EXIT_CAUSED_BY_USER         =
    tables
      t_outtab_header                = gt_master
      t_outtab_item                  = gt_slave
    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.

endform.                    " f01_call_list


*&---------------------------------------------------------------------*
*&      Form  f01_set_vari
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form f01_set_vari changing cs_vari type disvariant.

  check gs_test-vari_none eq space.

  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.

endform.                    " f01_set_vari

*&---------------------------------------------------------------------*
*&      Form  f01_set_layo
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form f01_set_layo changing cs_layo type slis_layout_alv.

*... Display options
  cs_layo-colwidth_optimize      = gs_test-layo_column_optimize.
  cs_layo-no_colhead             = gs_test-layo_no_colhead.
  cs_layo-no_hotspot             = gs_test-layo_no_hotspot.
  cs_layo-zebra                  = gs_test-layo_zebra.
  cs_layo-no_vline               = gs_test-layo_no_vert_lines.
  cs_layo-no_hline               = gs_test-layo_no_horiz_lines.
  cs_layo-cell_merge             = gs_test-layo_cell_merge.
  cs_layo-no_min_linesize        = gs_test-layo_no_min_linesize.
  cs_layo-min_linesize           = gs_test-layo_min_linesize.
  cs_layo-max_linesize           = gs_test-layo_max_linesize.
  cs_layo-window_titlebar        = gs_test-layo_title.
  cs_layo-no_uline_hs            = space.
  if gs_test-layo_count eq con_true.
    cs_layo-countfname             = 'COUNT'.
  endif.
*... Edit
  cs_layo-edit                   = space.
  cs_layo-edit_mode              = space.
*... Exceptions
  if gs_test-excp_display  eq con_true or
     gs_test-excp_condense eq con_true.
    cs_layo-lights_fieldname       = 'LIGHTS'.
  endif.
  cs_layo-lights_tabname         = 'GT_MASTER'.
  cs_layo-lights_rollname        = space.
  cs_layo-lights_condense        = gs_test-excp_condense.
*... Sums
  cs_layo-no_sumchoice           = gs_test-sum_no_sumchoice.
  cs_layo-no_totalline           = gs_test-sum_no_sumline.
  cs_layo-totals_before_items    = gs_test-sum_before.
  cs_layo-totals_only            = gs_test-sum_totals_only.
  cs_layo-totals_text            = gs_test-sum_totals_text.
  cs_layo-no_subchoice           = gs_test-sum_no_subchoice.
  cs_layo-no_subtotals           = gs_test-sum_no_subtotals.
  cs_layo-subtotals_text         = gs_test-sum_subtotals_text.
  cs_layo-numc_sum               = gs_test-sum_numc.
  cs_layo-no_unit_splitting      = gs_test-sum_no_unitsplit.
*... Interaction
  if gs_test-layo_box eq con_true.
    cs_layo-box_fieldname          = 'BOX'.
  endif.
  cs_layo-box_tabname            = 'GT_MASTER'.
  cs_layo-box_rollname           = space.

  if gs_test-layo_expand_field eq con_true.
    cs_layo-expand_fieldname       = 'EXPAND'.
  endif.

  cs_layo-no_input               = space.
  cs_layo-f2code                 = gs_test-layo_f2code.
  cs_layo-confirmation_prompt    = gs_test-layo_confirmation_prompt.
  cs_layo-key_hotspot            = gs_test-layo_keys_hotspot.
  cs_layo-flexible_key           = space.
  cs_layo-reprep                 = gs_test-layo_reprep.
  cs_layo-group_buttons          = space.
  cs_layo-no_keyfix              = gs_test-layo_no_keyfix.
  cs_layo-get_selinfos           = gs_test-layo_get_selinfo.
  cs_layo-group_change_edit      = gs_test-layo_group_change_edit.
  cs_layo-no_scrolling           = gs_test-layo_no_scrolling.
  cs_layo-expand_all             = gs_test-layo_expand_all.
  cs_layo-no_author              = gs_test-layo_no_authcheck.
*... Detailed screen
  cs_layo-detail_popup           = space.
  cs_layo-detail_initial_lines   = space.
  cs_layo-detail_titlebar        = space.
*... PF-status
  cs_layo-def_status             = space.
*... Display variants
  cs_layo-header_text            = space.
  cs_layo-item_text              = space.
  cs_layo-default_item           = space.
*... colour
  cs_layo-info_fieldname         = space.
  cs_layo-coltab_fieldname       = space.
*... others
  cs_layo-list_append            = space.

endform.                    " f01_set_layo

*&---------------------------------------------------------------------*
*&      Form  f01_set_fcat

*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form f01_set_fcat changing ct_fcat type slis_t_fieldcat_alv.

  data: lt_fcat_master type slis_t_fieldcat_alv,
        lt_fcat_slave  type slis_t_fieldcat_alv.

  clear ct_fcat[].

  perform f01_set_fcat_master changing lt_fcat_master.
  perform f01_set_fcat_slave  changing lt_fcat_slave.

  append lines of lt_fcat_master to ct_fcat.
  append lines of lt_fcat_slave  to ct_fcat.

endform.                    " f01_set_fcat

*&---------------------------------------------------------------------*
*&      Form  f01_set_fcat_master
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form f01_set_fcat_master changing ct_fcat type slis_t_fieldcat_alv.

  field-symbols: <ls_fcat> type slis_fieldcat_alv.

  data: lt_fcat type slis_t_fieldcat_alv,
        ls_fcat type slis_fieldcat_alv,
        l_lin   type i.

  call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
*     I_PROGRAM_NAME               =
*     i_internal_tabname           =
      i_structure_name             = con_spfli
*     I_CLIENT_NEVER_DISPLAY       = 'X'
*     I_INCLNAME                   =
      i_bypassing_buffer           = gs_test-bypassing_buffer
      i_buffer_active              = gs_test-buffer_active
    changing
      ct_fieldcat                  = ct_fcat
    exceptions
      inconsistent_interface       = 1
      program_error                = 2
      others                       = 3.
  if sy-subrc ne 0.
    exit.
  endif.

  call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
*     I_PROGRAM_NAME               =
*     i_internal_tabname           =
      i_structure_name             = con_sflight
*     I_CLIENT_NEVER_DISPLAY       = 'X'
*     I_INCLNAME                   =
      i_bypassing_buffer           = gs_test-bypassing_buffer
      i_buffer_active              = gs_test-buffer_active
    changing
      ct_fieldcat                  = lt_fcat
    exceptions
      inconsistent_interface       = 1
      program_error                = 2
      others                       = 3.
  if sy-subrc ne 0.
    exit.
  else.
    delete lt_fcat where fieldname ne 'PRICE'
                     and fieldname ne 'CURRENCY'.
    append lines of lt_fcat to ct_fcat.
    loop at ct_fcat assigning <ls_fcat>.
      case <ls_fcat>-fieldname.
        when 'CARRID' or 'CONNID'.
          l_lin = <ls_fcat>-col_pos.
        when 'PRICE' or 'CURRENCY'.
          add 1 to l_lin.
          <ls_fcat>-col_pos = l_lin.
        when others.
          add 4 to <ls_fcat>-col_pos.
      endcase.
    endloop.
  endif.

  ls_fcat-tabname = 'GT_MASTER'.
  modify ct_fcat from ls_fcat transporting tabname
                 where tabname ne ls_fcat-tabname.

  if gs_test-only_db_info eq space.
    add 1 to l_lin.

    clear ls_fcat.
    read table ct_fcat assigning <ls_fcat> with key fieldname = 'PRICE'.
    if sy-subrc eq 0.
      <ls_fcat>-ctabname     = 'GT_MASTER'.
      <ls_fcat>-seltext_l    = 'PRICE_M'.
      <ls_fcat>-seltext_m    = 'PRICE_M'.
      <ls_fcat>-seltext_s    = 'PRICE_M'.
      <ls_fcat>-reptext_ddic = 'PRICE_M'.

      ls_fcat = <ls_fcat>.
      ls_fcat-ref_fieldname = ls_fcat-fieldname.
      ls_fcat-fieldname     = 'PRICE_HEAD'.
      ls_fcat-cfieldname    = 'CURRENCY_ITEM'.
      ls_fcat-ctabname      = 'GT_SLAVE'.
      ls_fcat-seltext_l     = ls_fcat-fieldname.
      ls_fcat-seltext_m     = ls_fcat-fieldname.
      ls_fcat-seltext_s     = ls_fcat-fieldname.
      ls_fcat-reptext_ddic  = ls_fcat-fieldname.
      ls_fcat-col_pos       = l_lin.
      append ls_fcat to ct_fcat.
    endif.

    add 1 to l_lin.

    clear ls_fcat.
    read table ct_fcat assigning <ls_fcat>
               with key fieldname = 'CURRENCY'.
    if sy-subrc eq 0.
      <ls_fcat>-seltext_l    = 'CURRENCY_M'.
      <ls_fcat>-seltext_m    = 'CURRENCY_M'.
      <ls_fcat>-seltext_s    = 'CURRENCY_M'.
      <ls_fcat>-reptext_ddic = 'CURRENCY_M'.

      ls_fcat = <ls_fcat>.
      ls_fcat-ref_fieldname = ls_fcat-fieldname.
      ls_fcat-fieldname     = 'CURRENCY_HEAD'.
      ls_fcat-seltext_l     = 'CURRENCY_ITEM'.
      ls_fcat-seltext_m     = 'CURRENCY_ITEM'.
      ls_fcat-seltext_s     = 'CURRENCY_ITEM'.
      ls_fcat-reptext_ddic  = 'CURRENCY_ITEM'.
      ls_fcat-col_pos       = l_lin.
      append ls_fcat to ct_fcat.
    endif.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_MASTER'.
    ls_fcat-fieldname = 'CHECKBOX'.
    ls_fcat-checkbox  = con_true.
    ls_fcat-inttype   = 'C'.
    ls_fcat-datatype  = 'CHAR'.
    ls_fcat-intlen    = 1.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.

    add 1 to l_lin.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_MASTER'.
    ls_fcat-fieldname = 'CHAR'.
    ls_fcat-inttype   = 'C'.
    ls_fcat-intlen    = 10.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.

    add 1 to l_lin.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_MASTER'.
    ls_fcat-fieldname = 'STRING'.
    ls_fcat-inttype   = 'g'.
    ls_fcat-intlen    = 10.
    ls_fcat-outputlen = 10.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-lowercase = con_true.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.

    add 1 to l_lin.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_MASTER'.
    ls_fcat-fieldname = 'INT1'.
    ls_fcat-inttype   = 'b'.
    ls_fcat-intlen    = 3.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.

    add 1 to l_lin.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_MASTER'.
    ls_fcat-fieldname = 'INT2'.
    ls_fcat-inttype   = 's'.
    ls_fcat-intlen    = 5.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.

    add 1 to l_lin.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_MASTER'.
    ls_fcat-fieldname = 'INT4'.
    ls_fcat-inttype   = 'I'.
    ls_fcat-intlen    = 10.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.

    add 1 to l_lin.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_MASTER'.
    ls_fcat-fieldname = 'NUMC'.
    ls_fcat-inttype   = 'N'.
    ls_fcat-intlen    = 10.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.

    add 1 to l_lin.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_MASTER'.
    ls_fcat-fieldname = 'DEC'.
    ls_fcat-inttype   = 'P'.
    ls_fcat-intlen    = 10.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-decimals_out  = 2.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.

    add 1 to l_lin.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_MASTER'.
    ls_fcat-fieldname = 'FLTP'.
    ls_fcat-inttype   = 'F'.
    ls_fcat-intlen    = 10.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.

    add 1 to l_lin.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_MASTER'.
    ls_fcat-fieldname = 'DATS'.
    ls_fcat-inttype   = 'D'.
    ls_fcat-intlen    = 10.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.

    add 1 to l_lin.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_MASTER'.
    ls_fcat-fieldname = 'TIMS'.
    ls_fcat-inttype   = 'T'.
    ls_fcat-intlen    = 8.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.

    add 1 to l_lin.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_MASTER'.
    ls_fcat-fieldname = 'ICON'.
    ls_fcat-inttype   = 'C'.
    ls_fcat-intlen    = 4.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-icon      = con_true.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.

    add 1 to l_lin.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_MASTER'.
    ls_fcat-fieldname = 'ICON_QINFO'.
    ls_fcat-inttype   = 'C'.
    ls_fcat-intlen    = 30.
    ls_fcat-outputlen = 4.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-icon      = con_true.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.

    add 1 to l_lin.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_MASTER'.
    ls_fcat-fieldname = 'SYMBOL'.
    ls_fcat-inttype   = 'C'.
    ls_fcat-intlen    = 4.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-symbol    = con_true.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.
  endif.

*>>keyinfo external sort
  clear ls_fcat.
  read table ct_fcat with key fieldname = 'CARRID_MASTER'
                       transporting no fields.
  if sy-subrc ne 0.
    ls_fcat-tabname = 'GT_MASTER'.
    ls_fcat-fieldname    = 'CARRID_MASTER'.
    ls_fcat-ref_fieldname  = 'CARRID'.
    ls_fcat-ctabname     = 'GT_MASTER'.
    ls_fcat-seltext_l    = 'CARRID_MASTER'.
    ls_fcat-seltext_m    = 'CARRID_MASTER'.
    ls_fcat-seltext_s    = 'CARRID_MASTER'.
    ls_fcat-reptext_ddic = 'CARRID_MASTER'.
    ls_fcat-col_pos      = l_lin.
    add 1 to l_lin.
    append ls_fcat to ct_fcat.
  endif.
*<<keyinfo external sort

  data: ls_field type g_ty_s_fname.

  loop at gs_test-fcat_no_out_fields into ls_field
          where table eq ls_fcat-tabname.
    read table ct_fcat assigning <ls_fcat>
               with key fieldname = ls_field-field.
    if sy-subrc eq 0.
      <ls_fcat>-no_out = con_true.
    endif.
  endloop.

  loop at gs_test-fcat_tech_fields into ls_field
          where table eq ls_fcat-tabname.
    read table ct_fcat assigning <ls_fcat>
               with key fieldname = ls_field-field.
    if sy-subrc eq 0.
      <ls_fcat>-tech = con_true.
    endif.
  endloop.

  loop at gs_test-fcat_fix_column_fields into ls_field
          where table eq ls_fcat-tabname.
    read table ct_fcat assigning <ls_fcat>
               with key fieldname = ls_field-field.
    if sy-subrc eq 0.
      <ls_fcat>-fix_column = con_true.
    endif.
  endloop.

  loop at gs_test-fcat_do_sum_fields into ls_field
          where table eq ls_fcat-tabname.
    read table ct_fcat assigning <ls_fcat>
               with key fieldname = ls_field-field.
    if sy-subrc eq 0.
      <ls_fcat>-do_sum = con_true.
    endif.
  endloop.

  loop at gs_test-fcat_no_sum_fields into ls_field
          where table eq ls_fcat-tabname.
    read table ct_fcat assigning <ls_fcat>
               with key fieldname = ls_field-field.
    if sy-subrc eq 0.
      <ls_fcat>-no_sum = con_true.
    endif.
  endloop.

  data: ls_fcat_curr type g_ty_s_fcat_curr.

  loop at gs_test-fcat_curr_fields into ls_fcat_curr
          where table eq ls_fcat-tabname.
    read table ct_fcat assigning <ls_fcat>
               with key fieldname = ls_fcat_curr-fieldname.
    if sy-subrc eq 0 and <ls_fcat>-datatype eq 'CURR'.
      if ls_fcat_curr-cfieldname eq space.
        <ls_fcat>-cfieldname = ls_fcat_curr-cfieldname.
        <ls_fcat>-currency   = ls_fcat_curr-currency.
      else.
        read table ct_fcat into ls_fcat
                   with key fieldname = ls_fcat_curr-cfieldname.
        if sy-subrc eq 0 and ls_fcat-datatype eq 'CUKY'.
          <ls_fcat>-cfieldname = ls_fcat_curr-cfieldname.
          <ls_fcat>-currency   = ls_fcat_curr-currency.
        endif.
      endif.
    endif.
  endloop.

endform.                    " f01_set_fcat_master

*&---------------------------------------------------------------------*
*&      Form  f01_set_fcat_slave
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form f01_set_fcat_slave changing ct_fcat type slis_t_fieldcat_alv.

  data: ls_fcat      type slis_fieldcat_alv,
        l_lin        type i,
        l_index_from type i,
        l_index_to   type i.

  call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
*     I_PROGRAM_NAME               =
*     i_internal_tabname           =
      i_structure_name             = con_sflight
*     I_CLIENT_NEVER_DISPLAY       = 'X'
*     I_INCLNAME                   =
      i_bypassing_buffer           = gs_test-bypassing_buffer
      i_buffer_active              = gs_test-buffer_active
    changing
      ct_fieldcat                  = ct_fcat
    exceptions
      inconsistent_interface       = 1
      program_error                = 2
      others                       = 3.
  if sy-subrc ne 0.
    exit.
  endif.

  ls_fcat-tabname = 'GT_SLAVE'.
  modify ct_fcat from ls_fcat transporting tabname
                 where tabname ne ls_fcat-tabname.


  if gs_test-only_db_info eq space.
    describe table ct_fcat lines l_index_to.

    clear ls_fcat.
    read table ct_fcat into ls_fcat with key fieldname = 'PRICE'.
    if sy-subrc eq 0.
      l_lin = ls_fcat-col_pos.

      ls_fcat-ctabname     = 'GT_SLAVE'.
      ls_fcat-seltext_l    = 'PRICE_S'.
      ls_fcat-seltext_m    = 'PRICE_S'.
      ls_fcat-seltext_s    = 'PRICE_S'.
      ls_fcat-reptext_ddic = 'PRICE_S'.
      modify ct_fcat from ls_fcat index sy-tabix.

      ls_fcat-ref_fieldname = ls_fcat-fieldname.
      ls_fcat-fieldname     = 'PRICE_ITEM'.
      ls_fcat-cfieldname    = 'CURRENCY_HEAD'.
      ls_fcat-ctabname      = 'GT_MASTER'.
      ls_fcat-seltext_l     = ls_fcat-fieldname.
      ls_fcat-seltext_m     = ls_fcat-fieldname.
      ls_fcat-seltext_s     = ls_fcat-fieldname.
      ls_fcat-reptext_ddic  = ls_fcat-fieldname.
      ls_fcat-col_pos       = l_lin + 2.
      append ls_fcat to ct_fcat.
    endif.

    clear ls_fcat.
    read table ct_fcat into ls_fcat with key fieldname = 'CURRENCY'.
    if sy-subrc eq 0.
      l_lin = ls_fcat-col_pos.

      ls_fcat-seltext_l    = 'CURRENCY_S'.
      ls_fcat-seltext_m    = 'CURRENCY_S'.
      ls_fcat-seltext_s    = 'CURRENCY_S'.
      ls_fcat-reptext_ddic = 'CURRENCY_S'.
      modify ct_fcat from ls_fcat index sy-tabix.

      ls_fcat-ref_fieldname = ls_fcat-fieldname.
      ls_fcat-fieldname     = 'CURRENCY_ITEM'.
      ls_fcat-seltext_l     = 'CURRENCY_HEAD'.
      ls_fcat-seltext_m     = 'CURRENCY_HEAD'.
      ls_fcat-seltext_s     = 'CURRENCY_HEAD'.
      ls_fcat-reptext_ddic  = 'CURRENCY_HEAD'.
      ls_fcat-col_pos       = l_lin + 2.
      append ls_fcat to ct_fcat.
    endif.

    l_index_from = l_lin + 1.

    loop at ct_fcat from l_index_from to l_index_to into ls_fcat.
      add 2 to ls_fcat-col_pos.
      modify ct_fcat from ls_fcat index sy-tabix.
    endloop.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_SLAVE'.
    ls_fcat-fieldname = 'CHECKBOX'.
    ls_fcat-checkbox  = con_true.
    ls_fcat-inttype   = 'C'.
    ls_fcat-datatype  = 'CHAR'.
    ls_fcat-intlen    = 1.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.

    add 1 to l_lin.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_SLAVE'.
    ls_fcat-fieldname = 'CHAR'.
    ls_fcat-inttype   = 'C'.
    ls_fcat-intlen    = 10.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.

    add 1 to l_lin.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_SLAVE'.
    ls_fcat-fieldname = 'STRING'.
    ls_fcat-inttype   = 'g'.
    ls_fcat-intlen    = 10.
    ls_fcat-outputlen = 10.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-lowercase = con_true.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.

    add 1 to l_lin.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_SLAVE'.
    ls_fcat-fieldname = 'INT1'.
    ls_fcat-inttype   = 'b'.
    ls_fcat-intlen    = 3.
    ls_fcat-col_pos   = l_lin.
    ls_fcat-seltext_s = ls_fcat-fieldname.
    ls_fcat-seltext_m = ls_fcat-fieldname.
    ls_fcat-seltext_l = ls_fcat-fieldname.
    append ls_fcat to ct_fcat.

    add 1 to l_lin.

    clear ls_fcat.
    ls_fcat-tabname   = 'GT_SLAVE'.
    ls_fcat-fieldname = 'INT2
分享到:

你可能感兴趣的:(head item alv LIST)