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

line item repeating

Former Member
0 Likes
738

hi gurus....

my output is coming correctly with a small problem which iam not

not able to spot it out . My output is correct till 6100000004 having 2 line items but

6100000004 is reapeating the 2 line items again and 6100000002 details which has to be cleared

but showing in the output,,,,wat shud solve the problem, i have given clear too

sort it_ekko by ebeln.
sort it_bseg by belnr.

loop at it_bseg into wa_bseg .
   wa_final-ebeln = wa_bseg-ebeln.

   read table it_bkpf into wa_bkpf with key belnr = wa_bseg-belnr.
          if sy-subrc = 0 .
            wa_final-budat = wa_bkpf-budat.
          endif.

read table it_lfa1 into wa_lfa1 with key lifnr = wa_bseg-lifnr.
  if sy-subrc = 0.
     wa_final-name1 = wa_lfa1-name1.
     wa_final-ort01 = wa_lfa1-ort01.
  Endif.

read table  it_J_1IMOVEND into  wa_J_1IMOVEND with key lifnr = wa_bseg-lifnr.
   if sy-subrc = 0.
      wa_final-J_1ILSTNO =  wa_J_1IMOVEND-J_1ILSTNO.
   endif.

loop at it_ekpo into wa_ekpo where ebeln = wa_bseg-ebeln .
wa_final-ematn = wa_ekpo-ematn.
wa_final-txz01 = wa_ekpo-txz01.
wa_final-menge = wa_ekpo-menge.
wa_final-netwr = wa_ekpo-netwr.
wa_final-navnw = wa_ekpo-navnw.
wa_final-effwr = wa_ekpo-effwr.

append wa_final to it_final.

Endloop.


clear : wa_bkpf, wa_bseg, Wa_lfa1, wa_J_1IMOVEND , wa_ekko, wa_ekpo,  wa_final.

Endloop.

6100000001	10.03.2007	Homecast Co., Ltd	Korea		000000000030000000		10.000	450.00	0.00	0.00	450.00
6100000002	10.03.2007	Homecast Co., Ltd	Korea		000000000030000000		10.000	450.00	0.00	0.00	450.00
6100000003	10.03.2007	Homecast Co., Ltd	Korea		000000000030000000		1.000	45.00	0.00	0.00	45.00
6100000004	11.03.2007	Homecast Co., Ltd	Korea		000000000030000000		3.000	135.00	0.00	0.00	135.00
6100000004	11.03.2007	Homecast Co., Ltd	Korea		000000000030000000		4.000	180.00	0.00	0.00	180.00
6100000004	11.03.2007	Homecast Co., Ltd	Korea		000000000030000000		3.000	135.00	0.00	0.00	135.00
6100000004	11.03.2007	Homecast Co., Ltd	Korea		000000000030000000		4.000	180.00	0.00	0.00	180.00
6100000002	10.03.2007				                000000000030000000	        10.000	450.00	0.00	0.00	450.00

hi gurus....

my output is coming correctly with a small problem which iam not

not able to spot it out . My output is correct till 6100000004 having 2 line items but

6100000004 is reapeating the 2 line items again and 6100000002 details which has to be cleared

but showing in the output,,,,wat shud solve the problem, i have given clear too

sort it_ekko by ebeln.
sort it_bseg by belnr.

loop at it_bseg into wa_bseg .
   wa_final-ebeln = wa_bseg-ebeln.

   read table it_bkpf into wa_bkpf with key belnr = wa_bseg-belnr.
          if sy-subrc = 0 .
            wa_final-budat = wa_bkpf-budat.
          endif.

read table it_lfa1 into wa_lfa1 with key lifnr = wa_bseg-lifnr.
  if sy-subrc = 0.
     wa_final-name1 = wa_lfa1-name1.
     wa_final-ort01 = wa_lfa1-ort01.
  Endif.

read table  it_J_1IMOVEND into  wa_J_1IMOVEND with key lifnr = wa_bseg-lifnr.
   if sy-subrc = 0.
      wa_final-J_1ILSTNO =  wa_J_1IMOVEND-J_1ILSTNO.
   endif.

loop at it_ekpo into wa_ekpo where ebeln = wa_bseg-ebeln .
wa_final-ematn = wa_ekpo-ematn.
wa_final-txz01 = wa_ekpo-txz01.
wa_final-menge = wa_ekpo-menge.
wa_final-netwr = wa_ekpo-netwr.
wa_final-navnw = wa_ekpo-navnw.
wa_final-effwr = wa_ekpo-effwr.

append wa_final to it_final.

Endloop.


clear : wa_bkpf, wa_bseg, Wa_lfa1, wa_J_1IMOVEND , wa_ekko, wa_ekpo,  wa_final.

Endloop.

6100000001	10.03.2007	Homecast Co., Ltd	Korea		000000000030000000		10.000	450.00	0.00	0.00	450.00
6100000002	10.03.2007	Homecast Co., Ltd	Korea		000000000030000000		10.000	450.00	0.00	0.00	450.00
6100000003	10.03.2007	Homecast Co., Ltd	Korea		000000000030000000		1.000	45.00	0.00	0.00	45.00
6100000004	11.03.2007	Homecast Co., Ltd	Korea		000000000030000000		3.000	135.00	0.00	0.00	135.00
6100000004	11.03.2007	Homecast Co., Ltd	Korea		000000000030000000		4.000	180.00	0.00	0.00	180.00
6100000004	11.03.2007	Homecast Co., Ltd	Korea		000000000030000000		3.000	135.00	0.00	0.00	135.00
6100000004	11.03.2007	Homecast Co., Ltd	Korea		000000000030000000		4.000	180.00	0.00	0.00	180.00
6100000002	10.03.2007				                000000000030000000	        10.000	450.00	0.00	0.00	450.00

4 REPLIES 4
Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
699

sort it_ekko by ebeln netwr.

delete adjacent duplicates from it_ekko comapring ebeln netwr.

for 6100000002 :

if you do not want this in o/p , u can check if txz01 is initial.

delete this row.

endif.

Read only

Former Member
0 Likes
699

By using DELETE ADJACENT DUPLICATES you can avoid this.

when you are using this statement you must SORT the internal table

SORT it_ekko BY ebeln netwr.

DELETE ADJACENT DUPLICATES from it_ekko COMPARING ebeln netwr.

Hope your problem solved

Read only

Former Member
0 Likes
699

Hi,

when ever you select data from a table make sure that you are fetching all the key fields in addition to the fields which you require by giving all the key fields in the where condition. This will avoid the problem of geting duplicate records at the first place

Suppose you dont have all th ekey fields available for giving in the where condition then, you need to make a call on which all fields are important in your case.

suppose you get duplicate records, then you need to sort the internal table based on the key fields (This is the minimum requirement, you may also give additional fields as per your business requirement).

Then do a delete adjacent duplicates using the above fields.

in your case i think you are writing the records from EKPO, ebeln and ebelp are the key fields here

Regards,

Anil

Read only

Former Member
0 Likes
699

Hi,

Use like this

sort it_ekko by ebeln netwr.

delete adjacent duplicates from it_ekko comapring ebeln netwr.

Regards,

Jyothi CH.