Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

SPLIT String

Hi All,

Can anyone tell me how do i separate following:

01, Rupesh, Mhatre, "Mhatre, Rupesh", 23.08.2008

as

01

Rupesh

Mhatre

Mhatre, Rupesh

23.08.2008

Thanks in Advance

Regards,

Rupesh

Tags:
Former Member
Former Member replied

Try this:

DATA: g_text  TYPE string,
      g_text2 type string.

DATA: it_result_tab TYPE match_result_tab,
      wa_result_tab TYPE match_result,
      g_start  TYPE syindex,
      g_end    TYPE syindex,
      g_length TYPE syindex.

g_text = '01, Rupesh, Mhatre, "Mhatre, Rupesh", 23.08.2008'.


FIND ALL OCCURRENCES OF '"' IN g_text RESULTS it_result_tab.
IF sy-subrc EQ 0.

  READ TABLE it_result_tab INDEX 1 INTO wa_result_tab.
  IF sy-subrc EQ 0.
    g_start = wa_result_tab-offset.
  ENDIF.

  READ TABLE it_result_tab INDEX 2 INTO wa_result_tab.
  IF sy-subrc EQ 0.
    g_end = wa_result_tab-offset.
  ENDIF.

  g_length = g_end - g_start + 1.

  g_text2 = g_text+g_start(g_length).

  replace g_text2 in g_text with ''.


* Then do the splitting on G_TEXT

ENDIF.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question