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

please validate my select stmt.

Former Member
0 Likes
1,187

Can I use for all entries IN

with offset ?

SELECT KUNNR

FROM kna1

INTO TABLE gt_kna1

FOR ALL ENTRIES IN gt_soldto

WHERE name2+7(10) = gt_bstnk_storeno_kunnr-store_no

OR j_3astcu = gt_bstnk_storeno_kunnr-store_no.

Please guide me ... I need to select where kna1-name2 ( from 7th postion onwards ) contains the internal table value

then select kunnr field from kna1.

Thanks,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,139

Really sorry

SELECT KUNNR

FROM kna1

INTO TABLE gt_kna1

FOR ALL ENTRIES IN gt_soldto

WHERE name2+7(10) = gt_soldto-store_no

OR j_3astcu = gt_soldto-store_no

Is my select stmt

10 REPLIES 10
Read only

kiran_k8
Active Contributor
0 Likes
1,139

Sam,

Your For All entries is gt_soldto internal table but the where conditions are w.r.t to something else.

K.Kiran.

Read only

Former Member
0 Likes
1,140

Really sorry

SELECT KUNNR

FROM kna1

INTO TABLE gt_kna1

FOR ALL ENTRIES IN gt_soldto

WHERE name2+7(10) = gt_soldto-store_no

OR j_3astcu = gt_soldto-store_no

Is my select stmt

Read only

0 Likes
1,139

Hmmm....

Sorry - this isn't as simple as I first thought.

The solution I was thinking of involved patterns (Which is in the HELP for SELECT). But since you are using FOR ALL ENTRIES and not SELECT-OPTIONS or a range table, that doesn't help much.

You can still use a pattern, but it will involve looping through the internal table, and changing it to a pattern and using that in the SELECT.

An alternative is native SQL, but I think the first is better.

Sorry for my confusion Mea culpa

Rob

Read only

Former Member
0 Likes
1,139

HI,

This code may help u...


FIELD-SYMBOLS: <fs> like line of gt_soldto.

LOOP AT gt_soldto assigning <fs>.
CONCATENATE '%' <fs>-store_no into <fs>-store_no.
ENDLOOP

SELECT KUNNR
FROM kna1
INTO TABLE gt_kna1
FOR ALL ENTRIES IN gt_soldto
WHERE name2 LIKE gt_soldto-store_no
OR j_3astcu = gt_soldto-store_no
.

Edited by: Sukriti Saha on Oct 4, 2008 7:20 AM

Read only

Subhankar
Active Contributor
0 Likes
1,139

Hi

You can not offset the field name in the where condition(i.e left side of operator)

WHERE name2+7(10) = gt_bstnk-store_no.............> wrong

You can use offset right side of operator

like this way matnr = i_mara-matnr+0(18).

Read only

Former Member
0 Likes
1,139

Use the following code -

In case cases you cannot use offset in select statement and hence use substr

SELECT KUNNR FROM kna1

INTO TABLE gt_kna1

FOR ALL ENTRIES IN gt_soldto

WHERE substr(name2,7,10) IN gt_bstnk_storeno_kunnr-store_no

OR j_3astcu = gt_bstnk_storeno_kunnr-store_no.

-Siddhi Daftary

Read only

Former Member
0 Likes
1,139

Why not just press F1 on SELECT?? None of the other answers here are correct. Only one approaches correctness.

Rob

Read only

Former Member
0 Likes
1,139

Yes Rob. (Yes There is no one in Performance tunning like you solve :-)....)

Yes None of the answer is correct. Your answer about correction is correct. THANK YOU!

I tried with F1 help ... it did not help much.

I saw in debugging some where ... the offset is allowed .

But I missed to copy that and to document for my reference recently. I hoped on SDN ....Still waiting for some as well as looking trying my self with F1 and all.

Did any body do this offset in SELECT.

Read only

0 Likes
1,139

After pressing F1 on SELECT, look at the portion on WHERE. (This isn't performance; it's syntax).

Rob

Read only

Former Member
0 Likes
1,139

SAM,

ur internal table is FOR ALL ENTRIES IN is "gt_soldto" ...

the table in for all entries need to be compared with in the WHERE clause..

but you where not using the internal table "gt_soldto" in your where clause..

This leads to syntax error....

It has to lead to error .. COZ, There is no meaning in having a table in FOR ALL ENTRIES without using it in where clause.....

Make an additional comaprision between the fields of "KNA1" and "gt_soldto" .. that will resolve your prob...