ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

pass a multi-dimension array as a parameter

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

  • pass a multi-dimension array as a parameter

    I want to pass a multi-dimension array as a parameter, but I can't
    figure out how to call my procedure. Compiler keep complaining that
    "Array has too many omitted indexes"

    PHP Code:
    #MyDS        DS                                                          
    D  #MyArr                       90A   dim(100)                                 
    #Name                         30A   overlay(#MyArr : *Next)            
    #Addr1                        30A   overlay(#MyArr : *Next)            
    #Addr2                        30A   overlay(#MyArr : *Next)            

    D GetAddresses     PR                                                  
    @CustNo                         5A   const                           
    @MyArr                               likeds(#MyDS)              

    -----------------------------------------------------
    @Custno         5A       inz('99999')
    D Something       ??

    GetAddress(#CustNO:Something); 

  • #2
    Re: pass a multi-dimension array as a parameter

    perhaps this:
    Code:
    D Something                            likeds(#MyDS)
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: pass a multi-dimension array as a parameter

      PHP Code:
      D Something                            likeds(#MyDS) 
      Keyword is not allowed for a field definition; keyword ignored.
      (can't say its like a DS if it's not a DS can you?)


      PHP Code:
      D Something             DS             likeds(#MyDS) 
      Array has too many omitted indexes; specification is ignored.

      Comment


      • #4
        Re: pass a multi-dimension array as a parameter

        I placed the following into a program and it compiled fine:
        PHP Code:

             D 
        #MyDS           DS
             
        D  #MyArr                       90A   dim(100)
             
        #Name                         30A   overlay(#MyArr : *Next)
             
        #Addr1                        30A   overlay(#MyArr : *Next)
             
        #Addr2                        30A   overlay(#MyArr : *Next)

             
        d GetAddresses    PR                  extpgm('TEST')
             
        D NewDS                               likeDS#MyDS ) 
        Where exactly is the error occuring at? Is it on the call to the procedure?
        Last edited by MichaelCatalani; December 30, 2009, 04:02 PM.
        Michael Catalani
        IS Director, eCommerce & Web Development
        Acceptance Insurance Corporation
        www.AcceptanceInsurance.com
        www.ProvatoSys.com

        Comment


        • #5
          Re: pass a multi-dimension array as a parameter

          itp,

          I pass this guy around all the time.

          Code:
           D BegANVLDS     E DS                   OCCURS( 500    ) INZ
           D                                     EXTNAME( ANVLDS )    
           D                                     QUALIFIED
          Maybe that will help...
          "Tis better to be thought a fool then to open one's mouth and remove all doubt." - Benjamin Franklin

          Comment


          • #6
            Re: pass a multi-dimension array as a parameter

            nice fellow, but not a based on external file.
            Maybe my approach is wrong.

            Comment


            • #7
              Re: pass a multi-dimension array as a parameter

              Oh, I see now. You are using an array and I am using a MODS. Very different animals...
              "Tis better to be thought a fool then to open one's mouth and remove all doubt." - Benjamin Franklin

              Comment


              • #8
                Re: pass a multi-dimension array as a parameter

                how bout something like this

                program1
                PHP Code:
                      //
                      // Variable Definition
                      //

                     
                d count           s              3  0
                     d x               s              3  0

                     d lbldata         ds                  inz Qualified
                     d  WholeTomato                5000    varying
                     d   addresses                  500    overlay
                (WholeTomato:1dim(10)
                     
                d    address1                  100    overlay(addresses:1)
                     
                d    address2                  100    overlay(addresses:*next)
                     
                d    address3                  100    overlay(addresses:*next)

                     
                d $Multi2         pr                  extpgm('@MULTI2')
                     
                d   QueueData                 4096    options(*varsize)

                      /
                Free
                            
                for count 1 to 10;
                             
                lbldata.address1(count) = 'address 1 - OTH'+ %char(count);
                             
                lbldata.address2(count) = 'address 2 - OTH'+ %char(count);
                             
                lbldata.address3(count) = 'address 3 - OTH'+ %char(count);
                            endfor;

                            
                $multi2(lbldata);
                            *
                inlr = *on;


                      /
                End-Free 
                program2
                PHP Code:

                     d 
                @MULTI2         pr
                     d  indata                     4096

                     d 
                @MULTI2         pi
                     d  indata                     4096


                      
                //
                      // Variable Definition
                      //

                     
                d lbldata         ds                  inz Qualified
                     d  WholeTomato                5000    varying
                     d   addresses                  500    overlay
                (WholeTomato:1dim(10)
                     
                d    address1                  100    overlay(addresses:1)
                     
                d    address2                  100    overlay(addresses:*next)
                     
                d    address3                  100    overlay(addresses:*next)
                      /
                Free

                            lbldata 
                indata;
                            *
                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


                • #9
                  Re: pass a multi-dimension array as a parameter

                  yep, that will work but a bit of the big hammer approach, no?

                  Comment


                  • #10
                    Re: pass a multi-dimension array as a parameter

                    Like Friggen Thor!
                    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


                    • #11
                      Re: pass a multi-dimension array as a parameter

                      Thor... I think I found a more fitting image.



                      looks like you can't pass an array as a parm.

                      Comment


                      • #12
                        Re: pass a multi-dimension array as a parameter

                        Now Thats a hole!
                        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


                        • #13
                          Re: pass a multi-dimension array as a parameter

                          hey if you want something a bit more confusing for the .net guy that takes your place..

                          PHP Code:
                                  //
                                // Variable Definition
                                //

                               
                          d  mydata         ds                  Qualified
                               d   allmydata                 4096
                               d   customer                   234    dim
                          (10overlay(allmydata:1)
                               
                          d   ID                           5  0 overlay(allmydata:*next)
                               
                          d   contact                     30A   overlay(allmydata:*next)
                               
                          d   Company                     30A   overlay(allmydata:*next)
                               
                          d   Address                           likeds(Addroverlay(allmydata:*next)
                               
                          d   Shipto                            likeds(Shipoverlay(allmydata:*next)

                               
                          d  Addr           ds                  Qualified
                               d   street                      40
                               d   city                        30A
                               d   state                        2A
                               d   zip                         10a

                               d   ship          ds                  Qualified
                               d   ID                           5  0
                               d   street                      40
                               d   city                        30A
                               d   state                        2A
                               d   zip                         10a


                               d $Multi2         pr                  extpgm
                          ('@MULTI2')
                               
                          d   QueueData                 4096    options(*varsize)

                                /
                          Free

                                      $Multi2
                          (mydata.allmydata);
                                       *
                          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


                          • #14
                            Re: pass a multi-dimension array as a parameter

                            Made a test Q and D that works. I'm running on V5R3.
                            Code:
                                 H dftactgrp(*no)
                                 D i               S             10i 0
                                 D CustNo          S              5A
                            
                                 D GetAddresses    PR
                                 D  CustNo                        5A   const
                                 D  MyArr                              likeds(#MyDS) [B]dim(100)[/B]
                            
                                 D #MyDS           DS                  [B]dim(100) [/B]qualified
                                 D  #Name                        30A
                                 D  #Addr                        30A
                            
                                  /free
                                    *inlr = *on;
                            
                                   CustNo = '99999';
                                   for i = 1 to 10;
                                      #MyDS(i).#Name = ...;
                                      #MyDS(i).#Addr = ...;
                                   endfor;
                            
                                   GetAddresses (CustNo : #MyDS );
                                   return;
                            
                                  /end-free
                            
                                 P GetAddresses    B
                                 D GetAddresses    PI
                                 D  CustNo                        5A   const
                                 D  MyArr                              likeds(#MyDS) [B]dim(100)[/B]
                            
                                D idx             S             10i 0 
                                                                  
                                 /free                                
                                   for idx = 1 to 5;                 
                                     dsply MyArr(idx).#Name;          
                                     dsply MyArr(idx).#Addr;          
                                   endfor;                            
                                   return;
                                   /end-free
                                 P                 E
                            Philippe

                            Comment


                            • #15
                              Re: pass a multi-dimension array as a parameter

                              I sure am glad you guys got this figured out. I thought I was going to have to get involved...

                              Comment

                              Working...
                              X