Command or function to change/convert char to hex values in RPGLE

110 pts.
Tags:
AS/400
RPGLE
I have a string that needs to be converted to its hex values and then i need to check if any character in than string is less than x'40. If so, I need to replace it with blanks. The output should be the character string (The string will have its invalid character's (less than x'40) replaced with blanks). I'm not sure how %xlate helps.

Software/Hardware used:
AS400

Answer Wiki

Thanks. We'll let you know when a new response is added.

You can also loop through the characters in the data field and if *LT blank, move blank to that field. You do not have to convert to HEX.

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • philpl1jb

    Discussion is @

    http://www.rpgpgm.com/2014/01/translating-hexadecimal-values-using.html

    Looks like this will do the trick

    D from C X'000102030405060708090A0B0C0D0E0F-
    D 101112131415161718191A1B1C1D1E1F-
    D 202122232425262728292A2B2C2D2E2F-
    D 303132333435363738393A3B3C3D3E3F'
    D to   C X'                                -
    D -
    D -
    D '
                                                 
    
    /FREE
    
      FLD01 = %xlate(from:to:FLD01);
    
    
    49,950 pointsBadges:
    report
  • BigKat
    wouldn't that need to be
    D to   C X'4040404040...

    8,200 pointsBadges:
    report
  • BigKat
    also just in case it isn't clear because of the way the display shows this, those are D-specs to create constants named "to" and "from" and initialized to the appropriate hex values.  (x'000102...' and x'404040...')
    8,200 pointsBadges:
    report
  • philpl1jb

    BigKat yes

    D to C X'4040'

    or

    D to C '  '

    Either replaces the character with a space.  But I had toooo many spaces in the to

    49,950 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following