|
View previous topic :: View next topic
|
| Author |
Message |
VivekKhanna
New User

Joined: 09 Feb 2009 Posts: 57 Location: India
|
|
|
|
Hi,
I have an input file holding data as shown below:
| Code: |
----+----1----+----2----+----3----+----4----+----5
ABCDP01 JEFF
ABCD01 AUGS
ABCDEFGH01ABEDFG
ABC02 ABC
A02 A
|
Composite Key to my input file is present in first 10 bytes. e.g. Rec# 1, key is ABCDP01.
In the key the last 2 bytes are numeric.
I need to extract the last two bytes from the key and populate them in the output file starting at position 21. So, the final output should look like:
| Code: |
----+----1----+----2----+----3----+----4----+----5
ABCDP01 JEFF 01
ABCD01 AUGS 01
ABCDEFGH01ABEDFG 01
ABC02 ABC 02
A02 A 02
|
I am able to get the length of fields using below control cards:
| Code: |
//JS010 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//DFSPARM DD DSN=QCPPNP.CUS.PARMLIB(ADJEL050),DISP=SHR
//$ORTPARM DD DSN=QCPPNP.CUS.PARMLIB(ADJELG01),DISP=SHR
//X37IGN DD DUMMY
//INP DD *
ABCDEF01 ABCDEF
ABCD01 ABCD
A01 A
ABCE01 ABCE
ABCEDEFG01ABCEDEFG
/*
//OUT DD SYSOUT=*
//T01 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T02 DD SYSOUT=*
//SORTXSUM DD DUMMY
//TOOLIN DD *
COPY FROM(INP) USING(CTL1)
COPY FROM(T01) TO(T02) USING(CTL2)
*COPY FROM(T02) TO(OUT) USING(CTL3)
/*
//CTL1CNTL DD *
INREC BUILD=(1,10)
OUTFIL FNAMES=T01,FTOV,VLTRIM=C' '
/*
//CTL2CNTL DD *
OUTFIL VTOF,BUILD=(5,10,X,1,2,BI,SUB,+5,TO=ZD,LENGTH=2)
/*
|
Output of T2 is :
| Code: |
ABCDEF01 07
ABCD01 05
A01 02
ABCE01 05
ABCEDEFG01 09
|
Please suggest, how can we use the identified length to BUILD the outrec. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I'm not sure what you've identified the length of, but although you've applied code to get an answer, if you are reading an input three times you may as well write a program to do it.
However, what you seem to want can be done in one pass of the data. Have a look at what JFY with SHIFT=RIGHT can do. It can slam the contents of your field to the right, so that the last two bytes of the field are in a fixed position, which you can then use in BUILD.
You can't use anything directly from a field to indicate information for position/length in the sort control cards themselves. |
|
| Back to top |
|
 |
VivekKhanna
New User

Joined: 09 Feb 2009 Posts: 57 Location: India
|
|
|
|
Thanks Bill. I was able to to achieve it using the same approach shared by you. Please find the details mentioned below:
| Code: |
//JS010 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//DFSPARM DD DSN=QCPPNP.CUS.PARMLIB(ADJEL050),DISP=SHR
//$ORTPARM DD DSN=QCPPNP.CUS.PARMLIB(ADJELG01),DISP=SHR
//X37IGN DD DUMMY
//INP DD *
ABCDEF01 XXCDEF
ABCD02 XXCD
A01 DD
ABCE03 ABGG
ABCEDEFG05 AFFEDEFG
/*
//OUT DD SYSOUT=*
//T01 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T02 DD SYSOUT=*
//SORTXSUM DD DUMMY
//TOOLIN DD *
COPY FROM(INP) TO(T01) USING(CTL1)
COPY FROM(T01) TO(T02) USING(CTL2)
/*
//CTL1CNTL DD *
OPTION COPY
INREC PARSE=(%00=(ENDBEFR=C' ',FIXLEN=10),
%01=(ABSPOS=14,ENDBEFR=C' ',FIXLEN=10)),
BUILD=(%00,%00,JFY=(SHIFT=RIGHT),%01)
/*
//CTL2CNTL DD *
OUTREC BUILD=(1:1,10,11:19,2,13:X,14:21,10)
/*
|
The output is:
| Code: |
ABCDEF01 01 XXCDEF
ABCD02 02 XXCD
A01 01 DD
ABCE03 03 ABGG
ABCEDEFG0505 AFFEDEFG
|
Please share your thoughts, in case you have any other approach. |
|
| Back to top |
|
 |
expat
Global Moderator

Joined: 14 Mar 2007 Posts: 8798 Location: Welsh Wales
|
|
|
|
Your code looks as though you are still doing two passes of the data.
I think that Bill was hinting at something like building an INREC record where the right shifted field is added to the end of the record, and an OUTREC BUILD to select the required fields from the layout created by the INREC BUILD.
I have assumed that the RECFM=FB as you are using position 1 as the start of your data.
No mainframe access at the moment so can't test the theory, but it should get this done in a single pass of the data. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Code: |
OPTION COPY
INREC PARSE=(%00=(ENDBEFR=C' ',FIXLEN=10),
%01=(ABSPOS=14,ENDBEFR=C' ',FIXLEN=10)),
BUILD=(%00,%00,JFY=(SHIFT=RIGHT),%01)
OUTREC BUILD=(1:1,10,11:19,2,13:X,14:21,10) |
That should give you the same output, with only reading the data once.
However, you don't need PARSE, as the fields are in fixed position.
You can have multiple IFTHEN=(WHEN=INIT which allow you to use multiple functions in INREC (or OUTREC or OUTFIL), You can use OVERLAY to add a new temporary field to a record, then BUILD to make you final output. Unless you need column-numbers on a BUILD, it is easier to understand and maintain if you don't use them. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|