--
Yanti Budiman
IT-Security Review
Lippo Bank
www.lippobank.co.id
Hi Yanti
The following shows how a physical file can be cleared with a call to the
QCMDEXC api from within an RPG program.
In the CL program the file TMPACC is overridden to another file.
OVRDBF TMPACC TOFILE(QS36F/&TMPACC) OVRSCOPE(*JOB)
The following code is included in the RPG program.
By referencing the file information data structure, you can retrieve the
name of the file
that TMPACC has been overridden to.
F TMPACC UF E K DISK KINFDS ACC
By defining the data structure for the INFDS you can place the file name
into variable #TACC
I ACC DS
I 83 92 #TACC
Define 'CLRPFM myLibrary/' as a constant (obviously you substitute myLibrary
for whichever library is needed).
I 'CLRPFM myLibrary/' C #CMD
Then its just a case of concatenating the file name with the command you
wish to execute, in
this case #CMD, and call QCMDEXC.
You will also need to close the file you are going to clear so the CLRPFM
command will
execute without causing an exception.
The parameter PCMD must be defined as a charater field, with its length
defined as the same length
as the string passed into it. In this case the length is 23 Alpha.
PLEN must be defined as 15 5. The length of the string passed in PCMD must
be passed in this parameter.
Finally you will need to open the file so any further processing in the RPG
program can be completed.
C CLOSE TMPACC
C #CMD CAT #TACC PCMD
C CALL 'QCMDEXC'
C PARM PCMD 23
C PARM 23 PLEN 15 5
C OPEN TMPACC
Bear in mind that there are other ways to clear a physical file from within
an RPG program, such as reading the entire file and deleting each record.
If you would like anymore help, feel free to email me.
Anthony Chilton
The command to delete all records in a file is a CL Command for the
AS/400. It is CLRPFM Y/X, where Y is the name of the library and X is
the name of the file. CLRPFM stands for Clear a Physical File Member.
If your working with a multi-member file you have the option of
specifing which member you wish to clear. The keyword for this option
is MBR. The default for this keyword is *FIRST, meaning it will clear
the oldest member first. You could also clear the newest member by
using *LAST.
Note:
1. Be aware that when you execute this command there is no message
asking you to confirm your clearing the file. You may want to copy a
file and try this on the copied file to test it out.
2. Suggest that you always include the library name so that you don't
accidently clear the wrong file. A lesson that I learned the hard way.
Good luck.
Bruce E. Bardini
"Jay R. Winans" <Jayan...@Earthlink.Net> wrote in message
news:93787e9f.01091...@posting.google.com...
Bruce Bardini <bruc...@home.com> wrote in message
news:j9Un7.60778$xb.31...@news1.mntp1.il.home.com...
"Yanti" <yanti....@lippo.net.id> wrote in message
news:oYrn7.2277$96.18730@news...
Opening a file for output on an AS/400 doesn't clear it. Also, if the file
doesn't exist, opening it for output does NOT create it, as might happen on
some systems.
--
Bruce E. Bardini
"Rick Price" <ri...@hpdsoftware.com> wrote in message
news:9npo3l$8t6hp$1...@ID-39799.news.dfncis.de...
C DOU *IN87 = '1'
C DOU *IN88 = '0'
C KEYLIST DELETE YOURFILE 8788
C ENDDO
C ENDDO
C*
Matthias
"Drew Dekreon" <drew_dekreon@chugachelectric.!com!> wrote in message news:<tq22bvt...@corp.supernews.com>...
I've just looked and it still happens in ILE COBOL. I guess the same thing
doesn't happen in RPG.
Bruce Bardini <bruc...@home.com> wrote in message
news:yTdo7.62822$xb.33...@news1.mntp1.il.home.com...
**************************************************************************
FFILE UF E K DISK
*
**************************************************************************
C *LOVAL SETLL FILE
C *IN60 DOUEQ*ON
C DELETFILE 60
C ENDDO
or by key
**************************************************************************
FFILE UF E K DISK
*
**************************************************************************
C *IN60 DOUEQ*ON
C KEY DELETFILE 60
C ENDDO
On 14 Sep 2001 05:37:57 -0700, m...@matthias-martin.com (Matthias