Copying records with segmented data templates

Previous releases of Z Data Tools that copied data with a segmented template, desegmented the output file. This behaviour has been changed so segmented data can be copied, and the record segment relationships, or physical record structures, are maintained. This means you can:

Example 1.
Insert a new segment in the output record.

Consider the following input segmented record:

AsegBsegCsegDseg
is mapped by a segmented template with 5 layouts mapping segments A to E:
$$FILEM DSC ,
$$FILEM TCIN=MYSEG.TEMPLATE(SEGTP),,
$$FILEM PROC=*
IF FLD(1,1) = 'D' THEN DO              /* found a Dseg */
  WRITE()                              /* Write out current segment */
  OVLY_OUT('E',1)                      /* Create 'Eseg' in output area */
END                                    /* normal return writes Eseg  */
After running the above procedure, the output record would be
AsegBsegCsegDsegEseg.
Example 2.
Delete a segment in the output record.

Consider the following input segmented record:

AsegBsegCsegDseg
$$FILEM DSC ,
$$FILEM TCIN=MYSEG.TEMPLATE(SEGTP),,
$$FILEM PROC=*
IF FLD(1,1) = 'C' THEN                  /* found a Cseg */
  Return 'DROP'                         /* drop this segment */
After running the above procedure the output record would be
AsegBsegDseg 
Example 3.
Desegment a segmented file.
//DDIN     DD DISP=SHR,DSN=MYSEG.DATA
//DDOUT    DD DUMMY
//DDDESEG  DD DISP=SHR,DSN=MYDESEG.DATA
//SYSIN    DD *
$$FILEM DSC ,
$$FILEM TCIN=MYSEG.TEMPLATE(SEGTP),
$$FILEM PROC=*
WRITE(DDDESEG)   /* Write segment out as physical record */
RETURN 'DROP'    /* don't copy any data */
/*

Related topics