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

Syntax of internal table

Former Member
0 Likes
1,214

Hi experts,

What is the difference between the following 2 syntax:

data: lt_vbak like table of vbak.

data: ls_vbak like vbak.

I will reward all the helpful answers.

Thanks,

Ajay.

1 ACCEPTED SOLUTION
Read only

venkat_o
Active Contributor
0 Likes
1,168

Hi Ajay,

data: lt_vbak like table of vbak.
Means defining one internal table lt_vabk with structure of VBAK which has been defined in the Dictionary.
data: ls_vbak like vbak.
Means defining one structure or work area with structure of VBAK which has been defined in the Dictionary. I hope that it helps u. Regards, Venkat.O

Hi experts,

What is the difference between the following 2 syntax:

data: lt_vbak like table of vbak.

data: ls_vbak like vbak.

I will reward all the helpful answers.

Thanks,

Ajay.

7 REPLIES 7
Read only

venkat_o
Active Contributor
0 Likes
1,169

Hi Ajay,

data: lt_vbak like table of vbak.
Means defining one internal table lt_vabk with structure of VBAK which has been defined in the Dictionary.
data: ls_vbak like vbak.
Means defining one structure or work area with structure of VBAK which has been defined in the Dictionary. I hope that it helps u. Regards, Venkat.O

Read only

Former Member
0 Likes
1,168

Hello Venkat,

From your reply it seems that the following 2 syntax:

data: ls_vbak like vbak.

&

data: ls_vbak like line of vbak.

are same?

Is it true?

Thanks,

Ajay.

Read only

venkat_o
Active Contributor
0 Likes
1,168

No Ajay. Both syntax are not same. You have to write like below.

DATA: ls1_vbak LIKE vbak.

DATA: lt_vbak LIKE TABLE OF vbak.
DATA: ls2_vbak LIKE LINE OF lt_vbak.
Above statements syntax correct. But ls1_vbak and ls2_vbak structures are same. Regards, Venkat.O

Read only

Former Member
0 Likes
1,168

Thanks a lot Venkat.

My confusion is removed.

Read only

Former Member
0 Likes
1,168

Hi ,

data: lt_vbak like table of vbak.

This will create an internal table without header line.

data: ls_vbak like vbak.

This will create only work area or structure.

Regards,

Nishant

Read only

Former Member
0 Likes
1,168

Hi ajay,

the first statement

data: lt_vbak like table of vbak.

declares a table lt_vbak having the same structure as vbak

the second statement

data: ls_vbak like vbak.

will not create a table,instead it will create a work area/headerline (a table line) having the same structure of vbak

Read only

rakesh_kumar
Advisor
Advisor
0 Likes
1,168

Dear Ajay,

The first statement creates an internal table without header line where every row is of same type as VBAK.

The second statement creates a structured variable which has the same type as VBAK.

Internal table is a variable in ABAP program and denotes an array where each element has the same type and structure as VBAK.

(VBAK is a database table and referring to VBAK in ABAP only refers to the structure of VBAK's one row, not the array/ complete table in the database)

Regards, Rakesh