Run time DDM name for database access

Friends,

I have a requirement where:

  1. On a map user should enter a ddm-name (with it’s few related fileds) to be read
  2. The ddm-name with fields should be passed to prepare a view definition within DEFINE DATA in a program
  3. Start reading
  4. Show results

I have issues with step 2 that view syntax doesn’t support ( :?: neither structured nor reporting mode) a variable-name (where we got the input from user) but only ddm-name.

Not sure if this can be leveraged. Please share your thoughts.

Views are interpreted by Natural at compile time, not execution time. Hence what you want to do is not possible.

That said, there are ways to accomplish what you would like to do.

I suggest you read about “ampersand variables” which allow you to create program “skeletons”. You can then take user input, store the input values in global variables, and then RUN the program skeletons.

Education, education, education.

steve

One option, that I have done in the past, is to generate the Adabas Direct Calls from the DDM list and then use USR1043N to issue the direct call and display the results. Direct calls are easy, it is not rocket science, and I am a firm believer that everyone using Adabas should understand how it works.

I think the easiest way is to read all fields every time and reduce the data before displaying it.

Of course: You can write a program dynamically by printing it into natural’s source area, compile it, etc. … But I think this is too complex.

Thanks Steve, Peter and Matthias. I got it!

As specified by Peter, you can use USR routines. USR1058 will read the DDM into an array.Then you can format the array and create the view using USR2014.

Cheers
Arkantos

Thanks Arkantos,

Currently, I got it resolved with Steves’ suggestion. Will definitely look into USRs suggested by Peter and you once I have some spare time.

Is it possible to achieve this with any other option (FETCH RETURN etc). The reason being I want control back to my driver program. RUN doesn’t allow this. Well, to add I am starting a READ loop before RUN ‘prog’ and need to continue with the loop in driver program. A STACK TOP COMMAND would have helped but seems doesn’t continue the processing loop initiated.

Any thoughts?

You can use
STACK COMMAND “MYPROG”
to call “yourself” after execution.

(Sounds a bit like a life after death - but don’t worry;-)

I already tried this Finn but didn’t help (Am I missing anything?)

The scene is:

READ WORK FILE ..
DECIDE ON FIRST VALUE ...
VALUE ..
RUN 'skeleton1'
VALUE ..
RUN 'skeleton2'
NONE VALUE
..
END-DECIDE
...

I need control back to driver (after the DECIDE) to continue READ WORK once skeleton is executed and not to start again.

I didn’t quite have your scenario present, but I guess you could stack all the “runs” for execution after all records has been read and the program terminated ?
Finn

Finn,

My apology, but I really didn’t get your point :oops:

Let me be more precise on what I am after:

  1. I need to read no of DDMs and passing the names to driver from a work file
  2. Based on a value I need to decide what program should be executed
  3. Due to different and multiple ddm names I chosen to make it dynamic as per Steve’s suggestion (accessing it as globals in the driver and referring as amphersand variable in RUN ‘prog’
  4. The need is to read all the DDMs from workfile and process them.

After reading first record from workfile my driver goes to related RUN ‘prog’ but doesn’t come back to driver where my READ WORK has started a loop. Trying to find a way to complete this process.

I hope it makes sense :oops:

If I understand your dilemma correctly, you are trying to set the value of the global variables (the &things) based on input from the workfile - and using the RUN approach causes control fall out of the loop.

An alternative is that you have a stackable program that fills in the values on each invocation:

READ WORK FILE ..
DECIDE ON FIRST VALUE ...
VALUE ...
STACK COMMAND 'stackset "skeleton1" "ddm-name"'
VALUE ..
STACK COMMAND 'stackset "skeleton2" "ddm-name"'
NONE VALUE
..
END-DECIDE 

‘stackset’ would be a program that accepts skeleton and ddm-name as input, assigns the appropriate global variables and RUNs the appropriate program (skeleton?). Something like:

INPUT skeleton(a8) +ddm(a32)
RUN skeleton
END

If you have control over the work file that is input, then put the commands in front of the data:

stackset skeleton1 ddm1
stackset skelton2 ddm2
...

and input this workfile to CMOBJIN

Hi Douglas,

Thanks for the valuable suggestion. It worked successfully :D. I believe Finn tried to convey the same but I was unable to get it.

Cheers!!!