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 

HOW CAN I IN REXX?

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
nandy
Beginner


Joined: 22 Apr 2003
Posts: 2
Topics: 1

PostPosted: Tue Apr 22, 2003 9:22 am    Post subject: HOW CAN I IN REXX? Reply with quote

Hi ,
I am having 2 files OF FIXED LENGTH 80 . like below.

The content of file FILE A:

CR3004485
CR3006516
CR3088245
CR3089123
CR3500366
CR3000067

The content of file b:

++GROUP
2652,CR3000047 ; PHASE=001; RTYP=F; RTYPID=SRY900Z1; RCOMPANY=SR ;
RUSE=1; RAMT=0000900;.
++GROUPEND
++GROUP
2652,CR3006516 ; PHASE=001; RTYP=F; RTYPID=SRY900Z1; RCOMPANY=SR ;
RUSE=1; RAMT=0000900;.
++GROUPEND
++GROUP
2652,CR3000058 ; PHASE=001; RTYP=F; RTYPID=SRY900Z1; RCOMPANY=SR ;
RUSE=1; RAMT=0001600;.
++GROUPEND
++GROUP
2652,CR3000059 ; PHASE=001; RTYP=F; RTYPID=SRY900Z1; RCOMPANY=SR ;
RUSE=1; RAMT=0002000;.
++GROUPEND
++GROUP
2652,CR3000067 ; PHASE=001; RTYP=F; RTYPID=LNCK0082; RCOMPANY=LN ;
RUSE=1; RAMT=0001500;.
++GROUPEND
++GROUP
2652,CR3000067 ; PHASE=002; RTYP=F; RTYPID=LNCK0082; RCOMPANY=LN ;
RUSE=1; RAMT=0001500;.
++GROUPEND

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.

++GROUP
2652,CR3006516 ; PHASE=001; RTYP=F; RTYPID=SRY900Z1; RCOMPANY=SR ;
RUSE=1; RAMT=0000900;.
++GROUPEND
++GROUP
2652,CR3000067 ; PHASE=001; RTYP=F; RTYPID=LNCK0082; RCOMPANY=LN ;
RUSE=1; RAMT=0001500;.
++GROUPEND
++GROUP
2652,CR3000067 ; PHASE=002; RTYP=F; RTYPID=LNCK0082; RCOMPANY=LN ;
RUSE=1; RAMT=0001500;.
++GROUPEND

Can we do this one with REXX????????
Thanks in advance.
Back to top
View user's profile Send private message
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Tue Apr 22, 2003 11:44 pm    Post subject: Reply with quote

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.

The following is the link to the REXX manual if you need it -
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IKJ2C307/CCONTENTS?DT=19951106102633

Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
nandy
Beginner


Joined: 22 Apr 2003
Posts: 2
Topics: 1

PostPosted: Wed Apr 23, 2003 1:18 am    Post subject: Reply with quote

Hi,

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.


Once again thank you.
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Wed Apr 23, 2003 4:53 am    Post subject: Reply with quote

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.
Code:

//STEP     EXEC PGM=ICETOOL
//TOOLIN   DD *
 COPY   FROM(IN01) TO(T1) USING(CPY1)
 COPY   FROM(IN02) TO(T2) USING(CPY2)
 COPY   FROM(T3)   TO(T4)
 SELECT FROM(CON)  TO(T5) ON(6,9,CH) ALLDUPS
 COPY   FROM(T5)   TO(T6) USING(CPY3)
 /*
//IN01     DD *
CR3004485
CR3006516
CR3088245
CR3089123
CR3500366
CR3000067
/*
//IN02     DD *
++GROUP
2652,CR3000047 ; PHASE=001; RTYP=F; RTYPID=SRY900Z1; RCOMPANY=SR ;
RUSE=1; RAMT=0000900;.
++GROUPEND
++GROUP
2652,CR3006516 ; PHASE=001; RTYP=F; RTYPID=SRY900Z1; RCOMPANY=SR ;
RUSE=1; RAMT=0000900;.
++GROUPEND
++GROUP
2652,CR3000058 ; PHASE=001; RTYP=F; RTYPID=SRY900Z1; RCOMPANY=SR ;
RUSE=1; RAMT=0000900;.
++GROUPEND
++GROUP
2652,CR3000059 ; PHASE=001; RTYP=F; RTYPID=SRY900Z1; RCOMPANY=SR ;
RUSE=1; RAMT=0000900;.
++GROUPEND
++GROUP
2652,CR3000067 ; PHASE=001; RTYP=F; RTYPID=SRY900Z1; RCOMPANY=SR ;
RUSE=1; RAMT=0000900;.
++GROUPEND
++GROUP
2652,CR3000067 ; PHASE=001; RTYP=F; RTYPID=SRY900Z1; RCOMPANY=SR ;
RUSE=1; RAMT=0000900;.
++GROUPEND
/*
//T1       DD DSN=&&TEMP1001,
//            DISP=(,PASS),
//            DCB=(LRECL=160,RECFM=FB)
//T2       DD DSN=&&TEMP2001,
//            DISP=(,PASS),
//            DCB=(LRECL=80,RECFM=FB,BLKSIZE=160)
//T3       DD DSN=&&TEMP2001,
//            DISP=(SHR,PASS),
//            VOL=REF=*.T2,
//            LRECL=160
//T4       DD DSN=&&TEMP3001,
//            DISP=(,PASS)
//CON      DD DSN=&&TEMP1001,
//            DISP=(SHR,PASS),
//            VOL=REF=*.T1
//         DD DSN=&&TEMP3001,
//            DISP=(SHR,PASS),
//            VOL=REF=*.T4
//T5       DD DSN=&&TEMP4001,
//            DISP=(,PASS)
//T6       DD SYSOUT=*
//CPY1CNTL DD *
 OUTREC FIELDS=(5X,1,74,C'A',160:X)
/*
//CPY2CNTL DD *
 OUTFIL FNAMES=T2,
        OMIT=(1,7,CH,EQ,C'++GROUP')
/*
//CPY3CNTL DD *
 INREC  FIELDS=(1,160)
 OMIT   COND=(80,1,CH,EQ,C'A')
 OUTFIL FNAMES=T6,
        OUTREC=(C'++GROUP',80:X,/,
                1,80,/,
                81,22,80:X,/,
                C'++GROUPEND',80:X)
/*
//DFSMSG   DD SYSOUT=*
//TOOLMSG  DD SYSOUT=*


A brief explanation of the 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.
Back to top
View user's profile Send private message
Shilpi
Beginner


Joined: 23 Apr 2003
Posts: 8
Topics: 3

PostPosted: Wed Apr 23, 2003 7:26 am    Post subject: Reply with quote

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.

Very Happy
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Wed Apr 23, 2003 7:33 am    Post subject: Reply with quote

Shilpi,
You mean SYNCTOOL don't you? Anyway, I am glad, I could help.
_________________
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.
Back to top
View user's profile Send private message
mnandyal
Beginner


Joined: 21 Apr 2003
Posts: 3
Topics: 1
Location: Indore

PostPosted: Wed Apr 23, 2003 11:50 pm    Post subject: Reply with quote

Thank you very much for all of you!!!


Murali
Back to top
View user's profile Send private message
Shilpi
Beginner


Joined: 23 Apr 2003
Posts: 8
Topics: 3

PostPosted: Thu Apr 24, 2003 8:29 am    Post subject: Reply with quote

Hi,

I am facing a problem with the synctool option given.

My File A is e.g :

CR3004485
CR3006516
CR3088245
CR3089123
CR3500366
CR3501144

My File B is:

++GROUP
2652,CR3504803 ; PHASE=001; RTYP=F; RTYPID=LNCK0082; RCOMPANY=LN ;
RUSE=1; RAMT=0002654;.
++GROUPEND
++GROUP
2652,CR3501144 ; PHASE=001; RTYP=F; RTYPID=LNCK0082; RCOMPANY=LN ;
RUSE=1; RAMT=0002000;.
++GROUPEND
++GROUP
2652,CR3000084 ; PHASE=001; RTYP=F; RTYPID=SRY900Z1; RCOMPANY=SR ;
RUSE=1; RAMT=0002000;.
++GROUPEND
++GROUP
2652,CR3000121 ; PHASE=001; RTYP=F; RTYPID=LNCK0082; RCOMPANY=LN ;
RUSE=1; RAMT=0001500;.
++GROUPEND
++GROUP
2652,CR3000121 ; PHASE=002; RTYP=F; RTYPID=LNCK0082; RCOMPANY=LN ;
RUSE=1; RAMT=0001500;.
++GROUPEND

The output which is coming is :

++GROUP
2652,CR3000121 ; PHASE=001; RTYP=F; RTYPID=LNCK0082; RCOMPANY=LN ;
RUSE=1; RAMT=0001500;.
++GROUPEND
++GROUP
2652,CR3000121 ; PHASE=002; RTYP=F; RTYPID=LNCK0082; RCOMPANY=LN ;
RUSE=1; RAMT=0001500;.
++GROUPEND
++GROUP
2652,CR3501144 ; PHASE=001; RTYP=F; RTYPID=LNCK0082; RCOMPANY=LN ;
RUSE=1; RAMT=0002000;.
++GROUPEND
++GROUP
2652,CR3504803 ; PHASE=001; RTYP=F; RTYPID=LNCK0082; RCOMPANY=LN ;
RUSE=1; RAMT=0002654;.
++GROUPEND

While the desired output is :

++GROUP
2652,CR3501144 ; PHASE=001; RTYP=F; RTYPID=LNCK0082; RCOMPANY=LN ;
RUSE=1; RAMT=0002000;.
++GROUPEND
++GROUP
2652,CR3504803 ; PHASE=001; RTYP=F; RTYPID=LNCK0082; RCOMPANY=LN ;
RUSE=1; RAMT=0002654;.
++GROUPEND

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.

Can anybody help me in this??

Thanks,
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Thu Apr 24, 2003 8:52 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Shilpi
Beginner


Joined: 23 Apr 2003
Posts: 8
Topics: 3

PostPosted: Thu Apr 24, 2003 9:25 am    Post subject: Reply with quote

Hi,

We don't have DFSORT in our environment so, its not possible for me to try this.

Is any way of getting a soultion through REXX????

Looking forward for some help.

Thanks,
Sad
Back to top
View user's profile Send private message
Shilpi
Beginner


Joined: 23 Apr 2003
Posts: 8
Topics: 3

PostPosted: Thu Apr 24, 2003 9:27 am    Post subject: Reply with quote

Manas Biswal,

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.

Looking forward for your help.

Thanks,
Back to top
View user's profile Send private message
Able
Beginner


Joined: 02 Dec 2002
Posts: 3
Topics: 0

PostPosted: Thu Apr 24, 2003 8:56 pm    Post subject: Reply with quote

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'

/* Read untill EOF fileA                                        */
do while filea_eof_flag = 'no'
     fileb_eof_flag = 'no'
     record_fnd_flg = 'no'
     rc = 0
     "execio 1 diskr filea(stem filea."

     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.
Back to top
View user's profile Send private message
Shilpi
Beginner


Joined: 23 Apr 2003
Posts: 8
Topics: 3

PostPosted: Fri Apr 25, 2003 2:40 am    Post subject: Reply with quote

Thank you all for your help. I have achieved by objective by using a combination of SYNCTOOL and EZT.

I have used following and now I am getting the desired output.
Code:

//STEP     EXEC PGM=SYNCTOOL
//TOOLIN   DD *
 COPY   FROM(IN01) TO(T1) USING(CPY1)
 COPY   FROM(IN02) TO(T2) USING(CPY2)
 COPY   FROM(T3)   TO(T4)
 SELECT FROM(CON)  TO(T5) ON(6,9,CH) ALLDUPS
/*
//IN01     DD Input File1
//IN02     DD Input File2
//T1       DD DSN=&&TEMP1001,
//            DISP=(,PASS),
//            DCB=(LRECL=160,RECFM=FB)
//T2       DD DSN=&&TEMP2001,
//            DISP=(,PASS),UNIT=SCRPK,SPACE=(CYL,(50,10)),
//            DCB=(LRECL=80,RECFM=FB,BLKSIZE=160)
//T3       DD DSN=&&TEMP2001,
//            DISP=(SHR,PASS),
//            VOL=REF=*.T2,
//            LRECL=160
//T4       DD DSN=&&TEMP3001,
//            DISP=(,PASS)
//CON      DD DSN=&&TEMP1001,
//            DISP=(SHR,PASS),
//            VOL=REF=*.T1
//            DD DSN=&&TEMP3001,
//            DISP=(SHR,PASS),
//            VOL=REF=*.T4
//T5        DD Output File1
//            DISP=(,PASS),UNIT=SCRPK,SPACE=(CYL,(50,10))
//CPY1CNTL DD *
 OUTREC FIELDS=(5X,1,74,C'A',160:X)
/*
//CPY2CNTL DD *
 OUTFIL FNAMES=T2,
        OMIT=(1,7,CH,EQ,C'++GROUP')
/*
//DFSMSG   DD SYSOUT=*
//TOOLMSG  DD SYSOUT=*
//*
//EZT   EXEC PGM=EZTPA00
//SYSPRINT DD SYSOUT=T
//SYSUDUMP DD SYSOUT=T
//SYSOUT   DD SYSOUT=T
//EZTVFM   DD UNIT=SCRPK,SPACE=(4096,(50,20),,,ROUND)
//INFILE1   DD Output File1
//OUTFILE  DD Output File2
//            DISP=(NEW,PASS,DELETE),
//            UNIT=DEVPK,SPACE=(CYL,(1,1),RLSE),
//            DCB=(RECFM=FB,LRECL=160,BLKSIZE=27840)
//SYSIN DD *
FILE INFILE1
INREC1                 1   160  A
FILLER1        INREC1        5  A
POLICY1        INREC1  +5   10  A
*
FILE OUTFILE
OUTREC1         1  160 A
*
WS-POLICY    W  10 A VALUE '          '
*
JOB INPUT INFILE1                                                       
   IF FILLER1 EQ '     '
     WS-POLICY = POLICY1
   ELSE
     IF POLICY1 EQ WS-POLICY
      OUTREC1 = INREC1
      PUT OUTFILE
     END-IF
   END-IF
*                                                                       
//STEP2    EXEC PGM=SYNCTOOL
//TOOLIN   DD *
 COPY   FROM(T5)   TO(T6) USING(CPY3)
/*
//T5       DD Output File2
//            DISP=SHR
//T6       DD Final Outout File
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=DEVPK,SPACE=(CYL,(1,1),RLSE),
//            DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000)
//CPY3CNTL DD *
 INREC  FIELDS=(1,160)
 OMIT   COND=(80,1,CH,EQ,C'A')
 OUTFIL FNAMES=T6,
        OUTREC=(C'++GROUP',80:X,/,
                1,80,/,
                81,22,80:X,/,
                C'++GROUPEND',80:X)
/*
//DFSMSG   DD SYSOUT=*
//TOOLMSG  DD SYSOUT=*


Thanks,
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF 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