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: 

For all entries changes the order of the itab

Former Member
0 Kudos
2,371

Hi Experts

In the following query i have used two internal tables namely it_first and it_zlist.

The material inwhich the it_zlist is different sorting order

After executing this query, the order of the material inwhich the it_first is different from the it_zlist.

What could be the reason, pls explain me on this.

select matnr test zsno ztnam from zmaster1

into corresponding fields of table it_first

for all entries in it_zlist

where matnr = it_zlist-matnr.

Thanks in advance.

Regards

Rajaram

1 ACCEPTED SOLUTION

Former Member
0 Kudos
231

HI,

Based on matnr, test, zsno, ztnam fields the for all entries statement sort the internal table it_first and also do the delete adjacent duplicates from it_first.

cheers,

Bujji

11 REPLIES 11

Former Member
0 Kudos
232

HI,

Based on matnr, test, zsno, ztnam fields the for all entries statement sort the internal table it_first and also do the delete adjacent duplicates from it_first.

cheers,

Bujji

0 Kudos
231

instead of for all entries, what else we can try to obtain this situation.

0 Kudos
231

Hi Raja,

you can define your internal table as SORTED TABLE ... WITH UNIQUE KEY ...

Kind regards,

Clemens Li

0 Kudos
231

why not use 'order by' option?

just like this:

select matnr test zsno ztnam from zmaster1

into corresponding fields of table it_first

for all entries in it_zlist

where matnr = it_zlist-matnr

order by field1 field2 .....

here field1,field2... is the sort field you want.

0 Kudos
231

No i dont want to sort anything in this, my problem is its sorting the values.

need to avoid the sorting.

0 Kudos
231

It will sort the itab no, actually my problem is its sorting the values automatically,

i want to avoid the sorting when i use for all entries.

Former Member
0 Kudos
231

for all entries u should specified all primary key.

sort by u condition.

Effect

If the addition FOR ALL ENTRIES is specified before the language element WHERE, then the components comp of the internal table itab can be used as operands when comparing with relational operators.

The internal table itab must have a structured line type and the component comp must be compatible with the column col.

The logical expression sql_cond of the WHERE condition can comprise various logical expressions by using AND and OR. However, if FOR ALL ENTRIES is specified, there must be at least one Comparison with a column of the internal table itab, which can be specified either statistically or dynamically (Release 6.40 and higher). In a statement with a SELECTstatement with FOR ALL ENTRIES, the addition ORDER BY can only be used with the addition PRIMARY KEY.

The whole logical expression sql_cond is evaluated for each individual line of the internal table itab. The resulting set of the SELECT statement is the union of the resulting sets from the individual evaluations. Duplicate lines are automatically removed from the resulting set. If the internal table itab is empty, the whole WHERE statement is ignored and all lines in the database are put in the resulting set.

Notes

In Release 6.10 and higher, the same internal table can be specified after FOR ALL ENTRIES and after INTO.

The addition FOR ALL ENTRIES is only possible before WHERE conditions of the SELECT statement.

If the additions PACKAGE SIZE or UP TO n ROWS are specified together with FOR ALL ENTRIES, they are not passed to the database system but are applied instead to the resulting set once all selected rows on the application server have been imported.

With duplicated rows in the resulting set, the addition FOR ALL ENTRIES has the same effect as if addition DISTINCT were specified in the definition of the selection quantity. Unlike DISTINCT, the rows are not deleted from the database system but are deleted on the application server from the resulting set.

Addition FOR ALL ENTRIES is only possible for WHERE conditions of the SELECT statement.

Example

Exporting all flight data for a specified departure city. The relevant airlines and flight numbers are first put in an internal table entry_tab, which is evaluated in the WHERE condition of the subsquent SELECT statement.

0 Kudos
231

In my zmaster1 all of the fields are primary, then how can i sort it out.

whats the solution actually.

Former Member
0 Kudos
231

Raj,

Can you please explain me or give me the queries, how you are getting the material data into these internal tables then i can give you the reason why ?

Regards,

Giri

Former Member
0 Kudos
231

Hi,

Whats the problem. u can use the sorting.

Regards,

S.Nehru.

0 Kudos
231

Hi,

Why you dont want to sort the tables, i am not getting your requirement.

what is the problem if its sorted.once selection requirement is fulfilled. you can use the internal table anyway u want.

Thanks & Regards,

Poorna