Extracting SBX Source Members from RAMSBX to a PDS

Document ID : KB000056167
Last Modified Date : 14/02/2018
Show Technical Document Details

CA-Ramis System Building Executive (SBX) is a sophisticated application development and management tool that can be easily used to control a wide range of activities, both simple and complex. SBX enables more experienced users to create complex procedures, which can control the sequence of activities, accept values for variables, execute other procedures and subroutines, and control screen display. The source code to an SBX routine can be stored on a CA-Ramis database or in an external file.

The following CA-Ramis batch step first deletes then loads the source for the SBX sample routine named EXTRACT. EXTRACT is then compiled and executed.

The sample routine, EXTRACT, demonstrates a method of extracting multiple SBX source members from a CA-Ramis database into members of a PDS. EXTRACT dumps the selected SBX members to temporary dataset RAMSAVEX. Then, in a DO LOOP, EXTRACT reads the dumped extract and writes the source statements for each individual SBX member to an individual member of a PDS.

Please review this sample and modify it to suit your need.

 
//RAM EXEC PGM=RAMIS
//STEPLIB DD DISP=SHR,DSN=your.Ramis.CAILIB
//DATABASE DD DISP=SHR,DSN=your.DATABASE
//RAMLIBE DD DISP=SHR,LABEL=(,,,IN),DSN=your.RAMLIBE
//RAMSAVEX DD UNIT=SYSDA,SPACE=(TRK,(n,m))
//MEM1001 DD DISP=SHR,DSN=your.pds(MEM1001)
//MEM1002 DD DISP=SHR,DSN=your.pds(MEM1002)
//MEM1nnn DD DISP=SHR,DSN=your.pds(MEMnnnn)
//RAMPRINT DD SYSOUT=*
//RAMSYSIN DD *
SET MODE=BRF
*
* Delete any prior SBX members named EXTRACT.
MAINTAIN FILE RAMSBX
SOURCE IMBEDDED FORMAT FREE
WHEN MATCH ON NAME DELETE ALL RECORDS FOR NAME
DATA
NAME=EXTRACT;
END
*
* Load the source for SBX member EXTRACT.
SBXLOAD PROC='EXTRACT',TYPE='SOURCE',INPUT='LINE',LIBRARY=RAMSBX
****************************************************************
* *
* This SBX routine is UNSUPPORTED and is provided to you *
* as a sample. This routine will dump the source for *
* specified SBX procedures into members of a PDS. *
* *
* You will need to know how many members will be written *
* so you can provide DD statements with the DDnames: *
* MEM1001 to MEMnnnn. *
* *
****************************************************************
*
DCL REC AS A0; -- read record into here
DCL I AS I9 INITIAL 0; -- work integer
DCL FILENUM AS I4 INITIAL 1000; -- filenum to increment from 1000
DCL MEMNAME AS A8 INITIAL ' '; -- name of PDS member to write to
DCL NAME AS A32 INITIAL ' '; -- SBX member name
DCL T AS A9 INITIAL ' '; -- SBX typecode of member
DCL LINE AS A9 INITIAL ' '; -- SBX line number of member
DCL TMEM AS A80 INITIAL ' '; -- SBX text (source) line of member
DCL NAMESAVE AS A32 INITIAL ' '; -- saved name of member in progress
DCL HEADING AS A80 INITIAL ' '; -- to write comment with SBX name
*** Dump the RAMSBX file.
*** This is the format of the RAMSAVEX extract file:
*RP0825: FIELDNAME FORMAT LENGTH
* NAME A32 32
* TYPECODE I9 9
* LINE I9 9
* SOURCE A80 80
* *** SLACK X2 2
* TOTAL 132
DEFER;
TABLE FILE RAMSBX
PRINT NAME AND TYPECODE AND LINE AND TEXT AND SAVEX
IF NAME IS supply your selection criteria here
IF TYPECODE EQ 4
END
ENDDEF;
RUN;
* Did you dump any members? If not, exit.
IF %RECORDS EQ 0 THEN;
PRINT ** NO MEMBERS FOUND. EXITING... **;
EXIT;
ENDIF;
* Do loop to read the extracted records and write to the PDS...
READ LINE FROM HOST FILE RAMSAVEX INTO REC;
DO WHILE NOT %EOF('RAMSAVEX');
I=I+1;
NAME = %SUBST(REC,1,32); --- get the member name
TMEM = %SUBST(REC,51,80); --- get the text (source)
IF NAME NE NAMESAVE THEN; --- if new SBX member
PRINT Working on &NAME...;
IF FILENUM GT 1000 THEN; --- need to close previous file?
CLOSE &MEMNAME;
ENDIF;
FILENUM = FILENUM + 1; --- increment file number
MEMNAME = 'MEM' ! %TOSTRING(FILENUM); --- make the PDS member name
NAMESAVE = NAME; --- note the name of the current member
HEADING = '* SBX Member ' ! NAME ! ' extracted at ' !
%CDATE ! ' ' ! %TIME ! '*'; --- optional 1st line
WRITE LINE TO HOST FILE &MEMNAME FROM HEADING;
ENDIF;
WRITE LINE TO HOST FILE &MEMNAME FROM TMEM; --- write each text line
READ LINE FROM HOST FILE RAMSAVEX INTO REC; --- read next record
ENDDO;
CLOSE RAMSAVEX;
IF FILENUM GT 1000 THEN; --- close last file, if any
CLOSE &MEMNAME;
ENDIF;
PRINT Done. All selected members written.;
END SBXLOAD
*
* Now, COMPILE the above SBX routine named EXTRACT.
COMPILE EXTRACT END
*
* Now, execute the above SBX routine named EXTRACT to extract.
EXTRACT
/*
//
Read More About It

For more information on writing, storing, and compiling SBX procedures, refer to the publication, CA-Ramis System Building Executive (SBX). For more information on utilities, such as SBXLOAD, refer to the publication, CA-Ramis Utilities. For MAINTAIN, please refer to the publication, CA-Ramis Data Maintenance Facility (DMF). For TABLE and other reporting capabilities, refer to the publication, CA-Ramis Syntax Based Reporting.

Contribute Your Ideas

If you have a tried and true technique which you would like to share with the CA-Ramis community as a published article, please contact Computer Associates Support.