SORT OUTREC - Reformatting a register from dfsort parameters

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
filikindri
Member
Posts: 20
Joined: Fri Feb 17, 2012 2:11 am

SORT OUTREC - Reformatting a register from dfsort parameters

Post by filikindri » Thu Mar 01, 2012 5:50 pm

I've got this sort:

Code: Select all

//SORT    EXEC PGM=ICETOOL,                                
//        PARM='JP1"&PARA1",JP2"&PARA2",JP3"&PARA3"',                  
//        REGION=0M                                        
//TOOLMSG   DD SYSOUT=*                                    
//DFSMSG    DD SYSOUT=*                                    
//IN        DD DSN=EDI.HDRSMPL,DISP=SHR            
//OUT       DD DSN=.EDI.HEADER.R&PARA1..&PARA2,     
//         DISP=(NEW,CATLG,DELETE),                        
//         UNIT=(DISK),SPACE=(TRK,(1,1),RLSE)              
//TOOLIN DD DSN=TEPDXXX.XXX.JCLLIB(TOOLIN),DISP=SHR        
COPY FROM(IN)  TO(OUT) USING(CTL1)
//CTL1CNTL DD DSN=TEPDXXXM.XXX.JCLLIB(CTL1CNTL),DISP=SHR    
SORT FIELDS=COPY                                
OUTREC IFTHEN=(WHEN=(19,4,CH,EQ,C'FECH'),       
        OVERLAY=(19:&DATENS=(DM4),TRAN=HEX)),   
       IFTHEN=(WHEN=(23,6,CH,EQ,C'RRRRRR'),     
        OVERLAY=(23:C'ABCDEF')),                
       IFTHEN=(WHEN=(29,6,CH,EQ,C'SSSSSS'),     
        OVERLAY=(29:C'123456'))                 
(I'm using PDS members for DFSORT statements, so I paste the content after the jcl line.)

My sample file is:

Code: Select all

TEXTTEXTTEXT..... FECHRRRRRRSSSSSS   N..
ECEEECEEECEE220004CCCCDDDDDDEEEEEE444D23
3573357335730422006538999999222222000527

Code: Select all

PARA1='007302',PARA2='400'
a) I have to replace RRRRRR, with last four digits from PARA1 and two first digits from PARA2, so I would obtain '730240'. What is the correct way to do this?
b) I have to replace SSSSSS with PARA3. That´s no problem, I will just use JP3, "as is". PARA3 is 6 bytes long.
c) And I have to replace FECH with X'DDMMYYYY' , Using &DATENS=(DM4) is ok, but I.m not able to "pack" it. Can I use some value of TRAN= ?

I promise I have been looking for the answer in DFSORT manuals
Thanks a lot.

Perhaps it wuold be better two steps, using a temporal file?
COPY FROM(IN) TO(TMP) USING(CTL1)
COPY FROM(TMP) TO(OUT) USING(CTL1)

Edit: I could append PARA1+PARA2 in the first sort. In the second one , I would use BUILD to pick the correct bytes.
Packing the date, I can't see any path to do that, please, help me with this.

filikindri
Member
Posts: 20
Joined: Fri Feb 17, 2012 2:11 am

Post by filikindri » Thu Mar 01, 2012 6:54 pm

I'm very near from solution .

Two steps sort:

Code: Select all

SORT FIELDS=COPY                                  
OUTREC BUILD=(1,18,&DATENS=(DM4),JP1,JP2,JP3,35,6)

Code: Select all

SORT FIELDS=COPY                  
OUTREC BUILD(1,18,19,8,29,6,36,12)
Now I just need to convert "19,8' to packed., so my final lenght would be 40 again instead of 44.

I remember that using 'BI' I convert x'23092010' to c'23092010', but now I need the other way, from c'' to x''. I will look for in manuals.

I think to post here, even without any response, is helping me to think :-)

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Thu Mar 01, 2012 11:42 pm

You can use 19,8,TRAN=UNHEX to convert from 'ddmmyyyy' to X'ddmmyyyy'.

Of course, you don't need two passes to do what you want to do. You can just use multiple IFTHEN clauses, or INREC, OUTREC and/or OUTFIL in the same pass.

Note that X'ddmmyyyy' is NOT PACKED - it is binary. PACKED would be X'0ddmmyyyyC'.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

filikindri
Member
Posts: 20
Joined: Fri Feb 17, 2012 2:11 am

Post by filikindri » Fri Mar 02, 2012 1:45 am

Thanks Frank, one more time...

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others