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

APPEND

Former Member
0 Likes
810

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
788

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.

10 REPLIES 10
Read only

Former Member
0 Likes
788

Hi krishna,

Just delete adjacent duplicates in it_bkpf befiore using for all entries and also in it_bseg before using.

Regards,

Madhu..!!

Read only

0 Likes
788

hi madhu can u explain me exactly where to?

Read only

Former Member
0 Likes
788

Hi,

Try appending it separately after the two select statements.

Regards,

Ramya

Read only

0 Likes
788

HI RAMYA..

Can u tell me exactly where to?

Read only

Former Member
0 Likes
788

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.

Read only

Former Member
0 Likes
788

Before DELETE ADJACENT DUPLICATES you must SORT this table with relevant fields.

Read only

Former Member
0 Likes
788

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_bschl

Also you are selecting using the FOR ALL ENTRIES and the condition for this is

AND belnr EQ it_bseg-belnr

which is selected in the first SELECT

AND belnr EQ it_bkpf-belnr

Maybe you want to change the FOR ALL ENTRIES condition to some other field, perhaps the Reversal document number.

Rgds

Mat

Read only

Former Member
0 Likes
788

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

Read only

Former Member
0 Likes
788

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.

Read only

Former Member
0 Likes
789

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.