Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Split text

Former Member
0 Likes
939
IF t059zt-text40 = 'Rent- Land/Building or Furniture/Fitting'.

i want to split Rent- Land/Building into one variable and rest to another?

how to code?

1 ACCEPTED SOLUTION
Read only

venkat_o
Active Contributor
0 Likes
892

<li>Try this way.


DATA:
text1 TYPE string,
text2 TYPE string.          
IF t059zt-text40 = 'Rent- Land/Building or Furniture/Fitting'.
 SPLIT t059zt-text40 AT 'or' INTO text1 text2.
ENDIF.
Thanks Venkat.O

7 REPLIES 7
Read only

Former Member
0 Likes
892

Hello

Use FM RKD_WORD_WRAP with OUTPUTLEN = 20

Read only

Former Member
0 Likes
892

You can use

SPLIT AT 'or' INTO var1 var2.

Regards,

Mohaiyuddin

Read only

venkat_o
Active Contributor
0 Likes
893

<li>Try this way.


DATA:
text1 TYPE string,
text2 TYPE string.          
IF t059zt-text40 = 'Rent- Land/Building or Furniture/Fitting'.
 SPLIT t059zt-text40 AT 'or' INTO text1 text2.
ENDIF.
Thanks Venkat.O

Read only

Former Member
0 Likes
892

split at 'or' removes or from 'Rent- Land/Building or Furniture/Fitting'.

I did try this earlier.

Read only

jrg_wulf
Active Contributor
0 Likes
892

try


Field-Symbols:<part>.
data: part1 type string,
         part2 type string,
         pos type i.
if t059zt-text40 cs 'or'.
  pos = sy-fdpos.
  assign t059zt-text40(pos) to <part>.
  part1 = <part>.
  subtract 1 from pos.
  shift t059zt-text40 left by pos places.
  part2 = t059zt-text40
endif.

adjust pos according to your needs (leading or trailing blank)

regards

Jörg

Read only

0 Likes
892

Hi,

Take the offset if the length is fixed. Check below code.


DATA: l_off TYPE i.

l_off = strlen( t059zt-text40).
IF l_off GE 20.
l_first = t059zt-text40+0(20).
ELSE.
l_first = t059zt-text40.
ENDIF.

l_off = l_off - 20.

IF l_off GT 0.
l_rest = t059zt-text40+20(l_off)
ENDIF.

Thanks,

Vinod.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
892

data:lv_string type string.
lv_string = 'Rent- Land/Building or Furniture/Fitting'.
if lv_string ca 'or'.
write lv_string+0(sy-fdpos)."or it-field1 = lv_string+0(sy-fdpos).
skip1.
write lv_string+sy-fdpos(*)."or it-field2 = lv_string+sy-fdpos(*).
endif.

Edited by: Keshav.T on Feb 12, 2010 6:17 PM