Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Overlaying fields with the value of a previous record

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Overlaying fields with the value of a previous record
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7235

PostPosted: Sat May 09, 2015 12:25 pm    Post subject: Reply to: Overlaying fields with the value of a previous record
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    Post subject: Reply to: Overlaying fields with the value of a previous record
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7235

PostPosted: Sat May 09, 2015 2:09 pm    Post subject: Reply to: Overlaying fields with the value of a previous record
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    Post subject: Reply to: Overlaying fields with the value of a previous record
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: 159
Location: Chennai

PostPosted: Mon Jun 01, 2015 3:48 pm    Post subject: Reply to: Overlaying fields with the value of a previous record
Reply with quote

Try using VLSCMP


Code:

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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7235

PostPosted: Mon Jun 01, 2015 4:20 pm    Post subject: Reply to: Overlaying fields with the value of a previous record
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7235

PostPosted: Mon Jun 01, 2015 4:23 pm    Post subject: Reply to: Overlaying fields with the value of a previous record
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: 159
Location: Chennai

PostPosted: Mon Jun 01, 2015 4:43 pm    Post subject: Reply to: Overlaying fields with the value of a previous record
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7235

PostPosted: Tue Jun 02, 2015 5:57 am    Post subject: Reply to: Overlaying fields with the value of a previous record
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to get previous month in SYMNAMES Suganya87 SYNCSORT 9 Fri Oct 28, 2016 1:37 pm
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us