Automatically Generate an Advantage CA-Ramis QSAM File Description to Report From Data Extracted in SAVE or SAVB Format
search cancel

Automatically Generate an Advantage CA-Ramis QSAM File Description to Report From Data Extracted in SAVE or SAVB Format

book

Article ID: 55911

calendar_today

Updated On:

Products

Ramis Reporter

Issue/Introduction

This article provides techniques to automatically generate a QSAM file description for data extracted in Advantage CA-Ramis SAVE or SAVB format, enabling the user to report directly from the extracted data.

Environment

Release:
Component: RAMIS

Resolution

SAVE format data is written in EBCDIC format to an external sequential file named RAMSAVE(x), while SAVB format data is written in binary (also called Advantage CA-Ramis internal) format to an external sequential file named RAMSAVB(x). Both extract formats may also create an external file description dataset. It is the creation and use of that description dataset for subsequent reporting activities this article demonstrates.

When either the SAVEx or SAVBx extract activities are invoked, a description of the extracted file may be created at the same time. For a SAVEx activity, a valid data definition statement must exist for the external dataset, RAMSEFM(x). The SAVBx activity requires a valid data definition statement for the external dataset RAMSBFM(x).

SAVEx Extract:

Following is the Advantage CA-Ramis technique when data is extracted in SAVEx format:

The Advantage CA-Ramis commands TABLE, TABLEF, RETRIEVE or RELATE may be used to extract selected fields from some file to RAMSAVEx.

TABLE FILE file PRINT field1 AND fieldn ... AND SAVEx END

The following will erase and then build the QSAM file description by interpreting the RAMSEFMx file which contains the extract layout.

This will erase the QSAM file description if it already exists:

ERASE*
FILE QSAMRAMSAVEx
END

This COMPUTE will generate the file description field values:

COMPUTE COMPSAVE RETAIN FOR TRANSACTION
FILE RAMEXTMASTER
TNAME/A12 = TNAME ;
TTYPE/A1 = TTYPE ;
TLEN/A7 = TLEN ;
EXLEN/I4 = TEXLEN ;
FLDNUM/I4 = FLDNUM + 1 ;
FIELDNAME/A12 = IF TTYPE EQ 'X' THEN 'FILLER'|EDIT(FLDNUM) ELSE TNAME;
ALIAS/A12 = IF TTYPE EQ 'X' THEN 'FILL'|EDIT(FLDNUM)
ELSE 'FLD'|EDIT(FLDNUM);
ACTUAL/A8 = 'A'|EDIT(TEXLEN) ;
USAGE/A8 = IF TTYPE EQ 'X' THEN 'A1' ELSE TTYPE|TLEN ;
END

This DMF (MAINTAIN) activity will read the RAMSEFMx description, manipulate the fields using the above COMPUTE, and load the QSAM file description to the RAMEXTMASTER dictionary:

MAINTAIN FILE RAMEXTMASTER
SOURCE IS FILE NAMED RAMSEFMx
FORMAT IS FIXED
INSERT FILETYPE=QSAM,FILENAME=RAMSAVEx,LEVEL=1
ON NEW TRANSACTION PERFORM COMPUTE COMPSAVE
LAYOUT IS TNAME/12 AND TTYPE/1 AND TLEN/7 AND TEXLEN/4
WHEN NO MATCH ON FILETYPE AND FILENAME AND LEVEL AND FIELDNAME
INCLUDE THE RECORD
END

These utilities will display the generated QSAM file description. Review both reports, noting the USAGE and ACTUAL formats, the FIELDNAMEs and the generated ALIASes:

RAMEXTINDEX RAMSAVEx
RAMEXTOFFSET RAMSAVEx

Now, you can report against the extracted data in file RAMSAVEx using the generated QSAM file description:

TABLE FILE QSAMRAMSAVEx PRINT field1 AND fieldn END

SAVBx Extract:

Following is the Advantage CA-Ramis technique when data is extracted in SAVBx format:

Again, the Advantage CA-Ramis commands - TABLE, TABLEF, RETRIEVE or RELATE - may be used to extract fields from some file to RAMSAVBx.

TABLE FILE file PRINT field1 AND fieldn ... AND SAVBx END

The following will erase and then build the QSAM file description by interpreting the RAMSBFMx file which contains the extract layout:

This will erase the QSAM file description if it already exists:

ERASE*
FILE QSAMRAMSAVBx
END

This COMPUTE will generate the file description field values. Notice the handling of SLACK fields and PACKED fields:

COMPUTE COMPSAVB RETAIN FOR TRANSACTION
FILE RAMEXTMASTER
TNAME/A12 = TNAME ;
TTYPE/A1 = TTYPE ;
TLEN/A7 = TLEN ;
TEXLEN/I4 = IF TTYPE EQ 'P' THEN EDIT(TLEN) ELSE TEXLEN ;
FLDNUM/I4 = FLDNUM + 1 ;
FIELDNAME/A12 = IF TTYPE EQ 'X' THEN 'FILLER'|EDIT(FLDNUM) ELSE TNAME;
ALIAS/A12 = IF TTYPE EQ 'X' THEN 'FILL'|EDIT(FLDNUM)
ELSE 'FLD'|EDIT(FLDNUM);
ACTUAL/A8 = IF TTYPE EQ 'X' THEN 'A'|EDIT(TEXLEN)
ELSE TTYPE|EDIT(TEXLEN) ;
USAGE/A8 = IF TTYPE EQ 'X' THEN 'A1' ELSE TTYPE|TLEN ;
END

This DMF (MAINTAIN) activity will read the RAMSBFMx description, manipulate the fields using the above COMPUTE, and load the QSAM file description to the RAMEXTMASTER dictionary:

MAINTAIN FILE RAMEXTMASTER
SOURCE IS FILE NAMED RAMSBFMx
FORMAT FIXED
INSERT FILETYPE=QSAM,FILENAME=RAMSAVBx,LEVEL=1
ON NEW TRANSACTION PERFORM COMPUTE COMPSAVB
LAYOUT IS TNAME/12 AND TTYPE/1 AND TLEN/7 AND TEXLEN/4
WHEN NO MATCH ON FILETYPE AND FILENAME AND LEVEL AND FIELDNAME INCLUDE THE RECORD END

These utilities will display the generated QSAM file description. Review both reports, noting the USAGE and ACTUAL formats, the FIELDNAMEs and the generated ALIASes:

RAMEXTINDEX RAMSAVBx
RAMEXTOFFSET RAMSAVBx

Now, you can report against the extracted data in file RAMSAVBx using the generated QSAM file description:

TABLE FILE QSAMRAMSAVBx PRINT field1 AND fieldx END

To demonstrate the above technique, use the set of RAMSYSIN statements provided below. This request stream will extract a few records from system files that exist on any Advantage CA-Ramis database. You must provide the data definition statements for the extract files before executing this request. SAVE3 and SAVB3 are used in the extract requests, so RAMSAVE3, RAMSEFM3, RAMSAVB3, and RAMSBFM3 are the required data definition statements.

 

Note: This article is an enhanced version of an example shown in the Advantage CA-Ramis Reporting from External Files (REF) manual, Appendix E. Additional Examples and Techniques.

Read More About It

For more information about the Advantage CA-Ramis components discussed in this article, please refer to the publications Advantage CA-Ramis Syntax-Based Reporting, Advantage CA-Ramis Data Maintenance Facility (DMF) and to the publication Advantage CA-Ramis Reporting from External Files (REF).

Attachments

1558716095723000055911_sktwi1f5rjvs16u0z.gif get_app
1558716093625000055911_sktwi1f5rjvs16u0y.gif get_app