I'm doing the following looping (not all the code is here). The looping is working except when I try to create a graph and there is no data to graph. I display -TYPE &NOGRAPH; -TYPE &CLOSEPDF; -TYPE &RECORDS; and the values are (nograph) Y (closepdf) Y and (records=) 0. So, when I do my check of -IF &RECORDS EQ 0 GOTO EMPTYRPT; it should go to emptyrpt but it's not going there. It's falling down into the code immediately below the if. If I only do 1 account that has no data it goes correctly to the emptyrpt. What am I doing wrong? Thanks.
-SET &COUNT = 1; -REPEAT PDFLOOP WHILE &COUNT LE &NOOFACCTS; SET PAGE-NUM=NOPAGE
-* CHECK THAT PERCENTAGE IS GE 1 SO THAT ONLY ITEMS ON GRAPH APPEAR IN LEGEND SET LOOKGRAPH=PIE SET 3D=OFF GRAPH FILE HOLD220 SUM PCT_MKT_VL AS "" BY SEC_GRP_NM WHERE MKT_VL IS-NOT MISSING AND MKT_VL GT 0 AND PCT_MKT_VL GE 1 WHERE SORTORDER EQ &COUNT ON GRAPH SET VAXIS 4 ON GRAPH SET HAXIS 6 ON GRAPH SET GRAPHSTYLE * setFillColor(getSeries(0),new Color(0,0,255)); blue ENDSTYLE ON GRAPH SAVE AS ALLOC&COUNT FORMAT SVG END
-* CHECK TO SEE IF A GRAPH WAS CREATED -RUN -SET &NOGRAPH=IF &RECORDS EQ 0 THEN ‘Y’ ELSE ‘N’; -SET &CLOSEPDF=IF &RECORDS EQ 0 AND &COUNT EQ &NOOFACCTS THEN 'Y' ELSE 'N'; -SET &TITLE2 = IF &RECORDS EQ 0 THEN 'No Data Available For This Account' ELSE - '-TYPE &NOGRAPH; -TYPE &CLOSEPDF; -TYPE &RECORDS;
-IF &RECORDS EQ 0 GOTO EMPTYRPT; -* THE BELOW IS MODIFIED CODE TO GIVE THE IDEA OF WHAT I'M DOING. TABLE FILE HOLD200 PRINT ACCOUNTID -* CHECK IF IT'S THE LAST RECORD AND IF THERE IS NO GRAPH AND CLOSE -* PDF FILE IF IT IS -IF &COUNT GE &NOOFACCTS THEN GOTO CLOSEPDF; ON TABLE PCHOLD FORMAT PDF -GOTO PDFEND2 -CLOSEPDF ON TABLE PCHOLD FORMAT PDF CLOSE -PDFEND2 END
-EMPTYRPT TABLE FILE HOLD200 PRINT ACCOUNTID HEADING "No Data to display" -* CHECK IF IT'S THE LAST RECORD AND IF THERE IS NO GRAPH AND CLOSE -* PDF FILE IF IT IS -IF &COUNT GE &NOOFACCTS THEN GOTO CLOSEPDF2; ON TABLE PCHOLD FORMAT PDF -GOTO PDFEND -CLOSEPDF2 ON TABLE PCHOLD FORMAT PDF CLOSE -PDFEND END
1. I don't see the -PDFLOOP label in your posted code.
quote:
-* CHECK TO SEE IF A GRAPH WAS CREATED -RUN -SET &NOGRAPH=IF &RECORDS EQ 0 THEN ‘Y’ ELSE ‘N’; ... -SET &TITLE2 = IF &RECORDS EQ 0 THEN 'No Data Available For This Account' ELSE - '-TYPE &NOGRAPH; ... -IF &RECORDS EQ 0 GOTO EMPTYRPT;
2. If there is any code whatsovever between the -RUN and the -IF &RECORDS (or &LINES) test, best practice is to set your own &var (such as your &NOGRAPH) and test that.
3. "-SET &TITLE2" has unbalanced quotes. Perhaps there's something interesting between the lines.
4. &RECORDS can give false positives if you have IF TOTAL tests; use &LINES instead.
May 10, 2006, 02:43 PM
Pam Kratt
I changed to use the following code after the graph: -RUN -SET &NOGRAPH=IF &LINES EQ 0 THEN ‘Y’ ELSE ‘N’; -SET &CLOSEPDF=IF &LINES EQ 0 AND &COUNT EQ &NOOFACCTS THEN 'Y' ELSE 'N';
I'm noticing the following are the results of my -type ... do you know why I would get ? around the Y? I think that may be problem. The ?y? is the result for &NOGRAPH.
agreed. use &LINES and save it IMMEDIATELY after your extract.
ON GRAPH SAVE AS ALLOC&COUNT FORMAT SVG
END
-RUN
-SET &HOWMANY = &LINES;
..now go ahead and type and check whatever you like. these &LINES vars get reset to 0 very easily, so make sure you grab it immediately. as for the ?, in the code you copied, the marks around the Y and N in the first SET look different from the marks around the Y and N in the second SET; If your surround your code snippet with the code tags, we can see it better.This message has been edited. Last edited by: susannah,
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
May 10, 2006, 03:00 PM
Pam Kratt
the problem ended up being the quotes. The code must have been copied and they were not normal quotes on the set &nograph. Once I fixed the quotes the if statements appear to be working. More testing is needed but I think I have it. Thanks for the many helpful hints ... I didn't know that about &lines vs &records so that was helpful too.