Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
chandan.inst

Active User

Joined: 03 Nov 2005
Posts: 271
Location: Mumbai

Posted: Mon Feb 02, 2009 1:32 pm    Post subject: Convert Numeric field to chacter with supressing leading zer

Hi all,
Is it possible to suppress leading zeros using DFSORT .My requirement is as follows

I/P

 Code: ----+----1 00011111 00002222 01111111

O/P

 Code: ----+----1 11111 2222 1111111

Regards,
Chandan

chandan.inst

Active User

Joined: 03 Nov 2005
Posts: 271
Location: Mumbai

 Posted: Mon Feb 02, 2009 2:50 pm    Post subject: Reply to: Convert Numeric field to chacter with supressing l Hi All, I got one solution for above problem and the sort card is as below SORT FIELDS=COPY INREC BUILD=(1,10,ZD,EDIT=(IIIIIIII)) OUTREC BUILD=(1,10,JFY=(SHIFT=LEFT)) it solves the purpose and give desire output but there is one more issue with this solution for the fileds input fileds having alphanumeric character it converts to corresponding ZD format for example I/P ----+----1 00011EEE It gives O/P as ----+----1 11555 But I need it as ----+----1 11EEE Please help me out in this Regards, Chandan
dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

 Posted: Mon Feb 02, 2009 8:54 pm    Post subject: Hello, Your initial post showed numeric values. Now there are numeric and alpha values. You have defined a field with alphabetic values as a zoned-decimal numeric which is the reason for the 5's. What other "surprises" might there be? What are the recfm and lrecl of the data? What positions in the data are to be worked on?
Frank Yaeger

DFSORT Moderator

Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

Posted: Mon Feb 02, 2009 10:51 pm    Post subject:

Chandan,

Assuming you have 8 character values as shown in your example, you can use a DFSORT job like the following to do what you asked for:

 Code: //S1    EXEC  PGM=ICEMAN //SYSOUT    DD  SYSOUT=* //SORTIN DD * 00011111 00002222 00002200 01111111 00011EEE /* //SORTOUT DD SYSOUT=* //SYSIN    DD    *   OPTION COPY   INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'0',AND,2,1,CH,NE,C'0'),     OVERLAY=(1:X)),    IFTHEN=(WHEN=(1,2,CH,EQ,C'00',AND,3,1,CH,NE,C'0'),     OVERLAY=(1:2X)),    IFTHEN=(WHEN=(1,3,CH,EQ,C'000',AND,4,1,CH,NE,C'0'),     OVERLAY=(1:3X)),    IFTHEN=(WHEN=(1,4,CH,EQ,C'0000',AND,5,1,CH,NE,C'0'),     OVERLAY=(1:4X)),    IFTHEN=(WHEN=(1,5,CH,EQ,C'00000',AND,6,1,CH,NE,C'0'),     OVERLAY=(1:5X)),    IFTHEN=(WHEN=(1,6,CH,EQ,C'000000',AND,7,1,CH,NE,C'0'),     OVERLAY=(1:6X)),    IFTHEN=(WHEN=(1,7,CH,EQ,C'0000000',AND,8,1,CH,NE,C'0'),     OVERLAY=(1:7X)),    IFTHEN=(WHEN=(1,8,CH,EQ,C'00000000'),     OVERLAY=(1:8X))  OUTREC BUILD=(1,10,JFY=(SHIFT=LEFT)) /*

SORTOUT would have:

 Code: 11111      2222      2200      1111111    11EEE
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics How to include a particular field val... sakrat DFSORT/ICETOOL 8 Fri Apr 06, 2018 8:27 pm Sort numeric fields with trailing spaces sancraig16 SYNCSORT 7 Tue Apr 03, 2018 1:21 am Extract the records with a PD field's... sudhakar84 DFSORT/ICETOOL 11 Mon Apr 02, 2018 7:26 pm Searching a table for the field name? socker_dad COBOL Programming 8 Sat Mar 31, 2018 2:57 am Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us