‎2008 Mar 17 9:45 AM
Hi all
If u see below there are two SELECT statements.In the first statement am selecting RECORD1 and in the second SELECT statement i want to select RECORD2.But whats happening is RECORD 1 is getting selected TWICE and in the output am getting as
RECORD1
RECORD1
RECORD2.
I tried using INTO table it_bseg in the second statment but am not getting it.Am also using DELETE ADJACENT.....But am getting the same out put.Please help.
With regards
Vijay
SELECT
belnr gjahr buzei bschl koart shkzg wrbtr
sgtxt saknr hkont kunnr lifnr prctr FROM bseg
INTO TABLE it_bseg FOR ALL ENTRIES IN it_bkpf
WHERE bukrs EQ p_bukrs AND belnr EQ it_bkpf-belnr AND
gjahr EQ p_gjahr AND umskz NE 'F' .
if not it_bseg[] is initial.
SELECT
belnr gjahr buzei bschl koart shkzg wrbtr sgtxt saknr hkont kunnr lifnr prctr FROM bseg
APPENDING table it_bseg
FOR ALL ENTRIES IN it_bseg WHERE bukrs EQ p_bukrs AND belnr EQ it_bseg-belnr AND gjahr EQ p_gjahr
AND umskz NE 'F' AND bschl IN r_bschl.
DELETE ADJACENT DUPLICATES FROM it_bseg comparing bschl belnr prctr.
endif.
‎2008 Mar 17 10:02 AM
Hi Vijay,
I have a question here
Why are you doing 2 selects for the same table ?
anyway .......
Try something Like this ..
SELECT
belnr gjahr buzei bschl koart shkzg wrbtr
sgtxt saknr hkont kunnr lifnr prctr FROM bseg
INTO TABLE it_bseg FOR ALL ENTRIES IN it_bkpf
WHERE bukrs EQ p_bukrs AND belnr EQ it_bkpf-belnr AND
gjahr EQ p_gjahr AND umskz NE 'F' .
if not it_bseg[] is initial.
SELECT
belnr gjahr buzei bschl koart shkzg wrbtr sgtxt saknr hkont kunnr lifnr prctr FROM bseg
APPENDING table it_bseg
FOR ALL ENTRIES IN it_bseg WHERE bukrs EQ p_bukrs AND belnr EQ it_bseg-belnr AND gjahr EQ p_gjahr
AND umskz NE 'F' AND bschl IN r_bschl.
SORT it_bseg BY bschl belnr prctr.
DELETE ADJACENT DUPLICATES FROM it_bseg comparing bschl belnr prctr.
endif.
Reward if useful
Cheers
Kripa Rangachari.
‎2008 Mar 17 9:48 AM
Hi krishna,
Just delete adjacent duplicates in it_bkpf befiore using for all entries and also in it_bseg before using.
Regards,
Madhu..!!
‎2008 Mar 17 9:51 AM
‎2008 Mar 17 9:49 AM
Hi,
Try appending it separately after the two select statements.
Regards,
Ramya
‎2008 Mar 17 9:50 AM
‎2008 Mar 17 9:52 AM
hi ,
in your code use this..
after first select statement
sort the itab by field1.
delete adjacent duplicates from itab comparing the field1 .
regards,
venkat.
‎2008 Mar 17 9:52 AM
Before DELETE ADJACENT DUPLICATES you must SORT this table with relevant fields.
‎2008 Mar 17 9:53 AM
Hi
The record is selected twice because conditions in the second SELECT are almost equal to the conditions in the first SELECT. You only added the
AND bschl IN r_bschlAlso you are selecting using the FOR ALL ENTRIES and the condition for this is
AND belnr EQ it_bseg-belnrwhich is selected in the first SELECT
AND belnr EQ it_bkpf-belnrMaybe you want to change the FOR ALL ENTRIES condition to some other field, perhaps the Reversal document number.
Rgds
Mat
‎2008 Mar 17 9:55 AM
Hi,
First sort the internal table it_bkpf based on the primary keys & then delete the adjacent duplicates from it. Next after the 1st select statement sort the internal table it_bseg & then delete the duplicate entries.
This may help you.
Regards,
Sayee
‎2008 Mar 17 9:56 AM
Hi,
I think there may two differnt combination of RECORD1 may exist thats y its coming like that first of all check the internal table wether both the records having same values in all fields... if not then check for the condition....
check the internal table first by debugging..
Thanks.
Arunprasad.P
Reward if usefull.
‎2008 Mar 17 10:02 AM
Hi Vijay,
I have a question here
Why are you doing 2 selects for the same table ?
anyway .......
Try something Like this ..
SELECT
belnr gjahr buzei bschl koart shkzg wrbtr
sgtxt saknr hkont kunnr lifnr prctr FROM bseg
INTO TABLE it_bseg FOR ALL ENTRIES IN it_bkpf
WHERE bukrs EQ p_bukrs AND belnr EQ it_bkpf-belnr AND
gjahr EQ p_gjahr AND umskz NE 'F' .
if not it_bseg[] is initial.
SELECT
belnr gjahr buzei bschl koart shkzg wrbtr sgtxt saknr hkont kunnr lifnr prctr FROM bseg
APPENDING table it_bseg
FOR ALL ENTRIES IN it_bseg WHERE bukrs EQ p_bukrs AND belnr EQ it_bseg-belnr AND gjahr EQ p_gjahr
AND umskz NE 'F' AND bschl IN r_bschl.
SORT it_bseg BY bschl belnr prctr.
DELETE ADJACENT DUPLICATES FROM it_bseg comparing bschl belnr prctr.
endif.
Reward if useful
Cheers
Kripa Rangachari.