rpg400-l-bounces@xxxxxxxxxxxx wrote on 02/24/2012 07:58:54 AM:
From: "Shannon ODonnell" <sodonnell@xxxxxxxxxxxxxxxxxxxxxxxxx>
To: "'RPG programming on the IBM i / System i'" <rpg400-l@xxxxxxxxxxxx>
Date: 02/24/2012 07:59 AM
Subject: RE: SST In Logical FIle with Select
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
OK, for all interested parties...I have an answer, of sorts...
Sorry it took so long to check this but it takes freakin' forever to
build
that access path each time! I guess I should have used an existing path
just for testing this but oh well...
Anyway...I got this to work by taking the first Select off of the LF:
A CODEV I SST(DOCODE 1 2)
A K RRAKCN
A K RRAKYR
A K RRAKTY
A K RRAKNO
A*** S STATUS COMP(NE 'X')
A S CODEV COMP(EQ 'EV')
I need that first select on there though so I guess I need to figure
out/read the manual would probably work :-) , how to AND those two
Selects.
Man, this has been a real challenge for me! I barely write any RPG code
any
more and DDS...forget it!
I'd forgotten how much I used to know!
Shannon,
To "AND" the select statements just remove the "S" from position 17 on the
"S CODEV COMP(EQ 'EV')" line.
The text from the DDS Reference Manual is below.
Best regards,
Mike Garrison
When using the select/omit fields, specify either S or O in position 17.
By specifying either S or O, the select and omit comparison statements are
ORed together. The system treats the ORed select and omit comparison
statements independently from one another. That is, if the select or omit
comparison condition is met, the record is either selected or omitted. If
the condition is not met, the system proceeds to the next comparison.
By specifying a blank in position 17, the select and omit comparison
statements are ANDed together. The combined comparisons must be met before
the record is selected or omitted. See Figure 13 and Figure 14. In
positions 19 through 28, specify a field name whose contents at processing
time determine whether the record is to be selected or omitted based on
the select/omit keyword specified for this field. The select/omit keywords
are COMP, RANGE, and VALUES. The last select/omit specification can be
made with the ALL keyword, but a field name is not permitted.
Figure 13 shows how to specify the select/omit field using ANDed select
statements.
Figure 13. Specifying the Select/Omit Field (Example 1)
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A R RECORD1 PFILE(PARTS)
00020A PNO
00030A DSC
00040A UPR
00050A QOH
00060A K PNO
00070A S UPR COMP(GT 5.00)
00080A QOH COMP(LT 10)
00090A O ALL
A
In Figure 13, records are selected only if they satisfy two select
statements: the first statement selects records in which the value of
field UPR is greater than 5.00, and the second statement selects records
in which the value of field QOH is less than 10. S is not specified in
position 17 for field QOH. Therefore, these select statements are ANDed
together. For a record to be read by a program, both conditions specified
must be true.
Figure 14 shows how to specify the select/omit field using an omit
statement ORed with two select statements ANDed together.
Figure 14. Specifying the Select/Omit Field (Example 2)
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A R RECORD1 PFILE(PARTS)
00020A PNO
00030A DSC
00040A UPR
00050A QOH
00060A K PNO
00070A O DSC COMP(EQ 'HAMMER')
00080A S UPR COMP(GT 5.00)
00090A QOH COMP(LT 10)
00100A O ALL
A
In Figure 14, records are supplied to the program if they pass both of the
following tests:
The DSC field is not equal to HAMMER.
The UPR field is greater than 5.00 and the QOH field is less than 10.
As an Amazon Associate we earn from qualifying purchases.