View previous topic :: View next topic
|
Author |
Message |
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 148 Location: India
|
|
|
|
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 |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 734 Location: Denmark
|
|
|
|
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 |
|
|
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 148 Location: India
|
|
|
|
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 |
|
|
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 148 Location: India
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1333 Location: Bamberg, Germany
|
|
|
|
You probably are not in the right environment for EXECIO. |
|
Back to top |
|
|
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 148 Location: India
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1333 Location: Bamberg, Germany
|
|
|
|
Are you having an address command somewhere before? |
|
Back to top |
|
|
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 148 Location: India
|
|
|
|
no i dnt have any address command |
|
Back to top |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 734 Location: Denmark
|
|
|
|
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 |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2593 Location: Silicon Valley
|
|
|
|
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 |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2593 Location: Silicon Valley
|
|
|
|
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 |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 734 Location: Denmark
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1333 Location: Bamberg, Germany
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
|
|
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 |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 734 Location: Denmark
|
|
|
|
I know, I was just pointing it out.... |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1333 Location: Bamberg, Germany
|
|
|
|
Well, lets see. I assume the EXECSQL establishes a DB2 environment without properly restoring the previous state. |
|
Back to top |
|
|
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 148 Location: India
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
|
|
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 |
|
|
|