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

divide internal table.

Former Member
0 Likes
2,191

hi,

I have internal table with 4 crore records and i want to divide it in 8 separate internal tables i.e. 50 lakh records in one internal table and so on.

so how i can do it ? is there any command or i have to go through loop.

Regards,

Santosh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,041

Hi

Use APPEND LINES Statement as shown in below sample code:

Sample code

data : begin of itab occurs 0,

dat type sy-datum,

num type i,

END OF itab.

data : begin of itab1 occurs 0,

dat type sy-datum,

num type i,

END OF itab1.

itab-dat = '01012009'.

itab-num = '11111'.

append itab.

itab-dat = '03012009'.

itab-num = '22222'.

append itab.

itab-dat = '03012009'.

itab-num = '11111'.

append itab.

itab-dat = '04012009'.

itab-num = '11111'.

append itab.

append lines of itab from 1 to 2 to itab1.

It works as you required.

4 REPLIES 4
Read only

faisalatsap
Active Contributor
0 Likes
1,041

Hi, Santosh

Test the following Sample Code Hope will solve out your problem,

TABLES: kna1.

data: it1_kna1 like STANDARD TABLE OF kna1 WITH HEADER LINE,
      it2_kna1 like STANDARD TABLE OF kna1 WITH HEADER LINE,
      it3_kna1 like STANDARD TABLE OF kna1 WITH HEADER LINE,
      it4_kna1 like STANDARD TABLE OF kna1 WITH HEADER LINE,
      it5_kna1 like STANDARD TABLE OF kna1 WITH HEADER LINE,
      it6_kna1 like STANDARD TABLE OF kna1 WITH HEADER LINE.


SELECT * from kna1
  into CORRESPONDING FIELDS OF TABLE it1_kna1.

SORT it1_kna1 by kunnr.
LOOP AT it1_kna1 FROM  1 to 10.
  APPEND it1_kna1 to it2_kna1.
ENDLOOP.

LOOP AT it1_kna1 FROM  11 to 20.
  APPEND it1_kna1 to it2_kna1.
ENDLOOP.

LOOP AT it1_kna1 FROM  21 to 30.
  APPEND it1_kna1 to it3_kna1.
ENDLOOP.

LOOP AT it1_kna1 FROM  31 to 40.
  APPEND it1_kna1 to it4_kna1.
ENDLOOP.

LOOP AT it1_kna1 FROM  41 to 50.
  APPEND it1_kna1 to it5_kna1.
ENDLOOP.

LOOP AT it1_kna1 FROM  51 to 60.
  APPEND it1_kna1 to it6_kna1.
ENDLOOP.

Please Reply if any problem

Kind Regards,

Faisal

Read only

Former Member
0 Likes
1,041

HI,

APPEND LINES OF jtab [FROM idx1] [TO idx2] to ITAB.


EXAMPLE:
APPEND LINES OF jtab 1    TO 100 to ITAB.
APPEND LINES OF jtab 101 TO 200 to ITAB.
APPEND LINES OF jtab 201 TO 300 to ITAB.

Read only

Former Member
0 Likes
1,042

Hi

Use APPEND LINES Statement as shown in below sample code:

Sample code

data : begin of itab occurs 0,

dat type sy-datum,

num type i,

END OF itab.

data : begin of itab1 occurs 0,

dat type sy-datum,

num type i,

END OF itab1.

itab-dat = '01012009'.

itab-num = '11111'.

append itab.

itab-dat = '03012009'.

itab-num = '22222'.

append itab.

itab-dat = '03012009'.

itab-num = '11111'.

append itab.

itab-dat = '04012009'.

itab-num = '11111'.

append itab.

append lines of itab from 1 to 2 to itab1.

It works as you required.

Read only

0 Likes
1,041

I believe Avinash has given a better option.

you divide the total internal table lines using some logic and use the logic provided by Avinash. but what will be the benefit? I suggest you select upto 50 lakh lines