2019 Dec 04 10:45 AM
Hello friends,
I want to split a internal table field at the 10th charakter into two strings. (first string gets the first 10 charakters second gets the rest)
Is it possible to do this with SPLIT?
Or is there a function module for this?
All of this happens in a loop with a field-symbol.
Thanks in advance.
2019 Dec 04 10:55 AM
Hello teaman,
CALL FUNCTION 'TEXT_SPLIT'
EXPORTING
length = " Length for split
text = " Input
as_character =
IMPORTING
line = " Result
rest = " Remaining text .
Regards,
Igor
2019 Dec 04 10:55 AM
Hello teaman,
CALL FUNCTION 'TEXT_SPLIT'
EXPORTING
length = " Length for split
text = " Input
as_character =
IMPORTING
line = " Result
rest = " Remaining text .
Regards,
Igor
2019 Dec 04 12:07 PM
2019 Dec 04 12:43 PM
There is simply the assignment operator or ABAP built-in functions (as proposed in the other answers) which are much faster than calling a function module.
I think it's not the best answer.
2019 Dec 04 1:17 PM
2019 Dec 04 1:57 PM
Oh I'm sorry I didn't know that.
I just tried this and it worked for me so I made it best answer.
2019 Dec 04 2:06 PM
the important is to find an answer, when you have several choose the one you better understand. (to be able to maintain it)
2019 Dec 04 3:59 PM
2019 Dec 04 11:31 AM
hi,
Try like below.
TRY.
data(lv1) = substring( val = lv_longtext off = 0 len = 10 ).
data(lv2) = substring( val = lv_longtext off = 0 len = strlen( lv_teststring ) ).
CATCH cx_sy_range_out_of_bounds INTO DATA(lx_too_long).
data(lv_error_lx_too_long) = lx_too_long->get_text( ).
ENDTRY.
2019 Dec 04 11:56 AM
types: begin of type_1,
field type text20,
end of type_1,
tt_type_1 type standard table of type_1 with key field,
begin of type_2,
field1 type text10,
field2 type text10,
end of type_2,
tt_type_2 type standard table of type_2 with key field1 field2.
data(lt_table_1) = value tt_type_1( ( field = '0123456789abcdefghjk' )
( field = '0123456789abcdefghjk' ) ).
data(lt_table_2) = value tt_type_2( for ls_table_1 in lt_table_1 ( field1 = ls_table_1+0(10)
field2 = ls_table_1+10(10) ) ).
cl_demo_output=>write_data( lt_table_1 ).
cl_demo_output=>write_data( lt_table_2 ).
cl_demo_output=>display( ).
the important part is
data(lt_table_2) = value tt_type_2( for ls_table_1 in lt_table_1 ( field1 = ls_table_1+0(10)
field2 = ls_table_1+10(10) ) ).