Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8902

Re: A dynamic internal table having datatype of INT4 is of inttype I or X?

$
0
0

Hi Kavya,

 

 

My program is working fine check it out.

 

 

 

TABLES : zexample.

type-pools : abap, slis.

field-symbols: <fs_table> type standard table,

               <fs_wa>,

               <fs_field>.

data: dyn_table    type ref to data,

      dyn_line     type ref to data,

      wa_fieldcat type lvc_s_fcat,

      it_fieldcat type lvc_t_fcat.



*ALV data declarations

data: fieldcatalog type slis_t_fieldcat_alv with header line,

      gd_tab_group type slis_t_sp_group_alv,

      gd_layout    TYPE slis_layout_alv,

      gd_repid     like sy-repid.



selection-screen begin of block block1 with frame.

parameters: p_table(30) type c default 'SFLIGHT'.

selection-screen end of block block1.



**********************************************************************

*start-of-selection.

start-of-selection.

  perform get_table_structure.

  perform create_itab_dynamically.

  DATA : n TYPE zexample.

  n-test = 831.

MOVE-CORRESPONDING n TO <fs_wa>.

APPEND <fs_wa> TO <fs_table>.

WRITE :'HELLO'.



"&---------------------------------------------------------------------*

"&      Form  get_table_structure

"&---------------------------------------------------------------------*

*       Gt structure of an SAP table

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

form get_table_structure.

  data : it_tabdescr type abap_compdescr_tab,

         wa_tabdescr type abap_compdescr.

  data : ref_table_descr type ref to cl_abap_structdescr.



* Return structure of the table.

  ref_table_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).

  it_tabdescr[] = ref_table_descr->components[].

  loop at it_tabdescr into wa_tabdescr.

    clear wa_fieldcat.

    wa_fieldcat-fieldname = wa_tabdescr-name .

    wa_fieldcat-datatype  = wa_tabdescr-type_kind.

    wa_fieldcat-inttype   = wa_tabdescr-type_kind.

    wa_fieldcat-intlen    = wa_tabdescr-length.

    wa_fieldcat-decimals  = wa_tabdescr-decimals.

    append wa_fieldcat to it_fieldcat.

  endloop.

endform.                    "get_table_structure



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

*&      Form  create_itab_dynamically

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

*       Create internal table dynamically

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

form create_itab_dynamically.

* Create dynamic internal table and assign to Field-Symbol

  call method cl_alv_table_create=>create_dynamic_table

    EXPORTING

      it_fieldcatalog = it_fieldcat

    IMPORTING

      ep_table        = dyn_table.

  assign dyn_table->* to <fs_table>.

* Create dynamic work area and assign to Field Symbol

  create data dyn_line like line of <fs_table>.

  assign dyn_line->* to <fs_wa>.

endform.                    "create_itab_dynamically

 

 

Regards

Alenlee


Viewing all articles
Browse latest Browse all 8902

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>