2013 Mar 14 5:52 AM
Hi All,
If internal table it_tab[] is having lot of serial numbers but all serial numbers are not in sequece i.e
serial numbers:
1234
1235
1236
1237
1239
1240
1241
1249
1250
1253
1258
1267
1268
1269
1270
As shown above ,if records are in sequence then we need to print the records in range otherwise print the record individually.
i.e.
1234 to 1237
1239 to 1241
1249 to 1250
1253
1258
1267 to 1270
Can anyone suggest how to do it? Thanks in advance.
2013 May 06 6:11 AM
Dear abhi,
Sort the Internal table and Choose the range.
Thanks & Regards.
Kranthi.
2013 May 06 8:03 AM
Hi abhi,
First sort the internal table.
Create an local variable to store next serial number that should be in sequence.
Now iterate through each record in internal table.
LOOP AT itab INTO wa.
IF sy-tabix <> 1.
" Check if the numbers are in sequence
IF lv_next = wa-serial_no.
* Write your logic 1*
ELSEIF lv_next NE wa-serial_no.
* Write your logic 2*
ENDIF.
ELSE.
* Write your logic 1 *
ENDIF.
" Store the next number to be in sequence
lv_next = wa-serial_no + 1.
ENDIF.
Hope this will helps you.
Regards,
Satish