2007 Sep 28 9:00 AM
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
2007 Sep 28 9:06 AM
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
2007 Sep 28 9:05 AM
sort the internal table by the field which u are using in for all entries.
Regards
Vasu
2007 Sep 28 9:06 AM
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
2007 Sep 28 10:22 AM
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
2007 Sep 28 10:28 AM
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
2007 Sep 28 10:50 AM
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
2007 Sep 28 11:59 AM
2007 Sep 28 12:07 PM
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.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |