LECTURE
Description
This action is called when a search is launched, that is to say at the launch of the function, when it is paged or when the criteria are changed. This action is indispensable to load the enquiry screen with all the selected records.
Template
Inquiry
Use
It is indispensable and serves to load the enquiry screen with all the selected records. The "FILTRE" action is called in order that the specific/custom may insert a selection filter if required. This action will be written to the template shown below (extract from the quote enquiry). That which is specific to this example is written in no bold characters.
$LECTURE
#-- mandatory criteria (optional section)
If [M:CSQ1]CPY="" & [M:CSQ1]SALFCY="": NBLU=0 : Return
Endif
Gosub CHANGE_MSK From GCONSULT
If CHGPAG<0 : NOL = MAXLIG : Endif
#-- Setting of the filters
Gosub LOAD_FILTER
#-- only in the standard processes : call to the specific/custom
If PROGSPE<>""
ACTION = "FILTRE" : Gosub ACTION From =PROGSPE
Endif
#-- Application of the filters and the sorts to the records
If CHGPAG > 0
SUITE=1
If CHGPAG = 1 : RETOUR = 1 : Elsif CHGPAG = 2 : RETOUR = 2 : Endif
Case [M:CCSQ]TRI
When 1 : #sort by number
Filter [SQH] Where evalue(WFIL) & evalue(WFIL1) & evalue(WFIL2) Order By Key SQH0
When 2 : # sort by date
Filter [SQH] Where evalue(WFIL) & evalue(WFIL1) & evalue(WFIL2)
& Order By Key CLE=[F:SQH]QUODAT;[F:SQH]SQHNUM
Endcase
Else
RETOUR=1
If CHGPAG = -1 : SUITE = 1 : Else SUITE = 2 : Endif
Case [M:CCSQ]TRI
When 1 : #sort by number
Filter [SQH] Where evalue(WFIL) & evalue(WFIL1) & evalue(WFIL2) Order By Key SQH0Desc
When 2 : # sort by date
Filter [SQH] Where evalue(WFIL) & evalue(WFIL1) & evalue(WFIL2)
& Order By [F:SQH]QUODAT Desc ;[F:SQH]SQHNUM Desc
Endcase
Endif
#-- raz of the mask if the first or last page
If CHGPAG<>2 & CHGPAG<>-2 : Raz [M:CSQ2] : Endif
#-- read loop
$BOUCLE
For [SQH]
#-- Additional filter (optional section)
If [M:CSQ1]CPY <> ""
If [F:FCY]FCY <> [F:SQH]SALFCY
Read [F:FCY]FCY0 = [F:SQH]SALFCY
If fstat Raz [F:FCY] : Endif
Endif
If [F:FCY]LEGCPY <> [M:CSQ1]CPY Goto SUIV : Endif
Endif
If NBLU = 1
If CHGPAG=2 | CHGPAG=-2 : Raz [M:CSQ2] : Endif
NBLU = 2
Endif
#-- storage of the start and end range for the record on the screen
If CHGPAG > 0
If NOL >= MAXLIG-1 : SUITE=2 : Break: Endif
NOL += 1
If NOL=0
DEBNUM = [F:SQH]SQHNUM
DEBDAT = [F:SQH]QUODAT
Endif
FINNUM = [F:SQH]SQHNUM
FINDAT = [F:SQH]QUODAT
Else
If NOL <= 0 : RETOUR=2 : Break: Endif
NOL -= 1
If NOL=MAXLIG-1
FINNUM = [F:SQH]SQHNUM
FINDAT = [F:SQH]QUODAT
Endif
DEBNUM = [F:SQH]SQHNUM
DEBDAT = [F:SQH]QUODAT
Endif
#-- loading of the mask
nolign = NOL+1
[M:CSQ2]SQHNUM(nolign-1) = [F:SQH]SQHNUM
[M:CSQ2]BPCORD(nolign-1) = [F:SQH]BPCORD
[M:CSQ2]QUODAT(nolign-1) = [F:SQH]QUODAT
[M:CSQ2]VLYDAT(nolign-1) = [F:SQH]VLYDAT
[M:CSQ2]QUOSTA(nolign-1) = [F:SQH]QUOSTA
[M:CSQ2]QUONOT(nolign-1) = [F:SQH]QUONOT
[M:CSQ2]QUOATI(nolign-1) = [F:SQH]QUOATI
[M:CSQ2]CUR(nolign-1) = [F:SQH]CUR
...
$SUIV
Next
Filter [SQH]
Return
#--- Preparation of the filter #
$LOAD_FILTER
WFIL = "1=1"
WFIL1 = "1=1"
WFIL2 = "1=1"
If [M:CSQ1]SALFCY <> ""
WFIL += "&[F:SQH]SALFCY=[M:CSQ1]SALFCY"
Endif
...
Case CHGPAG
When 3 : # refresh
Case [M:CCSQ]TRI
When 1 : # sort by number
WFIL1 += "&[F:SQH]SQHNUM>=DEBNUM"
When 2 : # sort by date
WFIL1 += "&([F:SQH]QUODAT>DEBDAT | ([F:SQH]QUODAT=DEBDAT & [F:SQH]SQHNUM>=DEBNUM))"
Endcase
When 2 : # next
Case [M:CCSQ]TRI
When 1 : # sort by number
WFIL1 += "&[F:SQH]SQHNUM>FINNUM"
When 2 : # sort by date
WFIL1 += "&([F:SQH]QUODAT>FINDAT | ([F:SQH]QUODAT=FINDAT & [F:SQH]SQHNUM>FINNUM))"
Endcase
When -2 : # return
Case [M:CCSQ]TRI
When 1 : # sort by number
WFIL1 += "&[F:SQH]SQHNUM<DEBNUM"
When 2 : # sort by date
WFIL1 += "& ([F:SQH]QUODAT<DEBDAT | ([F:SQH]QUODAT=DEBDAT & [F:SQH]SQHNUM<DEBNUM))"
Endcase
Endcase
Return
The available variables in read are as follows :
CHGPAG : identify the action that triggers the read
1 < Search>
2 < Next >
3 < Refresh >
- 1 < Last >
- 2 < Return >
MAXLIG : maximum number of lines in the grid.
The available variables in update are as follows :
NBLU : number of records to display.
NOL : fill index for the grid
Increment if CHGPAG > 0
Decrement if CHGPAG < 0
SUITE : used to de-activate the < Next > and < Last > buttons
RETOUR : used to de-activate the < Return > button