W Pub: ABAPZINIPARAMS

  1. *
  2. REPORT ZINI_PRG_PARAMETROS.
  3. tables: e070.
  4.  
  5.  
  6. types: begin of ty_params,
  7.           name(8),
  8.           KIND   type RSSCR_KIND, "S / P
  9.           length type i, "<--- hay que / 2
  10.           dtyp(4),
  11.           objeto type REF TO data,
  12.        end of ty_params.
  13.  
  14. data: l_REPORT LIKE  RSVAR-REPORT,
  15.       t_selctab type STANDARD TABLE OF RSSCR,
  16.       t_tab type STANDARD TABLE OF ty_params,
  17.  
  18.       l_tab like LINE OF t_tab.
  19.  
  20.  
  21. l_report = '{NOMBRE_del_report}'.
  22.  
  23.   perform load_sscr(rsdbrunt) tables      t_selctab
  24.                               USING       l_REPORT
  25.                               CHANGING   sy-subrc.
  26.  
  27. loop at t_selctab into data(l_f) where kind ca 'SP'.
  28.    MOVE-CORRESPONDING l_f to l_tab.
  29.    l_tab-length = l_tab-length  div 2.
  30.  
  31.    case l_tab-kind.
  32.      when 'P'.
  33.          CREATE DATA l_tab-objeto type (l_f-type) LENGTH l_tab-length.
  34.      when 'S'.
  35.  
  36.  
  37. DATA:
  38.   gr_structdescr    TYPE REF TO cl_abap_structdescr,
  39.   gr_tabledescr     TYPE REF TO cl_abap_tabledescr,
  40.   gr_datadescr      TYPE REF TO cl_abap_datadescr,
  41.   gr_typedescr      type ref to cl_abap_typedescr,
  42.   gt_components     TYPE abap_component_tab,
  43.   gw_component      TYPE LINE OF abap_component_tab,
  44.   gr_wa             TYPE REF TO data,
  45.   gr_tab            TYPE REF TO data.
  46.  
  47. FIELD-SYMBOLS: <fs_wa> TYPE ANY.
  48. FIELD-SYMBOLS: <fs_tab> TYPE table.
  49.  
  50. MOVE 'SIGN' TO gw_component-name.
  51.  
  52.   refresh gt_components.
  53.   gw_component-type ?= cl_abap_elemdescr=>get_c( p_length = 1 ).
  54.   INSERT gw_component INTO TABLE gt_components.
  55.  
  56.   MOVE 'OPTION' TO gw_component-name.
  57.   gw_component-type ?= cl_abap_elemdescr=>get_c( p_length = 2 ).
  58.   INSERT gw_component INTO TABLE gt_components.
  59.  
  60.   MOVE 'LOW' TO gw_component-name.
  61.   gw_component-type ?= cl_abap_elemdescr=>get_c( p_length = l_tab-length ).
  62.   INSERT gw_component INTO TABLE gt_components.
  63.  
  64.   MOVE 'HIGH' TO gw_component-name.
  65.   gw_component-type ?= cl_abap_elemdescr=>get_c( p_length = l_tab-length ).
  66.   INSERT gw_component INTO TABLE gt_components.
  67.  
  68. * get structure descriptor -> GR_STRUCTDESCR
  69.   gr_structdescr ?= cl_abap_structdescr=>create( gt_components ).
  70.  
  71. * create work area of structure GR_STRUCTDESCR -> GR_WA
  72.   CREATE DATA gr_wa TYPE HANDLE gr_structdescr.
  73.   ASSIGN gr_wa->* TO <fs_wa>.
  74.  
  75.   gr_datadescr ?= gr_structdescr.
  76.   gr_tabledescr ?= cl_abap_tabledescr=>create( gr_datadescr ).
  77.  
  78. * Create dynmaic internal table
  79.   CREATE DATA L_TAB-OBJETO TYPE HANDLE gr_tabledescr.
  80. *  ASSIGN gr_tab->* TO <fs_tab>.
  81.  
  82.    endcase.
  83.  
  84.    append l_tab to t_tab.
  85. endloop.
  86.  
  87. BREAK-POINT.