dcl-pr ShowMSG extpgm('QMHSNDPM');
*n char(7) const;
*n char(20) const;
*n char(32767) const options(*varsize);
*n int(10) const;
*n char(10) const;
*n char(10) const;
*n int(10) const;
*n char(4);
*n char(32767) options(*varsize);
end-pr;
dcl-ds ErrorCode;
RPG
ctl-opt ALWNULL(*USRCTL) ;
dcl-ds ASP_INFO qualified inz ;
ASPnum int(5) ;
TotCap int(20) ;
TotCapa int(20) ;
Threshold int(5) ;
ErrorLogSpc int(5) nullind ;
MachineLogSpc int(5) nullind ;
MachineTrcSpc int(5) nullind ;
MainDmpSpc int(5) nullind ;
MicrocodeSpc int(5) nullind ;
end-ds ;
exec sql declare ASPspace cursor for SELECT ASP_NUM, TOTCAP, TOTCAPA,
THRESHOLD, VALUE(ERROR_LOG_SPACE,0), VALUE(MACHINE_LOG_SPACE,0),
VALUE(MACHINE_TRACE_SPACE,0), VALUE(MAIN_STORAGE_DUMP_SPACE,0),
VALUE(MICROCODE_SPACE,
dcl-pr putenv int(10) extproc('putenv');
*n pointer value options(*string:*trim) ;
end-pr;
putenv('QIBM_QSH_CMD_ESCAPE_MSG=Y') ;
//Program interface declaration
dcl-pi *n ;
Library char(10) ; // Library name
end-pi ;
dcl-s Filename char(21) ;
dcl-f TheFile usropn extfile(Filename) usage(*delete) ;
Filename = Library + '/File_name' ;
open TheFile;
read TheFile;
dow not %eof;
read TheFile;
enddo;
close TheFile;
At first - display file definition must have USROPN option ( display file isn't opened when program starts):
dcl-s CursorRows int(10) ;
...
exec sql declare C1 INSENSITIVE cursor for .........; // INSENSITIVE if we want exact count of rows fetched into cursor
...
exec sql open C1 ;
exec sql GET DIAGNOSTICS :CursorRows = DB2_NUMBER_ROWS ;
dcl-s Time time ;
dcl-s Today date;
dcl-s Date30 date ;
dcl-s Timestamp timestamp(0) ;
βββββββTimestamp = %date() + %time() ;
Today = %date() ;
Date30 = Today - %Days(30);
// declare variable for command
dcl-s cmd varchar(100);
// declare QCMDEXC interface
dcl-pr qcmdexc extpgm('QCMDEXC');
theCmd char(3000) const;
cmdLen packed(15 : 5) const;
dbcs char(3) const options(*nopass);
end-pr;
// create command and run it
cmd = 'STRBKUBRM CTLGRP(' + ctlgrp + ') SBMJOB(*NO)' ;
qcmdexc (cmd : %len(cmd)) ;