Can CLIST access PDS member and GDG file?

850 views Asked by At

I need to check a string in a GDG file, for example, to check 'ABCDEFG' in file : AAA.BBB.CCC.DDD(0).

IF YES, append this string 'ABCDEFG' to the bottom of a PDS member:

ABD.EFG.HIG(NAMES).

IF BOTH FILES ARE PSD FILES, there is no problem, while I changed to GDG and PDS member, it didn't work.

My Clist program can not allocate a gdg file, and also can not append to a member.It overided the member, when i allocated the file to SHR and OLD. MOD didn't work to a member file.

1

There are 1 answers

0
MikeC On

The clist can access a GDG but you have to convert the file name from a gdg relative reference (0) to a fully qualified dataset name. In your examble, you would need to reference the file as: AAA.BBB.CCC.DDD.G1234V00 (where G1234V00 is the most current version Identifier).

Typically you can do this by writing a routine to run a LISTCAT command on the dataset, SYSTRAPing the output and then parsing the fully qualified name into a CLIST variable.

Example:

PROC 0

  /* This illustrates a basic clist method using SYSTRAP */
  /* to extract a fully qualified GDG dataset name       */ 

     CONTROL NOFLUSH NOPROMPT NOLIST NOCONLIST NOSYMLIST NOMSG MAIN 

  /* Target dataset name */
     SET GDG = 'RAPP.RAP000.YQ.TAX.YQINFO.BK'                       

  /* SET SYSTRAP LIMIT and execute IDCAMS LISTC command */
     SET &SYSOUTTRAP = 300                                          
     LISTC ENTRIES(&GDG)                                            

  /* Calculate line number of last entry in LISTC results */
     SET &I = &SYSOUTLINE-21

  /* calculate ending position of GDG name in report */
     SET &L = &LENGTH(&GDG) + 23

  /* extract SYSTRAP data into clist string variable */
     SET &C = &&SYSOUTLINE&I

  /* substring data from SYSTRAP line into clist variable and list */
     SET &D = &SUBSTR(17:&L,&STR(&C))                               
     WRITE &D                                                       
END 

Example output...

RAPP.RAP000.YQ.TAX.YQINFO.BK.G8203V00