Can any of you send me a sample program on how a COBOL program accesses an ADABAS file.

You’ll find some in the Adabas documentation

Link is broken on Cobol to ADABAS code samples.

Replacing the old Adabas version-Number with the latest one …

Another way besides using direct calls is to use Adabas SQL Gateway.

I am not getting sample cobol adabas code in above links. Could you please send sample program on how a COBOL program accesses an ADABAS file.

As a TechCommunity member, you have access to documentation for several of the latest versions of Adabas, but “Documentation” must be checked as an area of interest in your member profile. Currently documentation is available for Adabas v8.2.6 through v8.4.2.

Here’s a link to Adabas call syntax:

And another for SQL Gateway Embedded SQL:

With regard to your comment that you are not getting ALL the data fields from the record:

Are you aware that Adabas is a field oriented, not a record oriented database package? On any READ, Adabas will only return fields that are included in the Format Buffer.

You said

I am not sure what this means. The ISN of a record is passed back to you. Is that what you mean?

First, and most importantly, you need access (if you do not already have it) to Adabas Documentation. If you are going to do real work with Adabas Direct Calls, you need a class on Direct Calls.

I understand you do not have any real knowledge of Adabas. Here are a few things to note:

The Search Buffer is where you tell Adabas what your search criteria is. You do not have S1. in this buffer.
Instead, you would have something like HC, where HC is the Adabas name for HA2-ACCOUNT-ID.

The Value Buffer would have the value you are searching for; like 21580012H. It looks like you have a null value buffer.

The Format Buffer you have looks correct, namely the list of fields you want to read.

The Record buffer is where you receive the values.

You will need to see the documentation for the Adabas Control Block which is not shown in what you posted; although it looks like
the fields that start with ADA-CTRL should be fields within WS-CONTROL-BLOCK.

I am surprised you did not get an error response from Adabas (or, did you?). But, I cannot see what you have in the Control Block and all the Buffers.

GET HELP. Namely, someone who knows Adabas Direct Calls.

The FIND command is used primarily to determine a set of records - records containing a specified value in a specified key. You appear to have this working with Search Buffer HC (HA2-ACCOUNT-ID field) and Value Buffer 21580012H, as you have ADA-CTRL-ISN-QUANTITY returned as 1.

Your Format Buffer is requesting 6 fields: HC, HI, HL, HM, WB, and ZJ4, but you are not finding their contents in the Record Buffer because, as stated above, the FIND command simply locates a set of records. You need to invoke the option to retrieve the first record of the set. To do that, set the ISN Buffer length to 4 prior to the CALL.


Megha’s approach is valid: the S1 command can return the content of the first record found if the format buffer is supplied. (see “By placing field names in the format buffer, the user can read the field’s contents from the record of the first ISN in the resulting ISN list. The field’s contents are read into the record buffer.”)

Setting the ISN Buffer length to 4 will not make any difference. “If the user intends to use the GET NEXT option of an L1 or L4 command to read the records identified by the ISNs, neither the ISN buffer entry nor the save-ISN-list option is required. In this case, the L1 and L4 commands obtain the ISNs automatically from the ISN list stored by Adabas.”.

I’d like to see the listing of the FDT and corresponding long field names. It isn’t clear why only the account number (HC) is being returned in the record buffer: are the fields for this record specified correctly? do those fields have non-null content?

You can return “ACCOUNT-HEADER-RECORD” - assuming “S1” is the short name for this field, simply include it in your Format Buffer (e.g. “S1,HC,HI,HL,HM,WB,ZJ4.”) and adjust the corresponding lengths of the FB and RB.

Note that the SB and VB work together. Supplying “S1” in the SB and “21580012H” in the VB you are asking for the records where S1=“21580012H”.

I am afraid I may have confused everyone.
When I said:

HC was an example of a field name. I thought that you placed S1. in the Search buffer because the Search Command is S1. What you need is not “HC.” but the two character name for the Super Descriptor (not field) ACCOUNT-HEADER-RECORD followed by a period. If the super’s two character name is indeed S1, then S1. is what should be in the Search Buffer. As Doug said, you need to supply a print out of the relevant part of the FDT (which is Adabas’s Field Description Table).
It looks like you have initialized the Value Buffer correctly. Please confirm whether S1 is indeed the mnemonic for ACCOUNT-HEADER-RECORD.

The Format Buffer looks correct assuming that all the two character mnemonics are the proper names for the fields you wish to read.

Assuming everything was correct in all the buffers, you should have gotten an ISN quantity of 1 and the proper ISN in the Control Block. If you only received the ACCOUNT-HEADER-RECORD, which I assume is also called the “client name”, and everything else in the record buffer was blank, this would only happen if the values were blank in the record.

Do you have Natural in your shop? If so, get a Natural programmer to write a program like:

1 MYVIEW VIEW OF the file name
::: long (Natural) names of the fields
GET MYVIEW nnnn where nnnn would be the ISN from the S1 command

This will show you what the values of the fields are in the specified record.

If Natural does not exist in your shop, let us know and we will take you through a read command (L1) which will read the specified ISN.


What I read in that same document (here’s the TechCommunity link

I read this to mean that you need a non-zero value to retrieve the first record with the S1.

Instead of a Search command, please try a READ IN LOGICAL SEQUENCE. This will give you the records, one at a time, in descriptor (school ID) sequence .

You could also do a Search for records greater than or equal to 20180001 and less than 20180500 (I presume what you posted, 2018500 is a typo). However this will be more expensive, and you will be getting the records in ISN sequence, not School ID sequence.

If you will be reading “chunks” of records upto 500 in number, you should probably be using the Adabas equivalent of Natural’s multifetch. This will reduce the number of Adabas calls.

Thanks Steve,


You need to get access to Adabas documentation. There are excellent examples of all the options for Search and Value buffers.

As I indicated, you probably want a READ in logical sequence (L3 command), not a Search command. Not only would this be more efficient, you would be getting the records in SCHOOL ID sequence, whereas if you do a Search, the records will be in ISN sequence.

I will point out again that you Adabas documentation as well as someone who knows Adabas to tutor you. If someone expects you to be competent in Adabas without documentation or tutoring, they are fools.

What goes in a Value buffer depends on what is in the accompanying Search buffer. For example, I could have a Search Buffer like AA,D,AB. The D is the “and” operator. The value Buffer might have JAMES A23 indicating I want a value of JAMES for AA, there are 5 blanks after JAMES (assumes AA is formatted A10 in the FDT), and the A23 is the desired value for AB. The Search Buffer can be used to format the value buffer. Similarly, the Format Buffer can format the record buffer other than with the default FDT values.

Direct Call programming is NOT a trivial task (that is one reason why Natural is so popular). No one in their right mind would assign you to write Direct Calls without a tutor and access to documentation, and , ideally, actual training.

Hi Steve,

I have managed to write cobol adabas code and it is running partially fine in production as for some records ISN limit is crossed and response code +0249 is triggering.

I have recreated issue in test region.

I need sample ISN code to put in application program’s control block. There is no file handling like batch programs here. These cobol adabas programs have direct ADABAS calls for online processing.

Error information:

The partitioning field value specified in the record buffer of the A1 command is inconsistent with the partition criteria defined to the partition identified by the ISN in the Adabas control block.

Such an update requires the relocation of the ISN to another partition, which is not allowed.

Action: Review the application program. Use a delete and store as an alternative.

Record buffer is receiving output as per format buffers. Value buffer has input and search buffer has descriptor.

Incorrect -ve ISN value is same from S1,HI and A1 call. While amending it is giving +0249.

Could you please suggest what changes i need to make in record buffer as per error description to get correct isn value from adabas call.

Below structure I am sending while calling adabas from cobol program and receiving +0249.

From Natural program ISN = +2147527533 for the same record and via cobol-adabas call with below structure i am getting ISN value as -2147448637.

Do i need to change isn’s data type S9(9) COMP to any other data type. Some leads suggested to try S9(10) and 9(10) comp, but it is not working.

Could you please suggest.

02 ADA-CTRL-FILLER-1 S9(4) COMP +0000
02 ADA-CTRL-ISN S9(9) COMP -2147448637
02 ADA-CTRL-ISN-LOW-LIMIT S9(9) COMP +00000000