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

moving data into internal table without header line

Former Member
0 Likes
3,635

Hello experts.

i have two internal tables . itab1 without headerline and itab2 with headerline. itab1 has 10 fields and itab2 has 2 fields.

BEGIN OF itab,

lifnr LIKE lfa1-lifnr,

ktokk LIKE lfa1-ktokk,

name1 LIKE lfa1-name1,

sortl LIKE lfa1-sortl,

pstlz LIKE lfa1-pstlz,

ort01 LIKE lfa1-ort01,

land1 LIKE lfa1-land1,

j_1ipanno LIKE j_1imovend,

end of itab.

DATA: itab1 TYPE STANDARD TABLE OF itab.

data: begin of itab2 occurs 0,

lifnr like j_1imovend-lifnr,

j_1ipanno like j_1imovend-j_1ipanno,

end of itab2.

now i want to move the data from itab2-j_1ipanno into itab1-j_1ipanno. so pls tell me how to do that. lifnr in both the tables are the same.

thanks for all the replies.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,357

Hi Shiva,

In with out header line,

You declare header line & body separately like

data: IT_MARA type standard table of MARA,

WA_MARA like line of IT_MARA.

Advantages:

1. Clear differentiation of header line over body

2. It is must in the ABAP Objects to have separate header line & body

3. Use ful in Nested Internal tables

Disadvantages:

1. Long syntax

for example: Loop at IT_MARA into WA_MARA.

In with header line

Data ITAB like MARA occurs 0 with header line.

Advantages:

1. Simple to use & declare over without header line.

Also,

With Header line:

codedata : itab like <dbtable> occurs 0 with header line.

Data: begin of itab occurs 0,

f1 type f1,

f2 type f2,

end of itab.[/code]

Without Header line.

codeTypes: begin of ty_tab,

f1 type f1,

f2 type f2,

end of ty_tab.

Data: itab type table of ty_tab, " Internal Table

wa type ty_tab. " Work Area[/code]

at any point of time use internal table without header line,it will be good performance as well OO ABAP will allow only internal table without header line.

Just use one simple example :

create one simple program with header line,use get run time field.

create one simple program without header line,use get run time field.

see the results ,here time will be micro seconds,so take 1000 records to internal table and do calculate the time.

***********************************

While adding or retrieving records to / from internal table we have to keep the record temporarily.

The area where this record is kept is called as work area for the internal table. The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.

Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.

e.g.

data: begin of itab occurs 10,

ab type c,

cd type i,

end of itab. " this table will have the header line.

data: wa_itab like itab. " explicit work area for itab

data: itab1 like itab occurs 10. " table is without header line.

The header line is a field string with the same structure as a row of the body, but it can only hold a single row.

It is a buffer used to hold each record before it is added or each record as it is retrieved from the internal table. It is the default work area for the internal table.

kindly reward if found helpful.

cheers,

Hema.

3 REPLIES 3
Read only

Former Member
0 Likes
1,358

Hi Shiva,

In with out header line,

You declare header line & body separately like

data: IT_MARA type standard table of MARA,

WA_MARA like line of IT_MARA.

Advantages:

1. Clear differentiation of header line over body

2. It is must in the ABAP Objects to have separate header line & body

3. Use ful in Nested Internal tables

Disadvantages:

1. Long syntax

for example: Loop at IT_MARA into WA_MARA.

In with header line

Data ITAB like MARA occurs 0 with header line.

Advantages:

1. Simple to use & declare over without header line.

Also,

With Header line:

codedata : itab like <dbtable> occurs 0 with header line.

Data: begin of itab occurs 0,

f1 type f1,

f2 type f2,

end of itab.[/code]

Without Header line.

codeTypes: begin of ty_tab,

f1 type f1,

f2 type f2,

end of ty_tab.

Data: itab type table of ty_tab, " Internal Table

wa type ty_tab. " Work Area[/code]

at any point of time use internal table without header line,it will be good performance as well OO ABAP will allow only internal table without header line.

Just use one simple example :

create one simple program with header line,use get run time field.

create one simple program without header line,use get run time field.

see the results ,here time will be micro seconds,so take 1000 records to internal table and do calculate the time.

***********************************

While adding or retrieving records to / from internal table we have to keep the record temporarily.

The area where this record is kept is called as work area for the internal table. The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.

Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.

e.g.

data: begin of itab occurs 10,

ab type c,

cd type i,

end of itab. " this table will have the header line.

data: wa_itab like itab. " explicit work area for itab

data: itab1 like itab occurs 10. " table is without header line.

The header line is a field string with the same structure as a row of the body, but it can only hold a single row.

It is a buffer used to hold each record before it is added or each record as it is retrieved from the internal table. It is the default work area for the internal table.

kindly reward if found helpful.

cheers,

Hema.

Read only

Former Member
0 Likes
1,357

Hi,

try this.

Loop at itab2.

MOVE-CORRESPONDING itab2 TO ls_itab1.

append ls_itab1 to itab1.

endloop.

Read only

Former Member
0 Likes
1,357

Hi,

Data: wa_itab1 like line of itab1.

loop at itab2.

wa_itab1-j_1ipanno = itab2-j_1ipanno.

append itab1 from wa_itab1.

clear wa_itab1.

endloop.

Hope this will guide you.

Jogdand M B