ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Negative sign and field exit problem

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

  • Negative sign and field exit problem

    I have just come across something very peculiar on the old green screen interface. I have a field defined like this in the DDS:

    PHP Code:
    Display file:
    A                                  4  4'Adjustment amount .'
    A            #AMT      R        B  4 24REFFLD(BCKADA BATCHC)             
    A                                      DSPATR(UL)                        
    A                                      EDTCDE(L)                         
    A                                      CHECK(RB)                         
    A  62                                  ERRMSG('Amount cannot be Zero' 62)

    Physical file:
    A            BCKADA        11  2       COLHDG('Keyed Adj' 'Amount-NCU'
    This field is a numeric price field which can accept positive or negative values. The problem is when I press the minus key the field is populated with junk. If I then prompt one of the other fields and press enter it magically sorts itself out and displays the correct value.

    For example:

    If I enter 16.00[-] then it displays 16.0}
    If I enter 16[-] then it displays 1O
    If I enter 19.55 then it displays 19.5N

    I just asked someone here about this and he said it was some funny to do with the way packed fields display. He thought maybe if I change the edit code to display the sign on the left then it might work. I'm not keen on this idea though, the program was written in 1996 so the users must be used to it with the sign on the right.

    Can anyone think of a nice way to resolve this? I rarely have to touch the green screen so this isn't really my area.

    Thanks
    Ben

  • #2
    Re: Negative sign and field exit problem

    cant test this now try changing the right adjust *Blank fill to Right adjust *zero fill.
    PHP Code:
    CHECK(RZ
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Negative sign and field exit problem

      Hi

      In DSPF on field level definition specify (DataType ) S.
      Maybe this wil do the trick.
      LP Zdenko

      Comment


      • #4
        Re: Negative sign and field exit problem

        If I add CHECK(RZ) then enter 15.50[-] I get 0000000015.5} back. So it's the same but with leading zeros.

        One other thing that may or may not be relevant, this screen is displaying as a window overlaying another screen. I don't think that should matter but you never know!
        Ben

        Comment


        • #5
          Re: Negative sign and field exit problem

          Ok, I don't really want to change it like that. At the moment it is referencing the actual field on the PF which has to be better then repeating the definition in the display file.

          I've given it a go anyway to see if it fixes the problem. The display file now looks like this:
          PHP Code:
          A            #AMT          11S 2B  4 24DSPATR(UL)                           
          A***                                      EDTCDE(L)                         
          A                                      CHECK(RB)                            
          A  62                                  ERRMSG('Amount cannot be Zero' 62
          Notice I had to comment out the EDTCDE to get it to compile.

          Now if I try to enter a number in this field I get the following error.
          "Only characters 0 through 9 allowed."
          What about "."?
          Ben

          Comment


          • #6
            Re: Negative sign and field exit problem

            Hi

            OK. I tried by myself. I cleared (data type) S and then use to exit field Field- key.
            It looks OK by me.
            Try ro remove REFFLD on the field and define it in dspf file.
            LP Zdenko

            Comment


            • #7
              Re: Negative sign and field exit problem

              I get the same funky 'N' here when using field exit.
              once you hit enter it changes to "-"
              I've tried multiple data types as well as editwords.... all to the same outcome.

              Can you change the field to require Field exit and then automatic record advance?
              I know this sucks as a solution but it would work.
              All my answers were extracted from the "Big Dummy's Guide to the As400"
              and I take no responsibility for any of them.

              www.code400.com

              Comment


              • #8
                Re: Negative sign and field exit problem

                IIRC, if you're running on Client Access it does the silly stuff, but on a good ole 3197 (or similar), it shows the number with the minus. Will have to check that later on our System Console to verify.
                http://www.linkedin.com/in/chippermiller

                Comment


                • #9
                  Re: Negative sign and field exit problem

                  As I said, you can't define it as an S because that doesn't let you enter a decimal point.

                  Between three of us here we now have something working. It's horribly complicated.

                  One of my colleagues found this article.

                  The field is now defined in the display file like this:
                  PHP Code:
                  A                                  4  4'Adjustment amount .'               
                  A            #AMT      R        B  4 24REFFLD(BCKADA BATCHC)               
                  A                                      DSPATR(UL)                          
                  A                                      EDTCDE(L)                           
                  A                                      CHECK(RB)                           
                  A                                      CHECK(ER)                           
                  A                                      CHANGE(95)                          
                  A  62                                  ERRMSG('Amount cannot be Zero' 62
                  The CHECK(ER) basically means that it passes control back to the program when you use field exit. We then had to change the program to not do the validation on these requests and simply re-display the screen. There was also a bit of fannying around to get the cursor to position on the right fields when you press a field exit key.

                  It's not the most efficient code as it has to trundle off back to the server to re-display the screen but there we have it. Bottom line is it's working now.

                  Thanks for looking at this guys. Maybe this solution will come in handy for someone else one day.
                  Ben

                  Comment

                  Working...
                  X