This article provides a technique using DBSQLPR to extract the first 80 bytes of a variable length field from a Datacom table that is SQL accessible.
This is a two step process:
Details for each step:
//DBSQLPR EXEC PGM=DBSQLPR,REGION=0M
//SYSUDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SNAPPER DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//STDALT DD DSN=dbsqlpr.extract.dataset,
// UNIT=unit,SPACE=(cyl,(n,n)),
// DISP=(NEW,CATLG,DELETE)
//OPTIONS DD *
DATASEPARATOR=,
PRTFILE=STDALT
PRTWIDTH=1500
NOCOLHDR
NOECHO
NOFORMFEED
NOPAGEHDR
NOPAGES
PAGELEN=99999
ROWLIMIT=9999
/*
//SYSIN DD DATA,DLM=$$
SELECT columnname FROM tablename;
$$
//IEBGENER EXEC PGM=IEBGENER,REGION=0M
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=dbsqlpr.extract.dataset,DISP=SHR
//SYSUT2 DD DSN=iebgener.output.dataset,
// DISP=(NEW,CATLG,DELETE),
// UNIT=unit,SPACE=(cyl,(n,n)),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=0)
//SYSIN DD *
GENERATE MAXFLDS=10
RECORD FIELD=(80,2,,1)
/*
NOTE: The Datacom table must be "SQL-able" in order to run SQL requests. That is, the value of the table's SQL-INTENT attribute must be "Y". "SQL-INTENT" for a table can be checked via a CXX report of the database.