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

How to split interanl table

Former Member
0 Likes
812

Hi,

Let one internal table t_tab contains 20,000 records. Requirement is to move the 500 records to other interanl table t_temp and will process these records from this table. then will take remaining 500 from t_tab n so on. How to implement this. Plz give any solution.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
783

Hi,

data:v_lines type sy-index,v_cnt like sy-index.

clear: v_lines,v_cnt.

describe t_tab lines v_lines.

if v_lines > 500.

loop at itab.

v_cnt = v_cnt + 1.

if v_cnt = 500

exit.

else.

move-corresponding t_tab to itab.

append itab.clear itab.

delete itab index sy-tabix.

endif.

endloop.

elseif v_lines LE 500.

move-corresponding t_tab to itab.

append itab.clear itab.

delete itab index sy-tabix.

endif.

clear:v_lines.

describe table t_tab lines v_lines.

do

if v_lines > 500.

**call above code by putting that code in some subroutine

perform process_itab.

endif.

enddo.

Regds

Sivaparvathi

Please reward points if helpful...

7 REPLIES 7
Read only

Former Member
0 Likes
783

Read only

Former Member
0 Likes
783

Hi,

do.

Refresh: itab1.

clear: count.

Describe table itab lines l_f_lines.

if l_f_lines = 0.

exit.

endif.

loop at itab.

append itab to itab1.

delete itab.

count = count + 1.

if count = 500.

exit.

endif.

endloop.

[ Do the required process using itab1 internal table.]

enddo.

Hope this helps you.

Read only

Former Member
0 Likes
783

Hi,

Here is a smple code for splitting internal table:

It is possible....and simple only.

any the code is as follows,

loop at itab where code = '1000'.

it1 = itab.

append it.

clear it.

endloop.

like this you have to do for all the code values

Also:

loop at itab into wa1.

no = no + 1.

at new.

loop at itab into wa2 where key = wa1.

append itab wa2 to it(no).

endloop.

endat.

try this code with neccesary data declarations.

Reward points if found helpful...

Cheers,

Chandra Sekhar.

Read only

Former Member
0 Likes
783

hi,

loop at ur first internal table first and then based on the condition with sy-subrc check move records from 1st internal table to temporary table and then append the temp one and thats it ur data is populated in both the tables.

reward points if helpful,

regards,

Sumanjeet

Read only

Former Member
0 Likes
783

hi

good

in this case i dont think the SPLIT statement will solve your problem,after getting all the data into the first internal table you can transfer those data into another internal table as per thr uniqui field value of the data that you transfer to the second internal table.

thanks

mrutyun^

Read only

Former Member
0 Likes
784

Hi,

data:v_lines type sy-index,v_cnt like sy-index.

clear: v_lines,v_cnt.

describe t_tab lines v_lines.

if v_lines > 500.

loop at itab.

v_cnt = v_cnt + 1.

if v_cnt = 500

exit.

else.

move-corresponding t_tab to itab.

append itab.clear itab.

delete itab index sy-tabix.

endif.

endloop.

elseif v_lines LE 500.

move-corresponding t_tab to itab.

append itab.clear itab.

delete itab index sy-tabix.

endif.

clear:v_lines.

describe table t_tab lines v_lines.

do

if v_lines > 500.

**call above code by putting that code in some subroutine

perform process_itab.

endif.

enddo.

Regds

Sivaparvathi

Please reward points if helpful...

Read only

paruchuri_nagesh
Active Contributor
0 Likes
783

hi

REPORT ZMOVE.

TYPES:BEGIN OF itab,

num TYPE i,

name(10) TYPE c,

amt TYPE i,

END OF itab.

DATA : itab TYPE STANDARD TABLE OF itab with header line.

data : jtab type table of itab with header line.

DATA : v_lines TYPE i.

itab-num = 1.

itab-name = 'nag'.

itab-amt = 1000.

APPEND itab.

itab-num = 2.

itab-name = 'ram'.

itab-amt = 2000.

APPEND itab.

itab-num = 3.

itab-name = 'raghu'.

itab-amt = 1500.

APPEND itab .

itab-num = 4.

itab-name = 'sudha'.

itab-amt = 500.

APPEND itab .

itab-num = 5.

itab-name = 'nirmala'.

itab-amt = 600.

APPEND itab .

itab-num = 6.

itab-name = 'kamala'.

itab-amt = 700.

APPEND itab .

itab-num = 7.

itab-name = 'srinu'.

itab-amt = 1200.

APPEND itab .

itab-num = 8.

itab-name = 'ganesh'.

itab-amt = 1300.

APPEND itab.

itab-num = 9.

itab-name = 'hari'.

itab-amt = 1400.

APPEND itab.

itab-num = 10.

itab-name = 'suresh'.

itab-amt = 900.

APPEND itab.

itab-num = 11.

itab-name = 'eswar'.

itab-amt = 300.

APPEND itab.

loop at itab where num > 5.

move-corresponding itab to jtab.

append jtab.

  • jtab[] = itab[].

endloop.

loop at jtab.

write 😕 jtab-num,jtab-name,jtab-amt.

endloop.

regards

Nagesh.Paruchuri