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

HEADER statements

Former Member
0 Likes
594

Hi guys,

can any one of u tell me watz the difference between

WITH HEADER LINE & WITHOUT HEADER LINE

and also give a statement on sorted table and its functionality

regards

venu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
562

Check the below links and example programs:

http://sap.mis.cmich.edu/sap-abap/abap04/sld013.htm

http://sap.mis.cmich.edu/sap-abap/abap04/sld012.htm

Internal table with header line

here i am using get time field command ,so use both program and see comparision time

report zxyz.

  • Internal table with header line.

DATA:BEGIN OF itab OCCURS 0,

lifnr LIKE lfa1-lifnr,

name1 LIKE lfa1-name1,

END OF itab.

data : f1 type i,

f2 type i,

f3 type i.

start-of-selection.

get run time field f1.

SELECT lifnr name1 FROM lfa1 INTO TABLE itab up to 200 rows.

loop at itab.

endloop.

get run time field f2.

f3 = f2 - f1 .

write 😕 'Time taken by query in Micro seconds', f3.

Internal table without header line

report zxyz1.

  • Internal table without header line.

types : begin of ty_itab ,

lifnr LIKE lfa1-lifnr,

name1 LIKE lfa1-name1,

end of ty_itab.

data itab type standard table of ty_itab.

data wa_itab like line of itab.

data : f1 type i,

f2 type i,

f3 type i.

start-of-selection.

get run time field f1.

SELECT lifnr name1 FROM lfa1 INTO TABLE itab up to 200 rows.

loop at itab into wa_itab.

endloop.

get run time field f2.

f3 = f2 - f1 .

write 😕 'Time taken by query in Micro seconds', f3.

Thanks

Seshu

4 REPLIES 4
Read only

Former Member
0 Likes
562

If an internal table has a header, you can LOOP AT it directly. If it has none, you have to LOOP AT itab INTO work_area and then work with the contents of the work area.

You can also use field symbols to work with the contents of either type of table.

Rob

Read only

Former Member
0 Likes
563

Check the below links and example programs:

http://sap.mis.cmich.edu/sap-abap/abap04/sld013.htm

http://sap.mis.cmich.edu/sap-abap/abap04/sld012.htm

Internal table with header line

here i am using get time field command ,so use both program and see comparision time

report zxyz.

  • Internal table with header line.

DATA:BEGIN OF itab OCCURS 0,

lifnr LIKE lfa1-lifnr,

name1 LIKE lfa1-name1,

END OF itab.

data : f1 type i,

f2 type i,

f3 type i.

start-of-selection.

get run time field f1.

SELECT lifnr name1 FROM lfa1 INTO TABLE itab up to 200 rows.

loop at itab.

endloop.

get run time field f2.

f3 = f2 - f1 .

write 😕 'Time taken by query in Micro seconds', f3.

Internal table without header line

report zxyz1.

  • Internal table without header line.

types : begin of ty_itab ,

lifnr LIKE lfa1-lifnr,

name1 LIKE lfa1-name1,

end of ty_itab.

data itab type standard table of ty_itab.

data wa_itab like line of itab.

data : f1 type i,

f2 type i,

f3 type i.

start-of-selection.

get run time field f1.

SELECT lifnr name1 FROM lfa1 INTO TABLE itab up to 200 rows.

loop at itab into wa_itab.

endloop.

get run time field f2.

f3 = f2 - f1 .

write 😕 'Time taken by query in Micro seconds', f3.

Thanks

Seshu

Read only

ferry_lianto
Active Contributor
0 Likes
562

Hi,

TABLE WITH HEADER LINE:

Data can be directly go to header first and will be placed in body when we used APPEND statement. It can not be used for nesting of internal tables.

example:

data: itab like mara occurs 0 with header line.

or

itab like standard table of ekko with header line.

then itab is a internal with header line so u can use itab directly.

example:

select * from itab INTO TABLE itab where matnr in p_matnr.

loop at itab.

write:/10 itab-fld1.

...

endloop.

TABLE WITHOUT HEADER LINE:

For this table, we need to create a explicit header [workarea] and doing anything for data should be through that explicit header only.

example:

data: itab like mara,

wa like mara.

itab is a internal table without header line [only body] and wa is the explicit workarea. For this itab when you want to populate data you have to do like this.

select * from mara into wa where mantr in p_matnr.

append itab from wa.

endselect.

For accessing data of internal table

loop at itab into wa.

write:/10 wa-fld1,

...

endloop.

Sorted tables are always saved correctly sorted by key. They also have a linear key, and, like standard tables, you can access them using either the table index or the key. When you use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique, or non-unique, and you must specify either UNIQUE or NON-UNIQUE in the table definition. Standard tables and sorted tables both belong to the generic group index tables.

This table type is particularly suitable if you want the table to be sorted while you are still adding entries to it. You fill the table using the (INSERT) statement, according to the sort sequence defined in the table key. Table entries that do not fit are recognised before they are inserted. The response time for access using the key is in logarithmic relation to the number of

table entries, since the system automatically uses a binary search. Sorted tables are appropriate for partially sequential processing in a LOOP, as long as the WHERE condition contains the beginning of the table key.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
562

Hi,

As u know Internal Table is temporary storage structure which holds the records while program running. This I.T can declare BODY with/without HEADER.

<b>HEADER</b> is nothing but Field String or Work Area contains similar structure of BODY which it HOLD ONE record only.

<b>BODY</b> can HOLD MULTIPLE records containing similar structure.

<b>Conclusion :</b> BODY contains multiple records and HEADER contains one record.

<b>Syntax</b>

<b>with header :</b>

DATA itab like mara occurs 0 with header line.

if you want declare i.t with required fields instead of all fileds

DATA begin of itab occurs 0,

matnr type matnr,

bukrs type bukrs,

.............

.......

END of itab.

<b>without header :</b>

DATA itab like mara occurs 0 .

if you want declare i.t with required fields instead of all fileds

DATA begin of itab1 ,

matnr type matnr,

bukrs type bukrs,

.............

.......

END of itab1.

DATA itab like itab1 occurs 0.

<b>Reward with points if helpful.</b>

Regards,

Vijay