HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
Operating System - NonStop OS
Showing results for 
Search instead for 
Did you mean: 

An odd but highly complex question

Occasional Visitor

An odd but highly complex question

I am working in a COBOL shop and I am wondering if it is possible to extract a field name from a string (PIC X(30)) variable and be able to then access that data element in memory.


What we are doing is attempting to create a process that will read through a database that contains field names in a PIC X(30) field.  Then using that field name access that data element in the program.  For example...


Data Elements in Working Storage


01 DATA.

  05 DE-ELEMENT-1    PIC X(02).

  05 DE-ELEMENT-2    PIC 9(04).

  05 DE-ELEMENT-3    PIC 9(06)V9(02).


An external table holds a single field




And assume it holds these 2 rows as text strings





What I am looking for is a way to process through the values in the external table and perform tasks on the fields listed in there.  The program we are looking at is attempting to log changes to fields but only specific fields are being checked.  So in this case we woudl only process on DE-ELEMENT-1 and DE-ELEMENT-3 and not DE-ELEMENT-2.


We are attempting to make this a table driven check because we have had to change the list of fields many times already and it requires a code promotion each time.


Re: An odd but highly complex question

I haven't used COBOL in decades.


It seems you need to dynamically select fields based on names.  I don't think there is any easy way to do this except with a big EVALUATE verb with the list of every field you might want to change.


Your problem will be even harder since DE-ELEMENT-1 & DE-ELEMENT-3 have different PICs.