ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Data Area

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

  • Data Area

    Can anyone provide me with a example of reading a data area in /Free function?

    Thnx
    Bill
    "A good friend will bail you out of jail,
    A true friend would be sitting beside you saying,
    'Wow, that was fun.'"

  • #2
    Re: Data Area

    Hi, You have to handle them in regular rpg IV "C" specs. At least that is how it is on version V5R2M0.
    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #3
      Re: Data Area

      PHP Code:
      CRTDTAARA DTAARA(QTEMP/JUNKTYPE(*CHARLEN(10VALUE('0123456789'TEXT('some junk'
      PHP Code:
       *                                                                
       * 
      Variable Definition                                            
       
      *                                                                
                                                                        
      d whathurts       DS                  DTAARA(JUNK)                
      d  allofme                      10                                
                                                                        
      d dsdata          ds                  qualified  inz              
      d  WholeTomato                  10                                
      d   zero                         1    overlay
      (WholeTomato:1)      
      d   one                          1    overlay(WholeTomato:*next)  
      d   two                          1    overlay(WholeTomato:*next)  
      d   three                        1    overlay(WholeTomato:*next)  
      d   four                         1    overlay(WholeTomato:*next)  
      d   five                         1    overlay(WholeTomato:*next)  
      d   six                          1    overlay(WholeTomato:*next)  
      d   seven                        1    overlay(WholeTomato:*next)  
      d   eight                        1    overlay(WholeTomato:*next)  
      d   nine                         1    overlay(WholeTomato:*next)  
                                                               
       /
      Free                                                   
                                                               
         
      //----------------------------------------------------
         // MAIN PROGRAM                                       
         //----------------------------------------------------
                                                               
             
      in whathurts;                                     
             
      dsdata.wholetomato allofme;                     
                                                               
              *
      inlr = *on;                                     
                                                               
                                                               
       /
      End-Free 
      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: Data Area

        Very nice. thanks.
        Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

        Comment


        • #5
          Re: Data Area

          Ya thnx. already got it programmed and working.
          Bill
          "A good friend will bail you out of jail,
          A true friend would be sitting beside you saying,
          'Wow, that was fun.'"

          Comment


          • #6
            Re: Data Area

            I haven't tried this but if you use UDS instead of DS to describe your data area, then it gets read in at the start of the program and out at the end implicitly.
            Originally posted by jamief View Post
            PHP Code:
            CRTDTAARA DTAARA(QTEMP/JUNKTYPE(*CHARLEN(10VALUE('0123456789'TEXT('some junk'
            PHP Code:
             *                                                                
             * 
            Variable Definition                                            
             
            *                                                                
                                                                              
            d whathurts       UDS                 DTAARA(JUNK)                
            d  allofme                      10                                
                                                                              
            d dsdata          ds                  qualified  inz              
            d  WholeTomato                  10                                
            d   zero                         1    overlay
            (WholeTomato:1)      
            d   one                          1    overlay(WholeTomato:*next)  
            d   two                          1    overlay(WholeTomato:*next)  
            d   three                        1    overlay(WholeTomato:*next)  
            d   four                         1    overlay(WholeTomato:*next)  
            d   five                         1    overlay(WholeTomato:*next)  
            d   six                          1    overlay(WholeTomato:*next)  
            d   seven                        1    overlay(WholeTomato:*next)  
            d   eight                        1    overlay(WholeTomato:*next)  
            d   nine                         1    overlay(WholeTomato:*next)  
                                                                     
             /
            Free                                                   
                                                                     
               
            //----------------------------------------------------
               // MAIN PROGRAM                                       
               //----------------------------------------------------
                            
                    //** IN is now carried out implicitly **//                                 
                   //*** in whathurts;                                     
                   
            dsdata.wholetomato allofme;                     
                                                                     
                    *
            inlr = *on;                                     
                                                                     
                                                                     
             /
            End-Free 
            Ben

            Comment


            • #7
              Re: Data Area

              Nice touch. Not sure if I like it though. It feels almost like taking a step back and using the rpg cycle Input primary.

              I can't see where it is read in using the IN statement. Just like reading a primary file, can't see a read statement.

              I guess once you get used to it, it would become second nature. I will keep it in mind and give it a try.

              Thnx Ben
              Bill
              "A good friend will bail you out of jail,
              A true friend would be sitting beside you saying,
              'Wow, that was fun.'"

              Comment


              • #8
                Re: Data Area

                Hi Bill:

                You don't need the dtaara keyword, if status data area is in your library list it will be read.

                Code:
                 D Status         uds
                 D  Stat                   1      8
                  /free
                      Stat = 'BR-549';
                And as benthurley pointed out status is read at program initialization and written at lr

                Best of Luck
                GLS
                The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

                Comment


                • #9
                  Re: Data Area

                  Is there a nice easy pretty way to clear a dtaara? I have one that I need to clear when someone hits F12. any suggestions?
                  Your future President
                  Bryce

                  ---------------------------------------------
                  http://www.bravobryce.com

                  Comment


                  • #10
                    Re: Data Area

                    I found this from TAATOOLS, but how would I implement it in RPGLE?

                    CLRDTAARA DTAARA(DTA1)

                    it is a command....something I would need to run in CL. But that is not practical for my project.... any thoughts?
                    Your future President
                    Bryce

                    ---------------------------------------------
                    http://www.bravobryce.com

                    Comment


                    • #11
                      Re: Data Area

                      create a physical file to the exact length of the dataarea with all its fields

                      use this hunk of code
                      PHP Code:
                      d Mydataarea   e ds                  extname(ARMARCH
                      Then just : clear mydataarea

                      update (out) the dataarea with the cleared mydataarea

                      make any sense I can see to form a thought today
                      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


                      • #12
                        Re: Data Area

                        CLEAR is not an opcode though is it?
                        Your future President
                        Bryce

                        ---------------------------------------------
                        http://www.bravobryce.com

                        Comment


                        • #13
                          Re: Data Area

                          oh but CLEAR actually is an opcode....so dumb sometimes....i got it. And I didn't even need a PF. :P
                          Your future President
                          Bryce

                          ---------------------------------------------
                          http://www.bravobryce.com

                          Comment


                          • #14
                            Re: Data Area

                            besides clear you could just use the reset opcode....
                            this would also set the variable program21 back to all blanks.



                            Code:
                                  *=====================================================
                                  *--------------------------------------------------------
                                  *
                                  * Variable Definition
                                  *
                                 d CmdLength       s             15  5 inz(0)
                                 d CmdString       s            256    inz(*blanks)
                                 d program21       s             21    inz(*blanks)
                                 d reply           s              1
                            
                                   //
                                   //  external calls
                                   //
                            
                                 d $command        pr                  extpgm('QCMDEXC')
                                 d   command                   5000    options(*varsize)
                                 d   Length                      15  5
                            
                            
                                  /Free
                            
                                    //--------------------------------------------------------
                                    // MAIN PROGRAM
                                    //--------------------------------------------------------
                            
                                         cmdstring = 'CRTDTAARA DTAARA(QTEMP/MYTWENTY1) TYPE(*CHAR)';
                                         cmdlength = %len(%trim(cmdstring));
                                         monitor;
                                         $command (cmdstring:cmdlength);
                                         on-error;
                                         endmon;
                            
                                       // populate it  ....
                            
                                         *in99 = *on;
                                         dow *in99 = *on;
                                         in(e) *lock Program21;
                                          *in99 = %error;
                                         enddo;
                            
                                         Program21 = 'Holy Crap Batman!';
                                         out  Program21;
                            
                                         in Program21;
                                         dsply program21 reply;
                            
                                       // now clear it  ....
                            
                                         *in99 = *on;
                                         dow *in99 = *on;
                                         in(e) *lock Program21;
                                          *in99 = %error;
                                         enddo;
                                         clear Program21;
                            
                                         out  program21;
                            
                                         in  Program21;
                            
                                         dsply program21 reply ;
                            
                                         *inlr = *on;
                                    //--------------------------------------------------------
                                    // *inzsr - initial one time subroutine
                                    //--------------------------------------------------------
                            
                                         begsr *inzsr;
                            
                                  /end-free
                                 c     *dtaara       define    MyTwenty1     Program21
                                  /Free
                            
                                         endsr;
                            
                                    //--------------------------------------------------------
                                  /End-Free
                            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


                            • #15
                              Re: Data Area

                              I appreciate all the hard work on the example Jamie, but here is what I did....

                              PHP Code:
                                    *
                                    *Array
                                   
                              D  SEQUENCE       S              4  0  DIM(5ASCEND INZ(*HIVAL)
                                   
                              D
                                   D FILEARRAY       DS
                                   D  SEQNCE                        4S 0  OVERLAY
                              (FILEARRAY:1)      
                                     * 
                              Program runs and fills dtaara with some stuffthen I call a routine to display
                                     
                              a screen, and upon a cancel of that screen I clear the dtaara.  
                                   
                              C
                                    
                              *
                                    * 
                              Was F12 pressed
                                   C                   
                              IF        RETURN
                                   
                              C                   CLEAR     SEQUENCE
                                   C                   
                              ENDIF 


                              just some clarifications.....CLEAR is the opcode and SEQUENCE goes into the Result Field, not Factor 2.
                              Last edited by bryce4president; July 5, 2007, 02:34 PM. Reason: code clarification.....
                              Your future President
                              Bryce

                              ---------------------------------------------
                              http://www.bravobryce.com

                              Comment

                              Working...
                              X