‎2014 Jul 28 11:47 AM
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
‎2014 Jul 28 11:58 AM
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
‎2014 Jul 28 11:58 AM
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
‎2014 Jul 28 12:04 PM
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
‎2014 Jul 28 12:08 PM
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
‎2014 Jul 28 12:17 PM
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.
‎2014 Jul 28 12:18 PM
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
‎2014 Jul 28 12:23 PM
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.