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

Diffrent options of select statement...

Former Member
0 Likes
916

What are the different options for the select statement...If you could provide code samples that will be helpful...

Thanks

Jim

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
880

SELECT * FROM MARA INTO TABLE ITAB WHERE MATNR = S_MATNR

SELECT * FROM MARA INTO ITAB WHERE MATNR = S_MATNR.

WRITE : / MARA-MATNR.

ENDSELECT.

SELECT SINGLE * FROM MARA INTO TABLE ITAB WHERE

SELECT * FROM MARA INTO TABLE ITAB UPTO 1 ROWS WHERE MATNR = TERM

Regards...

Balaji (Assign pts if this helps u.............)

What are the different options for the select statement...If you could provide code samples that will be helpful...

Thanks

Jim

5 REPLIES 5
Read only

Former Member
0 Likes
880
Read only

Former Member
0 Likes
880

hi

<b>

SELECT statements

Reading Single Entries</b>

e.g. Select single * from customers

<b>Getting statistical information using max, min, avg, sum</b>

<b>Reading each line using Select ….. EndSelect</b>

e.g. Select * from Customers.

Write 😕 Customers-name

EndSelect

<b>Reading all the table entries using Select .</b>

e.g. Select * from Customers into table all_Customers

<b>FROM variants</b>

FROM <dbtabname>

... FROM <tabref1> [INNER] JOIN <tabref2> ON <cond>

... FROM <tabref1> LEFT [OUTER] JOIN <tabref2> ON <cond>

<b>SELECT INTO variants</b>

INTO <wa>

... INTO CORRESPONDING FIELDS OF <wa>

... INTO (f1, ..., fn)

... INTO TABLE <itab>

... INTO CORRESPONDING FIELDS OF TABLE <itab>

... APPENDING TABLE <itab>

... APPENDING CORRESPONDING FIELDS OF TABLE <itab>

<b>

SELECT – Loop function</b>

On change of

SELECT * FROM T100

WHERE SPRSL = SY-LANGU

AND MSGNR < '010'

ORDER BY PRIMARY KEY.

ON CHANGE OF T100-ARBGB.

ULINE.

WRITE: / '**', T100-ARBGB, '**'.

ENDON.

WRITE: / T100-MSGNR, T100-TEXT.

ENDSELECT.

regards

ravish

<b>reward points if helpful</b>

Read only

Former Member
0 Likes
880

Hi,

To compare the value of a column of any data type with another value, use the following:

<b>SELECT ... WHERE <s> <operator> <f> ...</b>

To find out whether the value of a column lies within a particular interval, use:

<b>SELECT ... WHERE <s> [NOT ] BETWEEN <f 1> AND <f 2> ...</b>

To find out whether the value of a column satisfies the conditions in a selection table, use:

<b>SELECT ... WHERE <s> [NOT ] IN <seltab> ...</b>

To find out whether the value of a column is null, use:

<b>SELECT ... WHERE <s> IS [NOT ] NULL ...</b>

The condition is true if the value of <s> is [not] null.

To negate the result of a condition, use:

<b>SELECT ... WHERE NOT <cond> ...</b>

The condition is true if <cond> is false, and false if <cond> is true. The result of an unknown condition remains unknown when negated.

You can combine two conditions into one using the AND and OR operators:

<b>SELECT ... WHERE <cond 1> AND <cond 2> ...</b>

This condition is true if < cond1 > and < cond2 > are true.

<b>SELECT ... WHERE <cond 1> OR <cond 2> ...</b>

This condition is true if one or both of < cond1 > and < cond2 > are true.

The WHERE clause of the SELECT statement has a special variant that allows you to derive conditions from the lines and columns of an internal table:

<b>SELECT ... FOR ALL ENTRIES IN <itab> WHERE <cond> ...</b>

Regards,

Padmam.

Read only

Former Member
0 Likes
881

SELECT * FROM MARA INTO TABLE ITAB WHERE MATNR = S_MATNR

SELECT * FROM MARA INTO ITAB WHERE MATNR = S_MATNR.

WRITE : / MARA-MATNR.

ENDSELECT.

SELECT SINGLE * FROM MARA INTO TABLE ITAB WHERE

SELECT * FROM MARA INTO TABLE ITAB UPTO 1 ROWS WHERE MATNR = TERM

Regards...

Balaji (Assign pts if this helps u.............)

Read only

Former Member
0 Likes
880

hi,

select single * from mara into itab where matnr = p_matnr

[for selecting a single record ]

select matnr,ernam ,ersda from mara into itab where matnr = p_matnr

[ for selecting a specified no of fields into internal table]

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

..........

endselect.

select * from mara into table itab matnr = p_matnr [for selecting all fields of database table mara into itab ]

select * from mara into corresponding fields of itab matnr = p_matnr [for selecting all fields of database table mara into corresponding fields of table itab ]

.........

if helpful reward some points.

wiht reagrds,

suresh.