MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

logic of DO-WHILE

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
apiyan
Beginner


Joined: 16 May 2009
Posts: 9
Topics: 5

PostPosted: Tue Jun 02, 2009 2:46 am    Post subject: logic of DO-WHILE Reply with quote

I am reading one record from input file 1 and scanning all the records in the input file 2 with that one record (from input file 1)for matching. If match is found, i am writing to the output file, then the control of input file 2 should come to the initial position (1 st position), so that i can take the second record from input file 1 and read all the records again in input file 2.

is there any way to bring the control back to the initial position after EOF is reached ..(Here in my case , i have to bring the control back to the initial position.)


This is what i tried....

But ia m getting invalid file reference...please help me to solve this issue.

[/quote]INNER-DO-LOOP. PROC
DO UNTIL ( EOF INPUT2 )
PERFORM INP-PROC ----> (have move statements)
IF WS-INP-EOF = 'N'
GET INPUT2
IF EOF INPUT2
WS-INP-EOF = 'Y'
GOTO JOB
END-IF
END-IF
Quote:
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Tue Jun 02, 2009 3:13 pm    Post subject: Reply with quote

close your file and re-open it
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
apiyan
Beginner


Joined: 16 May 2009
Posts: 9
Topics: 5

PostPosted: Tue Jun 02, 2009 9:32 pm    Post subject: Reply with quote

Nic Clouston

I am using Easytrieve .. I think there is no option in EZT to close and open a file..
Back to top
View user's profile Send private message
HB0
Beginner


Joined: 20 Apr 2005
Posts: 25
Topics: 7

PostPosted: Wed Jun 03, 2009 3:45 am    Post subject: Reply with quote

Can't you sort the files ?
Back to top
View user's profile Send private message
callanand
Beginner


Joined: 12 Jun 2007
Posts: 23
Topics: 2

PostPosted: Wed Jun 03, 2009 3:47 am    Post subject: Reply with quote

apiyan,
use if MATCHED feature of eazytrieve if the first input file has no duplicate on keys. Otherwise store the second file in an internal table(array). The read the first file and search the record on the table. You can get search logic in any eazytrieve manual. If you didn't find one let me know.
Back to top
View user's profile Send private message
apiyan
Beginner


Joined: 16 May 2009
Posts: 9
Topics: 5

PostPosted: Wed Jun 03, 2009 6:08 am    Post subject: Reply with quote

callanand,

Your logic will work if the volume ..(total no of records) is less in both the input files. But in my case my total number of records is 307578 in input 1 (with duplicates) . 192324 in input 2 without duplicates.

So i tried to do in EZT, its not working...now ia m trying in COBOL...if anyone having COBOL logic for matching two files please share here...

But this is not a normal match....

I have to read one record from input2 and then i have to scan the input1 for matching if match is found i will write in a separate file.. so input 1 para should be in loop. until i scanned/read the whole file....
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Wed Jun 03, 2009 12:11 pm    Post subject: Reply with quote

If you are using COBOL then close and re-open the file. This will set it back to the first record
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jun 03, 2009 12:19 pm    Post subject: Reply with quote

apiyan wrote:
callanand,

Your logic will work if the volume ..(total no of records) is less in both the input files. But in my case my total number of records is 307578 in input 1 (with duplicates) . 192324 in input 2 without duplicates.

So i tried to do in EZT, its not working...now ia m trying in COBOL...if anyone having COBOL logic for matching two files please share here...

But this is not a normal match....

I have to read one record from input2 and then i have to scan the input1 for matching if match is found i will write in a separate file.. so input 1 para should be in loop. until i scanned/read the whole file....


apiyan,

I dont know where you got this info but it is utter BS. Easytrieve filematching can handle any volume of data and it is the simplest of the programs.

1. what is the lrecl /recfm of file 1 with duplicates
2. what is the lrecl/recfm of file 2 without duplicates
3. what is the position and length of the key to be matched in both files.
4. what is the desired output file lrecl and recfm?
5. what do you need to do if you find a match in both files? write all the duplicate keys?
6. What do you need to do if you dont find a match in the files?

Nic,

I know this is a basic file matching logic why push them to a wild goose chase?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
apiyan
Beginner


Joined: 16 May 2009
Posts: 9
Topics: 5

PostPosted: Wed Jun 03, 2009 9:50 pm    Post subject: Reply with quote

kolusu,

1. what is the lrecl /recfm of file 1 with duplicates

File1 : LRECL = 313

2. what is the lrecl/recfm of file 2 without duplicates
File1 : LRECL = 800

3. what is the position and length of the key to be matched in both files.

File 1 : (Matching key positions): INP-KEY1 13 27 A
File 2 : (Matching key positions): INP-KEY2 01 27 A

4. what is the desired output file lrecl and recfm?

oUTPUT1: Matched records from both the files
DCB=(RECFM=FB,LRECL=1131,BLKSIZE=0)

oUTPUT2: Records present only from input1
DCB=(RECFM=FB,LRECL=800,BLKSIZE=0)


5. what do you need to do if you find a match in both files? write all the duplicate keys?

If i find a match, i have to write both the file1 & file2 records in OUTPUT1 with duplicates also.

6. What do you need to do if you dont find a match in the files?

Actually, The logic is ..

I have to read File1 and i need to scan File2 with the File1 first record...if match is found, i need to write in OUTPUT1..same way i need to compare/search all the records in File2 with the first record from File1 for matching...(So this file2 comparison para should be in loop until it reached EOF, after it reaches EOF it has to go to the initial position..).

then again i need to read/take the second record from File1, and i have to read again File2...this will continue, until i read all the record from File1.


So if match is not found on comparison,that means that record is present only in File1. so i have to write that record in OUTPUT2 (which is file1 records only).

Kolusu...i tried this to achieve inj EZT. But i doubt that once the file reached EOF(File2) , I cannot be resetted or bring the control back to the initial position of file2.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jun 03, 2009 11:58 pm    Post subject: Reply with quote

apiyan,

Please don't tell me the program logic to write , just state the requirements that's all.

The step0100 and step0200 will sort the 2 files on the key positions to be matched.

Step0300 does the actual match . The actual match logic is just 7 lines of code.

This program creates 2 files.

1. Match file which will have 800 bytes from file2 + 313 bytes from file1 = 1113

2. 800 byte file which contains the unmatched records from non duplicate file.

Run this JCL and do lets us know the results

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=your 313 byte file1 with dups,
//            DISP=SHR
//SORTOUT  DD DSN=&&I1,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(300,100),RLSE)
//SYSIN    DD *
  SORT FIELDS=(13,27,CH,A)
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=your 800 byte file2 without dups,
//            DISP=SHR
//SORTOUT  DD DSN=&&I2,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(300,100),RLSE)
//SYSIN    DD *
  SORT FIELDS=(1,27,CH,A)
//*
//STEP0300 EXEC PGM=EZTPA00                       
//STEPLIB   DD DSN=EASYTREV.LOADLIB,     
//             DISP=SHR                           
//SYSPRINT  DD SYSOUT=*                           
//SYSOUT    DD SYSOUT=*                           
//IN1       DD DSN=&&I1,DISP=SHR
//IN2       DD DSN=&&I2,DISP=SHR                   
//MATCH     DD DSN=YOUR MATCH.FILE,                 
//             DISP=(NEW,CATLG,DELETE),           
//             UNIT=SYSDA,                         
//             SPACE=(CYL,(300,100),RLSE),             
//             DCB=(RECFM=FB,LRECL=1113,BLKSIZE=0)   
//*
//OUT1      DD DSN=ONLY.INPUT2.RECORDS,             
//             DISP=(NEW,CATLG,DELETE),           
//             UNIT=SYSDA,                         
//             SPACE=(CYL,(300,100),RLSE),             
//             DCB=(RECFM=FB,LRECL=800,BLKSIZE=0)   
//*
//SYSIN     DD *
                                   
 FILE IN1
  IN1-REC             001 313 A
  IN1-KEY             013 027 A
                                   
 FILE IN2
  IN2-REC             001 800 A
  IN2-KEY             001 027 A     
                                   
 FILE MATCH FB(0 0)
      O-I2-REC        001 800 A
      O-I1-REC        801 313 A
                 
 FILE OUT1  FB(0 0)                 
       
                                   
 JOB INPUT (IN2 KEY (IN2-KEY)  +   
            IN1 KEY (IN1-KEY))     
                                   
     IF MATCHED
        O-I2-REC = IN2-REC
        O-I1-REC = IN1-REC
        PUT MATCH
     ELSE-IF IN2                   
        PUT OUT1 FROM IN2           
     END-IF                         
/*



Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group