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: 

String templates - missing functionalities?

Former Member
0 Kudos

Hello everyone,

the ABAP documentation says that the "WRITE TO" statement can be replaced with "string templates" in most cases. So this means, that there are some cases that are not covered with "string templates".

Unfortunately the documentation does not clarify, which cases are left out.

I cannot find a "string template" equivalent to the following "WRITE TO" additions:

  • UNIT
  • LEFT-JUSTIFIED

Am I missing something, or is there no equivalent?
Does anyone know, if there are plans to make all functionalities of "WRITE TO" available for "string templates"?

ps. The string expression "ALIGN = LEFT" is not the same as "WRITE ... TO... LEFT JUSTIFIED".

1 ACCEPTED SOLUTION

former_member195402
Active Contributor
0 Kudos

Hi Andre,

formatting option "align = left" will replace LEFT-JUSTIFIED, but for UNIT I can't find an option .

Regards,

Klaus

6 REPLIES 6

former_member195402
Active Contributor
0 Kudos

Hi Andre,

formatting option "align = left" will replace LEFT-JUSTIFIED, but for UNIT I can't find an option .

Regards,

Klaus

0 Kudos

Thanks for your reply. But "ALIGN = LEFT" has different behavior regarding leading zeros

Edit: I have to correct that. You are right.

I made further tests and found out that "ALIGN = LEFT" is equivalent to LEFT-JUSTIFIED.

The difference, that a saw was coming from a conversion exit.

So thanks again

0 Kudos

That brings me to another difference. "WRITE TO" does an implicit conversion (when the underlying domain is assigned to a conversion exit). "string templates" do not provide a functionality to call conversion exits (except ALPHA conversion).

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

I'd say it's mainly the conversion routines. But since string formatting should not be mixed up with screen handling, that's OK.

And UNIT, well, well. Look at its documentation and forget it ...

Besides that, the string templates should have it all and more.

0 Kudos

Horst Keller wrote:

I'd say it's mainly the conversion routines. But since string formatting should not be mixed up with screen handling, that's OK. 

Yes, that makes sense.


Horst Keller wrote:

And UNIT, well, well. Look at its documentation and forget it ...

OK, after reading the documentation of UNIT carefully I think to understand what you mean.

Nobody can want to reimplement such a strange and implicit behavior for string templates.

There are some functionalities and bad implicit behavior of WRITE TO that are not worth being covered by string templates.

0 Kudos

So previously when you would output a quantity field (e.g. 99.000) with a unit of EA

WRITE qty UNIT 'EA'

which would output 99 instead of 99.000

To achieve the same in a String Template

|{ qty STYLE = SIMPLE }|.

which will retain any decimals if present, otherwise will just output the whole number.