IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Loading a file into an Array


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 3156
Location: Tucson AZ

PostPosted: Fri Jul 13, 2007 11:32 pm
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

Moderator Emeritus


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

PostPosted: Sat Jul 14, 2007 12:02 am
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
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

Moderator Emeritus


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

PostPosted: Sat Jul 14, 2007 1:03 am
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: 3156
Location: Tucson AZ

PostPosted: Sat Jul 14, 2007 1:08 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 8
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top