Inserting a Delimiter

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

sasirekha V
Member
Posts: 7
Joined: Sat Mar 21, 2009 8:37 pm

Inserting a Delimiter

Post by sasirekha V » Sat Mar 21, 2009 8:48 pm

Hi All,

I need to insert a delimiter(|) between two columns, when a file is generated after successful JCL submission.

Eg. File1:

EMP# EMPNAME EMPEXPER
111 AAAA 1
1112 BC 10
12 DBAC 2

This should be converted into

EMP#|EMPNAME|EMPEXP
111|AAAA|1
1112|BC|10
12|DBAC|2

What are the steps to be included in a JCL for this conversion?

Thanks In advance,
Rekha.

kapil agarwal
Member
Posts: 10
Joined: Thu Mar 05, 2009 5:50 pm
Location: Bangalore

Post by kapil agarwal » Sat Mar 21, 2009 10:52 pm

Hi

I think you can acheive this by writing a simple cobol program and this is not possible to do by jcl.
Kapil K Agarwal
Bangalore

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

Post by Frank Yaeger » Sat Mar 21, 2009 11:03 pm

Rekha,

You can use a DFSORT job like the following to do what you asked for.

Code: Select all

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
EMP#          EMPNAME      EMPEXPER
111           AAAA         1
1112          BC           10
12            DBAC         2
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC BUILD=(1,80,SQZ=(SHIFT=LEFT,MID=C'|'))
/*
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

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

Post by Frank Yaeger » Sat Mar 21, 2009 11:04 pm

I think you can acheive this by writing a simple cobol program and this is not possible to do by jcl.
Kapil,

You're obviously not aware of the capabilities of DFSORT. I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/servers/storage/support/sof ... tmpub.html
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

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Mon Mar 23, 2009 12:05 pm

Hi Frank.

What does this

Code: Select all

MID=C'|'))
convey to DFSort in above JCL? Please assist.
Regards,
Anuj

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

Post by Frank Yaeger » Mon Mar 23, 2009 8:01 pm

MID=C'|' tells DFSORT to insert a '|' character between the fields.

Paraphrasing from the "z/OS DFSORT Application Programming Guide" description of p,m,squeeze:

MID=string

specifies a string to be inserted in the output field wherever one or more blanks is removed between the first nonblank and the last nonblank. string can be 1 to 10 characters specified using a character string constant (C'xx...x') or a hexadecimal string constant (X'yy...yy'). For example, let's say we have an input field of:

Code: Select all

 AB  C   D E
If we specify:

Code: Select all

1,12,SQZ=(SHIFT=LEFT,MID=C',')
the output field is:

Code: Select all

AB,C,D,E
...

You can access all of the DFSORT books online from:

www.ibm.com/systems/support/storage/sof ... tmpub.html
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

sasirekha V
Member
Posts: 7
Joined: Sat Mar 21, 2009 8:37 pm

Post by sasirekha V » Mon Mar 23, 2009 9:38 pm

Thank you. :D Image

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

Post by Frank Yaeger » Mon Mar 23, 2009 10:32 pm

Is it possible to compare both files?
Compare them and do what?

Show a more complete example of the records in each input file and what you expect for output. Explain the "rules" for comparing the files. Are you looking for a match between all three fields in any record of file1 and file2, or what?
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

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Tue Mar 24, 2009 10:53 am

Thankyou Frank for such an explanation - You are a good Teacher as well . . . :).

Just out of curiosity: MID is an abbreviation for "middle"?
Last edited by Anuj Dhawan on Tue Mar 24, 2009 8:58 pm, edited 1 time in total.
Regards,
Anuj

sasirekha V
Member
Posts: 7
Joined: Sat Mar 21, 2009 8:37 pm

Post by sasirekha V » Tue Mar 24, 2009 7:23 pm

File1 is captured from the SPOOL output which will have space between entire column.
For EG. Customer ID is 10 digit number. But i can have Customer ID as 555 hence while displaying in the SPOOL, it leaves 7 more spaces and then value for the next column begins.
(precisely, it looks like output of a query which is run in SPUFI and which is viewed in the output PS.)

FIle 2 is a production file which has continuous column values. Eventhough customer ID is 10 in length, if the ID is 555 then no space is allocated. ID is immediately proceeded by the next value.

I need to compare these two files and get the unique records of File 1 in 1 file and unique records in File 2 in another File.

Hope i have given detailed explanation.

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

Post by Frank Yaeger » Tue Mar 24, 2009 8:52 pm

Anuj,

Yes, MID is an abbreviation for MIDDLE.

sasirekha V,

Again:
Show a more complete example of the records in each input file and what you expect for output.
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

sasirekha V
Member
Posts: 7
Joined: Sat Mar 21, 2009 8:37 pm

Post by sasirekha V » Thu Mar 26, 2009 7:22 pm

File 1:(has space between columns)

<first some 10 lines about execution of a query NOT REQUIIERD>
EMP# |EMPNAME |EMPEXP
111 |AAAA |1
1112 |BC |10

File 2:(No space between columns)

<Header-List of coulmn names EMP#|EMPNAME|EMPEXPR>
111|AAAA|1
1112|BC|12
12|DBAC|2

Com File 1: Unique records in File1 (No space between columns)
1112|BC|10

Com File 2: Unique records in File2 (No space between columns)
1112|BC|12
12|DBAC|2

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 26, 2009 8:13 pm

What is the RECFM and LRECL of File1 and File2?

What is the RECFM and LRECL of Com File1 and Com File2?

What is the maximum length of the records to be compared, that is, how big can

field1|field2|field3

be?

It looks like there are 11 lines that can be ignored before the data starts in file1 - right?

How many lines can be ignored before the data starts in file2? That is, now many lines are represented by

<Header-List of coulmn names EMP#|EMPNAME|EMPEXPR>
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

sasirekha V
Member
Posts: 7
Joined: Sat Mar 21, 2009 8:37 pm

Post by sasirekha V » Fri Mar 27, 2009 8:03 pm

File1 and File2:
RECFM:VB
LRECL :23036


CompFile1 and compFile2:
RECFM:VB
LRECL :23036

maximum length ~200

Field 1,Field 2 <=50

Only File 1 has some 10-12 lines to be deleted.
File 2 has only 1 header mentioned which need not be deleted.

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

Post by Frank Yaeger » Fri Mar 27, 2009 9:18 pm

Here's a DFSORT/ICETOOL job that will do what I think you asked for.

Code: Select all

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN1 DD DSN=... input file1
//IN2 DD DSN=... input file2
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=&#40;CYL,&#40;5,5&#41;&#41;,DISP=&#40;MOD,PASS&#41;
//OUT1 DD LRECL=23036,DSN=...  output file1
//OUT2 DD LRECL=23036,DSN=...  output file2
//TOOLIN DD *
COPY FROM&#40;IN1&#41; TO&#40;T1&#41; USING&#40;CTL1&#41;
COPY FROM&#40;IN2&#41; TO&#40;T1&#41; USING&#40;CTL2&#41;
SPLICE FROM&#40;T1&#41; TO&#40;OUT1&#41; ON&#40;7,200,CH&#41; KEEPNODUPS -
  WITH&#40;5,1&#41; USING&#40;CTL3&#41;
/*
//CTL1CNTL DD *
  OPTION SKIPREC=11
  INREC IFTHEN=&#40;WHEN=INIT,
      BUILD=&#40;1,4,5&#58;C'BB',7&#58;5,200,SQZ=&#40;SHIFT=LEFT&#41;&#41;&#41;
/*
//CTL2CNTL DD *
  OPTION SKIPREC=1
  INREC IFTHEN=&#40;WHEN=INIT,BUILD=&#40;1,4,5&#58;C'VV',7&#58;5,200&#41;&#41;
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT1,INCLUDE=&#40;5,2,CH,EQ,C'BB'&#41;,
    BUILD=&#40;1,4,5&#58;7&#41;,VLTRIM=C' '
  OUTFIL FNAMES=OUT2,INCLUDE=&#40;5,2,CH,EQ,C'VV'&#41;,
    BUILD=&#40;1,4,5&#58;7&#41;,VLTRIM=C' '
/*
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

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