Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

internal table

Former Member
0 Likes
607

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

7 REPLIES 7
Read only

Former Member
0 Likes
593

Hi,

go through this links

if they are helpful plzz reward me

Read only

Former Member
0 Likes
593

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.

Read only

0 Likes
593

Hey can u pls give me some sample code for this

Read only

0 Likes
593

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

Read only

0 Likes
593

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

Read only

Former Member
0 Likes
593

hi

check this

/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap

Read only

Former Member
0 Likes
593

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.