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

Do this through sort or other utilities other than cobol


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
lokesh vasanthi

New User


Joined: 19 Aug 2005
Posts: 17
Location: Chennai, India

PostPosted: Wed Mar 10, 2010 11:34 pm
Reply with quote

Hi,

My requirement is as below
I have the input flle which will have Policy Id(12bytes)

Another Input file which will have Policy Id Range(Start and End)

I need to read the both files and write into two output files based on If the policy id fall in the range then write into Inrange file and If not then write into Out of range.

Is anybody help me can we do this through sort or other utilities other than cobol.
Nanda
Back to top
View user's profile Send private message
lokesh vasanthi

New User


Joined: 19 Aug 2005
Posts: 17
Location: Chennai, India

PostPosted: Wed Mar 10, 2010 11:49 pm
Reply with quote

Hi Kevin,

We have SAS utility in our shop. If It is SAS it will be helpful.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Mar 11, 2010 12:17 am
Reply with quote

How many policy numbers? How many policy ranges?

Depending upon the number of policy ranges, you could write a SAS program that generates SAS code to create a format for the policy ranges with an OTHER value. Read the first file, do a X = PUT(policy_number, policy_format.) ; and if X is whatever value you assigned to OTHER then write to out of range file, else write to inrange file.

So your job would be two steps of SAS code; the first step generates the PROC FORMAT statements into a temporary file. The second step reads as input the temporary file followed by your code to process the policy number file.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Mar 11, 2010 12:38 am
Reply with quote

Nanda,

If you want a DFSORT solution, you need to supply more information because your requirement is not clear.

Please show an example of the records in each input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input files. If file1 can have duplicates within it, show that in your example. If file2 can have duplicates within it, show that in your example.
Back to top
View user's profile Send private message
lokesh vasanthi

New User


Joined: 19 Aug 2005
Posts: 17
Location: Chennai, India

PostPosted: Thu Mar 11, 2010 12:47 am
Reply with quote

Hi All,

Thanks for all your reply.

Frank,

Input file1 contains 722 Policy Ids(FM:FB,RECL:12Bytes)
Exp:
221010170993
221010589994

Input File2:Contains 6 records(FM:FB,RECL:30Bytes)
Exp:
Start Range End Range(In between One Filler)
221010000992 221010520999
221010522995 221010586990

Output Requirements:
We need to read each Policy id from Input file1 and check if that Policy id fall under any one of the range in the Input file2.If its falls then we need to write that Policy id into Range file and If not then we need write into Not range file.

I hope this will help.

Nanda
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Mar 11, 2010 1:07 am
Reply with quote

SAS does it via
Code:
//STEP1    EXEC SAS920,
//         OPTIONS='FULLSTATS'
//DD02     DD   DISP=SHR,DSN=TTSSRS0.MF0119.FILE2
//FMTCODE  DD   DISP=(,PASS),DSN=&&SASFMT,
//         UNIT=SYSDA,SPACE=(CYL,(1,1)),
//         DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=0
//SYSIN    DD   *
DATA _NULL_;
     INFILE DD02 END=EOF;
     INPUT @01 PLOW 12. @14 PHI 12. ;
     IF _N_ = 1 THEN DO;
        FILE FMTCODE;
        PUT 'PROC FORMAT;' ;
        PUT '     VALUE PFMT ';
        END;
     FILE FMTCODE;
     RANGEVAL = 'R' !! PUT(_N_,Z5.);
     PUT @17 PLOW Z12. ' - ' PHI Z12. ' = ' RANGEVAL $6.;
     IF EOF THEN PUT @39 'OTHER = UNKNOWN ; ' ;
/*
//STEP2    EXEC SAS920,
//         OPTIONS='FULLSTATS'
//DD01     DD   DISP=SHR,DSN=TTSSRS0.MF0119.FILE1
//INRANGE  DD   SYSOUT=*
//OUTRANGE DD   SYSOUT=*
//SYSIN    DD   DSN=&&SASFMT,DISP=(OLD,PASS)
//         DD   *
DATA _NULL_;
     INFILE DD01 ;
     INPUT @01 POLNUMB 12. ;
     X = PUT(POLNUMB, PFMT.) ;
     IF X = 'UNKNOWN' THEN FILE OUTRANGE;
                      ELSE FILE  INRANGE;
     PUT POLNUMB Z12. ;
/*
//
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Mar 11, 2010 2:15 am
Reply with quote

Quote:
Input File2:Contains 6 records(FM:FB,RECL:30Bytes)


Here's one way to do it with DFSORT assuming that input file2 always has 6 records:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file2 (FB/30)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
  OPTION COPY
  OUTFIL BUILD=(C'START',SEQNUM,1,ZD,C',+',1,12,80:X,/,
                C'END',SEQNUM,1,ZD,C',+',14,12)
/*
//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input file1 (FB/12)
//INRANGE DD DSN=...  output file1 (FB/12)
//OUTRANGE DD DSN=...  output file2 (FB/12)
//SYSIN DD *
  OPTION COPY
  OUTFIL FNAMES=INRANGE,
     INCLUDE=((1,12,ZD,GE,START1,AND,1,12,ZD,LE,END1),OR,
      (1,12,ZD,GE,START2,AND,1,12,ZD,LE,END2),OR,
      (1,12,ZD,GE,START3,AND,1,12,ZD,LE,END3),OR,
      (1,12,ZD,GE,START4,AND,1,12,ZD,LE,END4),OR,
      (1,12,ZD,GE,START5,AND,1,12,ZD,LE,END5),OR,
      (1,12,ZD,GE,START6,AND,1,12,ZD,LE,END6))
  OUTFIL FNAMES=OUTRANGE,SAVE
/*
Back to top
View user's profile Send private message
lokesh vasanthi

New User


Joined: 19 Aug 2005
Posts: 17
Location: Chennai, India

PostPosted: Thu Mar 11, 2010 3:47 am
Reply with quote

Hi Robert,

Your SAS worked as expected. Thanks for the help.

Hi Frank,
I didnt test yours but Input2 file will have more than 6 records also. I will test that also and let you know the results.

In the meantime I found another way in SAS we can achieve the same as below
Code:
//PSTY0010 EXEC SAS,                                                   
//             REGION=6M,                                               
//             OPTIONS='DQUOTE,LS=210,MACRO,MCOMPILE',                 
//             SORT=800,WORK='700,400',                                 
//             COND=(0,NE)                                             
//IPROD   DD DISP=SHR,DSN=ISDXFNS.HCA.POL                         
//ITEST   DD DISP=SHR,DSN=ISDXFNS.HCA.CARD                             
//FT12F001  DD SYSOUT=*                                                 
//SYSOUT    DD SYSOUT=*                                                 
//SYSPRINT  DD SYSOUT=*                                                 
//SYSIN     DD *                                                       
 DATA PRODDATA;                                                         
  INFILE IPROD END=EOF;                                                 
  INPUT  @001   POLINO    $CHAR12.;                                     
         OUTPUT;                                                       
  RUN;                                                                 
                                                                       
  DATA TESTDATA;                                                       
  INFILE ITEST END=EOF;                                                 
  INPUT  @001   POLINLOW  $CHAR12.                                     
         @014   POLINHIG  $CHAR12.;                                     
         OUTPUT;                                                       
  RUN;                                                                 
  PROC SQL;                                                             
    CREATE TABLE DADFAM1 AS                                             
    SELECT *                                                           
    FROM PRODDATA , TESTDATA                                           
    WHERE POLINO >= POLINLOW AND POLINO <= POLINHIG                     
    ORDER BY POLINO;                                                   
  QUIT;                                                                 
  PROC PRINT DATA=DADFAM1;RUN;                                         
  PROC SORT DATA=DADFAM1;BY POLINO;RUN;                                 
  PROC SORT DATA=PRODDATA;BY POLINO;RUN;                               
  DATA NOMATCH;                                                         
  MERGE PRODDATA(IN=A)                                                 
        DADFAM1(IN=B);BY POLINO;                                       
  IF A AND NOT B THEN OUTPUT;                                           
  RETURN;                                                               
  RUN;                                                                 
  PROC PRINT DATA=NOMATCH;RUN;
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Mar 11, 2010 3:58 am
Reply with quote

Glad to hear you got it working -- and glad to hear you came up with a different way as well -- congratulations.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Mar 11, 2010 4:00 am
Reply with quote

If it can have more than 6 records, then another approach would be needed (I posted the simplest solution based on the assumption that you only had 6 records). Since you have a SAS solution that works, I won't bother posting a solution for n records.
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 -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 9
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top