Page 1 of 1

Seperate line and merging

PostPosted: Tue May 21, 2013 5:57 pm
by Varun Dhawan
Hi all,

Thank you for having me here. I have been referring to this and its parent forum ibmmainframe.com for quite a while. It has gotten me through many of my MF queries.

This time around, my query is somewhat peculiar in nature. Please note that i can do this via COBOL but my intention is to do this via SORT.

INPUT FILE - (80 bytes/FB)
----+----1----+----2----+----3----+--
.³  XXX                20130520ABLO 


OUTPUT FILE - (80 bytes/FB)
----+----1----+----2----+----3----+----4----+----5----+----6---
 SIGNON                                                       
 SUBMIT PROC=MAPPLE                       -   
        NEWNAME=XABCD                      -           
        CASE=YES                                          -   
        &MAINDSN='XXXX.TOTAL'                     -
        &NETPATH='\\AB\\CD\      ||    -   
                 \\\IT\\PROD\      ||    -   
                 \\\POL\'\                    -   
        &NETFILE="POLCOUNT_20130520"               -   
        &EXT=".DAT"                                           
 SIGNOFF                                                       


All the lines in my output have to be hardcoded except this one '&NETFILE="POLCOUNT_<DATE>" where i want the '<DATE>' extracted from the input file and it has to be appended after the '_' sign. Can someone please assist me with this.

NOTE: the output files has some '-' signs which is required too and the first line in both files are column header for your reference. They are not required in the output file.

Regards
Varun

Re: Seperate line and merging

PostPosted: Tue May 21, 2013 6:25 pm
by BillyBoyo
Is the data fixed in format? IE is POLCOUNT_ always going to be in the same starting position?

Re: Seperate line and merging

PostPosted: Tue May 21, 2013 8:47 pm
by Varun Dhawan
Yes it will be at the exact same position. The only thing that will change is what comes after POLCOUNT_ which is date that will always be at the same positions in the input file.

Re: Seperate line and merging

PostPosted: Wed May 22, 2013 1:24 am
by NicC
If you are doing it using sort why are you posting in the JCL section when there are 2 perfectly good sort forums - one for DFsort and one for Syncsort. Moving to DFSort. If you use Syncsort then say so and it will be moved there.

Re: Seperate line and merging

PostPosted: Wed May 22, 2013 4:59 am
by BillyBoyo
You need one small step which reads your date file and generates a symbol/SYMNAME for the date.

Have a look at this, http://ibmmainframes.com/about58490.html#294618, for how to turn the date into a symbol on the SYMNAMES file for the second step.

In the second step, process your file with OPTION COPY.

Use INREC with IFTHEN=(WHEN=(condition to identify POLCOUNT_, and overwrite what follow with your generated symbol which will equate to the value of the date from your date file.

Re: Seperate line and merging

PostPosted: Wed May 22, 2013 3:42 pm
by Varun Dhawan
NicC, sorry didn't see the Sort forum in a a hurry. I will keep that in mind going forward.

BillyBoyo, thanks for your help. I have pasted the code below so that others can refer to it if required.

//STEP010  EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=VARUN.DATE,                         
//         DISP=SHR                                       
//SORTOUT  DD DSN=&&DTE,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SYSIN    DD *                                           
  OPTION COPY,STOPAFT=1                                   
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),                   
  HEADER1=('DTE,C''',24,8,C'''')                           
/*
//*                                                       
//STEP0200 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SYMNAMES DD DSN=&&DTE,DISP=(OLD,PASS)                   
//SORTIN   DD DSN=INPUT.PS,               
//         DISP=SHR                                       
//SORTOUT  DD DSN=OUTPUT.PS,               
//         DISP=SHR                                       
//SYSIN    DD *                                           
   OPTION COPY                                   
     INREC IFTHEN=(WHEN=(32,8,CH,EQ,C'YYYYMMDD'),
                OVERLAY=(32:DTE))                 
/*                                               
//*                                             


Thanks once again.

Regards
Varun Dhawan

Re: Seperate line and merging

PostPosted: Thu May 23, 2013 1:16 am
by Varun Dhawan
One more thing, can someone help me explain this line HEADER1=('DTE,C''',24,8,C'''') especially the single inverted commas, I dont understand the significance. Any help as time permits is appreciated.

Re: Seperate line and merging

PostPosted: Thu May 23, 2013 11:58 am
by BillyBoyo
 HEADER1=('DTE,C''',24,8,C'''')


If you change SORTOUT to a SYSOUT rather than a dataset, you'll be able to more conveniently experiment.

HEADER1=('DTE,C''',/,
         24,8,/,
         C'''')


What the slash-operator (the "/") does is say "that's the end of one output record", so allows multiple output records from the same input record.

If you use the above code in place of the existing HEADER1, you'll get three output records:

DTE,C'
the-date-from-your-input
'


For the symbol you need to have it bounded with 's. 's of course mean something in SORT Control Cards. So to get a ' in the output from a literal, you, like any language, have to "do something". As is common on the Mainframe, this is to "double them up". '' will get you one ' in the output.

If you notice, there are four 's in each of the two lines with 's that I have shown. The left-most and right-most are to define a literal, the two in the middle, always consecutive, will be turned into one ' in the output.

Re: Seperate line and merging

PostPosted: Wed May 29, 2013 12:13 pm
by Varun Dhawan
I apologise for the late reply, was out of town. Thanks for the explanation BillyBoyo. You rock :D