Skip to Content
0
Former Member
Jul 03, 2007 at 09:52 AM

Modify dynamic internal table

486 Views

Dear All,

I was able to generate internal table and even able to read the data from a data base table into dynamic internal table.

But I would like to manipulate the data in the internal table, für example I would like to update few fields and display it in the List.

Now how di Modify dynamic internal table..

I have attached the code below which I am using right now.

REPORT Z_DYN_TABLE

field-symbols: type standard table.

data: dy_table type ref to data,

dy_line type ref to data,

xfc type lvc_s_fcat,

ifc type lvc_t_fcat.

Parameters : P_BEGDA like P0001-BEGDA default '20071001',

P_INFTY like P0001-INFTY default 'P0001'.

START-OF-SELECTION.

  • to get the srurcute

perform get_structure using l_f_table.

perform create_dynamic_itab .

assign dy_table->* to BUT now I have to modify few fields from the dynamic internal table, how do I do it.

END-OF-SELECTION.

form get_structure using p_table.

data : idetails type abap_compdescr_tab,

xdetails type abap_compdescr.

data : ref_table_des type ref to cl_abap_structdescr.

clear : ifc[], dy_table.

  • Get the structure of the table.

ref_table_des ?=

cl_abap_typedescr=>describe_by_name( p_table ).

idetails[] = ref_table_des->components[].

loop at idetails into xdetails.

clear xfc.

xfc-fieldname = xdetails-name .

xfc-datatype = xdetails-type_kind.

xfc-inttype = xdetails-type_kind.

xfc-intlen = xdetails-length.

xfc-decimals = xdetails-decimals.

append xfc to ifc.

endloop.

endform.

form create_dynamic_itab.

  • Create dynamic internal table and assign to FS

call method cl_alv_table_create=>create_dynamic_table

exporting

it_fieldcatalog = ifc

importing

ep_table = dy_table.

endform.

*&----


*

*& Form get_data

*&----


*

form get_data tables p_table

using p_pernr

p_infty.

clear : p_table, p_table[].

CALL FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

PERNR = P_PERNR

INFTY = p_infty

BEGDA = p_datum

ENDDA = p_datum

TABLES

INFTY_TAB = p_table

EXCEPTIONS

INFTY_NOT_FOUND = 1

OTHERS = 2.

Endform.