IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Way to remove the quotes from the records


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
scorp_rahul22
Currently Banned

New User


Joined: 06 Aug 2007
Posts: 42
Location: chennai

PostPosted: Fri Dec 28, 2007 4:47 pm
Reply with quote

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
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Fri Dec 28, 2007 5:02 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Dec 28, 2007 5:22 pm
Reply with quote

Or you could look at the TRANSLATE function in REXX
Back to top
View user's profile Send private message
Ganesh.Deokar

New User


Joined: 30 Sep 2005
Posts: 26
Location: Buffalo,NY

PostPosted: Fri Dec 28, 2007 9:46 pm
Reply with quote

1)You can Edit the file in ISPF editor and type command
Code:
c all "'" ""
.
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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Dec 28, 2007 10:17 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Dec 28, 2007 10:37 pm
Reply with quote

is there any reason to have two thread with the same question ??
Back to top
View user's profile Send private message
Ganesh.Deokar

New User


Joined: 30 Sep 2005
Posts: 26
Location: Buffalo,NY

PostPosted: Fri Dec 28, 2007 11:24 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Dec 28, 2007 11:31 pm
Reply with quote

"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
View user's profile Send private message
Ganesh.Deokar

New User


Joined: 30 Sep 2005
Posts: 26
Location: Buffalo,NY

PostPosted: Fri Dec 28, 2007 11:35 pm
Reply with quote

Thanks enrico-sorichetti
Back to top
View user's profile Send private message
scorp_rahul22
Currently Banned

New User


Joined: 06 Aug 2007
Posts: 42
Location: chennai

PostPosted: Mon Dec 31, 2007 12:13 pm
Reply with quote

/* 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
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Mon Dec 31, 2007 12:38 pm
Reply with quote

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
View user's profile Send private message
scorp_rahul22
Currently Banned

New User


Joined: 06 Aug 2007
Posts: 42
Location: chennai

PostPosted: Mon Dec 31, 2007 12:46 pm
Reply with quote

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
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Mon Dec 31, 2007 1:14 pm
Reply with quote

As somebody already pointed out.....REXX stem variables can't handle so many records. Please check the following topic for help regarding this topic.

www.ibmmainframes.com/viewtopic.php?p=100518&highlight=#100518
Back to top
View user's profile Send private message
scorp_rahul22
Currently Banned

New User


Joined: 06 Aug 2007
Posts: 42
Location: chennai

PostPosted: Mon Dec 31, 2007 2:04 pm
Reply with quote

/*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
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Mon Dec 31, 2007 3:03 pm
Reply with quote

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
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Mon Dec 31, 2007 3:04 pm
Reply with quote

Please change "FREE F(INDSN)"; to "FREE F(IPFILE)";
Back to top
View user's profile Send private message
scorp_rahul22
Currently Banned

New User


Joined: 06 Aug 2007
Posts: 42
Location: chennai

PostPosted: Mon Dec 31, 2007 3:19 pm
Reply with quote

/*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
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Mon Dec 31, 2007 3:29 pm
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Mon Dec 31, 2007 3:49 pm
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Mon Dec 31, 2007 3:58 pm
Reply with quote

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
View user's profile Send private message
scorp_rahul22
Currently Banned

New User


Joined: 06 Aug 2007
Posts: 42
Location: chennai

PostPosted: Mon Dec 31, 2007 4:10 pm
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Mon Dec 31, 2007 6:57 pm
Reply with quote

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
View user's profile Send private message
scorp_rahul22
Currently Banned

New User


Joined: 06 Aug 2007
Posts: 42
Location: chennai

PostPosted: Tue Jan 01, 2008 12:27 pm
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Tue Jan 01, 2008 2:45 pm
Reply with quote

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
View user's profile Send private message
scorp_rahul22
Currently Banned

New User


Joined: 06 Aug 2007
Posts: 42
Location: chennai

PostPosted: Tue Jan 01, 2008 3:10 pm
Reply with quote

/*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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Remove leading zeroes SYNCSORT 4
No new posts Help in extracting data between doubl... DFSORT/ICETOOL 5
Search our Forums:

Back to Top