You are here:

Cobol/COBOL how to remove Leading zeros

Advertisement


Edwin Clements wrote at 2014-12-08 02:28:09
When you do a display statement, it is going to show it like that.  (That could vary depending on what computer system you are using.)

If you first move it to a numeric edited field, and then display that field, it will be displayed the way you want it.  



Example:  05  CUST-CODE  PIC S9(9) comp-3  VALUE 241285.

         05  DISP-CUST-CODE   PIC Z(8)9.



MOVE CUST-CODE TO DISP-CUST-CODE.

DISPLAY DISP-CUST-CODE.    



This should get you the results you want.




Cobol

All Answers


Answers by Expert:


Ask Experts

Volunteer


David Nelson

Expertise

I specialize in IBM z/OS COBOL and MicroFocus OCDS and Server Express non-OOP. Design, coding and performance oriented questions. Also linking to IBM Assembler from COBOL. Because the rules change with version, please state language level, version and platform environment. See CICS for questions about CICS.

Experience

Over 35 years working with COBOL on multiple platforms and OS.

Education/Credentials
Graduate, New York School of Computer Technology.

Past/Present Clients
Major Financial Institutions, State of NC (DHHS), Manufacturing, Financial services, Warehousing, Software developer and others.

©2016 About.com. All rights reserved.