× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



1 - If you are not passing in itemnum as a parameter, then yes, take it 
out of the prototypes.  In fact, with no parameters you can probably drop 
the prototypes.
2 - On your confusion, you dropped the cursor and used a single select 
statement.  Good.  However you left some old cursor logic in there.  For 
example, this is an infinite loop:
             dow SQLSTT = '00000';
               except detail;
             enddo;
Change it to something like
         If SQLSTT = '00000';
           except detail;
         Else;
           NotFound=*on;
         enddo;

3 - What are you doing with PgmNam?  If you are planning on adding this to 
your report heading that is a good idea.  However, never hardcode this. 
Check the RPGLE manuals for "program status data structure" and get the 
program name from that.  The problem is that if you copy this code you'll 
still have the program name of the original program in there.  Or at least 
have the potential for that.  There's lots of other cool stuff in the PSDS 
you can put on the report headings.  Like who ran the report.
4 - What will happen to your page headings when you reach end of page? 
Search also for "file information data structure".  Look for two fields in 
that data structure.  Overflow line and current line.  Except another 
heading when one approaches the other.  There's something else called the 
"fetch overflow" concept but coming from your background you'd probably 
appreciate the INFDS better.

"Back in the day" we had our heading line start at line 3 and not 1.  Made 
it easier for operators to line up green bar paper in printers.  However 
we've not purchased stock continuous bar paper in over a decade.  Don't 
know if that is a concern where you are at.

I've interspersed a lot of comments in your code.

By the way, good work using named indicators on the screen.

Look more at this:
       // run the set option once and forget about it.  Take out of loop
       // it would only run once anyway, but why confuse the eyeball
       // reading of the loop logic?
     C/EXEC SQL
     C+ Set Option
     C+     Naming    = *Sys,
     C+     Commit    = *None,
     C+     UsrPrf    = *User,
     C+     DynUsrPrf = *User,
     C+     Datfmt    = *iso,
     C+     CloSqlCsr = *EndMod,
     C+     Commit    = *NONE
     C/END-EXEC

      /FREE
       PgmNam = 'ITEMINQSQL';  // get this from the psds instead
       except heading;  // I moved initial headings outside of the loop.
                        // Unless if they input NO item's you don't want 
any report.
                        // Then we often use a flag like this logic right 
before your 
                        // except detail
                           if not HeadingDone;
                             except heading;
                             HeadingDone=*on;
                           EndIf;
                        // or better yet
                           if not HeadingDone or
                              infds.CurrentLine>=infds.OverflowLine
                             except heading;
                             HeadingDone=*on;
                           EndIf;
       Exfmt Prompt;
       Dow NOT Exit or Cancel;  // Don't they really mean the same thing?
      /END-FREE


     c/exec sql
     c+ select ITMNBR, ITMDESCR into :myDS from
     c+ testing/item_pf where itmnbr=:itemnum
     c/end-exec

      /FREE
         Dow NOT Cancel;  // Display details  // delete this line
          // blast the "Dow NOT Cancel" loop.  You already have an exfmt 
loop.  Use it.
         If SQLSTT = '00000';
           except detail;
         Else;
           NotFound=*on;
         enddo;

               If Exit;  // this If is redundant
                  // you already have it on the initial dow loop.
                  *InLR = *ON;  // trash line - redundant
                  Return;  // trash line.  Your loop control will handle.
               Endif;
         Enddo;  // delete this line

         // No Item record found or F12 pressed - display prompt  // trash 
line
         Cancel = *Off;  // trash line
         NotFound = *on;  // trash line
         Exfmt Prompt;
       Enddo;  // F3 Exit or F12 Cancel
       *InLR = *ON;
      /END-FREE


Rob Berendt

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.