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

Smartforms internal table serial numbers (Range) print

0 Likes
673

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.

2 REPLIES 2
Read only

Former Member
0 Likes
548

Dear abhi,

Sort the Internal table and Choose the range.

Thanks & Regards.

Kranthi.

Read only

Former Member
0 Likes
548

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