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

Displaying internal table data with out using Wor Area & Header Line?

former_member209120
Active Contributor
0 Likes
3,078

Dear experts,

Why we need to use work area to display internal table, why not with out using work area or header line?

With work are WA it works.

Data : it_sflight type TABLE OF sflight,
        wa_sflight type sflight.

select * from sflight into table it_sflight up to 10 rows.
Loop at it_sflight into wa_sflight.
   write 😕 wa_sflight-carrid.
endloop.


Why this code not works


Data : it_sflight type TABLE OF sflight. 
select * from sflight into table it_sflight up to 10 rows.
write 😕 it_sflight-carrid.

Thanks in advance....

Moderator message - Please search the forums for available content. Thread locked.


Message was edited by: Suhas Saha

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,767

Hi Ramesh,

In all programming languages using variable only they will display the data.

Data should be stored/pointed in variable. Workarea is collection of data (i.e structure will hold the many values).

Why this code not works


Data : it_sflight type TABLE OF sflight. 
select * from sflight into table it_sflight up to 10 rows.
write 😕 it_sflight-carrid.

WRITE keyword functionality will be programmed in kernel level by SAP it will display only variable/structure type value, but it_sflight is a table type.

As of now in ABAP language there is no keyword to display the all the values from internal table.

Hope this will be helpful for you

Regards,

Prasanna

Dear experts,

Why we need to use work area to display internal table, why not with out using work area or header line?

With work are WA it works.

Data : it_sflight type TABLE OF sflight,
        wa_sflight type sflight.

select * from sflight into table it_sflight up to 10 rows.
Loop at it_sflight into wa_sflight.
   write 😕 wa_sflight-carrid.
endloop.


Why this code not works


Data : it_sflight type TABLE OF sflight. 
select * from sflight into table it_sflight up to 10 rows.
write 😕 it_sflight-carrid.

Thanks in advance....

Moderator message - Please search the forums for available content. Thread locked.


Message was edited by: Suhas Saha

7 REPLIES 7
Read only

venkateswaran_k
Active Contributor
0 Likes
1,767

If you OCCURS clause, probably you may not use the Work Area.

Example:

DATA BEGIN OF it_sfligtht OCCURS n.

  ... include the sflight structure here.....

DATA END OF it_sflight

Read only

0 Likes
1,767

Hi,

If we use begin of ...occurs... there is an implicit work area which is being created with the same name as that of the internal table.

Regards,

Philip.

Read only

Former Member
0 Likes
1,768

Hi Ramesh,

In all programming languages using variable only they will display the data.

Data should be stored/pointed in variable. Workarea is collection of data (i.e structure will hold the many values).

Why this code not works


Data : it_sflight type TABLE OF sflight. 
select * from sflight into table it_sflight up to 10 rows.
write 😕 it_sflight-carrid.

WRITE keyword functionality will be programmed in kernel level by SAP it will display only variable/structure type value, but it_sflight is a table type.

As of now in ABAP language there is no keyword to display the all the values from internal table.

Hope this will be helpful for you

Regards,

Prasanna

Read only

NAeda
Contributor
0 Likes
1,767

Hi Ramesh,

Please go throgh these links get the concepts of Internal table and work area.

http://help.sap.com/saphelp_nw2004s/helpdata/EN/fc/eb367a358411d1829f0000e829fbfe/content.htm

http://scn.sap.com/thread/501035

Thank you.

Read only

philipdavy
Contributor
0 Likes
1,767

The purpose of internal table(body) is to hold the data. The writing, modifying, inserting, deleting all operations are carried out through the work area or header line.

Regards,

Philip.

Read only

Former Member
0 Likes
1,767

Hi Ramesh,

WRITE statement writes the content of the data object dobj to the current page of the current list in the list buffer.

it_sflight-carrid does not refer to the data object, instead refers to the table's field.

In case you define the table it_sflight WITH HEADER LINE then a header it_slight is created, which if contains any value would be displayed.

But in this case, the content it_sflight is filled in the table and nothing is filled in the header area yet and hence nothing will be displayed in the WRITE statement.

Data : it_sflight type TABLE OF sflight WITH HEADER LINE.

select * from sflight into table it_sflight up to 10 rows.

READ TABLE it_sflight WITH INDEX 1.

write 😕 it_sflight-carrid.

In this case, first record of it_sflight is updated into the header which displays that records value.

Hope the explanation helps.

Regards,

Adithi

Read only

Former Member
0 Likes
1,767

Hi Ramesh,

Any table will need to be processed from start to end to read each record at a time.

Well you can use SELECT .. ENDSELECT to write data without itab.

Like:

DATA : wa_sflight type sflight. 
select * from sflight into wa_sflight up to 10 rows.
write 😕 wa_sflight-carrid.

endselect.

But this will do a LOOP ENDLOOP kind of iteration at database level.

Regards