‎2008 Feb 06 9:55 AM
HI ,,
i have internal table with 10 fields ,
and in program based on some condition i have to add one more fields to that internal table so i mean dynamically ,
so how it is possible or not give some information abt procedure .
THX
‎2008 Feb 06 9:58 AM
‎2008 Feb 06 10:07 AM
Hi,
In case you are adding the field based on values entered in selection screen, you can use " Loop at screen" command and check for the values and then use the " Modify Internal Table" statement.
Reward if helpful.
Regards.
‎2008 Feb 06 10:15 AM
‎2008 Feb 06 10:17 AM
Hi,
try like this,
DATA: tb_seg_fcat TYPE lvc_t_fcat,
wa_seg_fcat TYPE lvc_s_fcat,
wa_dref1 TYPE REF TO data,
dy_line3 TYPE REF TO data,
dy_line2 TYPE REF TO data,
tb_edidd TYPE edidd,
wa_edidd TYPE edidd, "LIKE i_edidd,
FIELD-SYMBOLS: <itab1> TYPE STANDARD TABLE,
<wa_dref2>,
<wa_dref3>,
<fs_fval>.
Create dynamic work area and assign to FS
CREATE DATA dy_line2 LIKE LINE OF <itab>.
ASSIGN dy_line2->* TO <wa_dref2>.
**to add a field to the field catalog
wa_seg_fcat-fieldname = 'FIELDNAME'.
wa_seg_fcat-col_pos = 1.
wa_seg_fcat-ref_table = 'FIELDNAME'.
wa_seg_fcat-coltext = 'IDoc Number'.
wa_seg_fcat-outputlen = 16.
wa_seg_fcat-key = 'X'.
wa_seg_fcat-lzero = 'X'.
APPEND wa_seg_fcat TO tb_seg_fcat.
CLEAR wa_seg_fcat.
**-- Build the internal table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = tb_seg_fcat
IMPORTING
ep_table = wa_dref1.
ASSIGN wa_dref1->* TO <itab1>.
**-- Create dynamic work area and assign to FS
CREATE DATA dy_line3 LIKE LINE OF <itab1>.
ASSIGN dy_line3->* TO <wa_dref3>.
reward points if helpful
‎2008 Feb 06 10:19 AM
Hi Chaaya,
try like this,
DATA: tb_seg_fcat TYPE lvc_t_fcat,
wa_seg_fcat TYPE lvc_s_fcat,
wa_dref1 TYPE REF TO data,
dy_line3 TYPE REF TO data,
dy_line2 TYPE REF TO data,
tb_edidd TYPE edidd,
wa_edidd TYPE edidd, "LIKE i_edidd,
FIELD-SYMBOLS: <itab1> TYPE STANDARD TABLE,
<wa_dref2>,
<wa_dref3>,
<fs_fval>.
Create dynamic work area and assign to FS
CREATE DATA dy_line2 LIKE LINE OF <itab>.
ASSIGN dy_line2->* TO <wa_dref2>.
**to add a field to the field catalog
wa_seg_fcat-fieldname = 'FIELDNAME'.
wa_seg_fcat-col_pos = 1.
wa_seg_fcat-ref_table = 'FIELDNAME'.
wa_seg_fcat-coltext = 'IDoc Number'.
wa_seg_fcat-outputlen = 16.
wa_seg_fcat-key = 'X'.
wa_seg_fcat-lzero = 'X'.
APPEND wa_seg_fcat TO tb_seg_fcat.
CLEAR wa_seg_fcat.
Build the internal table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = tb_seg_fcat
IMPORTING
ep_table = wa_dref1.
ASSIGN wa_dref1->* TO <itab1>.
Create dynamic work area and assign to FS
CREATE DATA dy_line3 LIKE LINE OF <itab1>.
ASSIGN dy_line3->* TO <wa_dref3>.
reward points if helpful
‎2008 Feb 06 10:10 AM
hi
check this
/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap
‎2008 Feb 06 10:13 AM
Hello Chaaya,
Here is the excellent link for your query.
http://www.saptechnical.com/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm
Hope it is useful. But it is apart from your requirement I think. I'm sending this because you may get some idea.
Regards
--
Sasidhar Reddy Matli.