Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Issue with TESTN Function on V5R1M0

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Issue with TESTN Function on V5R1M0

    TESTN accepts '00000K' as a valid numeric. Read the description of TESTN in the RPG Reference Manual: The right-most character is considered valid numeric if the digit nybble is hex 0-9 and the zone nybble is hex C, D, or F. Character K is x'D2', and so is considered a valid numeric. Best to check for valid numerics using BIF %CHECK.

  • #2
    Issue with TESTN Function on V5R1M0

    Was wondering if this is a new feature of an error on IBM as I never noticed this happeneing before. What I have is a incoming patient number field that some can have alpha characters in the number. So what I want to do is test the field, if its numeric then convert over as is, if it fails the numeric test then renumber the account. The accounts I have problems with are like 'bbb0Tb' where b represents blanks and the number zero and letter T is actually in the field. I do the follow where adpatno is my incoming field: move *blanks wpatno 7 work field z-add *zeros tpatno 7 0 test field evalr wpatno = %trimr(adpatno) 'b':'0' xlate wpatno wpatno **where b is blanks** testn wpatno 20 ~~ then the code for if statement fails then renumber account and so on. Which for the example above, it right justifiys the 0K then xlates the blanks to zeros. After that the field is then '00000K' I do the test and it passes which it shouldn't. Was wondering if things has changed since later releases. I did a work around so to speak so that I can get this conversion on out the door but thought to bring this up. My work around was creating a UPPER field in the D specs from A to Z and one below it named Crap with 26 % signs. Then I just Upper:Crap xlate wpatno wpatno then 'b':'0' xlate wpatno wpatno which turns any blanks to zeros. And run the test and it works fine. Just that I never had this problem before where it skips the last digit. Thanks

    Comment


    • #3
      Issue with TESTN Function on V5R1M0

      Thanks Hans for the info. Just never had this happen before back in RPGIII but might not have ever encountered a letter K or C either. I'll look into using the BIF check as thats something new for me as well. One good thing about programming. . .learn something new every day. Thanks

      Comment


      • #4
        Issue with TESTN Function on V5R1M0

        If you z-add say -12 to a 2 digit zoned field, the result will be x'F1D2'. In character form, this is '1K'. So 'K' is a valid final byte to move to a numeric value, giving a negative result. Another workaround would be: after you've moved the character value to the numeric, do a further check to make sure the number isn't negative.

        Comment

        Working...
        X