|
View previous topic :: View next topic
|
| Author |
Message |
Bryant Shearin
New User
Joined: 31 Oct 2015 Posts: 1 Location: usa
|
|
|
|
I'm using DFSORT to reformat records. I want to suppress leading zeros on an alphnummeric field and shift the result left.
I cannot cause the data to shift left.
Please help,
JB
this is how my data looks before the overlay:
Command ===>
****** ***************************** Top of
000001 542 123456
000002 542 ABC012
000003 542 9874563210
000004 542 ABCC011
000005 542 ABCC013
000006 542 ABCC014
000007 542 ABCC015
000008 542 ABCC016
000009 542 017ABCC -- leading zeros
000010 542 018ABCC
this is how it looks after the overlay:
| Code: |
Command ===>
****** ***************************** Top of
000001 542 123456
000002 542 ABC012
000003 542 9874563210
000004 542 ABCC011
000005 542 ABCC013
000006 542 ABCC014
000007 542 ABCC015
000008 542 ABCC016
000009 542 17ABCC -- leading zeros overlayed with space
000010 542 18ABCC |
This is how I want it to look:
| Code: |
Command ===>
****** ***************************** Top of
000001 542 123456
000002 542 ABC012
000003 542 9874563210
000004 542 ABCC011
000005 542 ABCC013
000006 542 ABCC014
000007 542 ABCC015
000008 542 ABCC016
000009 542 17ABCC -- left justified after zeros replaced
000010 542 18ABCC |
here is my code:
| Code: |
IFTHEN=(WHEN=(19,01,CH,EQ,C'0'),
OVERLAY=(19:C' ')) |
Code'd |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| Pleas use the code-tags to preserve you spaces. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Code: |
IFTHEN=(WHEN=(19,01,CH,EQ,C'0'),
OVERLAY=(19:20,9,X)) |
This assumes your field is 10 bytes long and that you only want to shift out one leading zero. |
|
| Back to top |
|
 |
vasanthz
Global Moderator

Joined: 28 Aug 2007 Posts: 1753 Location: Tirupur, India
|
|
|
|
Added to Bill's code,
| Code: |
OPTION COPY
INREC IFTHEN=(WHEN=(19,10,CH,EQ,C'0000000000'),OVERLAY=(19:10X)),
IFTHEN=(WHEN=(19,09,CH,EQ,C'000000000'),OVERLAY=(19:28,1,9X)),
IFTHEN=(WHEN=(19,08,CH,EQ,C'00000000'),OVERLAY=(19:27,2,8X)),
IFTHEN=(WHEN=(19,07,CH,EQ,C'0000000'),OVERLAY=(19:26,3,7X)),
IFTHEN=(WHEN=(19,06,CH,EQ,C'000000'),OVERLAY=(19:25,4,6X)),
IFTHEN=(WHEN=(19,05,CH,EQ,C'00000'),OVERLAY=(19:24,5,5X)),
IFTHEN=(WHEN=(19,04,CH,EQ,C'0000'),OVERLAY=(19:23,6,4X)),
IFTHEN=(WHEN=(19,03,CH,EQ,C'000'),OVERLAY=(19:22,7,3X)), <- YES!! I can hear people with OCD crying!! muhahaha...! ";.;" :evil:
IFTHEN=(WHEN=(19,02,CH,EQ,C'00'),OVERLAY=(19:21,8,2X)),
IFTHEN=(WHEN=(19,01,CH,EQ,C'0'),OVERLAY=(19:20,9,X)) |
|
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
Add JFY=(SHIFT=LEFT) in OUTREC BUILD to your card, But I don't think Bill would encourage two passes ( I guess it will) otherwise he could have suggested.  |
|
| Back to top |
|
 |
boyti ko
New User

Joined: 03 Nov 2014 Posts: 78 Location: Malaysia
|
|
|
|
how about this one?
| Code: |
SORT FIELDS=COPY
INREC FINDREP=(STARTPOS=18,ENDPOS=28,
IN=(C' 0000000000',
C' 000000000',
C' 00000000',
C' 0000000',
C' 000000',
C' 00000',
C' 0000',
C' 000',
C' 00',
C' 0'),OUT=C' ') |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
boyti ko,
No, that will replace zeros anywhere in that range with blanks.
For information, to replace with "nothing" (ie cause the data to shift left) use nothing (C'').
Rohit, not so much two passes of the data as two operations. |
|
| Back to top |
|
 |
boyti ko
New User

Joined: 03 Nov 2014 Posts: 78 Location: Malaysia
|
|
|
|
Hi Bill,
I have indicated a space before the zeroes. So the zeroes in between will not be affected. Although I'm also expecting a better answer. Since vasanthz is correct that people with OCD will react on this one. |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
| Just a thought would not EDIT + SQZ help? |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
boyti ko,
OK. The IFTHEN=(WHEN=(logicalexpression has one test per possible leading-zero pattern. You, currently, have that many tests for the first element of the FINDREP.
You can improve that slightly by including DO=1. DO should always be there when there a limit to the number of changes possible (other than the length specified or implied to the FINDREP).
However, the number of tests can't be limited when there are no leading zeros.
You'd also have to know if there were actual data following the field being FINDREPed.
Pandora-Box,
There are alphanumeric data items as well. Any leading blanks there would disappear with SQZ or JFY (better for this example).
It would be less code, but more CPU. |
|
| Back to top |
|
 |
boyti ko
New User

Joined: 03 Nov 2014 Posts: 78 Location: Malaysia
|
|
|
|
| Yes Bill, now I realize it. Thanks for pointing out that one. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|