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

Editing a record in a file


IBM Mainframe Forums -> TSO/ISPF
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sparrow

New User


Joined: 26 Mar 2007
Posts: 57
Location: Pune

PostPosted: Sat Apr 17, 2010 1:22 am
Reply with quote

Hello All,

I have a rqreuirement for changing a value in the particular position in a particular line of a PDS member.

I have coded the like this..

Code:

/* REXX */
"EXECIO 4 DISKR INPUT1(STEM NEWVAR1. FINIS"
VAL=12345       
F=NEWVAR1.4                                                 
ADDRESS ISPEXEC "EDIT DATASET('"F"') MACRO(macroname) PARM(VAL)"
EXIT


My edit macro as below

Code:

/* REXX */         
ADDRESS ISREDIT "MACRO (VAL)"                     
ADDRESS ISREDIT "CHANGE P'=====' '"VAL"' 20 25"   
ADDRESS ISREDIT "SAVE"                             
ADDRESS ISREDIT "END"                             
EXIT                                               


I am receiving error when i run my code
*************
ISPS109

Unexpected list found
A list of names was found where a list was not expected.
*************


I can understand that " EDIT DATASET " is causing the error..Dont know what to use in that place to just edit a record in my file..

is there any way i can edit only the record in the 4th line ?

Please give me a suggestion

thanks
Sparrow.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Apr 17, 2010 3:06 am
Reply with quote

let us start by determining what is on line 4 of MM.XXX.YYY(ABCD)

and
in an edit macro
to only change a particular line,
the cursor has to be addressed to that line - which you have not done.

explain what are you trying to do? completely, no more of this
I want to change something on line 4
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Sat Apr 17, 2010 11:19 am
Reply with quote

The edit macro is for working on a dataset, not a stem variable.

As Dick has asked, please give us the full story
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Sun Apr 18, 2010 2:19 am
Reply with quote

This is what your code says:
1. In the 4th line of file INPUT1 there is a "dataset(member)" name.
2. In this member you change the 1st line. Anything you have in col 20-25 is replaced by '12345'.

It does not fit with your question.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Sun Apr 18, 2010 2:27 am
Reply with quote

For changing a field or fields on a specific record, I think I'd use a normal TSO/ EDIT Change command. Just my preference.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2546
Location: Silicon Valley

PostPosted: Sun Apr 18, 2010 9:50 am
Reply with quote

Probably, there is more data on line 4, maybe including trailing blanks.
Back to top
View user's profile Send private message
sparrow

New User


Joined: 26 Mar 2007
Posts: 57
Location: Pune

PostPosted: Mon Apr 19, 2010 9:47 pm
Reply with quote

Hi All, sorry for the confusion...I missed few lines while pasting..


Code:

/* REXX */               
"ALLOC FI(INPUT1) DA('MYPDS.DATA(MEM1)') SHR REUSE"             
DROP NEWVAR1.                                                     
"EXECIO 4 DISKR INPUT1(STEM NEWVAR1. FINIS"                       
"FREE FI(INPUT1)"                                                 
VAL=12345                                                       
F=NEWVAR1.4                                                     
ADDRESS ISPEXEC "EDIT DATASET('"F"') MACRO(NACRONAME) PARM(VAL)" 
EXIT



and macro looks like
Code:
 /* REXX */                                           
ADDRESS ISREDIT "MACRO (VAL)"                         
ADDRESS ISREDIT "CHANGE P'=====' '"VAL"' 20 25"       
ADDRESS ISREDIT "SAVE"                               
ADDRESS ISREDIT "END"                                 
EXIT 



and my aim is to

Read the 4th line of file INPUT1 and replace the value of VAL in position col 20-25
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Mon Apr 19, 2010 9:53 pm
Reply with quote

What does the output from a TRACE look like?
Back to top
View user's profile Send private message
sparrow

New User


Joined: 26 Mar 2007
Posts: 57
Location: Pune

PostPosted: Mon Apr 19, 2010 10:12 pm
Reply with quote

I added a SAY F in front of
ADDRESS ISPEXEC "EDIT DATASET('"F"') MACRO(NACRONAME) PARM(VAL)"

It displays the line 4 of the file.

I think the EDIT DATASET is causing the error because F is substituted with the record.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2546
Location: Silicon Valley

PostPosted: Mon Apr 19, 2010 10:21 pm
Reply with quote

repeating:

Probably, there is more data on line 4, maybe including trailing blanks.
Back to top
View user's profile Send private message
sparrow

New User


Joined: 26 Mar 2007
Posts: 57
Location: Pune

PostPosted: Mon Apr 19, 2010 10:31 pm
Reply with quote

Pedro you mean the position to replace the value is incorrect ?

my NEWVAR1.4 contains whole 4th line of the file. I wanted to replace some data in particular position..how the trailing blanks cause me trouble ?

Please throw some light
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2546
Location: Silicon Valley

PostPosted: Tue Apr 20, 2010 6:19 am
Reply with quote

Quote:
I added a SAY F in front of
ADDRESS ISPEXEC "EDIT DATASET('"F"') MACRO(NACRONAME) PARM(VAL)"

It displays the line 4 of the file.

You did not show us exactly what you saw. We can only guess.

I suspect it is something like this:
Code:

ADDRESS ISPEXEC "EDIT DATASET('      some.pds      ') MACRO(NACRONAME) PARM(VAL)"

I think the blanks within the quoted dataset name will cause a syntax error. If your lrecl is 80 bytes, then you will have many more blanks. but because of the original message about a 'list', there is probably something besides blanks.

Use the STRIP() function to remove the extra blanks.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Apr 20, 2010 11:53 am
Reply with quote

why is everyone assuming line 4 of the dataset
NEWVAR1.4
contains a dataset name?
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Tue Apr 20, 2010 2:37 pm
Reply with quote

Dick, that is along the lines of what I was thinking. As previously said, I would be tempted to use an edit macro to do this with a control for the line number.
Code:
/* REXX *** EDIT ONLY LINE 4 OF A DATASET / MEMBER USING EDIT MACRO  */
REQ = 4
"ISPEXEC EDIT DATASET('Data set name') MACRO(CHG04) PARM(REQ)"

Code:
"ISREDIT MACRO (REQ)"

DO FOREVER
  "ISREDIT X ALL"
  "ISREDIT F 'CHANGE-THIS' NEXT"
  "ISREDIT (CRSLINE) = CURSOR"
  IF CRSLINE = REQ
     THEN  "ISREDIT C '-THIS' '-THAT' NX ALL"
  ELSE
     IF CRSLINE > REQ THEN LEAVE
END
"ISREDIT END"
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Tue Apr 20, 2010 5:31 pm
Reply with quote

sparrow wrote:
my aim is to

Read the 4th line of file INPUT1 and replace the value of VAL in position col 20-25
Again, you're doing something else.

Here are some free tips:
  1. to know really the value of a variable, use:
    Code:
    Say '<'F'>'  /* look, no spaces */

    If you see:
    Code:
    <HLQ.DATASET.NAME         >
    there are trailing spaces
    If you see:
    Code:

    <HLQ.DATASET.NAME>
    then you have just what you need.

  2. I suggest using STRIP when allocating a variable:
    Code:
    F=Strip(NEWVAR1.4)


  3. As dbzTHEdinosauer suggested with his question, you should check that the member exists before trying to edit it:
    Code:
    Reply = SYSDSN(F)
    If Reply <> "OK" Then Do
       Say "Error on '"F"': "Reply
       Call Error_Process
    End
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 -> TSO/ISPF

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top