Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CRTPF/Adding Records, Sort by Ascending Order

833 views
Skip to first unread message

Jack Kingsley

unread,
Dec 6, 2002, 9:55:00 AM12/6/02
to
Is there a key word in the DDS that will do this.

Phil91

unread,
Dec 6, 2002, 11:01:41 AM12/6/02
to
Jack,
Add keys in the PF to sort the records in the desired order.
Phil

"Jack Kingsley" <jkin...@wmfinance.com> a écrit dans le message de news:
ce2fab65.02120...@posting.google.com...

Jack Kingsley

unread,
Dec 9, 2002, 7:52:50 AM12/9/02
to
"Phil91" <psorian...@freesurf.fr> wrote in message news:<asqhle$4m9$1...@news-reader11.wanadoo.fr>...

I have tried that and don't have much luck, I can get it to work
though if I build a logical over it though. Any other ideas.

Phil

unread,
Dec 9, 2002, 9:24:37 AM12/9/02
to
That's impossible or I don't understand the problem you get.
Explain it again or show us what you already did.

When adding a record in a keyed PF, DB2 automatically "sorts" the record
among the file.
Don't worry about its actual location in the file.
A single DSPPFM command shows records in arrival sequence even though the
file is sorted by keys.
However this PF is read in the key-order sequence when used in any program.
You can use keys in a any PFs and LFs.
You can even use a keyed LF pointing to a keyed PF sequenced by different
keys.

Where's the problem ?

Terrence Enger

unread,
Dec 9, 2002, 2:12:21 PM12/9/02
to
Phil wrote:

> That's impossible or I don't understand the problem you get.
> Explain it again or show us what you already did.
>
> When adding a record in a keyed PF, DB2 automatically "sorts" the record
> among the file.
> Don't worry about its actual location in the file.
> A single DSPPFM command shows records in arrival sequence even though the
> file is sorted by keys.
> However this PF is read in the key-order sequence when used in any program.


Hmmm, not quite *any* program. In RPG at least it is possible on an
F-spec to specify arrival-sequence access. The CRTPF and CRTLF commands
to have a parameter "Force keyed access path", but I have never thought
of using it.


> You can use keys in a any PFs and LFs.
> You can even use a keyed LF pointing to a keyed PF sequenced by different
> keys.


If for some reason (what might it be?) you really want the records
physically sorted by key, you can use RGZPFM.


>
> Where's the problem ?


Where, indeed?

Jack Kingsley

unread,
Dec 10, 2002, 12:26:58 PM12/10/02
to
Terrence Enger <ten...@idirect.com> wrote in message news:<3DF4EB15...@idirect.com>...
Ok, here is the physical file:

A R CALENDR
A MMDDYY 8 COLHDG('DAYSOFYEAR-MMDDYYYY')
A TEXT('DAYSOFYEAR-MMDDYYYY')
A HOL 1 COLHDG('HOLIDAY')
A TEXT('HOLIDAY')
A ME 1 COLHDG('MONTHEND')
A TEXT('MONTHEND')
A EMPDE 1 COLHDG('EMPTY DAYEND')
A TEXT('EMPTY DAYEND')
A K MMDDYY DESCEND

Here is what is looks like when I DSPPFM against it or query it:

File . . . . . . : YEAR2004 Library . . . . : QGPL
Member . . . . . : YEAR2004 Record . . . . . : 1
Control . . . . . Column . . . . . : 1
Find . . . . . . .
*...+....1.
02282003 M
01312003 M

Rolf P Mittag

unread,
Dec 10, 2002, 12:42:50 PM12/10/02
to
hey, you perfectly get what you are asking for

> A K MMDDYY DESCEND
^^^^^^^
if you want ascending order omit the "DESCEND" keyword
ascending is the default

hth
Rolf

--
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
! Dipl.Inf.(FH) Rolf P Mittag IBM Partner in Development !
! Leipziger Str. 50 D-69214 Eppelheim !
! Fon: +49 (6221) 76 78 60 Fax: +49 (6221) 76 80 26 !
! eMl: r...@r-m-e-d-v.de !
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

jack...@worldnet.att.net

unread,
Dec 10, 2002, 8:23:54 PM12/10/02
to
I tried it ascending as well with no luck on V5R1.

Terrence Enger

unread,
Dec 10, 2002, 11:04:44 PM12/10/02
to
Jack Kingsley wrote:

Well, DSPPFM is short for Display *Physical* File Member. It always
shows records in physical sequence. To see records ordered by key, you
could say CPYF YEAR2004 *PRINT.

If you want Query or any of its friends to show records in a particular
sequence, you *must* specify that sequence. Without such a
specification, Query will return records in the sequence which is
easiest. Even if this happens so far to be the sequence you want, a
change in the number of records in the file or the distribution of
values in a field or the number of processors in your iSeries may change
the output sequence.

BTW, now I am *really* curious. What do you want this sequence for?

Phil

unread,
Dec 11, 2002, 3:53:09 AM12/11/02
to

"Jack Kingsley" <jkin...@wmfinance.com> a écrit dans le message de news:
ce2fab65.02121...@posting.google.com...

| Terrence Enger <ten...@idirect.com> wrote in message
news:<3DF4EB15...@idirect.com>...
| > Phil wrote:
| >
| > That's impossible or I don't understand the problem you get.
| > Explain it again or show us what you already did.
| >
| > When adding a record in a keyed PF, DB2 automatically "sorts" the record
| > among the file.
| > Don't worry about its actual location in the file.
| > A single DSPPFM command shows records in arrival sequence even though
the
| > file is sorted by keys.
| > However this PF is read in the key-order sequence when used in any
program.
| >
| >
| > Hmmm, not quite *any* program. In RPG at least it is possible on an
| > F-spec to specify arrival-sequence access.

I should have said "this PF can be read in the key-order ..." but this is
not the subject of the post and anyway rarely used.

| A HOL 1 COLHDG('HOLIDAY')

| A ME 1 COLHDG('MONTHEND')

| A EMPDE 1 COLHDG('EMPTY DAYEND')

|| A K MMDDYY DESCEND
|
| Here is what is looks like when I DSPPFM against it or query it:
|
| File . . . . . . : YEAR2004 Library . . . . : QGPL
| Member . . . . . : YEAR2004 Record . . . . . : 1
| Control . . . . . Column . . . . . : 1
| Find . . . . . . .
| *...+....1.
| 02282003 M
| 01312003 M

This is the normal results of a DSPPFM command (discussed above).
The "02282003 M" rcd has been physically inserted first in the PF, then the
"01312003 M" rcd. They have been inserted *by chance* in the access path
sequence (descending on MMDDYY).
If this PF is read say in a CL program, you'd see that 1st rcd read is
02282003 M and then 01312003 M as well accordingly to the key-sequenced
access path.
If the 3rd record physically inserted was supposedly something like
"03152003 M", the DSPPFM would show now this rcd as the 3rd and the CL
program as the 1st one.

HTH
Phil

Phil

unread,
Dec 11, 2002, 3:53:26 AM12/11/02
to

<jack...@worldnet.att.net> a écrit dans le message de news:
3DF6BE86...@worldnet.att.net...

| I tried it ascending as well with no luck on V5R1.

Do NOT use a DSPPFM command to check out if the records are sorted in the
desired order.
The DSPPFM command always shows the records in arrival sequence even though
they are sequenced by key(s). It's a performance matter.
Check out my previous posts.
Phil

Jack Kingsley

unread,
Dec 11, 2002, 7:23:28 AM12/11/02
to
Terrence Enger <ten...@idirect.com> wrote in message news:<3DF6B95C...@idirect.com>...


As I enter dates into this file I might miss some and have to go back
and either enter new ones or change the exisiting one, want to have
them in order.

Marc Beauséjour

unread,
Dec 11, 2002, 7:38:41 AM12/11/02
to
You have everythings man,

You have your records in arrival sequence and you have them in order of
MMDDYYYY because your field is MMDDYYYY. If you want them in YYYYMMDD order,
you have to change the date format of the field to YYYYMMDD.

--

"Jack Kingsley" <jkin...@wmfinance.com> a écrit dans le message de news:

ce2fab65.02121...@posting.google.com...

Terrence Enger

unread,
Dec 11, 2002, 5:37:19 PM12/11/02
to ten...@idirect.com
Jack Kingsley wrote:

> Terrence Enger <ten...@idirect.com> wrote in message

news:<3DF6B95C...@idirect.com>...

[snip}

>>>>>
>>>Ok, here is the physical file:
>>>
>>>A R CALENDR
>>>A MMDDYY 8 COLHDG('DAYSOFYEAR-MMDDYYYY')
>>>A TEXT('DAYSOFYEAR-MMDDYYYY')
>>>A HOL 1 COLHDG('HOLIDAY')
>>>A TEXT('HOLIDAY')
>>>A ME 1 COLHDG('MONTHEND')
>>>A TEXT('MONTHEND')
>>>A EMPDE 1 COLHDG('EMPTY DAYEND')
>>>A TEXT('EMPTY DAYEND')
>>>A K MMDDYY DESCEND

[snip]

>>
>>BTW, now I am *really* curious. What do you want this sequence for?
>>
>
>
> As I enter dates into this file I might miss some and have to go back
> and either enter new ones or change the exisiting one, want to have
> them in order.
>

Yes, but as that order is mixed up with respect to the dates
represented, I am wondering what the order is good for.

Tim M

unread,
Dec 13, 2002, 8:46:55 AM12/13/02
to
If you meant to store dates in the file you should use a date data type,
then if you key on the date field you will retrieve records is date sequence
(when reading in index order) regardless of the date format.

"Jack Kingsley" <jkin...@wmfinance.com> wrote in message
news:ce2fab65.02121...@posting.google.com...

0 new messages