Add leading zeros by using cobol
Moderators: dbzTHEdinosauer, Moderator Group
Add leading zeros by using cobol
hi,
I have a file contains numeric data from 1st position to 9th position. Please see below.
input file:
2
23
456
4256
26879
236984
2457896
23696352
369874544
the maximum length of the numeric data is 9. Now I need to add leading zeros to the above data. The output should get like as I mentioned below.
Output:
000000002
000000023
000000456
000004256
000026879
000236984
002457896
023696352
369874544
Please look into this and should be done only by using cobol.
Regards,
Venky.
I have a file contains numeric data from 1st position to 9th position. Please see below.
input file:
2
23
456
4256
26879
236984
2457896
23696352
369874544
the maximum length of the numeric data is 9. Now I need to add leading zeros to the above data. The output should get like as I mentioned below.
Output:
000000002
000000023
000000456
000004256
000026879
000236984
002457896
023696352
369874544
Please look into this and should be done only by using cobol.
Regards,
Venky.
- dbzTHEdinosauer
- Moderator
- Posts: 981
- Joined: Mon Oct 02, 2006 8:31 pm
hi,
Thanks Numval is working, but I have one more question see below.
when there is space in between the row, the numval is notworking. Please see the below input file and suggest how to Ignore the space and remaining data should add leading zeros.
Inputfile:
2
23
456
4256
26879
236984
2457896
23696352
369874544
Thanks,
Venky.
Thanks Numval is working, but I have one more question see below.
when there is space in between the row, the numval is notworking. Please see the below input file and suggest how to Ignore the space and remaining data should add leading zeros.
Inputfile:
2
23
456
4256
26879
236984
2457896
23696352
369874544
Thanks,
Venky.
Thank you,
okay you are saying that I need to skip the record or pass default value,
but the spaces will be located at different rows in particular one column, It is difficult to find the spaces to skip the space records.
Is there is any other logic to Ignore the spaces and add leading zeros to other remaining values. I mean other then Numval???
Thanks once again.
Venky.
okay you are saying that I need to skip the record or pass default value,
but the spaces will be located at different rows in particular one column, It is difficult to find the spaces to skip the space records.
Is there is any other logic to Ignore the spaces and add leading zeros to other remaining values. I mean other then Numval???
Thanks once again.
Venky.
You are writing a program. . .
If you want something done, you need to code for it. There are no magic bullets that will "skip over things".
IF THE-FIELD = SPACES
whatever action.
If you want something done, you need to code for it. There are no magic bullets that will "skip over things".
I must be missing something. . . How can it be be difficult to code:It is difficult to find the spaces to skip the space records.
IF THE-FIELD = SPACES
whatever action.
Have a good one
Why are you against COMPUTE? Why even mention COMPUTE - it is not needed for this.
All you should need is to move the value to an output field that is not leading-zero suppressed (i.e. my-non-zero-field pic 9(9).) - unless there is more you have not posted. . .
All you should need is to move the value to an output field that is not leading-zero suppressed (i.e. my-non-zero-field pic 9(9).) - unless there is more you have not posted. . .
Last edited by DikDude on Tue Aug 07, 2012 9:24 pm, edited 1 time in total.
Have a good one
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
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