Data sent to device DSP01 not valid. Negative response code is 10050122.

15 pts.
Tags:
Display File
DSP01
IBM iSeries
iSeries RPG programming
RPG
Hello.

My display file crashes as it can not display the hexadecimal values in my character field. Is there an easy way to replace these values (like scan) in my 79 character long field that has valid characters mixed with hexadecimal values? (Please no APIs)

Thank you in advance.

Regards

Steven



Software/Hardware used:
iSeries RPG

Answer Wiki

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

Option 1 — TomLiotta’s suggestion: <i>You can loop through the characters in the string. Replace any byte that is less than x’3F’ with x’3F’</i>

<pre>
d replCharacter c const(x’3F’)
d fld79a s 79 inz(x’F0F1F2F3F44022′) ’01234′+ blank
+ unprintable
d loc s 5i 0

c for loc = 1 to %len(fld79a)
c if %subst(fld79a:loc:1) < replCharacter
c eval %subst(fld79a:loc:1) = replCharacter
c endif
c endfor
</pre>

Option 2 — BigKat’s original suggestion incorporating TomLiotta’s suggestion: <i>The Character Data Representation Architecture (CRDA) specifies the ‘3F’X character as a replacement character. It should show up as a reverse-image block on the display.</i>

<pre>
d validCharacters…
d c const(’0123456789 ‘)
d replCharacter c const(x’3F’)
d fld79a s 79 inz(’01234ABC56789′)
d loc s 5i 0

c eval loc = %check(validCharacters + replCharacter
c :fld79a)
c dow loc <> 0
c eval %subst(fld79a:loc:1) = replCharacter
c eval loc = %check(validCharacters + replCharacter
c :fld79a)
c enddo
</pre>

or if you prefer a procedure for use in a service program (and it even uses <b><i>RECURSION</i></b>) BTW: I arbitrarily chose 132 characters, as that should handle any field on the standard display sizes unless you have used CNTFLD to split a longer field into a continuous multi-line field.

<pre>
d displaySafe pr 132a
d input 132a const

p displaySafe b export
d displaySafe pi 132a
d input 132a const

d validCharacters…
d c const(’0123456789 ‘)
d replCharacter c const(x’3F’)

d loc s 5u 0
d wrk s 132a

c eval wrk = input
c eval loc = %check(validCharacters + replCharacter
c :wrk)
c if loc = 0
c return wrk
c else
c eval %subst(wrk:loc:1) = replCharacter
c return displaySafe(wrk)
c endif
p displaySafe e
</pre>

Discuss This Question: 7  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
  • BigKat
    %xlate could be used to translate all bad characters to good characters, but I figured it was easier to create a list of all valid characters rather than a list of all invalid ones.
    %xlate(from:to:string)
    8,210 pointsBadges:
    report
  • Cabero
    Hello BigKat. Thank you for the prompt response, I will give it a bash in the morning, it is sunset here in RSA. How does query display/report the values, even if it is garbage. Could the same technique not be used? Regards Steven
    15 pointsBadges:
    report
  • BigKat
    query does a character substituition for unprintable characters at the system level. It is not a function that you can call (as far as I know)
    8,210 pointsBadges:
    report
  • TomLiotta
    For this line:
     d replCharacter   c                   const(' ')
    ...consider making this change:
     d replCharacter   c                   const( x'3F' )
    The Character Data Representation Architecture (CRDA) specifies the '3F'X character as a replacement character. It should show up as a reverse-image block on the display. Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    You can loop through the characters in the string. Replace any byte that is less than x'3F' with x'3F'. Tom
    125,585 pointsBadges:
    report
  • BigKat
    if you do Tom's suggestion
    d replCharacter   c                   const(’ ‘)
    
    you need to change
    c                   eval      loc = %check(validCharacters:fld79a)
    
    to
    c                   eval      loc = %check(validCharacters + replCharacter
    c                             :fld79a)                                    
    
    8,210 pointsBadges:
    report
  • BigKat
    doh! Tom's suggestion of
    d replCharacter   c                   const( x’3F’)
    
    8,210 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