Why is RECORD-LENGTH always the length of the first segment read?

Document ID : KB000013551
Last Modified Date : 14/02/2018
Show Technical Document Details
Introduction:

Calculating Record Length when reading IMS Segments. 

Question:

We have a the problem where the RECORD-LENGTH is always the first segment read, not the length of the last segment read (i.e. the length of the segment that is currently in the segment RECORD area). Can this be fixed? 

This is both in compatibility and New Function mode.                       

Environment:
Reading IMS segments using Easytrieve.
Answer:

Ideally you would like RECORD-LENGTH to vary according to the sum of the lengths of the retrieved segments, but that is not available internally. 

You could pro-grammatically determine the length via the PATH-ID. For example;

 

RETRIEVE DLIFILE ... + 

SELECT (PARTROOT ID 'A' + 

STOKSTAT ID 'AC' + 

CYCCOUNT ID 'CE' + 

BACKORDR ID 'CF') 

 

PATH-ID Value Segments Available 

A PARTROOT 

AC PARTROOT - STOKSTAT 

CE PARTROOT - STOKSTAT - CYCCOUNT 

CF PARTROOT - STOKSTAT - BACKORDR