formatting a numeric field in input file
Moderators: Frank Yaeger, Moderator Group
-
- Member
- Posts: 6
- Joined: Thu Nov 08, 2012 12:56 am
formatting a numeric field in input file
Hi,
we get a input file from a different appilcation in the below format, X(18 byte
-131.1
290.05
265.07
251.52
252.37
281.78
304.78
421.37
418.1
354.66
361.05
254.33
277.33
68.64
125
My requirement is to convert this in to s9(16)v9(2) format. Is this possible. Please help.
we get a input file from a different appilcation in the below format, X(18 byte
-131.1
290.05
265.07
251.52
252.37
281.78
304.78
421.37
418.1
354.66
361.05
254.33
277.33
68.64
125
My requirement is to convert this in to s9(16)v9(2) format. Is this possible. Please help.
Assuming LRECL=80, use the below code
Thanks
Magesh
Code: Select all
OPTION COPY
INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'-'),
PARSE=(%00=(ENDBEFR=C'.',ENDBEFR=C' ',FIXLEN=16,PAIR=QUOTE),
%01=(FIXLEN=2)),
BUILD=(%00,UFF,ZD,LENGTH=16,
%01,81:C'-')),
IFTHEN=(WHEN=NONE,
PARSE=(%02=(ENDBEFR=C'.',ENDBEFR=C' ',FIXLEN=16,PAIR=QUOTE),
%03=(FIXLEN=2)),
BUILD=(%02,UFF,ZD,LENGTH=16,
%03,81:C' '))
OUTREC IFTHEN=(WHEN=(17,2,CH,EQ,C' '),OVERLAY=(17:C'00'),HIT=NEXT),
IFTHEN=(WHEN=(18,1,CH,EQ,C' '),OVERLAY=(18:C'0'),HIT=NEXT),
IFTHEN=(WHEN=(81,1,CH,EQ,C'-'),
OVERLAY=(1,18,ZD,MUL,-1,ZD,LENGTH=18)),
IFOUTLEN=80
Magesh
BANUREKHAB,
Also let us know if you need
I assumed to be
Regards,
Magesh
Also let us know if you need
Code: Select all
418.1 to be 418.10
or
418.1 to be 418.01
Code: Select all
418.1 to be 418.10
Magesh
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
-
- Member
- Posts: 6
- Joined: Thu Nov 08, 2012 12:56 am
Thank you very much and very sorry for the late reply. This is exactly what i needed.
My input file,
100402.24
1006961.9
103761.05
-100.31
170855.35
183
-159711.81
155213.69
152236.93
161383.16
After using the sort provided,
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'-'),
PARSE=(%00=(ENDBEFR=C'.',ENDBEFR=C' ',FIXLEN=16,PAIR=QUOTE),
%01=(FIXLEN=2)),
BUILD=(%00,UFF,ZD,LENGTH=16,%01,81:C'-')),
IFTHEN=(WHEN=NONE,
PARSE=(%02=(ENDBEFR=C'.',ENDBEFR=C' ',FIXLEN=16,PAIR=QUOTE),
%03=(FIXLEN=2)),
BUILD=(%02,UFF,ZD,LENGTH=16,%03,81:C' '))
OUTREC IFTHEN=(WHEN=(17,2,CH,EQ,C' '),OVERLAY=(17:C'00'),HIT=NEXT),
IFTHEN=(WHEN=(18,1,CH,EQ,C' '),OVERLAY=(18:C'0'),HIT=NEXT),
IFTHEN=(WHEN=(81,1,CH,EQ,C'-'),
OVERLAY=(1,18,ZD,SUB,-0,ZD,LENGTH=18 )),
IFOUTLEN=400
Output:
000000000010040224
000000000100696190
000000000010376105
00000000000001003J
000000000017085535
000000000000018300
00000000001597118J
000000000015521369
000000000015223693
000000000016138316
Thank you again. I will modify it for subtract from zero instead of multiplying by -1.
My input file,
100402.24
1006961.9
103761.05
-100.31
170855.35
183
-159711.81
155213.69
152236.93
161383.16
After using the sort provided,
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'-'),
PARSE=(%00=(ENDBEFR=C'.',ENDBEFR=C' ',FIXLEN=16,PAIR=QUOTE),
%01=(FIXLEN=2)),
BUILD=(%00,UFF,ZD,LENGTH=16,%01,81:C'-')),
IFTHEN=(WHEN=NONE,
PARSE=(%02=(ENDBEFR=C'.',ENDBEFR=C' ',FIXLEN=16,PAIR=QUOTE),
%03=(FIXLEN=2)),
BUILD=(%02,UFF,ZD,LENGTH=16,%03,81:C' '))
OUTREC IFTHEN=(WHEN=(17,2,CH,EQ,C' '),OVERLAY=(17:C'00'),HIT=NEXT),
IFTHEN=(WHEN=(18,1,CH,EQ,C' '),OVERLAY=(18:C'0'),HIT=NEXT),
IFTHEN=(WHEN=(81,1,CH,EQ,C'-'),
OVERLAY=(1,18,ZD,SUB,-0,ZD,LENGTH=18 )),
IFOUTLEN=400
Output:
000000000010040224
000000000100696190
000000000010376105
00000000000001003J
000000000017085535
000000000000018300
00000000001597118J
000000000015521369
000000000015223693
000000000016138316
Thank you again. I will modify it for subtract from zero instead of multiplying by -1.
BANUREKHAB,
Start using code tags. which will help people to read it better.
Regards,
Magesh
Start using code tags. which will help people to read it better.
Code: Select all
[ code ] ur code [ / code ]
Regards,
Magesh
BANUREKHAB,
Start using code tags. which will help people to read it better.
Regards,
Magesh
Start using code tags. which will help people to read it better.
Code: Select all
[ code ] ur code [ / code ]
Regards,
Magesh
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
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page