Application Development 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: 

Substring in a Simple Transformation. Possible?

Astashonok
Participant
0 Kudos

Can we split string by index or by regex in simple transformation during deserialization?

For example if we have XML tag <CAR> and want to split it's value by semicolon

<CAR>TYPE:LIMOUSINE; VENDOR:DODGE; VELOCITY:150; ENGINE:V8</CAR>

into internal table

 type		vendor      velocity	engine	
limousine 	 dodge	    	150	V8

I didn't find anything about this in tt:value help. Can we do this by means of ST, something like in XSLT?

<xsl:value-ofselect="substring(concat(., ''), 1, 1)"/>
1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor

You may call an ABAP method -> ABAP documentation ST - tt:call-method, Call Static Methods.

I tried tt:call-method and it worked for me. Of course, you can do whatever you want in the method, including the use of regular expressions.

6 REPLIES 6

Sandra_Rossi
Active Contributor
0 Kudos

You may call an ABAP method -> ABAP documentation ST - tt:call-method, Call Static Methods.

Astashonok
Participant
0 Kudos

sandra.rossi so this is not among the built-in features?

Astashonok
Participant
0 Kudos

I suppose it will be impossible to run CL_ABAP_REGEX or CL_ABAP_MATCHER via tt:call. Did you try it?

Sandra_Rossi
Active Contributor
0 Kudos

If you say that it's not a "built-in function", then there's almost no built-in function at all in Simple Transformations.

I don't understand why you say it is "impossible to run [a method] via tt:call", can you explain?

I tried tt:call-method and it worked for me.

Astashonok
Participant

Agreed, Sandra. The wording "built-in function" is misleading here, there is no btf in ST. Okay, thanks for suggestion, I will try to run CL_ABAP_MATCHER in ST. You can post this as answer.

Sandra_Rossi
Active Contributor

You may call an ABAP method -> ABAP documentation ST - tt:call-method, Call Static Methods.

I tried tt:call-method and it worked for me. Of course, you can do whatever you want in the method, including the use of regular expressions.