
September 2004
The LawsonGuru Letter is a free periodic newsletter containing provocative commentary about       issues important to the Lawson Software community.  The LawsonGuru Letter is published by-and       is solely the opinion of-John Henley of Decision Analytics.  Visit Decision Analytics at       https://www.danalytics.com.  For subscription       information, see the bottom of this message.
The LawsonGuru Letter is not affiliated with Lawson Software.
            
                
                    
                          | 
                        With the upcoming Labor Day holiday, many of you will either be on vacation or otherwise enjoying (hopefully!) some time off.  I had a great issue all ready to go, but decided to save it until next month.  In the meantime, enjoy these tips & tricks, and I'll be back next month with a great new issue!
                         Remember to share your tips. Send them to mailto:letter-tips@lawsonguru.com. 
                         | 
                    
                
            
            In this issue: 
            Tip 1: Tuning Lawson CACHE Settings
            Tip 2: Use 'nohup' for your Lawson Admin Tasks
            Tip 3: Calling Operating System Commands from COBOL
            Tip 4: Compile Queue Tricks
            Tip 5: Find out which programs use a particular library (pdlib)
            Tip 6: Creating .log files to Troubleshoot IOS CGI Programs
            
            Tip 1: Tuning Lawson CACHE Settings 
            
            One often-overlooked Lawson feature on Unix/NT is the use of CACHE settings for batch programs. Lawson's caching allows a job to "stash" recently-read records in memory, thereby eliminating redundant calls to the database. Of course, it's important to balance the use of caches-use them judiciously, but don't overuse them. For example, 
            it may be wise to cache 5 records for GLSYSTEM and 50 records for GLCHARTDTL, but it would be counter-productive to cache the entire GLCHARTDTL table.
            
            Here are some tips on using caches to reduce the runtime of your batch programs.
            
            Caching *only* works when the Lawson program does a direct read (e.g. 840-FIND-xxxSETn) on a table. It does nothing for sequential reads.  It does nothing for range-based (i.e. "cursor") reads (e.g. 850-FIND-BEGRNG-xxxSETn/860-FIND-NXTRNG-xxxSETn).
            
            To effectively use caching, you REALLY need to understand the ENTIRE COBOL program, including tables referenced in library (pdlib) routines.  Do a 'bldsh' of the program and read through the entire .cbl program to find the hot-spots. 
            
            You don't have to recompile; just put the <program>.cfg into the appropriate xxsrc directory, e.g., PR560.cfg goes into the $LAWDIR/<prodline>prsrc/ directory (or %LAWDIR%/<prodline>prsrc/ for NT/W2K systems).
            
            Entering CACHE <filename> -1 caches the entire table.
            
            When the job completes, check /tmp/xxxxx.stats and review the statistics.
            
            Here's a sample for PR560.cfg: 
            CACHE BANKFILE 100
            CACHE DEDCODE 1000
            CACHE DEPTCODE 100
            CACHE EMPLOYEE 10
            CACHE PAYCODE 100
            CACHE PRSTATE 52
            CACHE PSGRELATE 100
            CACHE TAXGROUP 100
            CACHESTATS TRUE
            STATSFILE /tmp/PR560.stats
            
            Here's a sample for GL165.cfg: 
            CACHE GLCHART 10
            CACHE GLINTCO 30
            CACHE GLSYSTEM 10
            CACHESTATS TRUE
            STATSFILE /tmp/gl165.stats
            
            For additional details, see the "Performance Tuning" section of the Lawson Administration Guide.
            
            Tip 2: Use 'nohup' for your Lawson Admin Tasks
            If you're running a Unix/NT version of Lawson, you can use the 'nohup' command to make your admin tasks a little easier. If you've ever had to fight a noisy phone line during a remote dbreorg, you'll appreciate this command:
            
            nohup dbreorg productline > dbreorg.log 2>&1 &
            
            - The nohup tells command processor to ignore hangup signals (SIGHUP)
            - The first redirection ">" captures Unix stdout to log file
            - The second (2>&1) captures stderr (which catches Lawson error messages)
            - The final & tells command processor to run detached (i.e. background). 
            
            If you log out or are disconnected from your current session, the command will continue to run, and you can periodically check dbreorg.log. 
            
            If you log out and have nohup'ed jobs running when you logout, you will be warned "You have jobs running". Simply logout again, and your background jobs will continue to run.
            
            You can also use this technique for impexp, expsysdb, etc.
            
            Tip 3: Calling Operating System Commands from COBOL
            If you're running Unix or NT, here's how to call an operating system command from inside a Lawson COBOL program (this is an example to move a file):
            
            Put something like this in your WS:
            
            02 WS-CMD-MOVE-REPLACE.
               03     FILLER       PIC X(06) VALUE "sh -c ".
               03     FILLER       PIC X(01) VALUE x"22".
               03     FILLER       PIC X(03) VALUE "mv ".
               03     WS-FROM-FILE PIC X(50) VALUE SPACES.
               03     FILLER       PIC X(01) VALUE SPACES.
               03     WS-TO-FILE   PIC X(50) VALUE SPACES.
               03     FILLER       PIC X(01) VALUE x"22".
               03     FILLER       PIC X(01) VALUE x"00".
            
            And this in your PD:
            
                MOVE "File1"     TO WS-FROM-FILE.
                MOVE "File2"     TO WS-TO-FILE.
                CALL "system" USING WS-CMD-MOVE-REPLACE.
            
            If you're running NT, remember that you're actually calling the MKS toolkit, so you'll need to use Unix-style commands.
            
            Tip 4: Compile Queue Tricks
            When doing a "cobcmp" mass-compile, you probably know that you can control the number of simultaneously program compiles by using the qcontrol command, e.g. to compile 4 programs at a time:
            
            $ qcontrol -jlocal,4 
            
            You can also set a default for this by creating/editing $LAWDIR/system/queue.cfg (%LAWDIR%/system/queue.cfg on W2K), and adding a single-line entry:
            local 4
            
            The next time the compile queue is started (stopqueue/startqueue on Unix; Stop/Start Lawson Services on W2K), this default will be used henceforth. A maximum of 50 programs may be compiled at a time. 
            
            To temporarily disable the compile queue, use (programs currently compiling will finish):
            
            $ qcontrol -jlocal,0 
            
            To re-enable it, use:
            
            $ qcontrol -jlocal,4
            
            Tip 5: Find out which programs use a particular library (pdlib)
            Need to find out which programs use a particular library (pdlib)?
            
            Do rngdbdump on dictionary "GEN", filename "PGMLIB", option "-k" (along with the product line and library name, both in UPPERCASE), and the PLBSET2 index. Example (enter the command all on one line): 
            
            $ rngdbdump -nt -iPLBSET2 gen pgmlib -f programcode -k PROD PRCHKPD | sort | uniq | lashow
            
            Again, make sure you enter the product line and library name in UPPERCASE.
            
            To see the syntax for the rngdbdump command, type "rngdbdump" at a command prompt and hit enter. Note: If you're using the Lawson Environment 7.3.3 or higher, you'll may need to turn off Lawson security to use rngdbdump and importdb with GEN.
            
            Tip 6: Creating .log files to Troubleshoot IOS CGI Programs
            
            If you need to troubleshoot the behavior of a particular Logan/IOS CGI program, you can try turning on logging for that program.   A "touch" file can be created in the Lawson for the particular CGI program. For example, to log messages related to the dme CGI program, create an empty file called dme.log. 
            
            After you've finished troubleshooting, be sure to delete the .log file. 
            
            According to the Lawson knowledge base, the following cgi programs are coded to write to ".log" files if one exists: 
            
            ags.exe 
            authen.exe 
            chgfile.exe 
            dme.exe 
            formdef.exe 
            jobrun.exe 
            userdocs.exe 
            webrpt.exe
            
            The LawsonGuru Letter is a free periodic newsletter providing provocative commentary on issues important to the Lawson Software community. The LawsonGuru Letter is published by--and is solely the opinion of--John Henley of Decision Analytics. Visit Decision Analytics at 
https://www.danalytics.com. 
            
            
To subscribe, visit https://www.danalytics.com/guru/letter/ 
            © Copyright 2004, Decision Analytics. All rights reserved.   Please share The LawsonGuru Letter in whole or in part as long as copyright and attribution are always included. 
            Decision Analytics is an independent consultancy, focusing on Lawson technical projects, and specializing in customization/modification, data conversion, and integration/interfaces.  Please visit 
https://www.danalytics.com for more information. 
            Decision Analytics. Integrating Lawson with the Real World.