ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Data Structure Array

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

  • Data Structure Array

    Hi
    Please explain me how a data structure can be declared as an array and how this array data structure could be loaded.

    for example, from one main module a Employee file is being read, for ech emp, another module is called where 'Dependents' for that emp is to be fetched. wheneever a "Dependent' is fetched , this array data structure should be loaded, this is to be done for 'n' number of dependents..
    please help me as soon as possible...

    Thanks
    Revathy

  • #2
    here is an example of an datastructure array

    Code:
         D*
         D* The file BUDGET hold budget info both $dollars and expected sold qtys
         D* We just want the money, so it starts in position 6 and ends with 77.
         D*  Its also stored by month (thats why 12) so now we have all $'s for all
         D* months in one place BUD 
         D*
         D               E DS                  EXTNAME(BUDGET)
         D  BUD                    6     77P 2
         D                                     DIM(12)
    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
      Pls More Specific

      Thanks Jammie..
      My data structure has 8 fields and it is not an External DS. how can this be declared and sent as an parameter across modules?

      Also tell me how it should be used in 'C' spec?

      For ex:

      D DSREP DS
      D Line1 7s 0
      D Line2 6
      D Line3 13

      and so on.....

      Thanks Jammie

      Comment


      • #4
        use the 'Dependents' file

        cant you just use the sdependents files as your external data structure? Each time you read a record in look from employee file then increment the counter to your dependents array.


        Im not sure why you are doing this cause you can just read the employee file then reade on the dependents file to get the depenents. This should only take nano seconds


        Thanks
        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


        • #5
          Nope i can't use your tech

          Jammie,
          i have to print the employee dependent details and other details in the main module, so when i got to this particular Dependent module, i have to collect the dependents of a emp(whose Emp no comes from main module) and move those to a temp data structure(got only some fields which are tobe printed) , this temp DS is then moved to the main module where 'WRTIE' to a Printer file is done.
          Thats the reason i am using the array DS to capture all the emp- dependents.

          now can you help????
          revthy

          Comment


          • #6
            This might be what you are looking for

            I'm not exactly sure if this is what you are needing, but I think it is.

            In your programs define a data structure like this. Of course use your own field names and sizes.
            Code:
            D Array           DS                  QUALIFIED DIM(999)      
            D  Field1                        3  0                         
            D  Field2                        5                            
            D  Field3                        5                            
            D  Field4                        6
            Pass the 'Array' parm as you would any other parm.

            In your called program, load the 'Array' like this simple example. Your loading loop will differ, but the principle is the same.

            Code:
            C     Key           CHAIN     Dependent                          46     
            C                   DOU       *IN46                                     
            C                   EVAL      Index += 1                                
            C                   EVAL      Array(Index).Field1 = Field001                
            C                   EVAL      Array(Index).Field2 = Field002               
            C                   EVAL      Array(Index).Field3 = Field003               
            C                   EVAL      Array(Index).Field4 = Field004                
            C     Key           READE     Dependent                              46 
            C                   ENDDO
            Back in your calling program, you access the array the same way as in the called program, by Array(Index).Element

            Hope that helps.
            Goodbye

            Comment


            • #7
              i have finished the coding and the proj is already delivered!
              thanks for your help!!!!

              Comment

              Working...
              X