How to access ADABAS file dynamically or Create a online screen tool to access ADABAS files

Hello All,

Our team doesn’t have a tool to access/update an ADABAS file. So every time we need to view the records of an ADABAS file or update even a single record, we write a new ADHOC Natural program.

So I am trying to create an online screen to access a ADABAS file dynamically.

I just tried the below as a start to access ADABAS file dynamically.

Program

RESET #A (A30) #B (A30) #C (A30)
MOVE ‘DATABASE-FILE’ TO #A
MOVE ‘DATABASE-FIELD’ TO #B
COMPRESS ‘READ’ #A INTO #C
INCLUDE DYN-PGM ‘#C’ ‘#B
END

Copy code

&1&
DISPLAY &2&
ESCAPE BOTTOM
LOOP

I am expecting the code in copy code to work as below

READ DATABASE-FILE
DISPLAY DATABASE-FIELD
ESCAPE BOTTOM
LOOP

I am not sure why it doesn’t work. Could you please let me know your comments.

Also please let me know if there is anyother way of creating this tool.

CopyCode is included at compile time. So your resulting statement is

READ #C
DISPLAY #B

What you need is to populate global variables.

RESET #A (A30) +B (A30) +C (A30) 
MOVE 'DATABASE-FILE' TO #A 
MOVE 'DATABASE-FIELD' TO +B 
COMPRESS 'READ' #A INTO +C 
RUN 'DYN-PGM'
END

Program DYN-PGM

+C 
DISPLAY +B 
ESCAPE BOTTOM 
LOOP 
END

The global variables will be evaluated when the program is RUN (which does a compile and execute).

1 Like

Thanks Douglas,

I am able to pass the variables from main program to the program called.

Main program



RESET #A (A30) +B (A30) +C (A30)   
MOVE 'ADABAS-FILE' TO #A       
MOVE 'ADABAS-FIELD' TO +B        
COMPRESS 'READ' #A INTO +C         
DISPLAY +C                         
 RUN 'DYN-READ'                    
END 

DYN-READ

WRITE '=' +C 'INSIDE DYN-READ'
+C                            
WRITE '=' +B                  
ESCAPE BOTTOM               
END                           

The below are the display statement

READ ADABAS-FILE

+C: ADABAS-FILE INSIDE DYN-READ
READ ADABAS-FILE
+B: ADABAS-FIELD

So I think it is taking READ ADABAS-FILE as a string and not as a statement, since it is not actually reading the records. In the +B field, we are having the field name instead of the field value.

SO do you think it is possible to access database this way?

Regards,
Vasanth

You would greatly benefit if you purchased PEEK from Blenheim Software International, Ltd. You could cost-justify it by calculating how much time you and others spend writing adhocs to browse Adabas files (or the time and effort you will put into building and maintaining this yourself). We did the same years ago and I don’t know how we’d live without it.

The product is listed on this Software AG webpage:

http://www.softwareag.com/corporate/products/adabas_2010/integration/related_products.asp

or you can go directly to Blenheim’s website:

http://www.blenheimintl.co.uk/adabas-details.php?s=peek-adabas-file-browser-editor

my apologies: for DYN-READ to work you have to change the +vars to &vars…so DYN-READ should be

WRITE '=' +C 'INSIDE DYN-READ'
&C                            
WRITE '=' &B                  
ESCAPE BOTTOM               
END

That lets Natural distinguish between dynamic program code (“&var”) and using the globals as variables (“+var”).

Yes Brain,

You are right. Don’t know the reason but our project doesn’t allow us to buy peek. So we all thought of checking how difficult it is to develop our own tool.

Hi Douglas,

It is working :slight_smile: :slight_smile: :slight_smile:

So I have taken this as a base to create the tool. Hope I wont get stuck…I will let you know the progress.

Thanks again for the prompt help

Hello Douglas,

I created the tool to display the fields of a database. It is working as expected.

So I tried to go to the next level of the tool, to update fields of a single record of a database.

But the problem here is that I created the dynamic program in which we are reading the database and displaying the required fields.

This dynamic program should be in reporting mode because we are not defining any fields.

But now when I want to update fields, it doesn’t allow because it is in reporting mode.

Do you have any other plan how this can be resolved?

Regards,
Vasanth

You can write update programs in reporting mode. Typically, you have a FIND or READ to obtain the record, then modifications to the values, then the UPDATE statement (line number reference to the FIND/READ). Approximately
READ/FIND view…
assign viewfieldone = ‘new value’
UPDATE
LOOP
END TRANSACTION
So, you need to generate the content of the &variables to produce valid reporting mode updates.

You can use structured mode too. Just more work since you need the fields listed

Thanks for the response Douglas,

I used UPDATE WITH SAME RECORD and it worked.

But incluDing the Update functionality seems to be complex.

It works fine when we are updating the alpha fields.

But when we want to update the numeric field OR date field it creates a problem ( NAT0300 Operands cannot be transfered)

The problem is that I defined 10 fields with A30 as common length and format.

When user wants to use update functionality, he will use a function key which will display the current values of all the fields that he selected. He will have to over ride on the current values and use another function key to update it.

So to display the current values I will have to move the current database values to Map fields. Since the map fields are defined as A30 commonly, if any date or numeric value needs to be updated, problem occurs.

Vasanth

You will need to use MOVE EDITED and/or the VAL function to assign values stored in A30 format variables to non-alpha fields (numbers, dates, etc).

Hi Brian,

The problem here is that…we dont know what field is what format.

To explain you more clearly…

The user will select some 5 fields to display data from database using the tool…

                    field 1
                    field 2
                    field 3
                    field 4
                    field 5

These fields that he has chosen are random and we dont have any idea which field is alpha and which field is numeric.

So I commonly defined all fields as A30.

Problem doesn’t occur when we simply display all the fields. But if we try to update/override a field, we will move these fields (of A30 format) to the database fields.

So if we try to move a date or numeric field to the map field defined as A30…it gives us Nat0300 error

let me know if i am still unclear

To go much further, you are going to have to consult meta-data. There are several sources you can look into:

  • Predict
  • Natural DDM
  • ADABAS FDT
    There are APIs around for accessing each of them. If you have Construct, it provides several utilities specifically for accessing Predict information. But the nature of what you are trying to write suggests that you don’t have access to Construct. Other options are to use SYSEXT API USR1051N or use the SYSDIC* DDM’s to read the dictionary information (see especially views SYSDIC-FI, SYSDIC-EL).

If you do not have Predict either, then check out SYEXT API’s with the keyword “DDM”. USR1058N, for example, will read a DDM, which you can parse to figure out what the fields and formats are that you are dealing with.

Finally, you can use Adabas direct calls to read the FDT for the lengths and formats of fields in a physical file.

Thanks Douglas,

It all made sense to me now. I will use SYSDIC-EL and code it.

Will let you know if any issues

Vasanth

You could have a look at Paul Macgowan’s toolkit, it’s free :

http://scctoolkit.atspace.com

Ronald

Hi Vasanth,
Just wondering how this went.
Am trying to do something similar at present - but wanting all DDM fields available. Am currently on the path of a program generator - to generate static programs.
I’m thinking that I may not be able to do this using the dynamic program method (unless I go field by field - which maybe quite inefficient :shock: ). Manual mentions not to use global variable with an index in dynamic modules.
Similar situation - no budget for a 3rd party tool at the moment.
Any advice / tips / techniques / code samples welcome. :smiley:

Thanks
Justin