Dynamic Source Code Generation seems impossible with NaturalONE

Dynamic Source Code Generation as described here…
http://techcommunity.softwareag.com/ecosystem/documentation/naturalONE/natONE826/natmf/sm/run.htm#Dynamic_Source
…just won’t work.

Running following DYNM-P01 yields:
NAT0082 Invalid command, or Object DYNM-P02 does not exist in library.

All the best,
DaveLaw

/** New Program DYNM-P01.
DEFINE DATA
    INDEPENDENT 1     +AVI (A8)
END-DEFINE
*
    +AVI  := 'CONS'
    RUN 'DYNM-P02' 
END
/** New Program DYNM-P02.
DEFINE DATA
    INDEPENDENT 1     +AVI (A8)
    LOCAL       1     CONS (A8) CONST<'CONS'>
END-DEFINE
*
    WRITE *TIME *PROGRAM &AVI
END

Just to confirm, both DYNM-P01 and DYNM-P02 are saved in the same library. If you do a LIST * * you do see DYNM-P02. There are no zero versus O typos?

steve

Hi Steve,

same Library & no Typos. NaturalONE doesn’t have a LIST command, in fact it doesn’t have any commands, which I quite miss actually…

And it gets mixed up very easily: the FUSER contains all sorts of dross, so if you save & build (“stow”) DYNM-P02 without +AVI & then save +AVI into the source again, it actually runs the old stowed object, which of course it shouldn’t, because the RUN Statement should not be using the object at all.

All the best,
DaveLaw

This is the way I understand it:

ONE includes a “Natural for Eclipse” run-time. In Eclipse you “build” a project, then “run” it. In Natural terminology, this is a Catall then EXecute. Eclipse has no understanding of the concept of compile-and-go, that is, Natural’s Run command.

Dynamic code generation cannot be tested with ONE’s local run-time. You can create a driver (your DYNM-P01) and a dynamic module (your DYNM-P02), but won’t be able to build the project because of syntax errors in the second module. An without a successful build, you can’t run.

To demonstrate, change the & variables to + variables in DYNM-P02, and you’ll be able to build and run. Of course, you don’t get the results you want, but it shows that the RUN statement is acting as an EXECUTE, just as the Eclipse RUN command is really an EXECUTE. (This explains the situation you describe at the end of your latest posting: “the RUN Statement should not be using the object”.)

ONE does support dynamic code generation, but the code must be uploaded to a server. There you would STOW (or SAVE) DYNM-P01 and save DYNM-P02, as you expected. Since the server is mainframe/LUW, you could issue an EXECUTE or RUN of DYNM-P01 from within ONE.

Unfortunately, the big difference between the licensed version and the Community edition of ONE is that CE does not include the connection to NDV.

Hi Ralph,

nice to hear from ya’.

I can’t really see any problem reconciling the Eclipse & ONE worlds.
Somewhere, wherever, there’s a runtime.
That runtime just needs to include the builder (which maybe the ONE Guys
forgot was required in the runtime too) to compile the source before executing it.
Basta!

The Navigator even has a “NaturalONE/Exclude” context menu, which would seem to be
just the ticket for preventing the builder from building the (at save time) unbuildable.

Simple enough & documented with no caveats.

Dave

Shame no one from Software AG has bothered to address this issue in the 5 years since it was posted.