2007 Aug 06 5:53 AM
Hi experts...
I have one output, like
101 102 103
444 000 000
444 000 000
444 000 000
444 333 000
444 333 000
000 333 000
000 333 000
000 000 666
000 000 666
000 000 666
000 000 666
It is in alv report. I want to delete all 0 s and dupllicate value form internal table.
and output like
101 102 103
444 333 666
here 101 102 103 is title.
plz anybody can help me.
thank you
2007 Aug 06 6:29 AM
Hi Ankita ,
Please check this.
DATA : BEGIN OF itab OCCURS 0,
101(3) TYPE c,
102(3) TYPE c,
103(3) TYPE c,
END OF itab.
DATA : itab1 LIKE TABLE OF itab WITH HEADER LINE.
itab-101 = '444'.
itab-102 = '000'.
itab-103 = '000'.
APPEND itab.
itab-101 = '444'.
itab-102 = '000'.
itab-103 = '000'.
APPEND itab.
itab-101 = '444'.
itab-102 = '000'.
itab-103 = '000'.
APPEND itab.
itab-101 = '444'.
itab-102 = '333'.
itab-103 = '000'.
APPEND itab.
itab-101 = '444'.
itab-102 = '333'.
itab-103 = '000'.
APPEND itab.
itab-101 = '000'.
itab-102 = '333'.
itab-103 = '000'.
APPEND itab.
itab-101 = '000'.
itab-102 = '000'.
itab-103 = '666'.
APPEND itab.
itab-101 = '000'.
itab-102 = '000'.
itab-103 = '666'.
APPEND itab.
itab-101 = '000'.
itab-102 = '000'.
itab-103 = '666'.
APPEND itab.
itab-101 = '000'.
itab-102 = '000'.
itab-103 = '666'.
APPEND itab.
SORT itab BY 101 102 103.
DELETE ADJACENT DUPLICATES FROM itab.
itab1[] = itab[].
LOOP AT itab.
LOOP AT itab1.
IF itab-101 = '000' AND itab-102 = '000' AND itab-103 = '000'.
EXIT.
ENDIF.
IF itab-101 = '000'.
itab-101 = itab1-101.
ENDIF.
IF itab-102 = '000'.
itab-102 = itab1-102.
ENDIF.
IF itab-103 = '000'.
itab-103 = itab1-103.
ENDIF.
MODIFY itab.
DELETE itab1 INDEX 1.
ENDLOOP.
ENDLOOP.
REFRESH itab1.
SORT itab BY 101 102 103.
DELETE ADJACENT DUPLICATES FROM itab.
LOOP AT itab WHERE 101 <> '000' AND 102 <> '000' AND 103 <> '000'.
APPEND itab TO itab1.
ENDLOOP.
itab[] = itab1[].
2007 Aug 06 6:02 AM
Loop at internal table
read Table itab where any of 101 , 102 103 is zero
then delete itab
endloop
regards
hitesh
2007 Aug 06 6:13 AM
Hi hitesh,
I am not able to get my output. plz try to understand my problem and plz help me out.
thank you.
2007 Aug 06 6:11 AM
2007 Aug 06 6:17 AM
use Delete adjacent duplicates comparing values field1 field2....etc what all fields you want to compare.
delete adjacent duplicate from itab comparing <field1 <field2>.
next delete the table which has 000 values
if the field type is type C (ie character)
delete itab where <field> = '000' " Use quotes
if the field type is numeric
delete itab where <field> is initial.
Regards
Gopi
2007 Aug 06 6:17 AM
Hi ankita,
Sort the internal table
Sort itab
delete adjacent duplicates from itab.
then you will get output like
101 102 103
444 000 000
444 333 000
000 333 000
000 000 666
Then do the code to get the required output
Regards
Arun
2007 Aug 06 6:18 AM
hi,
try like this,
loop at itab.
delete itab-fld1 where fld1 = '000'.
delete adjacent duplicates from itab.
write:/itab-fld1.
endloop.
if helpful reward some points.
with regards,
Suresh Aluri.
2007 Aug 06 6:20 AM
Hi,
try this one.Solve your problem.
loop at itab.
delete itab where field = '000'.
endloop.
Delete adjucent duplicates from table itab.
Regards
Debjani
Rewards point for helpful answer.
2007 Aug 06 6:29 AM
Hi Ankita ,
Please check this.
DATA : BEGIN OF itab OCCURS 0,
101(3) TYPE c,
102(3) TYPE c,
103(3) TYPE c,
END OF itab.
DATA : itab1 LIKE TABLE OF itab WITH HEADER LINE.
itab-101 = '444'.
itab-102 = '000'.
itab-103 = '000'.
APPEND itab.
itab-101 = '444'.
itab-102 = '000'.
itab-103 = '000'.
APPEND itab.
itab-101 = '444'.
itab-102 = '000'.
itab-103 = '000'.
APPEND itab.
itab-101 = '444'.
itab-102 = '333'.
itab-103 = '000'.
APPEND itab.
itab-101 = '444'.
itab-102 = '333'.
itab-103 = '000'.
APPEND itab.
itab-101 = '000'.
itab-102 = '333'.
itab-103 = '000'.
APPEND itab.
itab-101 = '000'.
itab-102 = '000'.
itab-103 = '666'.
APPEND itab.
itab-101 = '000'.
itab-102 = '000'.
itab-103 = '666'.
APPEND itab.
itab-101 = '000'.
itab-102 = '000'.
itab-103 = '666'.
APPEND itab.
itab-101 = '000'.
itab-102 = '000'.
itab-103 = '666'.
APPEND itab.
SORT itab BY 101 102 103.
DELETE ADJACENT DUPLICATES FROM itab.
itab1[] = itab[].
LOOP AT itab.
LOOP AT itab1.
IF itab-101 = '000' AND itab-102 = '000' AND itab-103 = '000'.
EXIT.
ENDIF.
IF itab-101 = '000'.
itab-101 = itab1-101.
ENDIF.
IF itab-102 = '000'.
itab-102 = itab1-102.
ENDIF.
IF itab-103 = '000'.
itab-103 = itab1-103.
ENDIF.
MODIFY itab.
DELETE itab1 INDEX 1.
ENDLOOP.
ENDLOOP.
REFRESH itab1.
SORT itab BY 101 102 103.
DELETE ADJACENT DUPLICATES FROM itab.
LOOP AT itab WHERE 101 <> '000' AND 102 <> '000' AND 103 <> '000'.
APPEND itab TO itab1.
ENDLOOP.
itab[] = itab1[].
2007 Aug 06 12:12 PM
Hi Arjun...
if I want output like this then plz give me some hint,
101 102 103
222 0.000 444
because in my data there is some also 0s.
from ur below code i m not able to get 0s.
LOOP AT itab WHERE 101 <> '000' AND 102 <> '000' AND 103 <> '000'.
APPEND itab TO itab1.
ENDLOOP.
plz help me Arjun...
2007 Aug 06 12:23 PM
your requirement is now confusing me....
you want to do away with the rows with 000 values altogether....but you want to hold 000.00??
i think you could use field symbols and remove the unwanted rows in a single loop.
2007 Aug 07 6:34 AM
Try this
DATA : BEGIN OF ITAB OCCURS 0,
101(3) type c,
102(3) type c,
103(3) type c,
END OF ITAB.
DATA : ITAB1 LIKE TABLE OF ITAB WITH HEADER LINE.
itab-101 = '444'.
itab-102 = '000'.
itab-103 = '000'.
append itab.
itab-101 = '444'.
itab-102 = '000'.
itab-103 = '000'.
append itab.
itab-101 = '444'.
itab-102 = '000'.
itab-103 = '000'.
append itab.
itab-101 = '444'.
itab-102 = '333'.
itab-103 = '000'.
append itab.
itab-101 = '444'.
itab-102 = '333'.
itab-103 = '000'.
append itab.
itab-101 = '000'.
itab-102 = '333'.
itab-103 = '000'.
append itab.
itab-101 = '000'.
itab-102 = '000'.
itab-103 = '666'.
append itab.
itab-101 = '000'.
itab-102 = '000'.
itab-103 = '666'.
append itab.
itab-101 = '000'.
itab-102 = '000'.
itab-103 = '666'.
append itab.
itab-101 = '000'.
itab-102 = '000'.
itab-103 = '666'.
append itab.
if not itab[] is initial.
sort itab by 101 descending.
read table itab index 1.
itab1-101 = itab-101.
sort itab by 102 descending.
read table itab index 1.
itab1-102 = itab-102.
sort itab by 103 descending.
read table itab index 1.
itab1-103 = itab-103.
append itab1.
endif.
*
itab[] = itab1[].
2007 Aug 06 8:05 AM
you said it was an ALV Report ..then the code was as follows :
here the internal table is %g00 ..
"step:1
call function 'REUSE_ALV_GRID_DISPLAY'
exporting i_callback_program = gc_repid
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
i_grid_title = lc_grid_title
is_layout = lc_layout
it_fieldcat = gt_fieldcat
it_sort = sort
i_save = l_save
is_reprep_id = l_bbs_id
is_variant = l_variant
tables t_outtab = %g00
exceptions program_error = 1
others = 2.
"step:2
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZSTANDARD'.
ENDFORM. "Set_pf_status
In the above case the GUI status copied was named ZSTANDARD and adjusted accordingly, adding and removing the desired buttons. A button was added called '%DELETE'
"step:3
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: li_count TYPE I.
IF r_ucomm EQ '%DELETE'.
LOOP AT %g00 WHERE mark EQ 'X'.
ADD 1 TO li_count.
ENDLOOP.
IF li_count GT 0.
gc_delete_flag = 'X'.
r_ucomm = '&F03'. "Back arraow
ELSE.
MESSAGE W000 WITH 'Please highlight the rows to be deleted!'.
ENDIF.
ENDIF.
ENDFORM. "User_command
reward points if it is usefull ...
Girish
2007 Aug 06 8:54 AM
Hi ankita patel ,
Before passing to the alv do this.
SORT ITAB BY F1 F2 F3.
DELETE ADJACENT DUPLICATES FROM ITAB.
DELETE ITAB WHERE F1 IS INITIAL.
DELETE ITAB WHERE F2 IS INITIAL.
DELETE ITAB WHERE F3 IS INITIAL.
Regatrds,
Rama.Pammi
2007 Aug 07 6:41 AM
FOR THE DUPLICATE
DELETE ADJACENT DUPLICATES FROM <itab> COMPARING <field name>.
for the zero valus
DELETE <itab> WHERE <field name> EQ '000'.
Don't Forget to Rewards.
2007 Aug 07 6:45 AM
Hi
You can use too statements at the lop condition
Delete adjacent duplicates from itab comparing '000'
It will solve your problem
Reward all helpfull answers
Regards
Pavan