.
 News & Views
  The online information source for iSeries and mrc-Productivity Series users
.  June 2002  
Volume 2, Issue 6  
.
. . . . . . . . .

Tech Corner

Running User-Specific Downloads Via Your Browser

by Tony Lowe


Downloading AS/400 data to your PC is a very common requirement. In MRC it's usually handled by a Summary with the 'Download to PC' option set to 'Y'.

However, the problem with this approach is that it only works successfully as a single-user application. This is because the Summary creates a file in the IFS with a name based on the Summary identity (e.g. SF01000.csv). If you have multiple users running the same Summary with different selection criteria they will all attempt to create the same file but with different content. When this happens, life can become very difficult!

One solution to this problem is to use a Prompt Maintainer with external objects to create user-specific download files in the IFS.

Incidentally, if you are not familiar with Prompt Maintainers, you will need to read up on the subject before proceeding. You can find a detailed description in the MRC Online User Guide at http://www.mrc-productivity.com/members/manual/How_To-21.htm#P4083_230239

The main elements of the solution described here are a CGI Form Maintainer (acting as browser-based prompt maintainer), an appropriate summary with the 'Download to PC' option set to N and external objects to do the following:

  • Get current user-ID
  • Get a unique file identity for the current user
  • Run the summary with output to QTEMP and copy to the IFS with a unique file identity
  • Re-direct the Maintainer to the file which has just been created in the IFS


  • The main steps in creating the application are as follows:.

    Let's assume that you have already created a standard 'green screen' summary with runtime selection criteria. This summary should place the output file in QTEMP so that the output is unique for the current user. The next step is to create a CGI Form Maintainer to prompt for selection criteria, run the summary and then redirect the browser to the .CSV file download option.

    The CGI Form Maintainer will need to call three of the external objects at the *AFTERADD template location:

    1. The first external object will get the current user-ID. An external object to do this (ORTNUSRCGI) is available on the MRC website.
    2. The second external object will determine a unique file identity for the current user. This must be a user-written routine, since the rules may vary from one installation to another. In its simplest form the file identity could be a cut down version of the user-ID.
    3. The third external object, which is also assumed to be user-written, will run the summary via the MRCSUM command then call program MRC413C (a standard MRC program for copying database files to the IFS). In the sample code shown below, Summary 40 in the dictionary MRCUSER is being processed with a single selection parameter and the output placed in QTEMP. Program MRC413C is then used to copy the database file from QTEMP to the 'MRCUSER' IFS directory. Note the use of parameters within program MRC413C.

    EXAMPLE:

    PGM PARM(&USER &ID &SEL1)

    DCL VAR(&USER) TYPE(*CHAR) LEN(10)
    DCL VAR(&ID) TYPE(*CHAR) LEN(5)
    DCL VAR(&SEL1) TYPE(*CHAR) LEN(29)

    DCL VAR(&TEXT) TYPE(*CHAR) LEN(30)
    CHGVAR VAR(&TEXT) VALUE('CSV Download for ' *CAT &USER)

    MRCSUM SUMNUM(40) DCTLIB(MRCUSER) JQO(O) + PRMPT1(&SEL1)

    CALL PGM(MRC413C) PARM('C' 'SF00040' 'QTEMP' + &TEXT &ID 'MRCUSER')

    MONMSG MSGID(CPF0000)
    ENDPGM

    The final step in the process is to get the CGI Form/Prompt Maintainer to redirect to the .CSV file that has been created by the previous external object.

    To do this you need a *OBJECT calculation. This will call the final external object in our list, which provides the name of the user's .CSV file for re-direction.

    Note: that for this to work, you must include the characters *REDIRECT in the calculation description. You also need to modify the HTML code for the CGI Forma Maintainer (in MRCUSER/QHTMLSRC), so that the 'Redirect' option is set to 'Y'. A sample external object to provide the name of the user's .CSV file is shown below:

    EXAMPLE:

    PGM PARM(&ID &URL) /* Get CSV file name for current user */
    DCL VAR(&URL) TYPE(*CHAR) LEN(99)
    DCL VAR(&ID) TYPE(*CHAR) LEN(5)
    CHGVAR VAR(&URL) VALUE('SF' *CAT &ID *CAT '.CSV')
    ENDPGM

    Take Our Poll

    How many people are in your IT department?

    0-5
    5-15
    16-35
    36-50
    51+
    Don't know

    View Results
    View Poll Archive

    .
    .
    .


    .
    . Quick Links...

    Visit mrc's Web site

    See a live demo

    Get more information

    View Latest Newsletter

    Last Month's Newsletter

    .
    .
    .
    .
    . Contact mrc...

    U.S. Offices
    mrc@mrc-productivity.com

    voice: 630-916-0662

    www.mrc-productivity.com



    U.K. Offices
    michaels, ross & cole (UK) ltd

    voice (UK): +44 (0)20 8282 1600

    mail@mrcuk.com

    .
     mrc publishes this newsletter on a monthly basis. Subscription is free of charge. Please send any questions or comments about this newsletter to news@mrc-productivity.com. This newsletter is edited by Heather Gately.

    Visit our subscription center to update your subscription or unsubscribe.
    View our privacy promise.

    .