‎2010 Oct 08 12:42 PM
Hi all,
i've an internal table with following entry.
xx123
xx231
xy546
xy987
i need to seperate into 2 variables and put in different internal table how to do this
var1 = xx var2 123
var1 = xx var2 231
var1 = xy var
‎2010 Oct 08 12:48 PM
Hi,
If the length of the value is fixed you can split the value as below.
var1 = value+0(2).
var2 = value+2(3).
thanks,
sudheer
‎2010 Oct 08 12:48 PM
Hi,
If the length of the value is fixed you can split the value as below.
var1 = value+0(2).
var2 = value+2(3).
thanks,
sudheer
‎2010 Oct 08 1:01 PM
Hi,
Do like this
Loop at itab into wa.
wa1-var1 = wa-f1+0(2) -
>XX
wa1-var2 = wa-f1+2(3) -
>123
Append wa1 to itab1.
endloop.
Regards,
Prashant
‎2010 Oct 08 1:20 PM
As long as you are working with flat character-type structured table this is easy
TYPES t_field TYPE c LENGTH 5.
DATA gt_in TYPE TABLE OF t_field WITH HEADER LINE.
APPEND: 'xx123' TO gt_in,
'xx231' TO gt_in,
'xy546' TO gt_in,
'xy987' TO gt_in.
TYPES: BEGIN OF t_out,
field TYPE c LENGTH 2,
field2 TYPE c LENGTH 3,
END OF t_out.
DATA: gt_out TYPE TABLE OF t_out.
FIELD-SYMBOLS <out_tab> TYPE t_out.
LOOP AT gt_in.
ASSIGN gt_in TO <out_tab> CASTING.
APPEND <out_tab> TO gt_out.
ENDLOOP.
Please note! Such casting is however not possible in Unicode system if source structure (line type of table GT_IN) has X type or is deep one. Otherwise you can have any target structure assuming the length of both is the same and components are mappable (are of character type too).
Regards
Marcin