0

A string is stored as a literal which contains the characters for an embedded expression.

For example:

'HELLO { sy-uname }!'

When the string is retrieved, I'm looking for a way for it to be processed as a string template. From my attempts no luck so far - but I'm hoping someone has an idea:

data(literal) = 'Hello { sy-uname }'.  "or '|Hello { sy-uname }|'. 
data(string1) = |{ literal }|.         "or  data(string1) = |\|{ literal }\||.
cl_demo_output=>display( string1  ).
  • AFAIK string templates are interpreted at compile-time, so doing this is easier said than done. Perhaps one could do it by dynamically creating and compiling a temporary ABAP program with `GENERATE SUBROUTINE POOL` and calling FORMs in that temporary program, but that would be quite a nasty hack. And you couldn't even access local variables that way unless you know in advance which one you want to pass to the FORM. Are you sure you want to go that far? – Philipp Oct 07 '21 at 13:43
  • Thanks Philipp, yes that's my understanding too.. however I'm just hoping that people who know more about abap than I do have a magic trick. The SUBROUTINE POOL option is the nuclear option and isn't worth the substantial effort. – biscuit Oct 07 '21 at 13:58
  • 2
    Maybe you can use an alternative like [mustache](https://github.com/sbcgua/abap_mustache)? – Sandra Rossi Oct 07 '21 at 15:17
  • 1
    Does this answer your question? [String template to set the default value of PARAMETER](https://stackoverflow.com/questions/41220119/string-template-to-set-the-default-value-of-parameter) – Dorad Oct 08 '21 at 04:02

0 Answers0