Application Development 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: 

cut ITAB

Former Member
0 Kudos

i have big itab with 1 column.

example:

1224321 213123 3423def efdfe d fddf dfd d d d d3333

how i can cut the fields into another itab?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi rani,

1. No need to cut.

2. just use ptab[] = itab[].

3. like this (just copy paste)

REPORT ABC.

DATA : BEGIN OF ITAB OCCURS 0,

F(100) TYPE C,

END OF ITAB.

DATA : BEGIN OF PTAB OCCURS 0,

A(1) TYPE C,

B(3) TYPE C,

C(5) TYPE C,

END OF PTAB.

ITAB-F = '1234567890'.

APPEND ITAB.

PTAB[] = ITAB[].

BREAK-POINT.

regards,

amit m.

8 REPLIES 8

Former Member
0 Kudos

hi

use <b>OFFSET</b> i.e,

<b>

Offset</b>

Data p(6) value ‘1224321 213123 3423def efdfe d fddf dfd d d d d3333’, q(3).

<b>q = p+2(3).</b>

Write 😕 q.

q = p+0(1).

Write:/ q.

Regards,

Santosh

former_member181962
Active Contributor
0 Kudos

You can use the split command.

loop at itab.

split itab at space into itab1-field1

itab1-field2

itab1-field3.

append itab1.

endloop.

now itab1 will have data in the form of separated fields.

regards,

Ravi

Former Member
0 Kudos

Hi rani,

1. No need to cut.

2. just use ptab[] = itab[].

3. like this (just copy paste)

REPORT ABC.

DATA : BEGIN OF ITAB OCCURS 0,

F(100) TYPE C,

END OF ITAB.

DATA : BEGIN OF PTAB OCCURS 0,

A(1) TYPE C,

B(3) TYPE C,

C(5) TYPE C,

END OF PTAB.

ITAB-F = '1234567890'.

APPEND ITAB.

PTAB[] = ITAB[].

BREAK-POINT.

regards,

amit m.

Former Member
0 Kudos

Hi,

You can use offset or 'split at space' and copy into fields of another itab.

regards

-Rakesh

Former Member
0 Kudos

Hi,

If you know the length of the field you can use substring

LV_FIRST_FIELD = ITAB-FIELD+0(4)

LV_SECOND_FIELD = ITAB-FIELD+4(10)

If the field has delimiters like space or comma you can use the SPLIT

SPLIT ITAB_FIELD AT <DELIMITER> INTO LV_FIRST_FIELD LV_SECOND_FIELD

Regards,

Sameena

Former Member
0 Kudos

Hey Rani,

make a new table itab with the fields you require.

You need to use offset method in this case.

loop at old_tab.

old_tab-col_name+0(2) = itab-field1.

old_tab-col_name+1(3) = itab-field2.

old_tab-col_name+4(5) = itab-field3.

append itab.

endloop.

You need to to decide the value of field and go ahead with this method..

If ur not sure of the length of the field, the above method wont work..

In that case, Use spilt method..

Regards,

Tanveer.

Please Mark helpful answers.

Former Member
0 Kudos

Hi Rani,

Depends on what sort of splitting you want. One possible way -

itab1 is the big itab, itab2 is split itab


loop at itab1 into wa1.
clear wa2.
split wa1 at space into wa2-field2 wa2-field2 ... 
append wa2 to itab2.
endloop

Regards,

Aniket

0 Kudos

hi Rani.

You can use OFFSET statement

Use Statement

Itab-fieldname+leaving_character(starting_character)

e.g.

constant = itab-f1+6(7)

now move this constant into another tale field as

itab1-field = constant

and also rotate this in loop so this can be done for every row in table.

Regards,

Robin.