• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Determining Whether a User Is Already Signed On, Take Three

    June 28, 2002 Timothy Prickett Morgan

    Hey, Ted:

    When it comes to determining whether a user was signed on to more than one session, I’d do it a little differently .

    I’d try to allocate the user’s message queue.

    That would eliminate a data area in the mix.

    — Tim

    Several people wrote in with the same suggestion, Tim.

    Most objected to creating the data area, saying it was unnecessary.

    Here is the code to do it your way:

    DCL        VAR(&FIRSTSESSN) TYPE(*LGL) VALUE('1')         
    DCL        VAR(&MSGQ) TYPE(*CHAR) LEN(10)                 
    DCL        VAR(&MSGQLIB) TYPE(*CHAR) LEN(10)              
                                                               
    RTVUSRPRF  USRPRF(*CURRENT) MSGQ(&MSGQ) MSGQLIB(&MSGQLIB) 
    ALCOBJ     OBJ((&MSGQLIB/&MSGQ *MSGQ *EXCL)) WAIT(0)      
    MONMSG     MSGID(CPF1002 CPF1085) EXEC(DO)                
       CHGVAR     VAR(&FIRSTSESSN) VALUE('0')                 
    ENDDO                                                     
    IF         COND(&FIRSTSESSN) THEN(DO)                     
       DLCOBJ     OBJ((&MSGQLIB/&MSGQ *MSGQ *EXCL))           
    ENDDO                                                     
    

    The program attempts to allocate the message queue with an exclusive lock. This only succeeds if the user is signing on to the first session. When the user signs on to a second or subsequent session, the allocation fails, setting variable &FIRSTSESSN to false.

    A reader named Mark pointed out that you should de-allocate the message queue in case other jobs need access to those messages. The de-allocation was not necessary with the original version that I presented.

    — Ted

    Sponsored By
    ADVANCED SYSTEMS CONCEPTS

    SEQUEL meets all your iSeries and AS/400 data access needs in a single, integrated solution:

    • Windows, Web or host user interfaces

  • Convert AS/400 data into PC file formats
  • E-mail or FTP query results, reports and spool files
  • Run-time prompted queries and reports for end users
  • IF-THEN-ELSE logic in queries and reports
  • Report, form and label formatting second to none
  • Easily convert date fields, character-to-numeric, numeric-to-character and other data manipulation
  • SORT or JOIN using a calculated field
  • Quick summarization of data with Tabling function
  • Run multiple SEQUEL requests as one with the SEQUEL Scripting function
  • OLAP Business Intelligence at a fraction of the cost of comparable solutions
  • Take 6 minutes to
    view a SEQUEL ViewPoint ScreenCam movie to see how simple Windows-based
    AS/400 and iSeries data access can be! In just a few short minutes, you
    can find out ways to make your job easier and improve data access throughout
    your organization. Download
    the ViewPoint movie here
    .

    For more information or a FREE trial of SEQUEL,
    call 847/605-1311 or visit Advanced Systems Concepts .

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags: Tags: mgo_rc, Volume 2, Number 50 -- June 28, 2002

    Sponsored by
    VISUAL LANSA 16 WEBINAR

    Trying to balance stability and agility in your IBM i environment?

    Join this webinar and explore Visual LANSA 16 – our enhanced professional low-code platform designed to help organizations running on IBM i evolve seamlessly for what’s next.

    🎙️VISUAL LANSA 16 WEBINAR

    Break Monolithic IBM i Applications and Unlock New Value

    Explore modernization without rewriting. Decouple monolithic applications and extend their value through integration with modern services, web frameworks, and cloud technologies.

    🗓️ July 10, 2025

    ⏰ 9 AM – 10 AM CDT (4 PM to 5 PM CEST)

    See the webinar schedule in your time zone

    Register to join the webinar now

    What to Expect

    • Get to know Visual LANSA 16, its core features, latest enhancements, and use cases
    • Understand how you can transition to a MACH-aligned architecture to enable faster innovation
    • Discover native REST APIs, WebView2 support, cloud-ready Azure licensing, and more to help transform and scale your IBM i applications

    Read more about V16 here.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Service Program Catch-22 Reader Feedback and Insights: Avoiding Object Locks

    Leave a Reply Cancel reply

MGO Volume: 2 Issue: 50

This Issue Sponsored By

    Table of Contents

    • Determining Whether a User Is Already Signed On, Take Three
    • Easy Subfile Windowing
    • Distinct File and Record Names with SQL

    Content archive

    • The Four Hundred
    • Four Hundred Stuff
    • Four Hundred Guru

    Recent Posts

    • Liam Allan Shares What’s Coming Next With Code For IBM i
    • From Stable To Scalable: Visual LANSA 16 Powers IBM i Growth – Launching July 8
    • VS Code Will Be The Heart Of The Modern IBM i Platform
    • The AS/400: A 37-Year-Old Dog That Loves To Learn New Tricks
    • IBM i PTF Guide, Volume 27, Number 25
    • Meet The Next Gen Of IBMers Helping To Build IBM i
    • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
    • Will Independent IBM i Clouds Survive PowerVS?
    • Now, IBM Is Jacking Up Hardware Maintenance Prices
    • IBM i PTF Guide, Volume 27, Number 24

    Subscribe

    To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

    Pages

    • About Us
    • Contact
    • Contributors
    • Four Hundred Monitor
    • IBM i PTF Guide
    • Media Kit
    • Subscribe

    Search

    Copyright © 2025 IT Jungle