I need to create a third file having all the data starting from ++GROUP to +GROUPEND when the number(CRXXXXXX) matches. Means the output(third ) file should be like below.
Joined: 29 Nov 2002 Posts: 382 Topics: 27 Location: Chennai, India
Posted: Tue Apr 22, 2003 11:44 pm Post subject:
nandy,
You can of course do it using REXX. The steps are as follows (Let me know if you need the complete syntax) -
1. Read File A and File B into two stem variables stema and stemb (say) using EXECIO DISKR.
2. Start reading stemb in a loop. Whenever you encounter a ++GROUP, pick up the first word of the next line, parse it to get the number. (Look up the following functions in the manual - LINE, SUBSTR, PARSE).
3. Now, find out whether the NUMBER that you have just extracted is present in stema.
4. If it is present, then start writing the whole block of ++GROUP to ++GROUPEND into a third stem variable stemc(say).
5. Continue this until the end of stemb.
6. Write the third stem variable stemc into a file using DISKW.
Thanks for your reply.Can you provide me the code because I am not fully aware of the Rexx.I am trying this one to write in COBOL,But it seems that it will take a considerable amount of time.As i saw your psedo code,it looks that the REXX is the easier way of getting my results.
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
Posted: Wed Apr 23, 2003 4:53 am Post subject:
Nandy,
Any particular reason why you are insisting REXX? I got a DFSORT/ICETOOL solution for this. Looking at your data, it seems there will be always be two records per header (++GROUP) and trailer (++GROUPEND). Also, you want matching blocks from the second file. Is the order of CRxxxxxxx relevant? If the first statement is true and the answer for the second query is no, then you can use the following ICETOOL job.
The basis for the above code is the assumption that there will be 2 records per header and trailer. These two 80-byte records will be written as one 160-byte record in an O/P file. Then, comparing the input file a, with this file for all those records that are in a AND the modified b file, will be taken. Finally, the 160-byte record will be broken into 2 and header and trailers inserted.
Hope this helps. _________________ ALL opinions are welcome.
Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Thank you very much for your help. I was facing this problem and wondering how to solve it. I am able to use your code just by changing ICETOOL to SYNCSORT because ICETOOL and DFSORT are not defined to our environment.
Thank you again for all your help and to everybody who has helped me doing this.
If any unwated policy is there having duplicate records in File B then it should not come in output. Only the policies which are there in File A if they are having matching records in File B should come.
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
Posted: Thu Apr 24, 2003 8:52 am Post subject:
Shilpi,
What you are reporting is obvious. This is because I am using the ALLDUPS parameter of SELECT. I had assumed that there would not be any duplicate policy numbers in the second file. I think, the latest PTF of DFSORT which has SPLICE operators can handle such a situation. Just a hunch...not sure. I cannot try that, because, our site does not have the latest PTF.
Sorry about that. _________________ ALL opinions are welcome.
Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Can I get the REXX code for the thing which you have explained below. We are not very familiar with REXX so, it would help if we can get some code for this.
As suggested by Cogito and proven record of DFSORT/SYNCTOOL, i would suggest you to still use SORT procedures for your requirement. I will try posting one such solution tommorow and if you are a big time fan of REXX, you can call these SORT pgms by REXX as well. Anyways, here is the sample REXX ...
Code:
/*rexx*/
/* Matches fileA and fileB and write the matched record into
fileC */
address tso
"alloc ds('<<filea>>') fi(filea) shr reuse"
"alloc ds('<<fileb>>') fi(fileb) shr reuse"
"alloc dataset('<<filec>>') fi(filec) new space(20,10)
cylinders lrecl(80) recfm(b,f) block(800) dsorg(ps)"
filea_eof_flag = 'no'
/* Assumption is that the policy record will always be between
header record ++GROUP and trailer record ++GROUPEND */
hdr_tag = '++GROUP'
trlr_tag = '++GROUPEND'
if rc = 2 then
do
filea_eof_flag = 'yes'
leave
end
policy_filea = strip(filea.1)
/* Read untill EOF fileB */
do while fileb_eof_flag = 'no'
"execio 1 diskr fileb(stem fileb."
if rc = 2 then
do
fileb_eof_flag = 'yes'
"execio 0 diskr fileb(finis"
end
/* Piece of not-so-intelligent-code to write the next record of the
matched record from fileB to fileC. Assumption is that the
policy record will span in two lines consecutively */
if record_fnd_flg = 'yes' then
do
record_fnd_flg = 'no'
fileb_eof_flag = 'yes'
/* Write the second line of policy record */
"execio 1 diskw filec(stem fileb."
/* Write the trailer record */
push trlr_tag
"execio 1 diskw filec"
/* Reset the record */
"execio 0 diskr fileb(finis"
end
/* Match the policy number in fileA from fileB */
if index(fileb.1,policy_filea) = 0 then
do
record_fnd_flg = 'yes'
/* Write the header record */
push hdr_tag
"execio 1 diskw filec"
/* Write the first line of policy record */
"execio 1 diskw filec(stem fileb."
end
end
end
"execio 0 diskr filea(finis"
"execio 0 diskw filec(finis"
You can post the same on UTILITIES help board (provided the moderator allows you to post duplicate messages) and i bet Frank has a answer for you.
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