06-17-2009 9:29 PM
Hi Guys,
I have a selection screen with input as TABLE.
TYPES: BEGIN OF ty_dyn.
INCLUDE STRUCTURE (Selection-Screen Table).
TYPES: END OF ty_dyn.
My requirement is if I enter the Table name as KNA1 in Selection Screen,My Include structure should be KNA1.
What should I do?
Thanks,
Prasad.
06-17-2009 9:42 PM
You need to use the RTTS - Run Time Type Services to get your type created at runtime.
Check this: http://help-abap.blogspot.com/2008/09/dynamic-internal-table-creation.htm
Regards,
Naimesh Patel
06-17-2009 9:42 PM
You need to use the RTTS - Run Time Type Services to get your type created at runtime.
Check this: http://help-abap.blogspot.com/2008/09/dynamic-internal-table-creation.htm
Regards,
Naimesh Patel
06-17-2009 9:46 PM
Hi Patel,
This is about creation of Dynamic ITAB.
I want Dynamic Structure.
Thanks,
prasad.
Edited by: Dheeru Prasad on Jun 17, 2009 10:52 PM
06-17-2009 9:56 PM
If you are on a newer release, you can use the RTTS to create an internal table and work area dynamically. You should not try to be create dynamic TYPE statements.
data: lo_dataref type ref to data.
PARAMETERS: p_table type char20.
FIELD-SYMBOLS: <lt_tab> type table.
FIELD-SYMBOLS: <ls_tab> type any.
*Create an internal table
create data lo_dataref type table of (p_table).
ASSIGN lo_dataref->* to <lt_tab>.
*create a work area
create data lo_dataref like line of <lt_tab>.
ASSIGN lo_dataref->* to <ls_tab>.
Regards,
Rich Heilman
06-17-2009 9:58 PM
So if you just want a structure(or work area) then you can do this. <LS_TAB> would be your dynamic structure
data: lo_dataref type ref to data.
PARAMETERS: p_table type char20.
FIELD-SYMBOLS: <ls_tab> type any.
*create a work area
create data lo_dataref type (p_table).
ASSIGN lo_dataref->* to <ls_tab>.
Regards
Rich Heilman
06-17-2009 10:14 PM
Hi Rich,
Thanks for your help.
How can I assign another table field values to this work area.
I mean
<ls_tab>-kunnr = kna1-kunnr.
When I am declaring this I am getting error like
The data object <ls_tab> has no structure and there fore
has no component called kunnr
Can you explain it.
Thanks,
Prasad.
06-17-2009 10:16 PM
06-17-2009 10:39 PM
Hi Rich,
Actually it will not be kunnr.
It will be fields of any table which is coming from selection field.
so how to map all the fields of that Dynamic table to our created dynamic <ls_tab>.
Thanks,
Prasad.
06-17-2009 10:53 PM
Rich,
Thanks a lot.
I got that resolved.
I need a small advise from you.
Where to get a good documentation of this classes & objects how to declare objects like itabs and workarea some thing like this stuff.
Thanks,
Prasad.