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

Overlaying fields with the value of a previous record


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Paul Gainsford

New User


Joined: 20 Feb 2008
Posts: 5
Location: Melbourne, VIC

PostPosted: Sat May 09, 2015 8:40 am
Reply with quote

Is it possible to overlay the contents of a field for one record with the value of a previous record using ICETOOL/DFSORT ?

My specific example is that if the current record = ‘0410’ in pos 7 for 4 characters and the previous record = ‘0210’ in pos 7 for 4 characters and the date field (pos 127 for 6 characters) in the current record does not equal that of the previous record then I wish to overlay the date field in my current record with the date of the previous record.

This is my sort JCL but it doesn’t overlay any values

Code:
//SORT01B  EXEC  PGM=ICETOOL                             
//MERGEFLE DD  DSN=INFILE1,DISP=SHR                     
//         DD  DSN=INFILE2,DISP=SHR                     
//TOOLMSG  DD  SYSOUT=*                                 
//DFSMSG   DD  SYSOUT=*                                 
//SORTOUT  DD  DSN=OUTFILE1,                             
//             UNIT=(DPERM,9),SPACE=(CYL,(10,10),RLSE), 
//             DISP=(NEW,CATLG,DELETE),                 
//             DCB=(RECFM=FB,LRECL=600,BLKSIZE=0)       
//TOOLIN   DD  *                                         
 SORT FROM(MERGEFLE) TO(SORTOUT) USING(CTL2)             
//CTL2CNTL DD  *                                         
  OPTION Y2PAST=1951                                     
 SORT FIELDS=(111,2,Y2C,A,113,4,BI,A,                   
              117,6,BI,A,139,7,BI,A,39,16,BI,A,15,5,BI,A,
              7,4,BI,A,11,4,BI,A,158,28,BI,A),           
      SIZE=E2500000       


Any help would be greatly appreciated.

Code'd
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat May 09, 2015 12:25 pm
Reply with quote

Yes. You use IFTHEN=(WHEN=GROUP with BEGIN= to define a group, and PUSH the data from that record to an extension on each record in the group. Since at most you want two records in the group, you code RECORDS=2.

The, on identifying the second record-type, you test the extended fields as needed and OVERLAY the required data if the tests indicate.
Back to top
View user's profile Send private message
Paul Gainsford

New User


Joined: 20 Feb 2008
Posts: 5
Location: Melbourne, VIC

PostPosted: Sat May 09, 2015 1:56 pm
Reply with quote

Thanks Bill,

I'm having some trouble with my syntax. The data I want isn't being overlayed correctly in the SORTOUT. What have I got wrong?

Code:
//SORT01B  EXEC  PGM=ICETOOL
//MERGEFLE DD  DSN=INFILE1,DISP=SHR     
//         DD  DSN=INFILE2,DISP=SHR 
//TOOLMSG  DD  SYSOUT=*                                               
//DFSMSG   DD  SYSOUT=*                                               
//SORTOUT  DD  DSN=OUTFILE,                 
//             UNIT=(DPERM,9),SPACE=(CYL,(10,10),RLSE),               
//             DISP=(NEW,CATLG,DELETE),                               
//             DCB=(RECFM=FB,LRECL=600,BLKSIZE=0)                     
//TOOLIN   DD  *                                                     
 SORT FROM(MERGEFLE) TO(SORTOUT) USING(CTL2)                         
//CTL2CNTL DD  *                                                     
  OPTION Y2PAST=1951                                                 
 SORT FIELDS=(111,2,Y2C,A,113,4,BI,A,                                 
              117,6,BI,A,139,7,BI,A,39,16,BI,A,15,5,BI,A,             
              7,4,BI,A,11,4,BI,A,158,28,BI,A),                       
      SIZE=E2500000                                                   
*                                                                     
   INREC  IFTHEN=(WHEN=GROUP,                                         
                 BEGIN=(7,4,BI,EQ,0210),RECORDS=2,                   
                  PUSH=(601:127,06)),                                 
*                                                                     
          IFTHEN=(WHEN=(7,4,BI,EQ,0410),                             
               OVERLAY=(601:127,6))


Code'd
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat May 09, 2015 2:09 pm
Reply with quote

Please use the Code tags to preserve spacing.

Code:
          IFTHEN=(WHEN=(7,4,BI,EQ,0410),                             
               OVERLAY=(127:601,6))


I assume you're just seeing the overlaying works before putting in the selection.

It is rare that you need RECORDS in a stand-alone SORT, so is there a specific reason for it?

In your first post you talked of "characters" for the record-type, but your source is a four-byte binary field. Are you sure it is four bytes, and binary?

You have fixed-length records of 600 bytes?
Back to top
View user's profile Send private message
Paul Gainsford

New User


Joined: 20 Feb 2008
Posts: 5
Location: Melbourne, VIC

PostPosted: Sat May 30, 2015 2:29 am
Reply with quote

That worked well, thanks.

I trying to do the same thing with a dataset that is RECFM=VB and LRECL=4100. When I try to PUSH I get this error

ICE217A 8 4116 BYTE VARIABLE RECORD IS LONGER THAN 4100 BYTE MAXIMUM FOR SORTOUT

Can DFSORT do this with an LRECL=4100 or is a COBOL program change required?
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Mon Jun 01, 2015 3:48 pm
Reply with quote

Try using VLSCMP


Code:

OPTION VLSCMP,Y2PAST=1951 
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jun 01, 2015 4:20 pm
Reply with quote

Magesh,

Perhaps you can indicate how you feel VLSCMP would help?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jun 01, 2015 4:23 pm
Reply with quote

If you search-engine for the message-number, you'll get to this.

I suspect you have an LRECL explicitly or on the SORTOUT or it is a pre-defined dataset with that LRECL.

The exact problem you have we can't tell, because you've not shown the control cards or the JCL.

Of course DFSORT can deal with your situation, however.
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Mon Jun 01, 2015 4:43 pm
Reply with quote

Sorry, My mistake, over sight error, It will work only for Short records where it will pad binary zeros.

we can try VLLONG option, But end of the long record will get truncated/lost/removed.
Back to top
View user's profile Send private message
Paul Gainsford

New User


Joined: 20 Feb 2008
Posts: 5
Location: Melbourne, VIC

PostPosted: Tue Jun 02, 2015 5:34 am
Reply with quote

Code:

//SORT2    EXEC GULVESRT                         
//SORTIN   DD DSN=INFILE,                         
//            DISP=SHR                           
//SORTOUT  DD DSN=OUTFILE,                       
//            DISP=(NEW,CATLG,DELETE),           
//            SPACE=(CYL,(10,10),RLSE),UNIT=DPERM,
//            DCB=(RECFM=VB,LRECL=4100,BLKSIZE=0)
//SYSIN    DD *                                                                         
 OPTION VLSHRT                                           
 SORT FIELDS=(295,6,CH,A,                               
              009,28,CH,A,                               
              066,6,CH,A,                               
              058,8,CH,A,                               
              330,15,CH,A,                               
              315,15,CH,A,                               
              1191,8,CH,A,                               
              960,7,PD,A,                               
              005,4,CH,A)                               
   OUTREC  IFTHEN=(WHEN=GROUP,                           
                 BEGIN=(5,4,CH,EQ,C'0210'),RECORDS=2,   
                  PUSH=(4105:5,380)),                   
          IFTHEN=(WHEN=(5,4,CH,EQ,C'0410',AND,           
                        9,63,CH,EQ,4109,63,CH,AND,       
                        88,225,CH,EQ,4188,225,CH,AND,   
                        315,70,CH,EQ,4115,70,CH,AND,     
                        80,12,CH,NE,4180,12,CH),         
               OVERLAY=(80:4180,12))                     
                                                         
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jun 02, 2015 5:57 am
Reply with quote

This is where you are limiting to 4100:

Code:
//            DCB=(RECFM=VB,LRECL=4100,BLKSIZE=0)


If you change that to:

Code:
//            RECFM=VB,BLKSIZE=0


(you can these days code the individual elements of the DCB rather than the DCB itself) you will be able to extend a record beyond 4100 (which is four bytes of RDW and 4096 bytes of data, I'm always initially suspicious when a VB LRECL is a round number..) with no problem.

DFSORT will supply the LRECL.

However, I'm not sure you are achieving what you want. The VB records you are changing will retain the extension you have given. When temporarily extending a V record, it is conventional (as it uses fewer resources) to extend the record at the beginning and then to drop the extension once it is finished with.

Use IFTHEN=(WHEN=INIT with BUILD something like this (1,4,nnX,5).

Replace nn by the number of bytes you need to extend by.

That will copy the RDW (necessary) leave a bunch of blanks, then copy the first position of the data (5) to the end of the variable-length record (because there is no "length" specified).

Then, when you have finished with the extension, BUILD=(1,4,<5+nn>).

When extending, only do so by the data you actually use. There is no point in extending by 380 bytes if you only use 12 of them. Extend by 12.
Back to top
View user's profile Send private message
Paul Gainsford

New User


Joined: 20 Feb 2008
Posts: 5
Location: Melbourne, VIC

PostPosted: Tue Jun 02, 2015 8:54 am
Reply with quote

Thanks Bill,

I had a play and this worked

Code:
OPTION VLSHRT                                                     
SORT FIELDS=(295,6,CH,A,                                     
             009,28,CH,A,                                 
             066,6,CH,A,                     
             058,8,CH,A,                   
             330,15,CH,A,                             
             315,15,CH,A,                         
             1191,8,CH,A,                             
             960,7,PD,A,                         
             005,4,CH,A)                               
  OUTREC  IFTHEN=(WHEN=INIT,                             
                BUILD=(0001,004,                         
                  0405:0005)),                           
          IFTHEN=(WHEN=GROUP,                             
                 BEGIN=(0405,004,CH,EQ,C'0210'),         
                   END=(0405,004,CH,EQ,C'0410'),         
                  PUSH=(0005:0405,380)),                 
          IFTHEN=(WHEN=(0405,004,CH,EQ,C'0410',AND,       
                        0009,067,CH,EQ,0409,067,CH,AND,   
                        0088,225,CH,EQ,0488,225,CH,AND,   
                        0315,070,CH,EQ,0715,070,CH,AND,   
                        0080,012,CH,NE,0480,012,CH),     
               OVERLAY=(0480:0080,012))                   
  OUTFIL   BUILD=(0001,004,                               
                  0405)   
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top