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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CLP - opnqry statement

Status
Not open for further replies.

jmd0252

Programmer
May 15, 2003
667
0
0
DCL VAR(&DIVN) TYPE(*CHAR) LEN(3)
DCL VAR(&TYPE) TYPE(*CHAR) LEN(1)
SNDUSRMSG MSG('ENTER DIVISION NUMBER ') +
TOMSGQ(*) MSGTYPE(*INQ) MSGRPY(&DIVN)
SNDUSRMSG MSG('ENTER P FOR PLANT REPORT - H FOR HAULER')
TOMSGQ(*) MSGTYPE(*INQ) MSGRPY(&TYPE)
CHGDTAARA DTAARA(*LDA (1 3)) VALUE(&DIVN)
CHGDTAARA DTAARA(*LDA (4 1)) VALUE(&TYPE)


OVRDBF FILE(TE604) TOFILE(EXLIB/TE604) SHARE(*YES)

OPNQRYF FILE((TE604)) OPTION(*INP) +
QRYSLT('DIVN04 *EQ "*LDA(1 3)" ') +
KEYFLD((DIVN04) (JOB#04) (CUST04) (DATE04)) +
OPTIMIZE(*MINWAIT)


ok here is the cl code,,,, I want the user to be able to enter a division number 3 long,, and have the opnqryf work so that only those that division number is sorted,,, this is with the LDA,, I have also had the variable in quotes,, and I get the same thing,,, of no records are selected,,, yes there are,,, I can do a wrkqry,,, look at the file, and see entries for that divison.. so how dead is my brain on a friday afternnon,, before a 3 day holiday??
 
jmd0252,

Take a look at the following CL. It takes info from the LDA and tucks it into variables then (with CAREFUL use of 's and *CAT) peices together the query select statement.

Code:
PGM                                                                 
                                                                    
DCLF       FILE(COMPANY)                                            
DCL        VAR(&DATE) TYPE(*CHAR) LEN(6)                            
DCL        VAR(&MO) TYPE(*CHAR) LEN(2)                              
DCL        VAR(&CY) TYPE(*CHAR) LEN(2)                              
DCL        VAR(&YR) TYPE(*CHAR) LEN(2)                              
DCL        VAR(&QRYSEL) TYPE(*CHAR) LEN(512)                        

                                                                    
RCVF                                                                
                                                                    
RTVDTAARA  DTAARA(*LDA (500 2)) RTNVAR(&MO)                         
RTVDTAARA  DTAARA(*LDA (502 2)) RTNVAR(&CY)                         
RTVDTAARA  DTAARA(*LDA (504 2)) RTNVAR(&YR)                         
                                                                    
CHGVAR     VAR(&QRYSEL) VALUE(' +                                   
           (ACPRMO *EQ ' *CAT &MO *CAT ' +                          
            *AND ACPRCY *EQ ' *CAT &CY *CAT ' +                     
            *AND ACPRYR *EQ ' *CAT &YR *CAT ' +                     
            *AND ACACCT *EQ 40291) +                                
            *OR +                                                   
                         (ACPRMO *EQ ' *CAT &MO *CAT ' +              
                          *AND ACPRCY *EQ ' *CAT &CY *CAT ' +         
                          *AND ACPRYR *EQ ' *CAT &YR *CAT ' +         
                          *AND ACACCT *EQ 24040)')                    
                                                                      
              CLRPFM     FILE(ACP030)                                 
                                                                      
              OVRDBF     FILE(ACCTRNHS) TOFILE(ACCTRNHS) SHARE(*YES)  
              OPNQRYF    FILE((ACCTRNHS)) +                           
                         QRYSLT(&QRYSEL) +                            
                         KEYFLD((ACPRCY) (ACPRYR) (ACPRMO) (ACPRDA) + 
                                (ACACCT) (ACPOL#) (ACPAY#))           
                                                                      
              CALL       PGM(ACB030)                                  
                                                                      
              DLTOVR     FILE(*ALL)                                   
              CLOF       OPNID(ACCTRNHS)

HTH,
MdnghtPgmr
 
Your problem is your CL is searching for the actual constant of '*LDA(1 3)' What you want is more like this

('DIVN04 *EQ "' + *LDA(1 3) + '"') or even
('DIVN04 *EQ "' + &DIVN + '"')

The reason is that anything inside quotes is treated as a constant. And, as suggested, its MUCH easier to create the query select as a variable. Much easier to debug, also.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top