Skip to Content
author's profile photo Former Member
Former Member

HOW TO READ CHAR FROM RIGHT TO LEFT

HI Gurus,

I have this field that has up to 20 characters. But the problem is that sometimes it might not be filled (that is it might just have 15 characters).

How can I read the the characters from right to left. For example,

01234567898765433, and i just want the last 7, i.e 8765433.

I know i can just do var+10(7). but i dont want to do it like that because sometimes the length of the field can change. The most important, is to be able to read it from right to left so that i can have correct data even if the length is not up to 20 sometimes.

thanks all.

Reward will be given.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 05:21 PM

    Try:

    REPORT ztest MESSAGE-ID 00.
    
    DATA: f1(20) VALUE '01234567898765433',
          f2(10),
          start TYPE i,
          length TYPE i.
    
    length = STRLEN( f1 ).
    start = length - 7.
    
    f2 = f1+start(7).
    
    write: /001 f2.
    

    Rob

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2007 at 05:16 PM

    hi Basil,

    use:

    length_of_string = STRLEN( string ).

    Now you have the actual length and you can code your var+n(7) accordingly (n will be length - 8 I think).

    ec

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.