Q:

In sapscript, how do I trim/offset from the right of a string?

I have a need in SAPScript to trim a string from the right. There doesn't appear to be a function to accomplish this. &myfield+3& only trims from the left.
Is there a way to trim from the right? Can offset accept a negative value?

A:

My ultimate goal was to take a number such as a quantity; 12.43 and convert that to: 001243.

6 characters long
padded left with zeroes
no special characters (decimals or thousands separators)

Ultimately I had to first define a field and do the intial number formatting:
/:DEFINE &myfield& = &qtyfield(.2CT)&

The above 

sets the number to 2 decimal points (.2)
space compreession (C)
removes the thousands separator (T)

Then I call a function within our print routine to do the special character stripping as such:
/:PERFORM get_unformatted_value IN PROGRAM zbc_rle_ean128_label
/:USING &myfield&
/:CHANGING &myfield&
/:ENDPERFORM

Then I can do the final output as such:
/ &myfield(K6RF0)&

which:

Ignores any conversions (K)
Sets output length to 6 and right aligns it (6R)
and left pad with zeros (F0)

That seems to work for me. Hopefully this helps someone!

