Sunteți pe pagina 1din 6

/*------------------------------------------------------------------*/

/*
Programmers Group & Management Resource
Copyright 1998
*/
/*
*/
/*
\\\\\\\
*/
/*
( o o )
*/
/*------------------------oOO----(_)----OOo-------------------------*/
/*
*/
/* System name . . . : Programmer Tool
*/
/* Program name . . . : RTVDB1
*/
/* Text . . . . . . . : Retrieve Database Source
*/
/*
*/
/* Author . . . . . . : Alexander Nubla
*/
/* Creation date. . . : 06/24/98
*/
/*
*/
/* Description. . . . : This is the CPP for command RTVDBSRC
*/
/*
*/
/*
ooooO
Ooooo
*/
/*
(
)
(
)
*/
/*----------------------( )-------------( )---------------------*/
/*
(_)
(_)
*/
/*
*/
/* Modification Log:
*/
/*
*/
/* Date
Task Programmer/Description
*/
/* -------- ----- ------------------------------------------------ */
/* 06/24/98
Alex Nubla
*/
/*
Created
*/
/*
*/
/********************************************************************/
pgm
(&QFile
/* File name & library */
+
&QSrc
/* To source file & lib */
+
&Tombr
/* To member name
*/
+
&Mbropt ) /* *REPLACE or *ADD
*/
/*--------------------------------------------------------*/
/* declaration
*/
/*--------------------------------------------------------*/
dcl
&QFile
*char 20
dcl
&QSrc
*char 20
dcl
&Tombr
*char 10
dcl
&Mbropt
*char
8
dcl
dcl
dcl
dcl
dcl
dcl
dcl
dcl

&File
&FileL
&Src
&SrcL
&ObjAtr
&Text
&FileTyp
&Rtncde

*char
*char
*char
*char
*char
*char
*char
*char

10
10
10
10
10
50
5
2

dcl
dcl
dcl
dcl
dcl
dcl
dcl
dcl
dcl

&error
&msgid
&msgkey
&msgdta
&msgf
&msgflib
&msgtyp
&msgtypctr
&pgmmsgq

*lgl
*char
7
*char
4
*char 100
*char 10
*char 10
*char 10 '*DIAG'
*char
4 X'00000001'
*char 10 '*'

/*
/*
/*
/*
/*
/*
/*
/*
/*

std
std
std
std
std
std
std
std
std

err
err
err
err
err
err
err
err
err

*/
*/
*/
*/
*/
*/
*/
*/
*/

dcl
dcl

&stkctr
*char
&errbytes *char

4 X'00000001' /* std err */


4 X'00000000' /* std err */

monmsg
chgjob

msgid(cpf0000) exec(goto error)


logclpgm(*no)

/*--------------------------------------------------------*/
/* break up the names and libraries
*/
/*--------------------------------------------------------*/
chgvar
&File
%sst(&QFile 1 10)
chgvar
&FileL
%sst(&QFile 11 10)
chgvar
&Src
%sst(&QSrc
1 10)
chgvar
&SrcL
%sst(&QSrc 11 10)
/*----------------------------------------------*/
/* validate the file
*/
/*----------------------------------------------*/
valfile:
chkobj

obj(&FileL/&File)
+
objtype(*file)
+
aut(*use)
monmsg
(cpf9801 cpf9802) exec(do)
rcvmsg
msgtype(*last)
+
msgdta(&msgdta)
+
msgid(&msgid)
+
msgf(&msgf)
+
msgflib(&msgflib)
sndpgmmsg msgid(&msgid)
+
msgf(&msgflib/&msgf) +
msgdta(&msgdta)
sndpgmmsg msgid(cpf9898)
+
msgf(qcpfmsg)
+
msgdta('RTVDBSRC command aborted')
return
enddo
rtvobjd

if
chgvar
enddo

Obj(&FileL/&File)
ObjType(*File)
RtnLib(&FileL)
ObjAtr(&ObjAtr)
Text(&Text)
(%sst(&FileL 1 1) = '*')
%sst(&QFile 11 10)

+
+
+
+
then(do)
&FileL

if
(&ObjAtr = 'PF')
then(goto valsrc)
if
(&ObjAtr = 'LF')
then(goto valsrc)
sndpgmmsg msgid(cpf9898)
+
msgf(qcpfmsg)
+
msgtype(*escape)
+
msgdta('RTVDBSRC command valid only +
for existing Physical or Logical file')
/*----------------------------------------------*/
/* validate the source file
*/
/*----------------------------------------------*/
valsrc:
if
rtvobjd

(%sst(&SrcL 1 1) = '*') then(do)


Obj(&Src)
+

chgvar
enddo
if
chkobj

ObjType(*File)
RtnLib(&SrcL)
%sst(&QSrc 11 10)

+
&SrcL

(&Tombr = '*FILE') then(chgvar


obj(&SrcL/&Src)
+
objtype(*file)
+
mbr(&Tombr)
+
aut(*change)
cpf9815
exec(do)
&MbrOpt
'*ADD'
filetyp

monmsg
chgvar
goto
enddo
if
(&MbrOpt = '*ADD')
do
sndpgmmsg msgid(cpf9898)
+
msgf(qcpfmsg)
+
msgtype(*escape)
+
msgdta('Member' |> &Tombr |>
'already exist in the source
file'
|> &Src |>
'in library' |>&SrcL
|>
'. *ADD for member option is
not allowed')
enddo

&Tombr

+
+
+
+
+

filetyp:
if
rtvmbrd

(&MbrOpt = '*ADD')
file(&SrcL/&Src)
mbr(*first)
filetype(&FileTyp)
cpf3019

do
+
+

monmsg
enddo
else
do
rtvmbrd
file(&SrcL/&Src)
+
mbr(&Tombr)
+
filetype(&FileTyp)
monmsg
cpf3019
exec(do)
chgvar
&MbrOpt
'*ADD'
enddo
enddo
if
(&FileTyp *ne '*SRC')
do
sndpgmmsg msgid(cpf9898)
+
msgf(qcpfmsg)
+
msgtype(*escape)
+
msgdta('RTVDBSRC valid only for
source physical file. RTVDBSRC
request to file' |> &Src |>
'in library' |>&SrcL
|>
'aborted.')
enddo
/*--------------------------------------------------------*/
/* Build the temporary source member. This protects
*/
/* the original member from being changed until all
*/
/* RTVDBSRC finished building the member.
*/
/*--------------------------------------------------------*/
tempsrc:
dltf
file(qtemp/qddssrc)
monmsg
cpf2105

+
+
+
+

&File)

cpyf

monmsg
cpyf

enddo
rmvm
addpfm

ovrdbf

fromfile(*libl/qddssrc)
tofile(qtemp/qddssrc)
mbropt(*add)
crtfile(*yes)
cpf2802
exec(do)
fromfile(qgpl/qddssrc)
tofile(qtemp/qddssrc)
mbropt(*add)
crtfile(*yes)

+
+
+

file(qtemp/qddssrc)
mbr(*all)
file(qtemp/qddssrc)
mbr(&Tombr)
srctype(&ObjAtr)
text(&Text)
file(qddssrc)
tofile(qtemp/qddssrc)
mbr(&Tombr)
secure(*yes)

+
+
+

+
+
+
+
+
+

/*--------------------------------------------------------*/
/* Build the outfile file for file access key
*/
/*--------------------------------------------------------*/
tempfd:
sndpgmmsg msgid(cpf9898)
+
msgf(qcpfmsg)
+
msgdta('Building DDS member +
for file'
|> &File |> +
'in library' |> &FileL)
+
topgmq(*ext)
+
msgtype(*status)
dspfd
file(&FileL/&File)
+
type(*accpth)
+
output(*outfile)
+
outfile(qtemp/QAFDACCP)
ovrdbf
file(qafdaccp)
+
tofile(qtemp/qafdaccp)
+
secure(*yes)
if
(&ObjAtr = 'LF')
do
dspfd
file(&FileL/&File)
+
type(*select)
+
output(*outfile)
+
outfile(qtemp/QAFDSELO)
ovrdbf
file(qafdselo)
+
tofile(qtemp/qafdselo)
+
secure(*yes)
dspfd
file(&FileL/&File)
+
type(*join)
+
output(*outfile)
+
outfile(qtemp/QAFDJOIN)
ovrdbf
file(qafdjoin)
+
tofile(qtemp/qafdjoin)
+
secure(*yes)
enddo
/*--------------------------------------------------------*/
/* Call RTVDBSRC2 - build new DDS member
*/
/*--------------------------------------------------------*/
callprc
'RTVDB2'
parm(&File
+

&FileL
&ObjAtr
&Tombr
&Text
&rtncde )

+
+
+
+

dltovr
*all
/*----------------------------------------------*/
/* Error in RTVDB2
(return code 99)
*/
/*----------------------------------------------*/
If
(&rtncde = '99')
do
sndpgmmsg msgid(cpf9898)
+
msgf(qcpfsg)
+
msgtype(*escape) +
msgdta('Error occured in RTVDBSRC')
enddo
/*----------------------------------------------*/
/* Move new member to the original member
*/
/*----------------------------------------------*/
cpyf
fromfile(qtemp/qddssrc) +
tofile(&SrcL/&Src)
+
frommbr(&ToMbr)
+
tombr(*frommbr)
+
mbropt(&mbropt)
monmsg
msgid(cpf2817)
+
cmpdta(cpf2869)
dltf
file(qtemp/qddssrc)
sndpgmmsg msgid(cpf9898)
+
msgf(QCPFMSG)
+
msgtype(*comp)
+
msgdta('RTVDBSRC completed. +
Member' |> &ToMbr |> +
'added in' |> &SrcL |< +
'/'
|< &Src)
rmvmsg
clear(*all)
goto

end

/*--------------------------------------------------------*/
/* error routine:
*/
/*--------------------------------------------------------*/
error:
if
&error
(goto errordone)
else
chgvar
&error '1'
/*----------------------------------------------*/
/* move all *DIAG message to *PRV program queue*/
/*----------------------------------------------*/
call
QMHMOVPM (&msgkey
+
&msgtyp
+
&msgtypctr +
&pgmmsgq
+
&stkctr
+
&errbytes)
/*----------------------------------------------*/
/* resend the last *ESCAPE message
*/
/*----------------------------------------------*/
errordone:
call
QMHRSNEM (&msgkey
+
&errbytes)
monmsg
cpf0000
exec(do)
sndpgmmsg msgid(cpf3cf2) msgf(QCFPMSG) +

end:

monmsg
enddo
endpgm

msgdta('QMHRSNEM') msgtype(*escape)
cpf0000

S-ar putea să vă placă și