‎2016 Apr 23 3:02 PM
The following coding has to be translated into ABAP 7.40:
DATA:
source TYPE string VALUE 'MARA-MATNR=12345',
tabname TYPE tabname,
fieldname TYPE fieldname,
attribute TYPE string.
SPLIT:
source AT '-'
INTO tabname fieldname,
fieldname AT '='
into fieldname attribute.
" RESULT: tabname = 'MARA', fieldname = 'MATNR', attribute = '12345' !
I do not understand the F1 help of "segment" functions' features....
appendix:
via trial & error:
tabname = segment( val = source index = 1 sep = '-' ).
fieldname = segment( val = segment( val = source index = 2 sep = '-' ) index = 1 sep = '=' ).
attribute = segment( val = source index = 2 sep = '=' ).
any shorter codings?
‎2016 Apr 23 7:23 PM
Hi Ralf,
the documentation ABAP Keyword Documentation looka quite clear, But I don't see any advantage over SPLIT in this context.
Your code will run in 740 as it is. Translation is 1 : 1.
I have no idea what the special purpose of segment function may be - don't eve like the sample code for determining min an max as given here ABAP Keyword Documentation.
Regards Clemens
‎2016 Apr 23 7:36 PM
I am just training 7.40.... So my example may offer no advantages. But it IS an advantage to append a part of a field to an internal table without using help variables, for instance. In my example:
data:
tabnames type table of tabname.
append to_upper( segment val = source index = 1 sep = '-' ) ) to tabnames.
instead of
data:
tabnames type table of tab name,
helpfield_1 type tabname,
helpfield_2 type string.
split source at '-'
into helpfield_1 " only used as split target field
helpfield_2. " helpfield_2 never used, just a dummy!
translate helpfield_1 to upper case.
append helpfield_1 to tabnames.