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 declaration

Former Member
0 Likes
660

experts

i have internal table with 10 fields itab1. now i want to add one more field in 2nd position in itab2.

aleady in the program it is decalared as

data: begin of itab occurs 0,

field1

field2

end of itab.

so how to decalre the itab2 with extra one filed at 2nd postion.

shall i need to decalre all the fileds again and insert 2nd.

data: begin of itab2 occurs 0,

field1

field2 " new filed

field3 - which is equal to field to in itab

etc

end of itab2.

or any other way to add a field with all the fields of itab in itab2.

5 REPLIES 5
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
619

Hello,

AFAIK this is not possible the way you've defined.

BR,

Suhas

Read only

sridhar_meesala
Active Contributor
0 Likes
619

Hi,

Please be more clear. What do you mean by fields? You mean columns? If it is so and you want to declare another internal table similar to itab1 exccept for the extra column in 2nd position, I guess you cannot refer to the itab1 and do that but declare a new structure with the required columns.

Thanks,

Sri.

Read only

Former Member
0 Likes
619

You can use deep structures,

But if you're trying

begin of itab2,

field1 - itab1(field1),

field2 - new field,

field3 - itab1(field2)......

Then its not possible.

You can use itab1 in itab2 in following ways:

DATA:BEGIN OF ty_message, (itab1)

count TYPE sytabix,

test type c,

bdc_messages TYPE STANDARD TABLE OF VBAK,

END OF ty_message.

DATA: Begin of all_messages,(itab2)

test2 type c,

bdc_messages1 like ty_message,(itab1)

test3 type c,

END OF all_messages.

I think this might prove usefull.

-Regards,

Rahul

Read only

Former Member
0 Likes
619

HI ,

Why dont you try splitting the internal table type into 2 parts?

Then you can add the 2nd field to the first half and then join these subsequently.

For eg:


TYPES : BEGIN OF t_itab1,
        a(3) TYPE c.
TYPES: END OF t_itab1.
TYPES:BEGIN OF t_itab2,
        b(3) TYPE c,
        c(3) TYPE c,
       END OF t_itab2.

DATA:  wa_itab1 TYPE t_itab1,
       wa_itab2 TYPE t_itab2.
TYPES : BEGIN OF t_itab3.
INCLUDE STRUCTURE wa_itab1 .
INCLUDE STRUCTURE wa_itab2.
TYPES : END OF t_itab3.

DATA:wa_itab3 TYPE t_itab3,
           i_itab3 TYPE TABLE OF t_itab3,

Read only

matt
Active Contributor
0 Likes
619

Don't use tables with header lines

Do what Rashmi R said.