I am working on a custom report that prompts the user for a range of locations, range of departments, allows the user to enter a list of "Hot" parts, a range of dates, etc.
My prblem is that if the user blanks the parts list parameter out, I would like the report to find all the parts matching the other criteria and ignore the part criteria. If the parts parameter is populated, I perform a lookup based on those values. I store the list in a temporary work table which I base a lookup on in the WHERE clause.
I am having problems with the logic to make the part work if the parts parameter is blank. I still get only the parts in the hot list.
The part in red works fine for the lookup when the parts list parameter is populated, but I need to add logic to find all parts if the parameter is blank.
Here is what I have so far:
My prblem is that if the user blanks the parts list parameter out, I would like the report to find all the parts matching the other criteria and ignore the part criteria. If the parts parameter is populated, I perform a lookup based on those values. I store the list in a temporary work table which I base a lookup on in the WHERE clause.
I am having problems with the logic to make the part work if the parts parameter is blank. I still get only the parts in the hot list.
The part in red works fine for the lookup when the parts list parameter is populated, but I need to add logic to find all parts if the parameter is blank.
Here is what I have so far:
Code:
FORM
loc COLON 20 loc1 COLON 45 LABEL {t001.i}
dept COLON 20 dept1 COLON 45 LABEL {t001.i}
SKIP
upartlist VIEW-AS EDITOR SIZE 50 BY 3
COLON 20 label "Part List"
SKIP
" Separate parts with a comma"
SKIP
ly-n COLON 20 label "Update List"
edate COLON 20 edate1 COLON 45 LABEL {t001.i}
SKIP(1)
excelfile colon 20 label "Excel Output File"
SKIP (1)
SPACE (10)
"NOTE: If Excel Ouput field is not blank then an Excel input file"
SKIP SPACE (10)
" will be created."
SKIP (1)
WITH FRAME A SIDE-LABELS WIDTH 80.
find usrw_wkfl where usrw_key1 eq "YIELDREPORT"
and usrw_key2 eq "CORE" NO-ERROR.
if not avail usrw_wkfl then
do: create usrw_wkfl.
assign usrw_key1 = "YIELDREPORT"
usrw_key2 = "CORE".
end.
upartlist = usrw_charfld[1].
UPDATE
loc
loc1
dept
dept1
upartlist
ly-n
edate
edate1
excelfile
WITH FRAME a.
{mfselbpr.i "printer" 132}
{mfphead.i}
if ly-n then
ASSIGN usrw_charfld[1] = upartlist.
FOR EACH op_hist NO-LOCK WHERE op_site >= loc AND
op_site <= loc1 AND
op_date >= edate and
op_date <= edate1 and
[COLOR=red]lookup(op_part, usrw_charfld[1]) <> 0[/COLOR] and
op_dept >= dept and
op_dept <= dept1 and
op_type = "LABOR"
BREAK BY op_site BY op_dept BY op_part BY op_date: