MVSFORUMS.com A Community of and for MVS Professionals
View previous topic :: View next topic
Author
Message
zossy Beginner Joined: 04 Sep 2018 Posts: 6 Topics: 1
Posted: Thu Sep 06, 2018 5:20 am Post subject: DFSORT VL-Problem
Hi everybody!
I have a variable legth dataset with the following records
REC1rrraaaaaxaaaaax
REC2rrrbbbbbbbybbbbbbby
The parts aaaaax and bbbbbbby can by repeated 1 to 100 times counted in rrr.
I want to remove every x and every y and get the correct VL RDW:
REC1rrraaaaaaaaaa
REC2rrrbbbbbbbbbbbbbb
Using an OUTREC statement
Code: OUTREC IFTHEN(WHEN=5,4,CH,EQ,C'REC1'),
BUILD=(1,4,5,7,12,5,18,5,24,5))
the record is filled with spaces and the RDW is the maximum.
To cut the record I tried to modify the RDW depending on rrr, e.g..
Code: OUTREC OVERLAY=(1,4:X'00FD')
but this is not allowed (error-message)
Thanks for any ideas.
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Thu Sep 06, 2018 1:58 pm Post subject:
zossy ,
The reason you got an error is because you already used OUTREC and the 2nd one is a duplicate.
DFSORT automatically calculates the RDW for you when you use BUILD. You don't have to overlay it once again by calculating it again.
for example try this jcl
Code:
//**********************************************************
//* CREATE THE INPUT VB FILE *
//**********************************************************
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
REC1RRRAAAAAXAAAAAXAAAAAZ
REC2RRRBBBBBBBYBBBBBBBY
//SORTOUT DD DSN=&&INVB,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//SYSIN DD *
OPTION COPY
OUTFIL FTOV,VLTRIM=C' '
//*
//**********************************************************
//* DISPLAY THE LENGTH OF EACH RECORD BEFORE REMOVING DATA *
//**********************************************************
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=SHR,DSN=&&INVB
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INCLUDE COND=(5,4,CH,EQ,C'REC1')
OUTFIL VTOF,
BUILD=(C'THE RDW BEFORE REMOVING DATA IS : ',
1,2,BI,SUB,+4,EDIT=(TTTT))
//*
//**********************************************************
//* MODIFY THE REC1 BY REMOVING UNWANTED DATA *
//**********************************************************
//STEP0300 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=SHR,DSN=&&INVB
//SORTOUT DD DSN=&&OUVB,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//SYSIN DD *
OPTION COPY
OUTREC IFTHEN=(WHEN=(5,3,CH,EQ,C'REC1'),
BUILD=(1,4,5,7,12,5,18,5,24,5))
//*
//**********************************************************
//* DISPLAY THE LENGTH OF EACH RECORD AFTER REMOVING DATA *
//**********************************************************
//STEP0400 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=SHR,DSN=&&OUVB
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INCLUDE COND=(5,4,CH,EQ,C'REC1')
OUTFIL VTOF,
BUILD=(C'THE RDW AFTER REMOVING DATA IS : ',
1,2,BI,SUB,+4,EDIT=(TTTT))
//*
The output from step0200 would be
Code:
THE RDW BEFORE REMOVING DATA IS : 0025
The output from step0400(after removing the data) would be
Code:
THE RDW AFTER REMOVING DATA IS : 0022
So as you can see DFSORT calculated the RDW automatically for you.
If your intention is to remove the trailing spaces then all you need is to add
and DFSORT will remove the trailing spaces and update the RDW for you. _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
zossy Beginner Joined: 04 Sep 2018 Posts: 6 Topics: 1
Posted: Fri Sep 07, 2018 4:14 am Post subject:
kolusu,
Thank you for your explanation and ideas. The VLTRIM would be very nice, but the last data field can contain spaces as well.
So I modified your JCL with some "real" data:
Code: //**********************************************************
//* CREATE THE INPUT VB FILE *
//**********************************************************
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
REC1003012JNX001J X999 X
REC1001200 KX
REC1001220 X
REC1002500 NX512 X
REC2RRRBBBBBBBYBBBBBBBY
//SORTOUT DD DSN=&&INVB,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//SYSIN DD *
OPTION COPY
OUTFIL FTOV,VLTRIM=C' '
//*
The output is
Code: THE RDW AFTER REMOVING DATA IS : 0020
THE RDW AFTER REMOVING DATA IS : 0012
THE RDW AFTER REMOVING DATA IS : 0010
THE RDW AFTER REMOVING DATA IS : 0015
but the recordlength should be 12 for record 3, 17 for record 4 and 22 for record 1.
So, is it possible to use another padding character in STEP300?
Back to top
zossy Beginner Joined: 04 Sep 2018 Posts: 6 Topics: 1
Posted: Fri Sep 07, 2018 8:09 am Post subject:
The displayed output was after adding VLTRIM in STEP0300:
Code:
OPTION COPY
OUTREC IFTHEN=(WHEN=(5,3,CH,EQ,C'REC1'),
BUILD=(1,4,5,7,12,5,18,5,24,5))
OUTFIL VLTRIM=C' '
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Fri Sep 07, 2018 11:24 am Post subject:
zossy wrote: kolusu,
The output is
Code: THE RDW AFTER REMOVING DATA IS : 0020
THE RDW AFTER REMOVING DATA IS : 0012
THE RDW AFTER REMOVING DATA IS : 0010
THE RDW AFTER REMOVING DATA IS : 0015
but the recordlength should be 12 for record 3 , 17 for record 4 and 22 for record 1.
So, is it possible to use another padding character in STEP300?
zossy,
you used BUILD to create the record as 4 byte RDW + 7 byte from pos 5+ 5 byte from pos 12 + 5 byte from pos 18 + 5 bytes from pos 24 = 26 bytes.
So lets take your 3rd record in question. I appended the RDW of 1234 so that we can see how the record is built
This is the original record.
Code:
----+----1----+----2----+----3-
REC1001220 X
with RDW it looks like this
Code:
----+----1----+----2----+----3-
1234REC1001220 X
Now according to your build statement
Code:
-------------------------------
|RDW|POS 5 |POS12|POS18|POS24|
| |LEN 7 |LEN05|LEN05|LEN05|
-------------------------------
|4 |REC1001|220 | | |
-------------------------------
You have a total of 12 spaces starting from position 15
So the data looks like this
with RDW ( the length is 14 - Since you used VLTRIM to remove the trailing spaces)
Code:
----+----1----+----2
1234REC1001220
without RDW ( the length is 10)
Code:
----+----1----+----2
REC1001220
So DFSORT is calculating the length correctly. I am not sure as to how you got the 12 bytes as length. _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
zossy Beginner Joined: 04 Sep 2018 Posts: 6 Topics: 1
Posted: Mon Sep 10, 2018 4:44 am Post subject:
kolosu,
sorry for not explaining the intention of that. Of course, DFSORT always put the correct length in the RDW.
The record contains a record header including a repeat count and n repeats of a fixed data part.
In the (real) input file there is a repeated length of 6 and the recordlength contains always all bytes of the last repeated part even if the last three bytes are spaces.
In the output file is a repeated length of 5. With VLTRIM the recordlength varies dependig on content of the last two bytes:
1 byte shorter if the last byte is space,
two bytes shorter if the two last bytes are space.
That is the problem, because the record must include all bytes of the last repeated part.
The easiest way would be
Code: BUILD (1,(4+8+n*5))
(with n from pos.9-11)
but I didn't find a possibility to calculate the length value in a build statement.
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Mon Sep 10, 2018 10:50 am Post subject:
zossy ,
If I understand your question correctly, you are indeed building a fixed length record in your variable length file.
You can achieve that using IFOUTLEN parm. Since you have 1 to 100 occurrences of data you can code
IFOUTLEN=511 ( 4 byte RDW + 7 byte indicator + (100 * 5 ) ) = 511
So your outrec statement will be
Code:
OUTREC IFOUTLEN=511,
IFTHEN=(WHEN=(5,3,CH,EQ,C'REC1'),
BUILD=(1,4,5,7,12,5,18,5,24,5))
You need to get rid off the OUFIL VLTRIM statement. Now all the records in your input file will a length of 511. _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
zossy Beginner Joined: 04 Sep 2018 Posts: 6 Topics: 1
Posted: Mon Sep 10, 2018 11:39 am Post subject:
kolusu,
thank you for your answer again.
No, I don't need a full fixed length record.
I now found the following solution (in STEP0300) to archive the result:
Code: OPTION COPY
INREC IFTHEN=(WHEN=(5,3,CH,EQ,C'REC1'),
BUILD=(1,4,5,7,12,5,18,5,24,5))
OUTREC IFTHEN=(WHEN=(5,3,CH,EQ,C'REC1',AND,
9,3,ZD,EQ,+1),BUILD=(1,16)),
IFTHEN=(WHEN=(5,3,CH,EQ,C'REC1',AND,9,3,ZD,EQ,+2),BUILD=(1,21)),
IFTHEN=(WHEN=(5,3,CH,EQ,C'REC1',AND,9,3,ZD,EQ,+3),BUILD=(1,26)),
IFTHEN=(WHEN=(5,3,CH,EQ,C'REC1',AND,9,3,ZD,EQ,+4),BUILD=(1,31))
and I get this result:
Code: THE RDW AFTER REMOVING DATA IS : 0022
THE RDW AFTER REMOVING DATA IS : 0012
THE RDW AFTER REMOVING DATA IS : 0012
THE RDW AFTER REMOVING DATA IS : 0017
This is the korrekt result, but I need 100 IFTHEN statements for REC1 (and the same amount for an other record type REC2)
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Mon Sep 10, 2018 3:05 pm Post subject:
zossy ,
You need to be clear on what you want. Looking at your control cards now, we can do it with 1 set of IFTHEN statements it self. You can use VLTRIM on any character. So we use $ as pad character. We validate the array counter and pad the rest of the contents with $. Also note that the last IFTHEN is checking for counter > 100 where I am initializing the contents as if there is no array at all. Similar to counter being zero.
Code:
//SYSIN DD *
OPTION COPY
INCLUDE COND=(5,4,SS,EQ,C'REC1,REC2')
OUTREC IFTHEN=(WHEN=(9,3,ZD,EQ,000),OVERLAY=(012:500C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,001),OVERLAY=(017:495C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,002),OVERLAY=(022:490C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,003),OVERLAY=(027:485C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,004),OVERLAY=(032:480C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,005),OVERLAY=(037:475C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,006),OVERLAY=(042:470C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,007),OVERLAY=(047:465C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,008),OVERLAY=(052:460C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,009),OVERLAY=(057:455C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,010),OVERLAY=(062:450C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,011),OVERLAY=(067:445C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,012),OVERLAY=(072:440C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,013),OVERLAY=(077:435C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,014),OVERLAY=(082:430C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,015),OVERLAY=(087:425C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,016),OVERLAY=(092:420C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,017),OVERLAY=(097:415C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,018),OVERLAY=(102:410C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,019),OVERLAY=(107:405C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,020),OVERLAY=(112:400C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,021),OVERLAY=(117:395C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,022),OVERLAY=(122:390C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,023),OVERLAY=(127:385C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,024),OVERLAY=(132:380C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,025),OVERLAY=(137:375C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,026),OVERLAY=(142:370C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,027),OVERLAY=(147:365C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,028),OVERLAY=(152:360C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,029),OVERLAY=(157:355C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,030),OVERLAY=(162:350C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,031),OVERLAY=(167:345C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,032),OVERLAY=(172:340C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,033),OVERLAY=(177:335C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,034),OVERLAY=(182:330C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,035),OVERLAY=(187:325C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,036),OVERLAY=(192:320C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,037),OVERLAY=(197:315C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,038),OVERLAY=(202:310C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,039),OVERLAY=(207:305C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,040),OVERLAY=(212:300C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,041),OVERLAY=(217:295C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,042),OVERLAY=(222:290C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,043),OVERLAY=(227:285C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,044),OVERLAY=(232:280C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,045),OVERLAY=(237:275C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,046),OVERLAY=(242:270C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,047),OVERLAY=(247:265C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,048),OVERLAY=(252:260C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,049),OVERLAY=(257:255C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,050),OVERLAY=(262:250C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,051),OVERLAY=(267:245C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,052),OVERLAY=(272:240C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,053),OVERLAY=(277:235C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,054),OVERLAY=(282:230C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,055),OVERLAY=(287:225C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,056),OVERLAY=(292:220C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,057),OVERLAY=(297:215C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,058),OVERLAY=(302:210C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,059),OVERLAY=(307:205C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,060),OVERLAY=(312:200C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,061),OVERLAY=(317:195C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,062),OVERLAY=(322:190C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,063),OVERLAY=(327:185C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,064),OVERLAY=(332:180C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,065),OVERLAY=(337:175C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,066),OVERLAY=(342:170C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,067),OVERLAY=(347:165C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,068),OVERLAY=(352:160C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,069),OVERLAY=(357:155C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,070),OVERLAY=(362:150C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,071),OVERLAY=(367:145C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,072),OVERLAY=(372:140C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,073),OVERLAY=(377:135C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,074),OVERLAY=(382:130C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,075),OVERLAY=(387:125C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,076),OVERLAY=(392:120C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,077),OVERLAY=(397:115C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,078),OVERLAY=(402:110C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,079),OVERLAY=(407:105C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,080),OVERLAY=(412:100C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,081),OVERLAY=(417:095C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,082),OVERLAY=(422:090C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,083),OVERLAY=(427:085C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,084),OVERLAY=(432:080C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,085),OVERLAY=(437:075C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,086),OVERLAY=(442:070C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,087),OVERLAY=(447:065C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,088),OVERLAY=(452:060C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,089),OVERLAY=(457:055C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,090),OVERLAY=(462:050C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,091),OVERLAY=(467:045C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,092),OVERLAY=(472:040C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,093),OVERLAY=(477:035C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,094),OVERLAY=(482:030C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,095),OVERLAY=(487:025C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,096),OVERLAY=(492:020C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,097),OVERLAY=(497:015C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,098),OVERLAY=(502:010C'$')),
IFTHEN=(WHEN=(9,3,ZD,EQ,099),OVERLAY=(507:005C'$')),
IFTHEN=(WHEN=(9,3,ZD,GT,100),OVERLAY=(012:500C'$'))
OUTFIL VLTRIM=C'$'
//*
_________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
zossy Beginner Joined: 04 Sep 2018 Posts: 6 Topics: 1
Posted: Tue Sep 11, 2018 4:32 am Post subject:
kolusu,
thanks a lot . With your suggestions I found this solution:
Code: OPTION COPY
INREC IFTHEN=(WHEN=INIT,FINDREP=(IN=C' ',OUT=C'$')),
IFTHEN=(WHEN=(5,3,CH,EQ,C'REC1'),
BUILD=(1,4,5,7,12,5,18,5,24,5))
OUTREC IFTHEN=(WHEN=INIT,FINDREP=(IN=C' ',OUT=C'%'),HIT=NEXT),
IFTHEN=(WHEN=INIT,FINDREP=(IN=C'$',OUT=C' '))
OUTFIL VLTRIM=C'%'
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Tue Sep 11, 2018 10:53 am Post subject:
zossy wrote: kolusu,
thanks a lot . With your suggestions I found this solution:
Code: OPTION COPY
INREC IFTHEN=(WHEN=INIT,FINDREP=(IN=C' ',OUT=C'$')),
IFTHEN=(WHEN=(5,3,CH,EQ,C'REC1'),
BUILD=(1,4,5,7,12,5,18,5,24,5))
OUTREC IFTHEN=(WHEN=INIT,FINDREP=(IN=C' ',OUT=C'%'),HIT=NEXT),
IFTHEN=(WHEN=INIT,FINDREP=(IN=C'$',OUT=C' '))
OUTFIL VLTRIM=C'%'
zossy,
I am confused now. What happened to the validation of array counter? If that is what gives you the desired results, then good for you.
Just so you know you don't need HIT=NEXT on WHEN=INIT _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum