sapscript

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?


Solution

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

    Ultimately I had to first define a field and do the intial number formatting:

    /:DEFINE &myfield& = &qtyfield(.2CT)&
    

    The above

    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:

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