‎2008 Mar 24 10:28 AM
&----
*& Report ZTEST1231212
*&
&----
*&
*&
&----
REPORT ZTESTSPLIT.
DATA: cmd(254), "Max length = 254 Bytes
result(255) OCCURS 100 WITH HEADER LINE, "No max length
BEGIN OF list OCCURS 100,
nr TYPE i,
line(255),
END OF list,
res(40) TYPE c,
res1(20) TYPE c,
res2(20) TYPE c,
list1 type table of string.
DATA list2 TYPE TABLE OF xstring.
DATA res3 TYPE xstring.
DATA res4 TYPE string.
CONCATENATE 'du -ks /usr/sap/' sy-sysid '/D*/work' INTO cmd.
CALL 'SYSTEM' ID 'COMMAND' FIELD cmd
ID 'TAB' FIELD result-sys.
CLEAR list.
LOOP AT result.
list-line = result.
APPEND list.
ENDLOOP.
WRITE: 'Execution success'.
WRITE: cmd.
DATA splt TYPE xstring.
DATA splt1 TYPE string.
LOOP AT list.
WRITE : list-line.
res = list-line.
SPLIT res AT '#' INTO: res1 res2, table list1.
SHIFT res UP TO '#'.
write: res.
ENDLOOP.
res3 = res.
splt1 = '#'.
DATA result1 TYPE string.
result1 = substring_after( val = res sub = '#' ).
DATA: result_tab TYPE match_result_tab.
FIND FIRST OCCURRENCE OF '#' IN res RESULTS result_tab.
res4 = res.
CALL FUNCTION 'LXE_COMMON_STRING_TO_XSTRING'
EXPORTING
in_string = res4
IN_CODEPAGE = '0000'
EX_CODEPAGE = '4110'
IMPORTING
EX_XSTRING = res3
EXCEPTIONS
ERROR = 1
OTHERS = 2
.
CALL FUNCTION 'LXE_COMMON_STRING_TO_XSTRING'
EXPORTING
in_string = splt1
IN_CODEPAGE = '0000'
EX_CODEPAGE = '4110'
IMPORTING
EX_XSTRING = splt
EXCEPTIONS
ERROR = 1
OTHERS = 2
.
DATA r11 TYPE xstring.
DATA r22 TYPE xstring.
SPLIT res3 AT splt INTO table list2 IN BYTE MODE.
DO.
TRY.
result1 = segment( val = res
index = sy-index
sep = '#' ).
CATCH cx_sy_strg_par_val.
EXIT.
ENDTRY.
ENDDO.
‎2008 Mar 24 10:35 AM
Hi
Use the class CL_ABAP_CHAR_UTILITIES with the attribute NEWLINE to remove the #.
lv_hash TYPE c VALUE cl_abap_char_utilities=>newline.lv_text1 TYPE string
lv_text1 = <req value>.
lv_char = lv_text1.
REPLACE lv_hash IN lv_char WITH gc_blank.
Thanks
Vijay
‎2008 Mar 24 10:35 AM
Hi
Use the class CL_ABAP_CHAR_UTILITIES with the attribute NEWLINE to remove the #.
lv_hash TYPE c VALUE cl_abap_char_utilities=>newline.lv_text1 TYPE string
lv_text1 = <req value>.
lv_char = lv_text1.
REPLACE lv_hash IN lv_char WITH gc_blank.
Thanks
Vijay
‎2008 Mar 24 10:51 AM
Sorry, but I am not able to work with code provided by you. Can you elaborate. I am a bit novice
Regards,
Ahmed
‎2008 Mar 24 10:40 AM
Hi,
Please refer sample code below :
data: lv_tabch TYPE char01 VALUE cl_abap_char_utilities=>horizontal_tab.
if you use lv_tabch system will take care of the Symbols either ',' or '#' or tab delimeted.......
and SPLIT LS_FILE AT lv_tabch INTO <var>.
Thanks,
Sriram Ponna.
‎2008 Mar 24 10:46 AM
Hi,
I think by '#' you mean the tab-character. In that case you can use
cl_abap_char_utilities=>horizontal_tab.
I would suggest you to use public constants available in the class CL_ABAP_CHAR_UTILITIES whenever possible.
HORIZONTAL_TAB --> "Horizontal Tab Stop" Character
VERTICAL_TAB --> "Vertical Tab Stop" Character
NEWLINE --> "New
CR_LF --> "Carriage Return and Line Feed" Character Pair
Hope this helps. Reward points if helpful.
Thanks,
Balaji