The portable subfile option for importing data files
Seamus BROWNE
Seamus.Browne@partage.org
Tue, 2 Oct 2001 12:39:50 +0200
C. Glass asked a question last week concerning a list of sequential numbers.
Forgive me if this is old hat but I did check the powerh-l archive with
Google
and did not see anything on using Portable subfiles for Importing data.
Personally I would have used a mix of
1. Basic on a PC for creating the subfile
2. FTP
3. The Quiz SET SUBFILE PORTABLE option
4. MPE, with some file manipulation options
Basically the idea is to create a (dummy) portable data subfile.
Then substitute the dummy file with the required list of numbers file.
Adavantages :
1. One fell swoop, for the list of numbers.
2. It illustrates a method for importing external data to PH from
other file systems, (e.g. datafiles from Web forms,)
without creating dictionary defined files.
Cognos says the PORTABLE SUBFILE option is for simplifying
"intermachine transfer".
OK, and it works both ways: Export **and** Import.
I am not an experienced PH user, apart from a bit of Quiz.
Perhaps you guys use this method routinely, but the few PH programmers
I have spoken to don't use the SUBFILE PORTABLE option.
So here's my two cents.
**********************
:purge Million
:purge Millionq
:purge Million ,temp
:purge Millionq ,temp
:QUIZ
can cle
set def
set sub name Million portable
def number packed * 6 = 1
rep number
go
EXIT
:listf million@ ,2
FILENAME CODE ------------LOGICAL RECORD----------- ----SPACE----
SIZE TYP EOF LIMIT R/B SECTORS #X MX
MILLION 647 80B FA 13 13 16 16 1 *
MILLIONQ 648 8B FA 1 10 32 16 1 2
:print million
;Subfile created by QUIZ 819C on 26/09/2001
Element NUMBER Numeric Size 7 &
Leading Sign "-" &
Significance 1 &
Picture "^^^^^^^" &
Heading "NUMBER"
Subfile MILLION Organization Direct
Record MILLION
Item NUMBER Datatype Portable Zoned Size 8
; end source
:print millionq
+0000001
The Millionq is a dummy file in the sense that it will soon be purged, but
we need to look at the way the number is stored, so that we can make an
ascii file with 999999 sequential "numbers" in that same format.
i.e.
"+0000001"
"+0000002"
...
"+0999999"
So we make the file MillionX that has an on each line an ascii string
representing a signed number, as in the MillionQ file.
Basic Example :
CLEAR
zero$ = "00000000"
OPEN "c:\MillionX" FOR OUTPUT AS 1
DO UNTIL ctr = 999999
ctr = ctr + 1
ctr$ = RTRIM$(LTRIM$(STR$(ctr)))
lenctr = LEN(ctr$)
myline$ = "+" + MID$(zero$, 1, 7 - lenctr) + ctr$
PRINT #1, RTRIM$(LTRIM$(myline$))
LOOP
CLOSE
FTP the MillionX file to the 3000, if necessary.
Now substitue the original (Quiz) Millionq file with the new (Basic)
Millionq.
:purge millionq
:build millionq;rec=-8,,f,ascii;code = 648 ;disc = 1000000
:file d = millionq
:fcopy from = millionx; to =*d
HP31900A.05.04 FILE COPIER (C) HEWLETT-PACKARD CO. 1999
*200*WARNING: FROMFILE RECSIZE IS 80 BYTES, TOFILE RECSIZE IS 8 BYTES.
CONTINUE OPERATION (Y OR N) ?y
(Reply Y to the RECSIZE question.)
EOF FOUND IN FROMFILE AFTER RECORD 999998
999999 RECORDS PROCESSED *** 0 ERRORS
END OF SUBSYSTEM
:listf million@ ,2
FILENAME CODE ------------LOGICAL RECORD----------- ----SPACE----
SIZE TYP EOF LIMIT R/B SECTORS #X MX
MILLION 647 80B FA 13 13 16 16 1 *
MILLIONQ 648 8B FA 999999 1000000 32 31264 34 *
MILLIONX 80B FA 999999 999999 3 312512 * 26
Now you have a PH usable subfile. Million still has the original dictionary.
MillionQ has the data, even though the file length has changed.
If you want to get back to something less unusual, why not create a
normal subfile from the portable file.
QUIZ
Acc *million
set rep lim 1000000
set sub name toto keep
rep sum all
Go
:listf toto ,2
FILENAME CODE ------------LOGICAL RECORD----------- ----SPACE----
SIZE TYP EOF LIMIT R/B SECTORS #X MX
TOTO 644 8B FA 999999 1000000 32 31264 34 32
Toto is a regular Quiz subfile, MPE filecode = 644.
Sorry once again if this is a run-of-the mill PH procedure.
Seamus Browne