Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Joined Logical File

Status
Not open for further replies.

USADarts

Programmer
Dec 20, 2004
21
US
Is there a way to sort a joined logical file from a field that is in the 2nd file of the JFILE command? What I need to do is sort the below by the EHCREATDTE field.

R JOINREC TEXT('EDI XREF FILE')
JFILE(EX_850DTL EX_850HDR)
J JOIN(1 2)
JFLD(EDARNO EHARNO)
JFLD(EDBEG03 EHBEG03)
EDARNO
EDSKU
EDUPC
EDSTCO#
EDSTCUST
EDSTSTYL
EDSTCOLR
EDSTPLNT
EDSIZE
EDPRICE
EHCREATDTE
K EDARNO
K EDSKU
 
No. The keys fields must come from the primary (first) file only. Key fields can not come from any secondary file. To sort by EHCREATDTE, you would need to swap the files putting EX_850HDR as the primary and EX_850DTL as the secondary.

Here's a link that desribes the key fields:

 
Thanks for the info, but that will not work for me. I need the EDARNO and EDSKU to be the main keys for the joined logical file.

Any suggestions? Should I just do an OPNQRYF?
 
I'd try to avoid the joined logical and OPNQRYF like pleague and use SQL JOIN instead.

Code:
CREATE TABLE QTEMP/MYTABLE AS 
( SELECT a.EDARNO, ..., a.EDPRICE, b.EHCREATDTE
FROM EX_850DTL a JOIN EX_850HDR b 
ON a.EDARNO = b.EHARNO 
AND a.EDBEG03 = b.EHBEG03
ORDER BY a.EDRANO, a.EDSKU, b.EHCREATDTE )
WITH DATA

Then I'd use the newly created table in QTEMP lib.
 
You could use OPNQRYF to do that. I have not used it this way, but according to the InfoCenter, it ought to work.

Solum potestis prohibere ignes silvarum.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top