Not good at Clist, but have a small task need to use Clist, need some help or hits:
I need to check names in a GDG file, for example, to check if name 'John' in the file abc.efg.names(0), if yes, then add 'john' to the member aaa.bbb.ccc(namelog).
when i use a flat file like 'AAA.BBB.CCC.NAMELOG' and 'ABC.DEF.GHI.NAMES' , it works ok, but when i chenge to GDG file and PDS member,errors happen. it can not find file abc.efg.names(0), and can not add to the member. If i change to SHR, it will clear the old records and write the new name to the member.
here is the code:
(this code extracted from a long program manually, may contain some other errors, but the most important thing i need help is how to read a GDG file and how to append records to a member file)
PROC 0 DSN1('AAA.BBB.CCC.NAMELOG')
ALLOCATE FILE(OFILE) DA('&DSN1') MOD
OPENFILE OFILE OUTPUT
SET EOF = OFF
SET RCODE = 0
SET CNAME = 'JOHN'
SET DNS2 = 'ABC.DEF.GHI.NAMES'
ALLOCATE FILE(NEXTNAME) DA(&DNS2) SHR
OPENFILE NEXTCARD INPUT
DO WHILE &EOF = OFF OR &RCODE ¬= 0
GETFILE NEXTNAME
IF &EOF=ON THEN DO
SET RCODE = 1
END
IF &STR(&SUBSTR(1:4,&NEXTNAME) = &CNAME THEN DO
CLOSFILE NEXTNAME
FREE F(NEXTNAME)
SET RCODE = 0
GOTO WRITELOG
END
END
WRITELOG: SET OFILE = &CNAME
PUTFILE OFILE
EXIT