Inhoud blog
  • Original CL vs. ILE CL
  • Windows and Other Functions in iSeries Access PC5250
  • XML, Namespaces, and Expat
  • Quick Download of All Source Members to a PC
  • Retrieve Source Code of ILE CL
    Zoeken in blog

    Qmma developer network

    23-02-2007
    Klik hier om een link te hebben waarmee u dit artikel later terug kunt lezen.Double-Click a Green-Screen Field to Open a Browser

    Q: Open a browser when the user double-clicks an entry in my subfile! In the subfile record, there's an invoice number. When the user clicks that number, I want the browser to open and point to a document that contains the number.

    For example, if a subfile contains order number 1111111, I want it to open a browser to http://ourserver/invoiceviewer/viewer.php?inv=1111111. How can I do that?

    A: The previous article already explains how to open the browser, but there's still one part missing: How do you get your code to run when the user double-clicks your screen?

    In some 5250 clients (e.g., the PC5250 product that comes with iSeries Access), you can enable http links. Click Edit|Preferences|Hotspots and select Execute URL. Then, when the user double-clicks a string that starts with "http://", the page automatically opens in a browser. Unfortunately, that means that you have to include the entire URL on the screen, not just the invoice number.

    Perhaps a better solution is to use the Mouse Button (MOUBTN) DDS keyword to let your RPG program receive mouse events. With this option, you can use the technique that I presented in the previous tip to open a browser.

    In a recent post to the System iNetwork forums, Barbara Morris of IBM Toronto posted some sample code that presents a simple subfile in which the user can key text. When the text is double-clicked, a browser opens and searches Google for that text. It's just a simple proof-of-concept program, but I thought it was an interesting use of these techniques.

    For your invoice example, you'd have to adapt the program to display the invoice number and create a different URL (instead of Google). Otherwise, the same principle applies: Trap the mouse event with MOUBTN, use the screen coordinates to figure out the subfile record number, read the subfile to get the invoice number, and launch the browser with STRPCCMD.

    Here's the DDS for Barbara's subfile. As you can see, it's very bare-bones, just enough to demonstrate the technique:

         A          R SFL                       SFL
         A            FIELD1        10A  B 10 10
         A            FIELD2        10A  B 10 25
         A          R SFLCTL                    SFLCTL(SFL)
         A                                      MOUBTN(*ULD CF23)
         A                                      SFLCSRRRN(&RELRCD)
         A                                      RTNCSRLOC(&CSRRCD &CSRFLD)
          * Use CF23, not CA23, so any data changed by the user is
          * sent back to the program. When the subfile is
          * displayed again, it will have their updated values.
         A                                      CF23(23)
         A                                      SFLSIZ(100)
         A                                      SFLPAG(10)
         A  70                                  SFLDSP
         A  70                                  SFLDSPCTL
         A N70                                  SFLCLR
         A            RELRCD         5S 0H
         A            CSRFLD        10A  H
         A            CSRRCD        10A  H
         A                                  5 10'Subfile example'

    Here's the RPG code. For the sake of demonstration, it simply loads some letters and numbers — you can change the values of the fields when you run the program. Then, double-click the field that you want to search on, and the program opens a Google search on that field.

    If your 5250 emulator doesn't support mouse events, you can emulate the double-click by positioning your cursor in one of the fields and pressing F23.

         Fsubf      cf   e             workstn sfile(sfl:rrn)
         D rrn             s             10i 0
         D google          pr
         D   fld                         10a   const
          /free
              exsr loadSubfile;
              exsr showSubfile;
              *inlr = '1';
    
              begsr loadSubfile;
                 *in70 = '0';
                 write sflctl;
                 for rrn = 1 to 100;
                    field1 = %char(rrn);
                    field2 = %xlate('0123456789' : 'abcdefghij' : field1);
                    write sfl;
                 endfor;
              endsr;
    
              begsr showSubfile;
                 *in70 = '1';
                 exfmt sflctl;
                 dow *in23;
                    exsr handleDoubleclick;
                    exfmt sflctl;
                 enddo;
              endsr;
    
              begsr handleDoubleclick;
                 chain relrcd sfl;
                 if %found;
                    select;
                    when CSRFLD = 'FIELD1';
                       google(field1);
                    when CSRFLD = 'FIELD2';
                       google(field2);
                    endsl;
                 endif;
              endsr;
          /end-free
    
         P google          b
         D google          pi
         D   fld                         10a   const
         D url             s            500a   varying
         D cmd             s           1000a   varying
         D qcmdexc         pr                  extpgm('QCMDEXC')
         D   cmd                       1000a   const
         D   cmdlen                      15p 5 const
         D first           s              1n   static inz(*on)
          /free
             if (first);
                cmd = 'STRPCO';
                callp(e) qcmdexc(cmd: %len(cmd));
                first = *off;
             endif;
    
             // this probably isn't the correct way to build a google url ...
             url = 'http://www.google.com/search?q=' + fld;
             cmd = 'STRPCCMD PCCMD('rundll32 url,FileProtocolHandler '
                 + %trim(url) + ') PAUSE(*NO)';
             qcmdexc (cmd : %len(cmd));
          /end-free
         P google          e

    23-02-2007 om 08:59 geschreven door Qmma  


    09-02-2007
    Klik hier om een link te hebben waarmee u dit artikel later terug kunt lezen.Launch document command from iSeries

    In "How to Open a Web Browser from a 5250 Session" (October 27, 2005, article ID 51721), I described how to use the Start PC Command (STRPCCMD) command to open a browser window from an interactive CL program. In that article, I demonstrated using the Start command from a Windows MS-DOS prompt to open a URL using the user's default browser.

    To demonstrate this technique, I've written a command called LAUNCH. To open a browser, you need only run the LAUNCH command and pass it a parameter. For example, to open this article from a CL program, you could code the following:

    LAUNCH FILE('http://www.systeminetwork.com/article.cfm?id=54009')

    The LAUNCH utility opens that URL in the user's default browser. So if the user has decided to let Firefox be the default, Firefox opens the link. If the user has decided to let Internet Explorer be the default browser, then it opens the link.

    Most of the time when a reader asks me about launching a Windows program, that's exactly what they want to do — open a browser. But that's not the only use for this command. It can also launch any Windows document associated with a program on the system. For example, if I have Microsoft Word installed, I can use the LAUNCH utility to open a Word document.

    LAUNCH FILE('Z:docsWurstlong.doc')

    When the preceding command is run, Microsoft Word opens with the Wurstlong.doc document open.

    It starts with a basic command interface, which is important in this situation because the URL can be more than 32 characters long. Here's the code for the command object:

    CMD        PROMPT('Launch Document')
    
    PARM       KWD(FILE) TYPE(*CHAR) LEN(90) MIN(1) +
               EXPR(*YES) PROMPT('FILE to launch')

    See, I told you it was short! Those two commands make up the entire source member for the command object. The command calls a CL program that's not much longer. Here's the code for that program:

    PGM  PARM(&URL)
    
         DCL VAR(&CMD) TYPE(*CHAR) LEN(123)
         DCL VAR(&URL) TYPE(*CHAR) LEN(90)
    
         STRPCO
         MONMSG IWS4010
    




    /* The value field is case sensitive */ CHGVAR VAR(&CMD) + VALUE('RunDll32.exe url.dll,FileProtocolHandler ' *BCAT &URL )  
    STRPCCMD PCCMD(&CMD) PAUSE(*NO) ENDPGM

    The STRPCCMD command uses the 5250 emulator's ability to run programs on the PC. In this case, it runs a program called RunDll32, which is included with Windows and can run all sorts of nifty little things. Here, I told it to call a function named FileProtocolHandler, which is in the URL.DLL component of Windows. It accepts one parameter, which is the document to be opened.

    Of course, the RunDll32 utility can do other things besides open documents. A web search for RunDll32 in conjunction with common Windows DLL names such as Shell32, User32, and URL.DLL comes back with lots of interesting things that you can do — and with STRPCCMD, you can do them from a CL program!

    Check out some of the search results: http://www.google.com/search?q=RunDll32+Shell32+User+URL

    09-02-2007 om 10:12 geschreven door Qmma  


    07-02-2007
    Klik hier om een link te hebben waarmee u dit artikel later terug kunt lezen.Can a Limited User Run Commands from a Command Line?

    When you create a user profile on the System i, one of the profile attributes that you can assign is called limited capabilities, LMTCPB. For end users, this attribute is typically set to the value *YES; for technical staff, it's often set to *NO.

    CHGUSRPRF USRPRF(ENDUSER) LMTCPB(*YES)

    Many people believe that the setting LMTCPB(*YES) restricts users from running any CL commands when presented with a command line. Some believe it also prevents users from running CL commands at all (unless the commands are contained in a CL program). Both of these perceptions are incorrect.

    If you specify LMTCPB(*YES) for a user profile, you restrict the user from entering MOST commands at a command line.

    Each CL command object has the attribute ALWLMTUSR (Allow Limited Users) that determines if the command can be used by a user with limited capabilities. If the value is set to *YES, the command can be used by any user with limited capabilities.

    Some commands ship from IBM with the ALWLMTUSR(*YES) attribute set, and therefore CAN be ran by a limited capability user. Here are some commands with that setting:

    • Sign off (SIGNOFF)
    • Send message (SNDMSG)
    • Display messages (DSPMSG)
    • Display job (DSPJOB)
    • Display job log (DSPJOBLOG)
    • Work with messages (WRKMSG)

    If you decide that you want your limited capability users to be able to run additional commands at a command line, you can add commands to the above list by changing the command definition itself. For example, if you want your limited capability users to be able to run the WRKWTR (Work with Writers) command from a command line, use the command CHGCMD (Change Command):

    CHGCMD CMD(WRKWTR) ALWLMTUSR(*YES)

    Remeber that the limited capabilities attribute is simply a command line restriction when the user is constrained to a green screen 5250 session (e.g., TELNET). Because most users today run a Windows workstation with TCP/IP utilities and iSeries Access installed, TELNET is only one access avenue to i5/OS data and programs.

    Desktop tools such as ODBC, DDM, File Transfer, DRDA, and FTP are available on almost all end-user desktops. Many of these desktop tools can be used to send commands to OS/400. And almost all of these disregard the Limit Capabilities attribute in the user profile.

    Have you ever tried the command RMTCMD CRTLIB HACKER from a DOS prompt?

    07-02-2007 om 10:47 geschreven door Qmma  




    Archief per maand
  • 04-2007
  • 03-2007
  • 02-2007
  • 01-2007
  • 12-2006
  • 11-2006
  • 10-2006
  • 08-2006
  • 07-2006
  • 09-2005

    E-mail mij

    Druk op onderstaande knop om mij te e-mailen.



    Blog tegen de wet? Klik hier.
    Gratis blog op https://www.bloggen.be - Meer blogs