Page 1 of 1

Natural API USR0201N

PostPosted: Wed Sep 15, 2010 10:48 am
by Arkantos
Hi All,

I tried to create an object dynamically using USR2014N, and able to write in the SWA using USR2019N and able to save that object. When i tried to stow the object using USR0210N, the return code is 0(ERR is 0) , still object doesnt get stowed.

While going thru the documentation, I found the below explanation.

---
Once the subprogram(USR0210N)has returned to the calling program
with ERR=0, the NATURAL STACK will have been modified.
The caller has to issue a STOP statement to give control
to the STACK mechanism.
.
On the STACK, there are now commands that start the wanted function.
.
A Natural module will be catalogued or stowed via the Natural stack,
because it is not possible to call the Natural compiler from a Natural
module. With USR1052N (Send a command to the operating system) a user
may start a batch Natural and catalog an object in a separate Natural
batch session.
---


1. Natural module cannot be cataloged/Stowed using a module?
2. I want to stow the saved object using a module. Is there any other way to do that?


Note: I am calling these three subprograms in a single program one after the other.

Cheers
Arkantos

Re: Natural API USR0201N

PostPosted: Wed Sep 15, 2010 2:10 pm
by ats
Hi Anbu

I need to know what actions (passed parameters) you are taking after calling USER0210N. I assume you're passing something similar to this:

Save, cat, stow NATURAL source:
-------------------------------

Action .................... STOW__
Name of source ............ TEST07
Library ................... my-lib
Read source into editor ... N
Type of source ............ P


Press any PF-key to stop.,


I used the above details and was able to STOW the code in SWA (currently USR0210P) into my-library as TEST07. Attached are the before/after screen captures.

Regards,
Ats

Re: Natural API USR0201N

PostPosted: Wed Sep 15, 2010 2:13 pm
by RGZbrog
1. Natural module cannot be cataloged/Stowed using a module?

The documentation does not lie. You certainly are not the first to be frustrated by this.

2. I want to stow the saved object using a module. Is there any other way to do that?

Use the API to save the source, then either stack a CAT command or submit a batch job via NATRJE. Both these methods are asynchronous, so if you need to guarantee the result, you'll have to test for success. With Entire System Server you can check the return code of the job. With vanilla Natural you can see whether the object exists in the target library and check the time stamp (via API).

If you are very careful (and with a bit of luck), you may be able to stack your utility program after the CAT. If you stack enough control data, you may be able to pick up where you left off when you executed the STOP statement.

Re: Natural API USR0201N

PostPosted: Wed Sep 15, 2010 2:26 pm
by ats
I checked (as it was my attempt to STOW from SWA) on CAT with already saved but not cataloged object. The API USR0210N did work perfect for me. Hence I dare to say:

1. Natural module cannot be cataloged/Stowed using a module?

No, it can be with the API USR0210N

2. I want to stow the saved object using a module. Is there any other way to do that?

Use the API USR0210N

I hope, I have taken it correctly :)

Regards,
Ats

Re: Natural API USR0201N

PostPosted: Wed Sep 15, 2010 11:37 pm
by RGZbrog
Ats,

Arkantos wants to stay within his utility program as he makes multiple calls to USR0210N. This is not possible. Take a closer look at USR0210P, at the end of the module.
/* STACK has been modified. Execute the commands:
STOP

For the CAT and STOW to complete, you must return to the command prompt.

To simulate what Arkantos wants to do, change the STOP statement to IGNORE. Execute USR0210P and make several requests. Without leaving USR0210P, check the results with another mainframe session. You will see that the CATs and STOWs do not take place until you exit USR0210P.

Re: Natural API USR0201N

PostPosted: Thu Sep 16, 2010 11:42 am
by ats
Agreed Ralph,

My point was it is possible using modules!

Regards,
Ats

Re: Natural API USR0201N

PostPosted: Fri Sep 17, 2010 8:53 am
by Arkantos
Ralph,

Exactly thats what i was doing(removed STOP statement) and it was not stowing. So I issued a Stop command and it is stowing perfectly.

Thanks a ton Ralph and Ats.

Cheers
Arkantos