Operating System - NonStop OS
cancel
Showing results for 
Search instead for 
Did you mean: 

An odd but highly complex question

ChrisMDorn
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

 

 01 PROCESSING-FIELD    PIC X(30).

 

And assume it holds these 2 rows as text strings

 

DE-ELEMENT-1

DE-ELEMENT-3

 

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.

1 REPLY
Dennis Handly
Acclaimed Contributor

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.