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

Using a standard table as an array

Former Member
0 Likes
789

Hi,


I have one  table and it has a 1000 entries
I'd like to take the records from it and split it across to tables so that each of them will have 500 entries.
** /abs/tbl_Exec_Rec is a standard table from the Table Types in the Dictionary

whole type /abs/tbl_Exec_Rec   "This one has 1000 entries

part1  type /abs/tbl_Exec_Rec   "This one will have 500 entries
part2  type /abs/tbl_Exec_Rec   "This one will have 500 entries

In JAVA I don't need a loop to do this I can simply do:


T
[] subArray Arrays.copyOfRange(T[] array, int start, int end)

so for my table it'll be something like that:

T[] part1 Arrays.copyOfRange(T[] big, 0, 499)

T[] part2 Arrays.copyOfRange(T[] big, 500, 999)

How can do it in SAP I don't want to use any loops?

Thanks .

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
693

Hello izhak

Not Active Contributor

In abap it you can do is:

Example

Table_1 has 1000 rows

Table_2 and Table_3 are auxiliar tables.

*..In table_2 you can copy the rows from 1 to 499

   APPEND LINES OF  Table_1 FROM 1 TO 499 TO Table_2 .

 

In table_3 you can copy the rows from 500 to 1000

   APPEND LINES OF  Table_1 FROM 500 TO 1000 TO Table_3 .

5 REPLIES 5
Read only

Former Member
0 Likes
694

Hello izhak

Not Active Contributor

In abap it you can do is:

Example

Table_1 has 1000 rows

Table_2 and Table_3 are auxiliar tables.

*..In table_2 you can copy the rows from 1 to 499

   APPEND LINES OF  Table_1 FROM 1 TO 499 TO Table_2 .

 

In table_3 you can copy the rows from 500 to 1000

   APPEND LINES OF  Table_1 FROM 500 TO 1000 TO Table_3 .

Read only

0 Likes
693

Thanks this works

Read only

Former Member
0 Likes
693

Hi,

Well the answer is already given...I was just wondering what could be hidden in this java method copyOfRange? Looks a bit like an abap method or a macro where some loop occurs

cheers,

Manu.

Read only

0 Likes
693

Hi Manu

The method copyOfRange is a method in java . That method use the class System.ArrayCopy and this routine use a method

public static native void arraycopy.

This method is writing in code native for best performance.

Read only

0 Likes
693

Hello Manu,

there are some differences from other languages, so we don't find same things in ABAP. and ABAP has limitations and Flexibilities when compared to others.. when talking about its always good to have scenario  which is related to business. so that there would be some better alternative than in the lines your thinking about.

so have some business scenario  always..

Regards,

Andrew