ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

using data structures for DSPF processing...

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

  • using data structures for DSPF processing...

    is anyone using it on a regular basis for your code? you know crap like this:
    Code:
         d DspIn           ds                  LikeRec( Sfl1 : *Input )
         d DspOut          ds                  LikeRec( Sfl1 : *Output )
         d AddDsp          ds                  LikeRec( Scr1 : *Input )
         d AddDspOut       ds                  LikeRec( Scr1 : *Output )
    
         d In              ds                  LikeRec( NoCallR : *Input )
         d Out             ds                  LikeRec( NoCallR : *Output )
    
             DoU FKey = Exit
               Or FKey = Previous;
    
               // ExFmt Scr1;
               Write Scr1 AddDspOut;
               Read Scr1 AddDsp;
               ClearMsg();
               Customer_Err = *Off;
               Reason_Err = *Off;
               Person_Err = *Off;
               Store_Err = *Off;
               SubExtract_Err = *Off;
    
               // Check For User Exit Request
               If FKey = Exit;
                 Return *On;
               EndIf;
    
               // Check For User Previous Screen Request
               If FKey = Previous;
                 FKey  = ' ';
                 Return *Off;
               EndIf;
    
    
               If Not ProtectAll;
                 // Check For Validity
                 If Mode = Write_Record;
                   Chain ( AddDsp.Customer ) DGNoCallI1;
                   If %Found;
                     AddDspOut.Msg = 'Customer Record Already Exists';
                     Customer_Err = *On;
                     Reason_Err = *On;
                     Person_Err = *On;
                     Store_Err = *On;
                     SubExtract_Err = *On;
                     ProcessMsg(*On);
                     Iter;
                   EndIf;
                 EndIf;
    
                 IsValid = Validate_Entry();
                 If IsValid;
                   If Mode = Write_Record;
                     AddDspOut.Msg = 'Customer Added';
                   Else;
                     AddDspOut.Msg = 'Customer Updated';
                   EndIf;
                   Msg = AddDspOut.Msg;
                   ProcessMsg( *Off );
                 Else;
                   Msg = AddDspOut.Msg;
                   Eval-Corr AddDspOut = AddDsp;
                   ProcessMsg( *On );
                   Iter;
                 EndIf;
    
    
                 // Add The Record
                 Eval-Corr Out = AddDsp;
    
                 If Mode = Write_Record;
                   Write NoCallR Out;
                   AddDspOut.Msg = 'Customer Record Added';
                 Else;
                   Update NoCallR Out;
                   AddDspOut.Msg = 'Customer Record Updated';
                 EndIf;
                 Msg = AddDspOut.Msg;
                 ProcessMsg(*Off);
    
               EndIf;
    
               Leave;
             EndDo;
    
             Return *Off;
    kinda reminds me of RPG II/36 display programming (or COBOL). can anyone see a real benefit to this type of coding?
    I'm not anti-social, I just don't like people -Tommy Holden

  • #2
    Re: using data structures for DSPF processing...

    If ain't broke...

    Comment


    • #3
      Re: using data structures for DSPF processing...

      Michael C. is going to come on and yell like a bad dog!

      I believe he will say something like:
      The reason is that you can move screen fields back and forth.. without keying them all in.
      If you add of remove fields it still works.

      I've played with it, but have never made it part of my copy code list..

      jamie
      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


      • #4
        Re: using data structures for DSPF processing...

        yeah i love eval-corr i'm more interested in the display logic. i can only see one true benefit at the moment and there are easy ways around that.
        I'm not anti-social, I just don't like people -Tommy Holden

        Comment


        • #5
          Re: using data structures for DSPF processing...

          I almost use them all the time now. It makes life a lot easier.

          But before IBM made a few enhancements a release or two back to improve them, they were kind of a pain to implement, which you can see in Tom's code. For example:

          A) Since about V6R1 you could use *ALL for defining the workstation data structures, so that you dont need one data structure for input and a different one for output. Man, I hated that.

          B) Sometime around V5R4, you could use the data structure on the EXFMT op code. Before then, you could only use them on the read and write op codes.

          You'll probably find that as more and more of your code gets tucked away in service program logic, which requires the use of a defined IO buffer for all files, the more you start using defined IO buffers all the time, even in programs that dont require them.

          Then again, SNDRCVF in a CL program still works.
          Michael Catalani
          IS Director, eCommerce & Web Development
          Acceptance Insurance Corporation
          www.AcceptanceInsurance.com
          www.ProvatoSys.com

          Comment


          • #6
            Re: using data structures for DSPF processing...

            i'm at v7.1 and using *ALL was giving me some grief...but maybe i "fixed" it when i changed to using INDDS i might need to review it some on my next project (provided this trip down memory lane hasn't ticked me off bad enough lol)
            I'm not anti-social, I just don't like people -Tommy Holden

            Comment


            • #7
              Re: using data structures for DSPF processing...

              Yea, the indds is able to handle the output indicators automatically when *ALL is specified. I seem to remember having to use separate input and output data structures if I didnt use an indds.
              Michael Catalani
              IS Director, eCommerce & Web Development
              Acceptance Insurance Corporation
              www.AcceptanceInsurance.com
              www.ProvatoSys.com

              Comment

              Working...
              X