03-18-2009 9:02 AM
Hi,
Can I change the structure of my internal table in runtime?
Say,
I am having my internal table like this:
types: begin of ty_tab,
f1, f2, f3, f4, f5, f6,
end of ty_tab.
data: itab type standard table of ty_tab with header line.
Now I want to change it in runtime(Debugging mode) where it contains f1 and f2 fileds only not the other four fields.
FYI: regarding some memory allocation issues i want to change it like that as I am not having access to change the code in that server.
--Naveen Inuganti
03-18-2009 9:06 AM
Hi,
Its not possible to change the structure in debug mode, but at program run time there are ways of creating new structures and moving data from your existing internal table to an internal table of this structure.
Regards,
Sesh
03-18-2009 9:06 AM
Hi,
Its not possible to change the structure in debug mode, but at program run time there are ways of creating new structures and moving data from your existing internal table to an internal table of this structure.
Regards,
Sesh
03-18-2009 9:09 AM
>but at program run time there are ways of creating new structures and moving data from your existing >internal table to an internal table of this structure.
How can I do it?
03-18-2009 9:13 AM
03-18-2009 9:17 AM
Hi,
You can create dynamic types and data for those types are run time.
lets assume that you have structure of some type and you have work area of that type.
DATA: lv_data type SPFLI.
DATA: lr_rtti_struc TYPE REF TO cl_abap_structdescr.
DATA: lt_comp TYPE cl_abap_structdescr=>component_table.
DATA: ls_comp LIKE LINE OF lt_comp.
DATA: lr_data TYPE REF TO data.
FIELD-SYMBOLS: <fs_data> TYPE ANY.
lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( lv_data ).
lt_comp = lr_rtti_struc->get_components( ).
"Now lets remove two fileds from the table as follows.
LOOP AT lt_comp into ls_comp.
DELETE lt_comp INDEX sy-tabix.
IF sy-tabix = 2.
EXIT. " Delete two components of the structure now lt_comp as two components less from SPFLI
ENDIF.
ENDLOOP.
CALL METHOD cl_abap_structdescr=>create
EXPORTING
p_components = lt_comp
p_strict = abap_false
RECEIVING
p_result = lr_rtti_struc.
CREATE DATA lr_data TYPE HANDLE lr_rtti_struc. "Now you have data of the new type
ASSIGN lr_data->* TO <fs_data>.
CREATE DATA lr_table LIKE STANDARD TABLE OF <fs_data>.
ASSIGN lr_table->* TO <fs_table>.
Regards,
Sesh
03-18-2009 9:09 AM
I guess there is no chance to delete the structure fields while runtime(I'm open for others suggestions as well).
We can only delete Lines with data but debugging will not allow us to temper the structure while run time.
03-18-2009 9:10 AM
Hi,
No you cannot exclude any COLUMN from Internal table in debug,you can change the order of columns in debug but not exclude them.
you can do such manipulation with rows add,remove,change...
Regards,
Neha
03-18-2009 9:28 AM
Neha,
> you can change the order of columns in debug but not exclude them.
How can I do it?
--Naveen Inuganti.
03-18-2009 9:51 AM
hi,
In debug(NEW abap debugger) go to the internal table,there on right hand side is an icon for "Services of the tool",the bottom most icon-> double click on that->Column Configuration --->Edit Order of Columns ===> here you can change there order.
regards,
neha
03-18-2009 9:56 AM
03-18-2009 9:59 AM
Hi,
yes true,but following the menu path he can explore aother options too.
regards,
neha