|
View previous topic :: View next topic
|
| Author |
Message |
senthilnathanj
New User
Joined: 31 Jul 2007 Posts: 47 Location: chennai
|
|
|
|
Hi,
The input is like below in UFF format of 7 bytes (decimal point upto 3 bytes and whole number upto 3 bytes)
| Code: |
5
4.2
10.66
10.66
11.81
11.81 |
I want to convert that into below format... like 9(3)V9(3) format.
Expected output:
| Code: |
005000
004200
010660
010660
011810
011810 |
Tried with the below code.
| Code: |
OPTION COPY
INREC BUILD=(1,7,UFF,EDIT=(TTTTTT),LENGTH=6) |
I got the below result.
| Code: |
000005
000042
001066
001066
001181
001181 |
Please advise on how to adjust SORT card. |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Why the trailing zero?
To get what you want, you could MULtiply by 10? |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Have a look at this. |
|
| Back to top |
|
 |
senthilnathanj
New User
Joined: 31 Jul 2007 Posts: 47 Location: chennai
|
|
|
|
Hi Dick,
I have tried with MULTIPLY by 10 in Sort card.
My Output:
| Code: |
005000
000420
010660
010660
011810
011810
|
Excepted Output :
| Code: |
005000
004200
010660
010660
011810
011810
|
Please Advise... |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
It may help if you post your new sort control statements.
When i first read your data, i missed some of the expected output and got hung up on the trailing zero
Suspect you will be ahead if you review the link Bill provided and try that approach. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
The Sort products do not know about decimal places in any data definitions.
If you want to use assumed, or actual, decimal places, then you have to cater for them yourself.
In your case, you have a "floating" decimal place, which at times is absent - caused by the removal of trailing zeros by whatever has generated the data.
The easiest thing is if whatever that is can be changed to produce the format you want instead.
If that is not possible, then you have to do the processing to deal with the 0, 1, 2 (or 3?) decimal places following the decimal point. Kolusu has already provided (in the link) code to do this which you should be able to adapt for your specific situation.
If you have problems with that, post the full sysout from the step in the Code tags, please, and explain what is wrong, showing your sample input which covers all possible cases (does the three places exits?) and expected and received output. RECFM and LRECL of files. |
|
| Back to top |
|
 |
senthilnathanj
New User
Joined: 31 Jul 2007 Posts: 47 Location: chennai
|
|
|
|
Hi ,
My Input File:
| Code: |
1023654,Y30,04/01/2012,11.81,BV,,Q,
1023654,Y42,04/01/2012,5.00,BV,,Q,
1023654,Y43,04/01/2012,0.5,BV,,Q,
1023654,Y45,04/01/2012,0.81,BV,,Q,
1023654,Y46,04/01/2012,4.2,BV,,Q,
1023654,Y47,04/01/2012,11.81,BV,,Q,
1023654,Y48,04/01/2012,5.97,BV,,Q,
|
Sort card:
| Code: |
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
PARSE=(%01=(ENDBEFR=C',',FIXLEN=09),
%02=(ENDBEFR=C',',FIXLEN=03),
%03=(ENDBEFR=C',',FIXLEN=10),
%04=(ENDBEFR=C',',FIXLEN=06),
%05=(ENDBEFR=C',',FIXLEN=02),
%06=(ENDBEFR=C',',FIXLEN=11),
%07=(ENDBEFR=C',',FIXLEN=01),
%08=(ENDBEFR=C',',FIXLEN=10)),
BUILD=(1,4,
%01,UFF,M11,LENGTH=09,X,
%02,
%03,UFF,M11,LENGTH=08,X,
%04,UFF,M11,LENGTH=06,X,
%08,UFF,M11,LENGTH=08,X,
%07,X,
%05,X,
%06,UFF,EDIT=(TTTTTTTTTTT),LENGTH=11,X,
%03))
OUTFIL VTOF,BUILD=(5,13,24,2,18,2,20,2,26,1,
27,6,ZD,MUL,+10,TO=ZDF,LENGTH=6,
33,1,38,4,34,2,36,2,42,18,
66,4,60,2,63,2)
/* |
My Output dataset:
| Code: |
001023654 Y30120401 011810 00000000 Q BV 00000000000 20120401
001023654 Y42120401 005000 00000000 Q BV 00000000000 20120401
001023654 Y43120401 000050 00000000 Q BV 00000000000 20120401
001023654 Y45120401 000810 00000000 Q BV 00000000000 20120401
001023654 Y46120401 000420 00000000 Q BV 00000000000 20120401
001023654 Y47120401 011810 00000000 Q BV 00000000000 20120401
001023654 Y48120401 005970 00000000 Q BV 00000000000 20120401
|
Excepted Output:
| Code: |
001023654 Y30120401 011810 00000000 Q BV 00000000000 20120401
001023654 Y42120401 005000 00000000 Q BV 00000000000 20120401
001023654 Y43120401 000500 00000000 Q BV 00000000000 20120401
001023654 Y45120401 000810 00000000 Q BV 00000000000 20120401
001023654 Y46120401 004200 00000000 Q BV 00000000000 20120401
001023654 Y47120401 011810 00000000 Q BV 00000000000 20120401
001023654 Y48120401 005970 00000000 Q BV 00000000000 20120401
|
3th and 5th record is not correct.
Please advise.. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Did you follow that link? You don't have any code to deal with the "." and the number of decimal places. |
|
| Back to top |
|
 |
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Hi,
I've changed your SORT card as below.
| Code: |
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
PARSE=(%01=(ENDBEFR=C',',FIXLEN=09),
%02=(ENDBEFR=C',',FIXLEN=03),
%03=(ENDBEFR=C',',FIXLEN=10),
%04=(ENDBEFR=C',',FIXLEN=06),
%05=(ENDBEFR=C',',FIXLEN=02),
%06=(ENDBEFR=C',',FIXLEN=11),
%07=(ENDBEFR=C',',FIXLEN=01),
%08=(ENDBEFR=C',',FIXLEN=10)),
BUILD=(1,4,
%01,UFF,M11,LENGTH=09,X,
%02,
%03,UFF,M11,LENGTH=08,X,
%04,X,
%08,UFF,M11,LENGTH=08,X,
%07,X,
%05,X,
%06,UFF,EDIT=(TTTTTTTTTTT),LENGTH=11,X,
%03))
OUTFIL VTOF,BUILD=(5,13,24,2,18,2,20,2,26,1,
27,6,
33,1,38,4,34,2,36,2,42,18,
66,4,60,2,63,2)
/* |
Added one more SORT step with the below card, to apply the numeric conversion.
| Code: |
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,PARSE=(%01=(ABSPOS=21,ENDBEFR=C'.',FIXLEN=3),
%02=(FIXLEN=3)),
OVERLAY=(21:%01,UFF,TO=ZD,LENGTH=3,24:%02)),
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=21,ENDPOS=26,
INOUT=(C' ',C'0')))
/* |
Please test and let us know the results. Thank you. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| It doesn't need the 2nd step, can be done in the same step. Only the last three bytes need to be checked for space - in fact, it seems the third byte will always be zero, so on confirmation could be made a literal. |
|
| Back to top |
|
 |
bodatrinadh
Active User

Joined: 05 Jan 2007 Posts: 101 Location: chennai (India)
|
|
|
|
I did few changes to senthilnathanj's code and got the output...
| Code: |
//STEP1 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1023654,Y30,04/01/2012,11.81,BV,,Q,
1023654,Y42,04/01/2012,5.00,BV,,Q,
1023654,Y43,04/01/2012,0.5,BV,,Q,
1023654,Y45,04/01/2012,0.81,BV,,Q,
1023654,Y46,04/01/2012,4.2,BV,,Q,
1023654,Y47,04/01/2012,11.81,BV,,Q,
1023654,Y48,04/01/2012,5.97,BV,,Q,
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
PARSE=(%01=(ENDBEFR=C',',FIXLEN=09),
%02=(ENDBEFR=C',',FIXLEN=03),
%03=(ENDBEFR=C',',FIXLEN=10),
%04=(ENDBEFR=C'.',FIXLEN=04),
%05=(ENDBEFR=C',',FIXLEN=04),
%06=(ENDBEFR=C',',FIXLEN=03),
%07=(ENDBEFR=C',',FIXLEN=11),
%08=(ENDBEFR=C',',FIXLEN=01),
%09=(ENDBEFR=C',',FIXLEN=10)),
BUILD=(%01,UFF,M11,LENGTH=09,X,
%02,
%03,UFF,M11,LENGTH=08,X,
%04,UFF,M11,LENGTH=5,
%05,JFY=(SHIFT=LEFT),X,
%09,UFF,EDIT=(TTTTTTTTTTT),LENGTH=08,X,
%08,X,
%06,X,
%07,UFF,EDIT=(TTTTTTTTTTT),LENGTH=11,X,
%03))
OUTREC BUILD=(1,13,20,2,14,2,16,2,
20:25,6,ZD,M11,LENGTH=7,28:33,8,X,42,1,X,44,2,X,48,11,X,
54:66,4,60,2,63,2)
|
| Code: |
001023654 Y30120401 011810 00000000 Q BV 00000000000 20120401
001023654 Y42120401 005000 00000000 Q BV 00000000000 20120401
001023654 Y43120401 000500 00000000 Q BV 00000000000 20120401
001023654 Y45120401 000810 00000000 Q BV 00000000000 20120401
001023654 Y46120401 004200 00000000 Q BV 00000000000 20120401
001023654 Y47120401 011810 00000000 Q BV 00000000000 20120401
001023654 Y48120401 005970 00000000 Q BV 00000000000 20120401
|
Thanks
-3nadh |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|