You need to use the keyword QUALIFIED on the DS specification for data structure RD :
RLS e ds extname(rs)
rd ds QUALIFIED
fmt1 likeds(rls)
fmt2 30a
fmt3 2a
Now your program will compile, BUT, I suspect that you will have problems with the SQL.
This is because the data structure is now qualified – that is, every field name in the structure is prefixed by the structure name. So, your FMT2 field is now called RD.FMT2 – and so SQL cannot match it with the names of the fields in the files it is referencing.
I’m afraid that you will have to do it the boring way, by creating a data structure (unqualified and not externally-described) with the names of all the fields explicitly stated as subfield names.
Or, you can create two externally-described data structures, one for each of the files you are reading from in your SQL, and then in the SELECT and FETCH statements you write the full explicit list of field names. This is the way I prefer to do it.
Regards,
Sloopy
Thanks you but I got it to work by just coding the two remaining fields at the end of the DS statement:
rd eds extname(rdlftm)
fmt1 30a
fmt2 2a.
From Sloopy:
Excellent! Do you know, I did not think you could do that – thanks for teaching me something new!
— Sloopy
Discuss This Question: 2  Replies