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

Difference between SELECT Statement in MPP and Report Program

Former Member
0 Likes
949

Hi all,

Being new to abap I am pondering over the difference in SELECT statement in MPP and Report Program.

I am using SELECT Statement:

SELECT SINGLE * FROM Ztable where A1 = wa_itab-A1 AND A2 = wa_itab-A2 AND K1 = wa_itab-K1.

IF sy-subrc = 4.

----------------------

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

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

ENDIF.

In MPP the above syntax works but why doesn't the above statement works in Report Program. I get errors like.

" A target area must be defined either explicitly with INTO clause or implicitly with a TABLES statement."

Purpose: The purpose of the above syntax in MPP and Report Progg is to do a check if the data of itab exists in DB table: Ztable or not.

Cab any1 help in understaing the difference in use of SELECT in MPP and in Repost Progg and Why?

Regards

Chandan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
882

Hi Mr. Chandan

If you are using

SELECT SINGLE * FROM Ztable where A1 = wa_itab-A1 AND A2 = wa_itab-A2 AND K1 = wa_itab-K1.

this one you should define ZTABLE i.e.

TABLES: ztable.

regards.

laxman

6 REPLIES 6
Read only

Former Member
0 Likes
883

Hi Mr. Chandan

If you are using

SELECT SINGLE * FROM Ztable where A1 = wa_itab-A1 AND A2 = wa_itab-A2 AND K1 = wa_itab-K1.

this one you should define ZTABLE i.e.

TABLES: ztable.

regards.

laxman

Read only

rajkumarnarasimman
Active Contributor
0 Likes
882

Hi Chandan,

As per my understanding, if we are using select statement, the data is fetched from database and we will store the value in some variable which is fetched.

In Read statement, it is not necessary, we can use 'TRANSPORTING NO FIELDS'.

So it is required to mention the INTO <variable_name> in select statement.

"Data Declarations

data: wa_ztable type ztable.

SELECT SINGLE * FROM Ztable into ztable where A1 = wa_itab-A1 AND A2 = wa_itab-A2 AND K1 = wa_itab-K1.

Please do correct me, if i am wrong.

Regards

Rajkumar Narasimman

Read only

0 Likes
882

Hi Mr. Rajkumar..

You are correct..But you can write like below also..

TABLES: Ztable.

SELECT SINGLE * FROM Ztable into ztable where A1 = wa_itab-A1 AND A2 = wa_itab-A2 AND K1 = wa_itab-K1.


Here ztable works like work area, in ZTABLE you wil have one record.


regards.

laxman

Read only

0 Likes
882

Hi Lakman,

Thank you for sharing the coding. I hope, if we mention as Header line, it is not required to mention INTO <VARIABLE>

REPORT  ZSELECT_STMT_01.

TABLES: ZSMARTFORM_LIST.

DATA: wl_form type TABLE OF ZSMARTFORM_LIST WITH HEADER LINE.

SELECT SINGLE * FROM ZSMARTFORM_LIST.

Regards

Rajkumar Narasimman.

Read only

0 Likes
882

Hi Laxman,

                yes i agree.. if we declare tables it will work like work area,it will hold one row of values.

Regards,

Thanagm.P

Read only

0 Likes
882

No need of declaring header line part..

REPORT  ZSELECT_STMT_01.

TABLES: ZSMARTFORM_LIST.

SELECT SINGLE * FROM ZSMARTFORM_LIST.


this enough now in ZSMARTFORM_LIST you wil have one record.

check once. i have checked it.

if its wrong tel me.


regards.

laxman.