Application Development 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: 

CAN USE SELECT OPTION FIELD IN FOR ALL ENTRIES CONCEPT

Former Member
0 Kudos

Hi sir/ madam,

can i write code like this .

i have data in itab1 .

select-options : s_matnr like lips-matnr.

SELECT VBELN VGBEL VGPOS MATNR

FROM LIPS

INTO TABLE I_LIPS

FOR ALL ENTRIES IN ITAB1

WHERE VBELN = ITAB1-VBELN AND

MATNR = S_MATNR.

Thanks & Regards

Suresh kumar

10 REPLIES 10

Former Member
0 Kudos

Hi Suresh,

Yes. You can write the code as given with slight modification in condition for MATNR..

SELECT VBELN VGBEL VGPOS MATNR

FROM LIPS

INTO TABLE I_LIPS

FOR ALL ENTRIES IN ITAB1

WHERE VBELN = ITAB1-VBELN AND

MATNR <b>IN</b> S_MATNR

<b>Reward points for informative answers.</b>

Best Regards,

Ram.

Former Member
0 Kudos

select-options : s_matnr like lips-matnr.

SELECT VBELN VGBEL VGPOS MATNR

FROM LIPS

INTO TABLE I_LIPS

FOR ALL ENTRIES IN ITAB1

WHERE VBELN = ITAB1-VBELN AND

MATNR IN S_MATNR. " Changed '=' with 'IN'

Reward points if useful

Former Member
0 Kudos

Hi

You can use like this, nothing wrong from syntax point of view

but data point of view you have to see

first fetch the data into ITAB1 using the S_MATNR in the where clause of that ITAB1 selection and then use ITAB1-MATNR in this select.

It is better to validate the data based on select options in the first select then use for all entries.

<b>Reward points for useful Answers</b>

Regards

Anji

Former Member
0 Kudos

Hi,

you can use the Select-option field in the for all entries

select-options : s_matnr like lips-matnr.

SELECT VBELN VGBEL VGPOS MATNR

FROM LIPS

INTO TABLE I_LIPS

FOR ALL ENTRIES IN ITAB1

WHERE VBELN = ITAB1-VBELN AND

MATNR IN S_MATNR.

Thanks & Regards

Sudheer

former_member208856
Active Contributor
0 Kudos

Hi,

You can use this statement.

Try to use all Key fields in your select statement as POSNR is also a key field, please use that for correct data fatching.

Sandeep Kaushik

Former Member
0 Kudos

hi suresh,

the query will be like this,

IF NOT itab[] IS INITIAL.

SELECT VBELN VGBEL VGPOS MATNR

FROM LIPS

INTO TABLE I_LIPS

FOR ALL ENTRIES IN ITAB1

WHERE VBELN = ITAB1-VBELN AND

MATNR IN S_MATNR.

ENDIF.

u can use it...just check before that query whether it is not initilal...

hope this may help u,

please reward in case usefull...

regards,

prashant

Former Member
0 Kudos

Hi....

Since Select Option is like a semi internal table you cannot use the comparison operator = in this case (MATNR = S_MATNR.)

In place of '=' u will have to use <b>IN</b> Operator as shown below:

SELECT VBELN

VGBEL

VGPOS

MATNR

FROM LIPS

INTO TABLE I_LIPS

FOR ALL ENTRIES IN ITAB1

WHERE VBELN = ITAB1-VBELN AND

MATNR <b>IN</b> S_MATNR.

Pablo

Reward if helpful...

Former Member
0 Kudos

Hi

you can write this code no problem with that

if ur client requremenr is for that value in t hat query

then u can use there won't be any problem

reward if usefull

SuhaSaha
Advisor
Advisor
0 Kudos

Hi Suresh,

To correct ur code syntactically, repacle the

=

operator with

IN

. This may be correct but from data consistency point of view this may not be the ideal thing to do.

You can foolow thw following steps:

1. Fetch data in ITAB1 using the MATNR in the select-option. I hope you do have

MATNR in ITAB1.

2.

SELECT VBELN VGBEL VGPOS MATNR
FROM LIPS
INTO TABLE I_LIPS
FOR ALL ENTRIES IN ITAB1
WHERE VBELN = ITAB1-VBELN AND
MATNR = ITAB1-MATNR.

This should be correct form data consistency view-point.

Hope this answers ur query. Please award points if u find the answer helpful.

Regards,

Suhas

Former Member
0 Kudos

Hi ,

Read this once...

FOR ALL ENTRIES works with the database on the basis of sets. Data is initially

collected in an internal table. You need to evaluate the value of SY-SUBRC after

every SELECT statement. If the result of the first array fetch does not return any

data, the subsequent SELECT statements retrieve all entries from the database.

SELECT...FOR ALL ENTRIES IN <itab> is usually mapped to a

SELECT statement with an external OR condition (depending on the optimizer and

profile parameters). The system selects only the table entries that fulfill the logical

condition (WHERE carrid = itab_sflight-carrid), and replaces the

placeholders (itab_spfli-carrid) with values from every entry in the

internal table itab_spfli when doing so. Note that itab_spfli-carrid

is a placeholder and not part of the internal table. Duplicates are excluded using

DELETE ADJACENT DUPLICATES. The internal table can, in principle, be

as large as you want it to be.

Using FOR ALL ENTRIES is recommended when data is not being read from

the database, that is, it is already available in the program, for example if the user

has input the data. Otherwise a join is recommended.