Application Development 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: 

filtering of field.

Former Member
0 Kudos

hi all,

In a report .I am able to display serial no's. for certain records.

When i filter according to one field .I am not able to display. serial no's in order.

for ex.

1 91000001

2 91000001

3 90000001

4 90000002

5 90000002

when i filter for no. 90000002 serial no. showing from 4.

how do i get serial no's from 1 when i filter.

4 90000002

5 90000002

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

In your code define a numeric field called Serial Number which will be of type integer. Now you can loop the table and can search for the number 90000002 in a loop using the where clause. So when you will get the value you will keep on increasing the serial number. Now create an internal table to store the serial number and the value '9000002'.

Example code :

DATA : begin of itab occurs 0 with header line,

serial_no type i,

value type char10,

end of itab.

Loop at itab where number = '90000002'.

itab-serial_no = itab-serial_no + 1.

itab-value = '9000002'.

append itab.

endloop.

You can now use the ITAB Internal Table to display it.

This logic is easy. You can put your own program logic inside the code if required.

Hope this will help.

Thanks,

Samantak.

6 REPLIES 6

Former Member
0 Kudos

Hi,

How are you filtering the records? Is the output of the report classical list or ALV grid? Post your code snippet for better understanding of your problem

Regards,

Vik

0 Kudos

classical list

0 Kudos

Hi,

Well then check this,


DATA : BEGIN OF it occurs 0,
slno TYPE I,
TEXT TYPE STRING,
END OF it.
 
DATA: it1 type standard table of it.

parameters: p_slno type i.
 
it-slno = '91000001'.
it-TEXT = 'RED'.
APPEND IT.
 
it-slno = '91000001'.
it-TEXT = 'BLUE '.
APPEND IT.
 
it-slno = '90000002'.
it-TEXT = 'YELLOW'.
APPEND IT.
 
it-slno = '90000002'.
it-TEXT = 'WHITE'.
APPEND IT.
 
loop at it.
if not it-slno = p_slno.
move-corresponding it to it1.
endif.
endloop.
 
loop at it1.
write: it1-slno, it1-text.
endloop

Regards,

Vik

0 Kudos

for 2 no's it ok. wht abt 100 of no's.

Former Member
0 Kudos

Try this logic..

DATA: BEGIN OF IT OCCURS 0,
      SRNO TYPE I,
      RNO TYPE I,
  END OF IT.

DATA WA LIKE LINE OF IT.

DATA: RNO TYPE I VALUE '9100001'.
DATA: index TYPE I.

DO 5 TIMES.
  WA-SRNO = SY-INDEX.
  WA-RNO = RNO.
  APPEND WA TO IT.
  if sy-index = 3.
  RNO = RNO + 1.
  endif.
ENDDO.

LOOP AT it INTO wa WHERE rno = '9100001'.
  if sy-subrc = 0.
    index = index + 1.
    ENDIF.
WRITE: index,wa-rno.
write / .
ENDLOOP.

Regards,

Sumit Nene.

Edited by: Sumit Nene on Aug 18, 2009 7:25 AM

Former Member
0 Kudos

Hi,

In your code define a numeric field called Serial Number which will be of type integer. Now you can loop the table and can search for the number 90000002 in a loop using the where clause. So when you will get the value you will keep on increasing the serial number. Now create an internal table to store the serial number and the value '9000002'.

Example code :

DATA : begin of itab occurs 0 with header line,

serial_no type i,

value type char10,

end of itab.

Loop at itab where number = '90000002'.

itab-serial_no = itab-serial_no + 1.

itab-value = '9000002'.

append itab.

endloop.

You can now use the ITAB Internal Table to display it.

This logic is easy. You can put your own program logic inside the code if required.

Hope this will help.

Thanks,

Samantak.