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

FOR ALL ENTRIES ERROR

Former Member
0 Likes
933

When we use FOR ALL ENTRIES, its order of data in internal table is changed what exists in the FIRST internal table.

Why its order changed, can anyone suggest me.

THANKS IN ADVANCE.

Regards

Rajaram

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
906

Hi

why the data in the first Internal table will change?

see the selects here, it won't change

select

vbeln " Billing Doc

fkdat " Billing Date

kunag " Customer Number

fkart " Billing Type

vkorg " Sales Organization

land1 " Country

bukrs " Company Code

netwr " Net Value

waerk " Currency

kdgrp " Customer Group

bzirk " Sales Employee

into table it_vbrk

from vbrk

where

bukrs = p_bukrs and

vkorg in s_vkorg and

land1 in s_land1 and

kunag in s_kunnr and

kdgrp in s_kdgrp and

bzirk in s_bzirk and

rfbsk = c_rfbsk.

sort it_vbrk by vbeln fkdat kunnr.

select kunnr " Customer Number

gjahr " Fiscal Year

belnr " Acc.Document

buzei " Item

budat " Posting Date

blart " Doc Type

shkzg " Dr/Cr Indicator

dmbtr " Amount(Local Curr)

dmbe2 " Amount(Doc Curr)

waers " Currency

zterm " Payment Terms

vbeln " Billing Doc

zfbdt " Baseline Date

zbd1t " No of days

into table it_bsad1

from bsad

for all entries in it_vbrk

where kunnr = it_vbrk-kunnr and

vbeln = it_vbrk-vbeln and

bukrs = it_vbrk-bukrs and

( budat le p_date and

budat ge v_date1 ) and

blart = c_blart.

sort it_bsad1 by kunnr gjahr belnr buzei budat.

Regards

Anji

When we use FOR ALL ENTRIES, its order of data in internal table is changed what exists in the FIRST internal table.

Why its order changed, can anyone suggest me.

THANKS IN ADVANCE.

Regards

Rajaram

7 REPLIES 7
Read only

Former Member
0 Likes
906

sort the internal table by the field which u are using in for all entries.

Regards

Vasu

Read only

Former Member
0 Likes
907

Hi

why the data in the first Internal table will change?

see the selects here, it won't change

select

vbeln " Billing Doc

fkdat " Billing Date

kunag " Customer Number

fkart " Billing Type

vkorg " Sales Organization

land1 " Country

bukrs " Company Code

netwr " Net Value

waerk " Currency

kdgrp " Customer Group

bzirk " Sales Employee

into table it_vbrk

from vbrk

where

bukrs = p_bukrs and

vkorg in s_vkorg and

land1 in s_land1 and

kunag in s_kunnr and

kdgrp in s_kdgrp and

bzirk in s_bzirk and

rfbsk = c_rfbsk.

sort it_vbrk by vbeln fkdat kunnr.

select kunnr " Customer Number

gjahr " Fiscal Year

belnr " Acc.Document

buzei " Item

budat " Posting Date

blart " Doc Type

shkzg " Dr/Cr Indicator

dmbtr " Amount(Local Curr)

dmbe2 " Amount(Doc Curr)

waers " Currency

zterm " Payment Terms

vbeln " Billing Doc

zfbdt " Baseline Date

zbd1t " No of days

into table it_bsad1

from bsad

for all entries in it_vbrk

where kunnr = it_vbrk-kunnr and

vbeln = it_vbrk-vbeln and

bukrs = it_vbrk-bukrs and

( budat le p_date and

budat ge v_date1 ) and

blart = c_blart.

sort it_bsad1 by kunnr gjahr belnr buzei budat.

Regards

Anji

Read only

0 Likes
906

Hi Anji

I have used the following queries

SELECT matnr arktx KWMENG VRKME FROM vbap

INTO corresponding fields of table it_zlist

WHERE vbeln = zctlk-vbeln.

if sy-subrc = 0.

select matnr test zsno ztnam from zmaster

into corresponding fields of table it_first

for all entries in it_zlist

where matnr = it_zlist-matnr.

endif.

first query(it_zlist) gives some data for example (0001, 0002, 0002)

But after executing second query(it_first) the output is (0002 , 0001 , 0003)

it changed the order, i dont know the reason, but i want as what the order in query1.

Please suggest me.

Thanks in advance.

Regards

Rajaram

Read only

0 Likes
906

hI

FOR ALL ENTRIES MEANS

FROM FIRST SELECT QUERY YOU WILL GET SOME DATA

AND BY USEING PRIMARY KEY IN THAT TABLE YOU WILL RETRIVE SOMEDATA FROM OTHER TABLE

THERE IS NO RULE THAT THE 2 SELECT QUERYS HAVE SAME ORDER

WHEN EVER UR GETTING OUTPUT AT THAT TIME

LOOPING AT THE 1ST SELECT QUERY AND GETTING THE DATA IN CORECT FORMAT

REWARD IF USEFULL

Read only

0 Likes
906

but for all entries does not change the order of the data na.

while executing my first query, i have some order, after executing second query it is different order yar.

for example first query have two matnrs likely 'AAA' and 'BBB'.

after second query its order like 'BBB' and then 'AAA'.

Why its changed, whats the reason, can you pls exaplin this.

Regards

Rajaram

Read only

0 Likes
906

i got the solution by own, thank you one and all.

Read only

0 Likes
906

Hi Rajaram..

This is the reason:

Here the FOR ALL ENTRIES is used to fetch the data from ZMASTER. So the records are fetched in the SORTED Order of the Primary key in Table ZMASTER.

If you want them to be in the Sorted order of MATNR then.

SELECT matnr arktx KWMENG VRKME FROM vbap

INTO corresponding fields of table it_zlist

WHERE vbeln = zctlk-vbeln.

if sy-subrc = 0.

select matnr test zsno ztnam from zmaster

into corresponding fields of table it_first

for all entries in it_zlist

where matnr = it_zlist-matnr.

endif.

<b>

SORT IT_ZLIST BY MATNR.</b>

Reward if Helpful.