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

I want to append a record in an existing ps file using rexx


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 138
Location: India

PostPosted: Thu Dec 15, 2022 2:51 pm
Reply with quote

Hi All,

My requirement is : I have a ps file and it has 8 record and one record that is 5th record in file is stud_id in my rexx i want to use this stud_id and fetch student name and want to append this stuent name at the end of the same input file which we are reading.

I am able to fetch the stud_name from db2 into a variable now i want to add this stud-name at the end of the file this same file. How i can acchive this any hint or syntax would be great as i dnt carry much experties here in rexx.

Thanks
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Thu Dec 15, 2022 3:40 pm
Reply with quote

Using EXECIO and the stack:

Code:
 "EXECIO * DISKR ddname (FINIS)" /* puts records on the stack */
 queue new-record
 "EXECIO" queued()" DISKW ddname (FINIS)" /* rewrite dataset from the stack */


or use a stem instead of the stack.
Back to top
View user's profile Send private message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 138
Location: India

PostPosted: Thu Dec 15, 2022 4:16 pm
Reply with quote

Hi

Thanks for reply.

I am using below syntax to write the data into new file

Code:
  outline.1 = prjval                         
 "EXECIO 1 DISKW DD02 (STEM outline.1 FINIS"
 return 0;                                   

but getting below error my outline.1 has right data
    >>>    "EXECSQL CLOSE C1"                         
 84 *-*  outline.1 = prjval                           
    >>>    "P0007809"                                 
 85 *-*  "EXECIO 1 DISKW DD02 (STEM outline.1 FINIS"   
    >>>    "EXECIO 1 DISKW DD02 (STEM outline.1 FINIS"
    +++ RC(-3) +++                                     
 86 *-*  return 0                                     
    >>>    "0"         
Back to top
View user's profile Send private message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 138
Location: India

PostPosted: Thu Dec 15, 2022 4:32 pm
Reply with quote

Also when i used your logic .

getting below erro

Code:
 86 *-*  queue prjval                                                       
     >>>    "P0007809"                                                       
  87 *-*  "EXECIO" queued()" DISKW dd01 (FINIS)" /* rewrite dataset from the 
     >>>    "EXECIO 2 DISKW dd01 (FINIS)"                                     
     +++ RC(-3) +++                                                           
  89 *-*  return 0                                                           
     >>>    "0"                                                               
J56500I COMMAND P0007809 NOT FOUND                                           
J56500I COMMAND P0007809
NOT FOUND
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1231
Location: Bamberg, Germany

PostPosted: Thu Dec 15, 2022 4:45 pm
Reply with quote

You probably are not in the right environment for EXECIO.
Back to top
View user's profile Send private message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 138
Location: India

PostPosted: Thu Dec 15, 2022 5:10 pm
Reply with quote

what it does mean ?

Do i need to include something in my code. I am sorry as I am still learning rexx.


Thanks for you reply
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1231
Location: Bamberg, Germany

PostPosted: Thu Dec 15, 2022 6:06 pm
Reply with quote

Are you having an address command somewhere before?
Back to top
View user's profile Send private message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 138
Location: India

PostPosted: Thu Dec 15, 2022 6:27 pm
Reply with quote

no i dnt have any address command
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Thu Dec 15, 2022 6:57 pm
Reply with quote

Well, you must have changed the environment somewhere.
Verify by doing SAY ADDRESS()
To fix the problem, put ADDRESS TSO in front of the EXECIOs.
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Fri Dec 16, 2022 5:08 am
Reply with quote

Quote:
COMMAND P0007809 NOT FOUND

In your stack example, you had a syntax error in the EXECIO statement. It should not have the right paren. And because of that error, you leave something in the stack and rexx tries to process the stack after your exec ends. The stack does not have a valid TSO command, so you get the 'not found' message.
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Fri Dec 16, 2022 5:12 am
Reply with quote

In your earlier try, you are using a stem. In the code shown:
Code:
"EXECIO 1 DISKW DD02 (STEM outline.1 FINIS"

you should provide the name of the stem only (without the trailing '1').

This assumes that you allocated the DD02 file with DISP(MOD)
Code:
newrec.0 = 1
newrec.1 = new-record 
"EXECIO * DISKW DD02 (STEM newrec. FINIS"
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Fri Dec 16, 2022 9:41 am
Reply with quote

A right paran in EXECIO is perfectly fine, I do it all the time.
I tried the following
Code:
 outline.1 = 'Just testing'                             
 "EXECIO 1 DISKW DD1 (STEM outline.1 FINIS)"   

it wrote 'OUTLINE.11' to the dataset. Clearly not what I intended, but did not cause a syntax error either.
I will maintain that the RC -3 is caused by a wrong environment, it must be TSO or CMD as far as I am aware.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1231
Location: Bamberg, Germany

PostPosted: Fri Dec 16, 2022 2:03 pm
Reply with quote

There is that "EXECSQL CLOSE C1" thing inside your EXEC. Please do what Willy has suggested and add ADDRESS TSO before the EXECIO command.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Fri Dec 16, 2022 5:56 pm
Reply with quote

Willy Jensen wrote:
A right paran in EXECIO is perfectly fine, I do it all the time.
I tried the following
Code:
 outline.1 = 'Just testing'                             
 "EXECIO 1 DISKW DD1 (STEM outline.1 FINIS)"   

it wrote 'OUTLINE.11' to the dataset. Clearly not what I intended, but did not cause a syntax error either.
I will maintain that the RC -3 is caused by a wrong environment, it must be TSO or CMD as far as I am aware.

The option STEM in this example is using OUTLINE.1 as a stem name, not variable name. Since exactly 1 output record is requested, the (incorrect) "stem name" OUTLINE.1 is extended with the first number of element, e.g. number 1, producing OUTLINE.11 which value might be either string "OUTLINE.11", or empty string "", depending on the way the OUTLINE stem is defined - outside of the presented scope of code.

The correct way to specify a stem for output is:
Code:
 . . . . (STEM OUTLINE.


Please, RTFM carefully!!!
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Fri Dec 16, 2022 6:52 pm
Reply with quote

I know, I was just pointing it out....
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1231
Location: Bamberg, Germany

PostPosted: Fri Dec 16, 2022 6:54 pm
Reply with quote

Well, lets see. I assume the EXECSQL establishes a DB2 environment without properly restoring the previous state.
Back to top
View user's profile Send private message
Digvijay Singh

Active User


Joined: 20 Apr 2022
Posts: 138
Location: India

PostPosted: Wed Dec 28, 2022 3:57 pm
Reply with quote

Thank you, guys, ,


It worked there were syntax errors and i fixed it , and made my code lil bit clearer by calling para.

Thanks Again
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Wed Dec 28, 2022 6:33 pm
Reply with quote

Digvijay Singh wrote:
Thank you, guys, ,


It worked there were syntax errors and i fixed it , and made my code lil bit clearer by calling para.

Thanks Again

There is no PARA in REXX; it is not COBOL.

REXX code may be divided into FUNCTIONS, and PROCEDURES.
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

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top