Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Loading a file into an Array

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sasikumar1984

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Fri Jul 13, 2007 10:39 pm    Post subject: Loading a file into an Array
Reply with quote

Hi,

Pls help me on this requirement.

I have a file of length 100 and thousands of records where it contains duplicates also. Now i want this file loaded into an array and add one more new byte 101 position with initial value as 'N'. I have another file, i get key from that file and search in this array, as soon as i get the key in the array i move 'Y' to 101 position. pls provide me some example program loading a file into an array by adding extra field. I need very urngently now... pls plsplpls i searched in many places, i couldnt find program... pls u guys provide me.
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Jul 13, 2007 11:32 pm    Post subject:
Reply with quote

What part of the program do you need help with?

The reading of the file?
The moving of the file data to an array entry?
The setting of the extra byte initially N?
The looping of the 3 above until EOF?

The reading of the key?
The scanning of the array until you get a key match?
The setting of the extra byte to Y?
The looping of the 3 above until EOF?

This could be done much quicker wit a sort / join utility.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Jul 14, 2007 12:02 am    Post subject:
Reply with quote

Hello,

Please post your requirement and show the input files and what you want for output.

From what i understand of the size of the data used by your requirement, you will not get your file into an array (and there is probably no need to do so).

You might do as suggested and look at using the sort or if other logic is needed, you might use the sample match/merge code that is attached to a "Sticky" near the top of the cobol forum.
Back to top
View user's profile Send private message
sasikumar1984

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Sat Jul 14, 2007 12:38 am    Post subject: Re: Loading a file into an Array
Reply with quote

This is my requirement.

File-1

Acct-Num Trans Amt
1817415 wdl 200
1817416 dcb 300
1817416 dcb 300
1817416 dcb 300
1817416 dcb 300
1817416 ret 300
1817417 dcb 300
1817418 dcb 300

File-2


Acct-Num Trans Amt
1817415 wdl 200
1817416 dcb 300
1817416 dcb 300
1817416 dcb 300
1817416 ret 300
1817417 dcb 300
1817418 dcb 300


See the above files, In file-2 one record for the Acct-Num 1817416 is missed. Now my i want do is

File-2 should be loaded into an array like the below

Acct-Num Trans Amt Flag
1817415 wdl 200 n
1817416 dcb 300 n
1817416 dcb 300 n
1817416 ret 300 n
1817417 dcb 300 n
1817418 dcb 300 n


So i take Acct-Num from File-1 and check in File-2 array, when it finds that then i will validated other two values, once it is ok then i move 'Y' to Flag variable in File-2 array. So that when 3rd record comes for the Acct-Num 1817416, it will catch the Acct-Num, but i check flag, if it is 'Y' then it means that record in array already matched for some other record in File-1 for the same Acct-Num.

Please give sample programs for the above... i have some other validations to be performed... i cant tell my whole requirement here... pls provide me sample programs... thats enjough... i dont want new solutions like sorting and doing, File and V-Sam concept.. sorry for telling this... i just need sample programs for above requirement... .

loading a file into an array by adding extra field in the array.
and making this array as lookup array.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Jul 14, 2007 1:03 am    Post subject:
Reply with quote

Hello,

You could do what was recommended earlier:
Quote:
you might use the sample match/merge code that is attached to a "Sticky" near the top of the cobol forum.


Using that sample, you can
Quote:
i have some other validations to be performed... i cant tell my whole requirement here...
do what you need.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sat Jul 14, 2007 1:08 am    Post subject:
Reply with quote

Probably missed a few things, but that's what testing is for..... icon_smile.gif
Code:

01 record-count pic s9(8) comp-5.
01 table.
   05 table-entry occurs "thousands" depending upon record-count.
   05 table-record       pic x(100)
   05 filler redefines table-record.
      10 table-Acct-Num  pic x(7).
      10 table-Trans     pic x(3).
      10 table-Amt       pic x(3).
   05 table-Flag         pic x.

move zero to record-count.
move low-values to table.
open file-1
perform until file-1-eof
   read file-1
      at-end set
         file-1-eof to true
      not-at-end
         add 1 to record-count
         move record-1 to table-entry (record-count)
         move 'n' to table-flag (record-count)
   end-read
end-perform
close file-1
open file-2
perform until file-2-eof
   read file-2
      at-end set
         file-2-eof to true
      not-at-end
         perform varying x from 1 by 1
                 until x > record-count
            if record-2-Acct-Num = table-Acct-Num and
               record-2-Trans    = table-Trans    and
               record-2-Amt      = table-Amt
                  move 'y' to table-flag (x)
                  move record-count to x
            end-if
         end-perform
      end-read
end-perform
close file-2
goback
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Table(Unicode(Graphic) table) loading... muralikrishnan_new DB2 0 Thu Oct 05, 2017 5:10 pm
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us