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: 

Problem with FOR ALL ENTRIES IN

Former Member
0 Kudos

This is my simple source code.

TABLES: stpo.

DATA: t_stpo LIKE stpo OCCURS 0 WITH HEADER LINE,

t_stpo_itm LIKE stpo OCCURS 0 WITH HEADER LINE,

t_stpo-stlnr = '00000058'.

t_stpo-stlkn = '00000003'.

append t_stpo.

t_stpo-stlnr = '00000058'.

t_stpo-stlkn = '00000007'.

append t_stpo.

SELECT * FROM stpo INTO TABLE t_stpo_itm

FOR ALL ENTRIES IN t_stpo

WHERE stlnr = t_stpo-stlnr " BOM No.

AND stlkn <> t_stpo-stlkn. " BOM item node number

-


The output from this source including BOM item node number 00000003, 00000007 but at SQL stlkn <> t_stpo-stlkn doesn't effected.

Could Anyone please tell me why?

Are there something wrong?

Thank you in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Tiwa,

I think the result is good.

At the first loop you got 00000058 / 00000003 in your 'stpo' table so you retrieve ( following your 'where clause' ) the 0000000058 / 000000007 record .

At the 2nd loop you got 00000058 / 00000007 in your 'stpo' table so you retrieve the 0000000058 / 000000003 record .

The result is correct.

Regards,

Erwan

9 REPLIES 9

Former Member
0 Kudos

Why dont you try just ;

t_stpo-stlnr = '00000058'.

append t_stpo.

t_stpo-stlnr = '00000058'.

append t_stpo.

SELECT * FROM stpo INTO TABLE t_stpo_itm

FOR ALL ENTRIES IN t_stpo

WHERE stlnr = t_stpo-stlnr " BOM No.

AND stlkn <> '00000003'

and stlkn <> '00000007' .

0 Kudos

Thanks for your answer, I know that I can use the code like your.

I just wonder why FOR ALL ENTRIES IN can't give me an output that should be.

Former Member
0 Kudos

Hi,

You can also Use ranges for Stlnr and Stlkn fields, instead of int table.

TABLES: stpo.

DATA: begin of t_stpo OCCURS 0.

stlnr like stpo-stlnr,

stlkn like stpo-stlkn,

end of t_stpo.

data t_stpo_itm LIKE stpo OCCURS 0 WITH HEADER LINE.

t_stpo-stlnr = '00000058'.

t_stpo-stlkn = '00000003'.

append t_stpo.

clear t_stpo.

t_stpo-stlnr = '00000058'.

t_stpo-stlkn = '00000007'.

append t_stpo.

clear t_stpo.

if not t_stpo[] is initial.

SELECT * FROM stpo INTO TABLE t_stpo_itm

FOR ALL ENTRIES IN t_stpo

WHERE stlnr = t_stpo-stlnr " BOM No.

AND stlkn <> t_stpo-stlkn. " BOM item node number

endif.

or you can simply write a select for STPO like this:

SELECT * FROM stpo INTO TABLE t_stpo_itm

WHERE stlnr = '00000058' " BOM No.

AND ( stlkn <> '00000007' or stlkn <> '00000003' ). " BOM item node number

regards,

Anji

Former Member
0 Kudos

SELECT * FROM stpo INTO TABLE t_stpo_itm

FOR ALL ENTRIES IN t_stpo

WHERE stlnr = t_stpo-stlnr " BOM No.

AND NOT stlkn = t_stpo-stlkn. " BOM item node number

TRY THIS IT MAY HELP YOU...

REGARDS

SHIBA DUTTA

Former Member
0 Kudos

PARAMETERS p_city TYPE spfli-cityfrom.

TYPES: BEGIN OF entry_tab_type,

carrid TYPE spfli-carrid,

connid TYPE spfli-connid,

END OF entry_tab_type.

DATA: entry_tab TYPE TABLE OF entry_tab_type,

sflight_tab TYPE SORTED TABLE OF sflight

WITH UNIQUE KEY carrid connid fldate.

SELECT carrid connid

FROM spfli

INTO CORRESPONDING FIELDS OF TABLE entry_tab

WHERE cityfrom = p_city.

SELECT carrid connid fldate

FROM sflight

INTO CORRESPONDING FIELDS OF TABLE sflight_tab

FOR ALL ENTRIES IN entry_tab

WHERE carrid = entry_tab-carrid AND

connid ne '005'.

write 'sunil'.

see this is working if u have any more call me

Former Member
0 Kudos

hI..

IF YOU DON'T HAVE ANY DTA FROM THE 1ST SELECT...

THEN IT WILL FETCJH ALL THE RECORDS INT THE SECOND SELECT...

IT WILL IGNORE THE WHERE CONDITIONS...

SO MAKE SURE THAT THE 1ST QUERY IS GETTING SOME DATA...THEN ONLY IT WORKS..

FOR ALL ENTRIES..WILL NOT WORK WELL FOR INITIAL TABLE

former_member582701
Contributor
0 Kudos

Conditions with <> penalize the performance.

Better do this code:

SELECT * FROM stpo INTO TABLE t_stpo_itm

FOR ALL ENTRIES IN t_stpo

WHERE stlnr = t_stpo-stlnr

DELETE t_stpo_itm WHERE stlkn = 00000003 AND stlkn = 00000007

Former Member
0 Kudos

Hi Tiwa,

I think the result is good.

At the first loop you got 00000058 / 00000003 in your 'stpo' table so you retrieve ( following your 'where clause' ) the 0000000058 / 000000007 record .

At the 2nd loop you got 00000058 / 00000007 in your 'stpo' table so you retrieve the 0000000058 / 000000003 record .

The result is correct.

Regards,

Erwan

Former Member
0 Kudos

hi,

Before using the for all entries,first check the internal to be used in for all entries is having entries or not.if it is not having entries...it will satisfy the condition.

thanks & regards,

sangeetha.a