View previous topic :: View next topic
|
Author |
Message |
Lavansekar247
New User
Joined: 09 Jun 2009 Posts: 5 Location: Chennai
|
|
|
|
Hi,
My team is new to REXX and looking for an assistance for one issue which they are struggling to find the solution. I feel its worth to post the concern here and hope we might get possible advise on the Problem resolution.
To brief you,
We are developing an REXX tool for an automation. There is necessary to Re-write or Update the file for a particular line which we have already written earlier Logic.
What we have done,
We have opened the file in write mode as below
"ALLOC DA('"OUTNAME"') F(OUTREC) MOD REUSE"
"EXECIO 0 DISKW OUTREC(OPEN"
Once we write some details in the file successfully, the file is closed as below
"EXECIO * DISKW OUTREC(FINIS"
Here is the Problem statement,
We are trying to update the identified line with new information as part of logic. But nothing is getting updated in file Physically, I mean when we try to have SAY before & after write statement it has the new information in that line.
We have opened the Same file as follows,
"ALLOC DA('"OUTNAME"') F(OUTREC) SHR REUSE"
"EXECIO * DISKRU OUTREC(STEM INREC1."
Here is the Piece of code on how we are identifying the line to be re-written and try to update the file,
Code: |
DO I = 1 TO INREC1.0
SEARCH_STR = '^'
REPLACE_STR = '¬'
IF POS(SEARCH_STR,INREC1.I) > 0 THEN
DO
POSN = POS(SEARCH_STR,INREC1.I)
ST = INREC1.I
ST = TRANSLATE(ST,'¬','^')
WRITE_STR = ' ' || ST
PUSH WRITE_STR
"EXECIO 1 DISKW OUTREC"
SAY 'AFTER WRITE ' ST
END
END |
Your help on this matter would be of great assitance to compltete the tool as its a really challenging for us being we are just beginner.
Looking forward your responses.
Cheers,
Dhana |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
Here's an example, I use it to replace my IBM userid in XMIT files by something innocent.
Code: |
"alloc f(xmi) da(whatever) reu"
"execio 10 diskr xmi (stem inrec. finis"
s = ''
do r = 1 to inrec.0 until pos('INMR03', inrec.r) \= 0
s = s !! inrec.r
end
l = length(userid())
select
when l = 7 then moi = 'CLOGGIE'
when l = 5 then moi = 'PRINO'
otherwise moi = left('XXXXXXX', l)
end
old = d2c(l)userid()
new = d2c(l)moi
p = pos(old, s)
do while p \= 0
s = substr(s, 1, p - 1) !! new !! substr(s, p + l + 1)
p = pos(old, s)
end
do q = 1 to r
"execio 1 diskru xmi" q
pull zap
out = substr(s, 1 + 80 * (q - 1), 80)
push out
"execio 1 diskw xmi (finis"
end
"free f(xmi)"
|
|
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
You want to read and then update a specific record? Is that what I'm reading?
If that's what you want, you need to:
Read the 1 record in update mode:
"EXECIO 1 DISKRU DDNAME "record_number
Pull from the stack:
Parse Pull therec
Make your changes:
/* make changes to the variable therec */
Push out to the stack:
Push therec
Write the 1 updated record:
"EXECIO 1 DISKW DDNAME" |
|
Back to top |
|
|
Lavansekar247
New User
Joined: 09 Jun 2009 Posts: 5 Location: Chennai
|
|
|
|
Hi Kevin,
Thanks for your response. You are right, we are trying to update the specific record.
We are reading the file for identifying the particular line to be updated and then replacing with what to be replaced.
Let me try this out and keep you poseted on how it go.
Thanks,
Dhana |
|
Back to top |
|
|
Lavansekar247
New User
Joined: 09 Jun 2009 Posts: 5 Location: Chennai
|
|
|
|
Hi Kevin,
You are champ. The solution is working but with other problem. Now we able re-write the file Physically.
But it throws an error as below and not allowing to run the Tool next time. See the message at the end "A command entered or contained in a CLIST has invalid syntax."
Code: |
AFTER WRITE IF SQLWARN0 ¬= 'W' THEN
AFTER WRITE DO WHILE(¬ EO_CHILD);
AFTER WRITE IF(PRODUCER_ID = ' ') & (SAVE_PRODUCER_ID ¬= ' ') THEN
VALUE OF L 1
BDM.J MI489XXX
A command entered or contained in a CLIST has invalid syntax.
***
|
When we try to run the Tool again,It does work as expected. Appears it starts executing the Lines from the file which we rewrite for above problem.
Does this file still Open and assumes file content as REXX statements?
Here is the error message when we rerun the tool. We expected the tool should ask for Input file and Output file, but it is NOT.
Code: |
File Edit Edit_Settings Menu Utilities Compilers Test Help
-IPT- VIEW HIQUAL.TEST.REXX(DOCODE) - 01.08 Columns 00001 00072
Command ===> R Scroll ===> CSR
000001 /*****************REXX****************/
000002 /*****************************/
000003 /* MAIN PROCEDURE CALLS OTHER SUBROUTINES ***/
000004 /************************************/
000005 DOCODE:
000006 CALL REXXNEW4
000007 CALL VERIFY
000008 CALL LINK_OUTALLOC
000009 CALL GET_LINK
000010 CALL CHANGE_LINK
000011 CALL GET_MODULES
000012 CALL CLOSE_LINK
000013 CALL MOD_OUTALLOC
000014 CALL CHANGE_MODULES
000015 EXIT
000016 /**************************/
000017 /* TO GET THE OUTPUT OF TOOL AND SOURCE PDS AGAIN */
000018 /**********************************/
000019 VERIFY:
000020 SAY 'ENTER THE SOURCE PDS NAME AGAIN WITH OUT QUOTES: '
000021 PARSE PULL DSNAME
000022 DSNAME = STRIP(DSNAME)
000023 IF POS("'",DSNAME) > 0 THEN /* PDS */
000024 DO
000025 SAY 'ENTER THE SOURCE PDS NAME WITH OUT QUOTES'
000026 EXIT
000027 END
000028 IF POS("'",DSNAME) = 0 THEN
000029 DO
000030 PDS_NAME = "'" || DSNAME || "'"
000031 IF SYSDSN(PDS_NAME) ¬= "OK" THEN
000032 DO
000033 SAY 'ERROR: ' DSNAME SYSDSN(PDS_NAME)
000034 EXIT
ENTER THE SOURCE PDS NAME WITH OUT QUOTES:
IKJ56709I INVALID DATA SET NAME, '*
IKJ56716I EXTRANEOUS INFORMATION WAS IGNORED: BALANCE ----PR574B06 - SR65487 -
***
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* I N T E R N A L S E R V I C E S D A T A E N T R Y *
* C O M M A N D P R O C E S S O R *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
DATE = 06/10/09 TIME = 07:41:29
DO YOU WANT TO DELETE THE DATASET "MQUV.IS.DATA"? TYPE "YES" OR
"NO" AND PRESS ENTER. YES
Command rejected - 'SPF ' command not supported under ISPF.
***
|
But it is executing as usual when we log off and Login again. But again same issue as above.
Your further advise would be greatly appreciated.
Thanks for your assistance.
Thanks,
Dhana |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
I think you are putting stuff into the stack, but your program ends abnormally.
The next time you start program, the data is already in the stack and your PARSE PULL statement uses that data instead of waiting for you to enter the parameters. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
See the rexx reference manual... read the sections about DELSTACK, NEWSTACK and general information about stacks. |
|
Back to top |
|
|
|