Sequence of the DDS makes a difference.
This does not work... (defined the first join then listed the fields from that join, then defined the second join). This sequence does work with other join LFs we have as long as the join files are all different.
                                     Data Description Source
 SEQNBR  *...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8  Date
    100       A          R EMFLE                     JFILE(UTPUNAME LWPEMFLE UTPUNAME)    03/05/08
*                CPD7989-*
    200       A          J                           JOIN(1 2)                            03/05/08
    300       A                                      JFLD(USS# LWPCTID)                   03/05/08
    400       A            USER               I      JREF(1)                              03/05/08
    500       A            USS#               I      JREF(1)                              03/05/08
    600       A            UNOVEL             I      JREF(1)                              03/05/08
    700       A            LWLNME             I                                           03/05/08
    800       A            LWFRST             I                                           03/05/08
    900       A            LWPCTID            I                                           03/05/08
   1000       A            LWEMPS             I                                           03/05/08
   1100       A          J                           JOIN(2 3)                            03/05/08
*                CPD7913-*
   1200       A                                      JFLD(LWEMPS USS#)                    03/05/08
   1300       A            USER               I      JREF(3)                              03/05/08
   1400       A            USS#               I      JREF(3)                              03/05/08
   1500       A            UNOVEL             I      JREF(3)                              03/05/08
   1600       A            LWLNME             I                                           03/05/08
   1700       A            LWFRST             I                                           03/05/08
   1800       A            LWPCTID            I                                           03/05/08
   1900       A            LWEMPS             I                                           03/05/08
   2000        *                                                                          03/05/08
   2100       A          K UNOVEL                                                         03/05/08
                         * * * * *   E N D   O F   S O U R C E   * * * * *
                                             Messages
    ID      Severity  Number
* CPD7913      30        1      Message . . . . :   Type of specification not valid or out of sequence.
* CPD7989      30        1      Message . . . . :   Number of join specifications not valid.
=====================================================================================================================
This does work... (specified the joins and then listed all the fields)
                                      Data Description Source
 SEQNBR  *...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8  Date
    100       A                                      JDFTVAL                              03/05/08
    200       A          R EMFLE                     JFILE(UTPUNAME LWPEMFLE UTPUNAME)    03/05/08
    300       A          J                           JOIN(1 2)                            03/05/08
    400       A                                      JFLD(USS# LWPCTID)                   03/05/08
    500       A          J                           JOIN(2 3)                            03/05/08
    600       A                                      JFLD(LWEMPS USS#)                    03/05/08
    700       A            USER               I      JREF(1)                              03/05/08
    800       A            USS#               I      JREF(1)                              03/05/08
    900       A            UNOVEL             I      JREF(1)                              03/05/08
   1000       A            LWLNME             I      JREF(2)                              03/05/08
   1100       A            LWFRST             I      JREF(2)                              03/05/08
   1200       A            LWPCTID            I      JREF(2)                              03/05/08
   1300       A            LWEMPS             I      JREF(2)                              03/05/08
   1400       A            SUPERUSER          I      JREF(3)                              03/05/08
   1500       A                                      RENAME(USER)                         03/05/08
   1600       A            SUPERUSS#          I      JREF(3)                              03/05/08
   1700       A                                      RENAME(USS#)                         03/05/08
   1800       A            SUPERNOVEL         I      JREF(3)                              03/05/08
   1900       A                                      RENAME(UNOVEL)                       03/05/08
   2000       A            SUPERLNME          I      JREF(2)                              03/05/08
   2100       A                                      RENAME(LWLNME)                       03/05/08
   2200       A            SUPERFRST          I      JREF(2)                              03/05/08
   2300       A                                      RENAME(LWFRST)                       03/05/08
   2400       A            SUPERPCTID         I      JREF(2)                              03/05/08
   2500       A                                      RENAME(LWPCTID)                      03/05/08
   2600       A            SUPEREMPS          I      JREF(2)                              03/05/08
   2700       A                                      RENAME(LWEMPS)                       03/05/08
   2800        *                                                                          03/05/08
   2900       A          K UNOVEL                                                         03/05/08
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Simon Coulter
Sent: Tuesday, March 04, 2008 7:50 PM
To: Midrange Systems Technical Discussion
Subject: Re: Join Logical file using the same physical file twice
On 05/03/2008, at 4:12 AM, Mike Cunningham wrote:
I have a need to join two files as if they were three. We have an
employee file that has an employee ID and an employees supervisors
smeployee ID. We have a second file that is part of our menu system
that has an employees employee id and their system userid and e-
mail address. I want to create a single join file that has the
employee's userid and e-mail and the supervisors userid and e-mail.
I can't do this
R EMFLE                     JFILE(UTPUNAME LWPEMFLE UTPUNAME)
J                           JOIN(1 2)
                             JFLD(USS# LWPCTID)
J                           JOIN(2 3)
                             JFLD(LWEMPS USS#)
The create fails saying there are two many "J" specs. Acts like the
second UTPUNAME is being ignored.
Don't know why you got this error. DDS LF supports joining a file to
itself. See below.
So I tried creating an alias pointing to UTPUNAME named UTAUNAME
and tried this..
R EMFLE                     JFILE(UTPUNAME LWPEMFLE UTAUNAME)
 J                           JOIN(1 2)
                             JFLD(USS# LWPCTID)
  J                           JOIN(2 3)
                              JFLD(LWEMPS USS#)
This create failed because it said DDM file UTAUNAME could not be
accessed at remote location *LOCAL. We do have a *LOCAL defined
under WRKRDBDIRE that net.data needed that points to the local
system name. (Interesting that the SQL CREATE ALIAS used DDM files).
Can anyone offer any suggestions on how to fix the DDM issue or how
to setup the kind of join I want to create?
Don't know about the DDM issue. I consider that the wrong approach.
Either do the join in DDS, do the join in a VIEW, or do the join in
the SELECT statement.
p.s. The app that needs this is doing a JDBC connection from a PC
and using SQL commands to access the data and could do two SELECT
commands but I would prefer to keep the logic for how this join is
defined and the fields it contains and what the application sees on
the iSeries side and not in the PC application.
You could create a VIEW as others have shown. You could specify the
join directly on the SELECT statement from the client (you do NOT
need two SELECT statements). You could get the join correct in the
DDS. Actually, I don't like any of these approaches because you are
giving the JDBC client direct access to your database. I consider
that a wrong approach and limiting clients to calling stored
procedures is a better approach.
Anyway, just to prove it can be done:
MIKE_EMP1:
*************** Beginning of data
**********************************************
                                            UNIQUE
                R EMPFMT1
                  EMPID          5P 0
                  SVSRID         5P 0
                K EMPID
****************** End of data
*************************************************
MIKE_EMP2:
*************** Beginning of data
**********************************************
                                            UNIQUE
                R EMPFMT2
                  EMPID          5P 0
                  EMPUSRPRF     10A
                  EMPEMAIL      30A
                K EMPID
****************** End of data
*************************************************
runqry *n mike_emp1
  Line   ....+....1....+.
          EMPID   SVSRID
  000001      1        2
  000002      2        3
  000003      3        0
  ****** ********  End of report  ********
runqry *n mike_emp2
Line   ....+....1....+....2....+....3....+....4....
         EMPID   EMPUSRPRF   EMPEMAIL
000001      1   FREDNURK    fred.nurk@xxxxxxxxxxx
000002      2   JOEBLOW     joe.blow@xxxxxxxxxxx
000003      3   BOSS        boss@xxxxxxxxxxx
****** ********  End of report  ********
MIKE_EMPLF
*************** Beginning of data
**********************************************
                                             JDFTVAL
                 R EMPFMT3                   JFILE(MIKE_EMP1
MIKE_EMP2 MIKE_EMP2)
                 J                           JOIN(1 2)
                                             JFLD(EMPID EMPID )
                 J                           JOIN(1 3)
                                             JFLD(SVSRID EMPID)
       *           EMPID                     JREF(1)
       *                                     COLHDG('EMPLOYEE' 'ID')
                   EMPUSRPRF                 JREF(2)
                                             COLHDG('EMPLOYEE'
'PROFILE')
                   EMPEMAIL                  JREF(2)
                                             COLHDG('EMPLOYEE' 'E-MAIL')
       *           SVSRID                    JREF(1)
       *                                     COLHDG('SUPERVISOR' 'ID')
                   SVSRUSRPRF                RENAME(EMPUSRPRF) JREF(3)
                                             COLHDG('SUPERVISOR'
'PROFILE')
                   SVSREMAIL                 RENAME(EMPEMAIL) JREF(3)
                                             COLHDG('SUPERVISOR' 'E-
MAIL')
****************** End of data
*************************************************
runqry *n mike_emplf
Line   ....+....1....+....2....+....3....+....4....+....5....+....
6....+....7....+.
        EMPLOYEE    EMPLOYEE                        SUPERVISOR
SUPERVISOR
        PROFILE     E-MAIL                          PROFILE     E-MAIL
000001 FREDNURK    fred.nurk@xxxxxxxxxxx           JOEBLOW
joe.blow@xxxxxxxxxxx
000002 JOEBLOW     joe.blow@xxxxxxxxxxx            BOSS
boss@xxxxxxxxxxx
000003 BOSS        boss@xxxxxxxxxxx
****** ********  End of report  ********
Taa daa! This appears to satisfy your requirements:
"I want to create a single join file that has the employee's userid
and e-mail and the supervisors userid and e-mail."
FREDNURK reports to JOWBLOW. JOEBLOW reports to BOSS. BOSS reports
to ... well no-one really ...
Regards,
Simon Coulter.
--------------------------------------------------------------------
    FlyByNight Software         OS/400, i5/OS Technical Specialists
    
http://www.flybynight.com.au/
    Phone: +61 2 6657 8251   Mobile: +61 0411 091 400        /"\
    Fax:   +61 2 6657 8251                                   \ /
                                                              X
                  ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: 
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at 
http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.