/* REXX */
"alloc f(xxin) ds('HLQ.TEST.INPUT') shr"
"execio * diskr xxin (finis stem in."
"free f(xxin)"
do recid = 1 to in.0
parse var in.recid a ',' b ',' c ',' d ',' e ',' f
ra=overlay('0',a,1,wordindex(a,1)-1,'0')
rb=overlay('0',b,1,wordindex(b,1)-1,'0')
rc=overlay('0',c,1,wordindex(c,1)-1,'0')
rd=overlay('0',d,1,wordindex(d,1)-1,'0')
re=overlay('0',e,1,wordindex(e,1)-1,'0')
rf=overlay('0',f,1,wordindex(f,1)-1,'0')
out.recid = ra||','||rb||','||rc||','||rd||','||re||','||rf
end
say 'Completed'
"alloc da('HLQ.TEST.OUTPUT') f(out) old"
"execio * diskw out (finis stem out."
"free f(out)"
Input
Code:
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
****** ***************************** Top of Data ******************************
000001 10305,1 9267041, 1, 11, 1,123453456
000002 10 05,169237041, 1, 11, 1,123453456
****** **************************** Bottom of Data ****************************
Output
Code:
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
****** ***************************** Top of Data ******************************
000001 000010305,1 9267041,0001,0011,0001,123453456
000002 000010 05,169237041,0001,0011,0001,123453456
****** **************************** Bottom of Data ****************************
Hi Arun,
Tou can use the simple logic to remove the leading spaces
Code:
IDENTIFICATION DIVISION.
PROGRAM-ID. TSTPGM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-IN PIC X(80) VALUE SPACES.
01 A REDEFINES WS-IN.
05 B PIC X OCCURS 80 TIMES.
01 C PIC 9 VALUE ZERO.
01 X PIC 99 VALUE ZERO.
01 Y PIC 99 VALUE ZERO.
PROCEDURE DIVISION.
P1.
ACCEPT WS-IN.
INSPECT WS-IN TALLYING Y FOR CHARACTERS.
PERFORM P2 VARYING X FROM 1 BY 1 UNTIL X > Y.
DISPLAY WS-IN.
STOP RUN.
P2.
IF C = 0
IF B ( X ) IS NUMERIC
MOVE 1 TO C
END-IF
IF B ( X ) = SPACES
MOVE 0 TO B ( X )
END-IF
END-IF
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
from what I heard on the forums You can use
SORT ( dfsort/syncsort )
Quote:
If by JCL you mean SORT, yes, I do believe it can be done.....
I think you're sending the OP off on a wild goose chase. Can you figure out how it can be done or are you just assuming sort can do everything?
The input records have leading blanks and embedded blanks like this:
Code:
10305,1 9267041,...
10 05,169237041,...
According to the OP, the output records should have the leading blanks changed to leading zeros, but keep the embedded blanks.
Code:
000010305,1 9267041,...
000010 05,169237041,...
I can't think of a way to do that with sort. Replacing the leading and embedded blanks with zeros could certainly be done with sort, but here the embedded blanks must be kept.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
I was not figuring out anything, I am no sort expert,
I was just listing some alternative to INVESTIGATE
Well then perhaps you could phrase it that way to indicate your level of confidence to avoid having somebody go chasing down something in the books that might not exist, rather than the more confident (but vague):