View previous topic :: View next topic
|
Author |
Message |
scorp_rahul22 Currently Banned New User
Joined: 06 Aug 2007 Posts: 42 Location: chennai
|
|
|
|
Is there anf way to way to remove unwanted charcters from file.
EXAMPLE
INPUT
'DW3P.LKP.KBMA'
'DW4P.LKP.KBMAA'
'DW5P.LKP.KBMAAA'
'DW6P.LKP.KBMAAAA'
'DW7P.LKP.KBMAAAAA'
OUTPUT
DW3P.LKP.KBMA
DW4P.LKP.KBMAA
DW5P.LKP.KBMAAA
DW6P.LKP.KBMAAAA
DW7P.LKP.KBMAAAAA
ACTUALLY STARTING POSITION IS NOT FIXED FOR THESE ENTERIES :- What i mean to say it not necessary that DW will start from 1 column only and any number of useless symbols can be there before actual name. |
|
Back to top |
|
|
Srihari Gonugunta
Active User
Joined: 14 Sep 2007 Posts: 295 Location: Singapore
|
|
|
|
read the file into the stem inrec.
and process each record in the following manner
Code: |
do i=1 to inrec.0
inprec=strip(inrec.i,'L',' ');
j=length(inprec)-2;
inprec=substr(inprec,2,j);
out.i=inprec
end |
write the output file from stem out.
I assumed that each record starts with a quote and ends with a quote |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Or you could look at the TRANSLATE function in REXX |
|
Back to top |
|
|
Ganesh.Deokar
New User
Joined: 30 Sep 2005 Posts: 26 Location: Buffalo,NY
|
|
|
|
1)You can Edit the file in ISPF editor and type command
.
2)You can use TRANSLATE or OVERLAY function of REXX.
But if it's a big file then you'll face problem while allocating it in the program.
3) Write a COBOL program and use INSPECT and REPLACING function. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Quote: |
But if it's a big file then you'll face problem while allocating it in the program. |
In what way will problems be faced ? All you need to do is to process the file in blocks. I have processed over 23 million records in one REXX exec with no problems. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
is there any reason to have two thread with the same question ?? |
|
Back to top |
|
|
Ganesh.Deokar
New User
Joined: 30 Sep 2005 Posts: 26 Location: Buffalo,NY
|
|
|
|
Expat,
Quote: |
In what way will problems be faced ? All you need to do is to process the file in blocks. I have processed over 23 million records in one REXX exec with no problems. |
I tried to allocate a big file (around 3000 Tracks) in REXX and got the error that system cannot bring this big file into memory for edit purpose.
I didn't know the technique to split the file in blocks. Could you please throw some more light on this. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
"EXECIO * DISKR" will read from the current position to the end of file
"EXECIO" number "DISKR" will read from the current position for the requested number of records
as usual stem.0 will be set to the number of record read |
|
Back to top |
|
|
Ganesh.Deokar
New User
Joined: 30 Sep 2005 Posts: 26 Location: Buffalo,NY
|
|
|
|
Thanks enrico-sorichetti |
|
Back to top |
|
|
scorp_rahul22 Currently Banned New User
Joined: 06 Aug 2007 Posts: 42 Location: chennai
|
|
|
|
/* REXX */
DROP INREC. ;
/* "ALLOC F(INDSN) DA('NBK3EYB.FILE.INPUT(QOTES)') SHR" */
"ALLOC F(INDSN) DA('NBK3EYB.TEMP.REXX') SHR"
SAY RC ;
"EXECIO * DISKR INDSN (STEM INREC. FINIS" ;
"FREE F(INDSN)";
SAY RC ;
EXIT ;
"FREE F(INDSN)" ;
D = 1 ;
O = 1 ;
I = 1 ;
DROP OUTPUT. ;
SAY INREC.0
DO INREC.0
INPREC = STRIP(INREC.I,'L',"'");
J = LENGTH(INPREC) - 2 ;
INPREC = SUBSTR(INPREC,2,J) ;
OUT.I = INPREC
I = I + 1
END
CALL WRITE_LOAD
SAY "END OF THE PROGRAM";
EXIT ;
WRITE_LOAD
"ALLOC F(INDSN2) DA('NBK3EYB.FILE.OUTPUT1') SHR";
"EXECIO * DISKW INDSN2 (STEM OUTPUT. FINIS" ;
RETURN;
i am writting this but its not generating any output
its generating
empty file |
|
Back to top |
|
|
Srihari Gonugunta
Active User
Joined: 14 Sep 2007 Posts: 295 Location: Singapore
|
|
|
|
Your EXIT statements in the code are not allowing it to go to the main loop. Try the following Snippet
/*REXX*/
"ALLOC F(INDSN) DA('NBK3EYB.TEMP.REXX') SHR"
"EXECIO * DISKR INDSN (STEM INREC. FINIS" ;
"FREE F(INDSN)";
do i=1 to inrec.0
inprec=strip(inrec.i,'L',' ');
inprec=strip(inrec.i,'T',' ');
j=length(inprec)-2;
inprec=substr(inprec,2,j);
out.i=inprec
end
"ALLOC F(INDSN2) DA('NBK3EYB.FILE.OUTPUT1') SHR";
"EXECIO * DISKW INDSN2 (STEM OUT. FINIS" ;
EXIT; |
|
Back to top |
|
|
scorp_rahul22 Currently Banned New User
Joined: 06 Aug 2007 Posts: 42 Location: chennai
|
|
|
|
DATA SET NBK3EYB.TEMP.REXX NOT ALLOCATED, FILE IN USE
EXECIO error. Unable to obtain storage.
FILE INDSN NOT FREED, DATA SET IS OPEN
6 +++ INPREC=STRIP(INREC.I,'L',' ')
***
Error running REXXTEST, line 6: Machine storage exhausted
***
IT IS SHOWING THIS OUTPUT AND HAVE TO WORK ON 50 CRORES RECORD. SO CAN U TELL WHAT MODIFICATION WE HAVE TO DO IN THIS |
|
Back to top |
|
|
Srihari Gonugunta
Active User
Joined: 14 Sep 2007 Posts: 295 Location: Singapore
|
|
Back to top |
|
|
scorp_rahul22 Currently Banned New User
Joined: 06 Aug 2007 Posts: 42 Location: chennai
|
|
|
|
/*REXX*/
DSN1=NBK3EYB.DSN.OUTPUT2 /*FILE CONTAINS 64716 RECORDS*/
"ALLOC FI(IPFILE) DA('"DSN1"') SHR"
CURRENT=1
HEAP=40000
RCODE=0;
DO UNTIL RCODE <> 0
"EXECIO "HEAP" DISKR IPFILE "CURRENT" (STEM INREC. FINIS"
RCODE=RC
DO I=1 TO INREC.0
INPREC=STRIP(INREC.I,'L',' ');
INPREC=STRIP(INREC.I,'T',' ');
J=LENGTH(INPREC)-2;
INPREC=SUBSTR(INPREC,2,J);
OUT.I=INPREC
END
CURRENT=CURRENT+HEAP;
END
"ALLOC F(INDSN2) DA('NBK3EYB.FILE.OUTPUT1') SHR";
"EXECIO * DISKW INDSN2 (STEM OUT. FINIS" ;
EXIT;
its not working properly, its not quote at the end.
and when i run next time it is saying
that input file is in use |
|
Back to top |
|
|
Srihari Gonugunta
Active User
Joined: 14 Sep 2007 Posts: 295 Location: Singapore
|
|
|
|
Rahul,
Please try this out.
Please empty the output file 'NBK3EYB.FILE.OUTPUT1' before running the following exec.
/*REXX*/
DSN1=NBK3EYB.DSN.OUTPUT2 /*FILE CONTAINS 64716 RECORDS*/
"ALLOC FI(IPFILE) DA('"DSN1"') SHR"
"ALLOC F(INDSN2) DA('NBK3EYB.FILE.OUTPUT1') MOD";
CURRENT=1
HEAP=40000
RCODE=0;
DO UNTIL RCODE <> 0
"EXECIO "HEAP" DISKR IPFILE "CURRENT" (STEM INREC. FINIS"
RCODE=RC
DO I=1 TO INREC.0
INPREC=STRIP(INREC.I,'L',' ');
INPREC=STRIP(INPREC,'T',' ');
J=LENGTH(INPREC)-2;
INPREC=SUBSTR(INPREC,2,J);
OUT.I=INPREC
END
CURRENT=CURRENT+HEAP;
"EXECIO * DISKW INDSN2 (STEM OUT. FINIS" ;
END
"FREE F(INDSN)";
"FREE F(INDSN2)";
EXIT; |
|
Back to top |
|
|
Srihari Gonugunta
Active User
Joined: 14 Sep 2007 Posts: 295 Location: Singapore
|
|
|
|
Please change "FREE F(INDSN)"; to "FREE F(IPFILE)"; |
|
Back to top |
|
|
scorp_rahul22 Currently Banned New User
Joined: 06 Aug 2007 Posts: 42 Location: chennai
|
|
|
|
/*REXX*/
"FREE F(INDSN)";
SAY RC;
DSN1=NBK3EYB.DSN.OUTPUT2 /*FILE CONTAINS 64716 RECORDS*/
"ALLOC FI(INDSN) DA('"DSN1"') SHR"
"ALLOC F(INDSN2) DA('NBK3EYB.FILE.OUTPUT.REXX') MOD";
CURRENT=1
HEAP=40000
RCODE=0;
DO UNTIL RCODE <> 0
"EXECIO "HEAP" DISKR IPFILE "CURRENT" (STEM INREC. FINIS"
RCODE=RC
DO I=1 TO INREC.0
INPREC=STRIP(INREC.I,'L',' ');
INPREC=STRIP(INPREC,'T',' ');
J=LENGTH(INPREC)-2;
INPREC=SUBSTR(INPREC,2,J);
OUT.I=INPREC
END
CURRENT=CURRENT+HEAP;
"EXECIO * DISKW INDSN2 (STEM OUT. FINIS" ;
END
"FREE F(INDSN)";
"FREE F(INDSN2)";
EXIT;
ITS SHOWING
FILE INDSN NOT FREED, IS NOT ALLOCATED
12
*** |
|
Back to top |
|
|
Srihari Gonugunta
Active User
Joined: 14 Sep 2007 Posts: 295 Location: Singapore
|
|
|
|
ok...change INDSN to some INDSN5 make sure you use INDSN5 everywhere. In your code, I can see that you are using INDSN at one place and IPFILE at other. Please you allocate, read and close the same file. Otherwise you will end up with these errors. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Quote: |
"EXECIO "HEAP" DISKR IPFILE "CURRENT" (STEM INREC. FINIS" |
Each time you execute the EXECIO, you open the file, position yourself at "CURRENT", read the lines then close the file.
To obtain a better performance, (the file stays open all the time) try:
Code: |
"EXECIO "HEAP" DISKR IPFILE (STEM INREC." |
Quote: |
INPREC=STRIP(INREC.I,'L',' ');
INPREC=STRIP(INPREC,'T',' ');
J=LENGTH(INPREC)-2;
INPREC=SUBSTR(INPREC,2,J);
OUT.I=INPREC |
Consider using this. Everything on the left of the left quote goes to garbage, Everything on the right of the right quote goes as well, quotes are gone too:
Code: |
Parse Var INREC.I garb1 "'" Data "'" garb2
OUT.I = Data |
|
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Yes, of course, you alloc INDSN but read IPFILE, that can be a problem too...
Use TRACE R (or TRACE I) and TRACE O to start/stop the trace function.
Place TRACE R right after the /* REXX */
Place TRACE O right before the DO UNTIL (no need to trace 40000 times that part).
Resume tracing after the END of the loop.
Then run and verify TSO return code for you ALLOC, EXECIO and FREE commands. |
|
Back to top |
|
|
scorp_rahul22 Currently Banned New User
Joined: 06 Aug 2007 Posts: 42 Location: chennai
|
|
|
|
000000010 'EWP.SQ.MB.DERVTN.TABLE.ALS' RDWDDWIS
000000011 'EWP.SQ.MB.DERVTN.TABLE.HIER' RDWDDWIS
000000013 'EWP.SQ.MB.DERVTN.TABLE.ST' RDWDDWIS
000000014 'NSP.EDW.LOADLIB' EWWM31CU
000000015 'NSP.EDW.LOADLIB' EWWM31IU
000000016 'NSP.EDW.LOADLIB' EWWM31PU
000000017 'NSP.EDW.LOADLIB' EWWM310U
000000018 'NSP.EDW.LOADLIB' EWWM312U
000000019 'NSP.EDW.LOADLIB' EWWM316U
Its not removing quotes
in the case
INPREC=STRIP(INREC.I,'L',' ');
INPREC=STRIP(INPREC,'T',' ');
J=LENGTH(INPREC)-2;
INPREC=SUBSTR(INPREC,2,J);
OUT.I=INPREC
and when i m writting
DO I=1 TO INREC.0
PARSE VAR INREC.I GARB1 "'" DATA "'" GARB2
OUT.I = DATA
it is generating empty file |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Code: |
/*REXX*/
DSN1="NBK3EYB.DSN.OUTPUT2"
"ALLOC FI(INDSN) DA('"DSN1"') SHR"
"ALLOC F(INDSN2) DA('NBK3EYB.FILE.OUTPUT.REXX') SHR";
HEAP=40000
RCODE=0;
DO UNTIL RCODE <> 0
"EXECIO "HEAP" DISKR INDSN (STEM INREC."
RCODE=RC
OUT. = ""
DO I=1 TO INREC.0
Parse Var INREC.I . "'" Data "'" .
OUT.I = Data
END
"EXECIO * DISKW INDSN2 (STEM OUT."
END
"EXECIO 0 DISKW INDSN2 (FINIS"
"FREE F(INDSN)";
"FREE F(INDSN2)";
EXIT; |
I did some tests with that rexx but I had to change from MOD to SHR in the ALLOC command because I used PDS and not DS.
I removed the FINIS in the EXECIO DISKW and placed a FINIS after the loop.
The OUT. = '' cleans the output array, it's useful when reading the last pack of records.
For cosmetics, I used placeholders (.) instead of garbage fields in the PARSE line.
It worked for me. |
|
Back to top |
|
|
scorp_rahul22 Currently Banned New User
Joined: 06 Aug 2007 Posts: 42 Location: chennai
|
|
|
|
I AM TRYING BUT THAT IS NOT WORKING IN THIS CASE ALSO
IT IS SHOWING
FILE INDSN5 NOT FREED, DATA SET IS OPEN
***
/*REXX*/
DSN1="NBK3EYB.TEMP.REXX"
"ALLOC FI(INDSN5) DA('"DSN1"') SHR"
"ALLOC F(INDSN6) DA('NBK3EYB.FILE.OUTPUT.REXX') SHR";
HEAP=40000
RCODE=0;
DO UNTIL RCODE <> 0
"EXECIO "HEAP" DISKR INDSN5 (STEM INREC."
RCODE=RC
OUT. = ""
DO I=1 TO INREC.0
PARSE VAR INREC.I . "'" DATA "'" .
OUT.I = DATA
END
"EXECIO * DISKW INDSN6 (STEM OUT."
END
"EXECIO 0 DISKW INDSN6 (FINIS"
"FREE F(INDSN5)";
"FREE F(INDSN6)";
EXIT; |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Forgot to close the input file before the FREE:
Code: |
"EXECIO 0 DISKR INDSN5 (FINIS"
"EXECIO 0 DISKW INDSN6 (FINIS"
"FREE F(INDSN5)";
"FREE F(INDSN6)";
|
|
|
Back to top |
|
|
scorp_rahul22 Currently Banned New User
Joined: 06 Aug 2007 Posts: 42 Location: chennai
|
|
|
|
/*REXX*/
DSN1="K3EYB.DSN.OUTPUT2"
"ALLOC FI(INDSN5) DA('"DSN1"') SHR"
"ALLOC F(INDSN6) DA('K3EYB.FILE.OUTPUT.REXX') SHR";
CURRENT=1
HEAP=40000
RCODE=0;
DO UNTIL RCODE <> 0
"EXECIO "HEAP" DISKR INDSN5 (STEM INREC."
RCODE=RC
DO I=1 TO INREC.0
INPREC=STRIP(INREC.I,'L',' ');
INPREC=STRIP(INPREC,'T',' ');
J=LENGTH(INPREC)-2;
INPREC=SUBSTR(INPREC,2,J);
OUT.I=INPREC
END
CURRENT=CURRENT+HEAP;
"EXECIO * DISKW INDSN6 (STEM OUT."
END
"EXECIO 0 DISKR INDSN5 (FINIS"
"EXECIO 0 DISKW INDSN6 (FINIS"
"FREE F(INDSN5)";
"FREE F(INDSN6)";
EXIT;
this is not working . its not removing the quotes |
|
Back to top |
|
|
|