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

Splitting Large internal tables

Former Member
0 Likes
404

Hi All,

How to split large internal table into smaller ones of fixed number of lines.

The total number of lines are not known and is subjected to vary.

Regards,

Naba

2 REPLIES 2
Read only

vinod_vemuru2
Active Contributor
0 Likes
361

HI,

Check below logic.


DESCRIBE TABLE i_main LINES l_lines.
IF l_lines GT 100.
l_num = l_lines / 100.
ENDIF.
l_start = 1.
l_end = 100.
DO l_num TIMES.
APPEND LINES OF i_main FROM l_start TO l_end INTO i_subtab.
Process ur subtab.
ADD 100 TO: l_start, l_end.
IF l_end GT l_lines.
l_end = l_lines.
ENDIF.
CHECK l_start GT l_lines.
EXIT.
ENDDO.

Thanks,

Vinod.

Read only

Former Member
0 Likes
361

I am not sure about your requirements, you try with the below solution

Itab : contains all entries let us say 3000

Itab1

itab2

itab3

No.of entries to be split based on 3000/n ( 3000/3) = 1000

split_val = 1000

N_split_from = 1

N_split_to = 1000

APPEND LINES OF ITAB1 FROM N_split_from TO N_split TO ITAB1.

N_split_from = 1 + split_val

N_split_to = 1000 + split_val

APPEND LINES OF ITAB1 FROM N_split_from TO N_split TO ITAB2.

N_split_from = 1 + split_val

N_split_to = 1000 + split_val

APPEND LINES OF ITAB1 FROM N_split_from TO N_split TO ITAB3.

Regards

Sasi