× 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.



I create/use a data area when the specific program is called,

If the data area exists (same name as pgm) I pop a message w/ user/time
about it being in use.

John

example -

d-specs
// Data struc used to insure only 1 user can run at 1 time
dcl-ds myda dtaara(gQDANam) qualified;
data char( 25);
user char( 10) overlay(data);
dttm char( 15) overlay(data:*next);
end-ds;
dcl-s gCorpLib varchar( 10);
dcl-s gQDANam varchar( 21);
dcl-s gDANam varchar( 10);
dcl-s gIAmInUse ind;

initialization
// Build the softcoded inuse data area name before we
// go calling the amiinuse() function
gCorpLib = 'MRPRODF';
gDANam = %trim(psds.Pgm);
gQDANam = gCorpLib + '/' + gDANam;

// Lock/Grab program so it cannot be used by others but
// if another user already is using this, give them
// some info about who it is, then back out
gIAmInUse = AmIInUse();
if gIAmInUse and myda.User <> psds.User;
gMsg = %trim(psds.Pgm) + ' in use by ' + %trimr(myda.User)
+ ' since ' + myda.dttm + '.';
msg_WinInfo(gMsg
:'Please try again later.'
:'Contact IT if this keeps happening.'
);
msg_Completion(gMsg:3);
msg_Completion('Contact the IT Dept. if this continues.':3);
log_Add(gMsg);
exsr @exit;
endif;

local procedure
//===============================================================
dcl-proc AmIInUse;
dcl-pi *n ind;
end-pi;
// Checks to see if "I" am in use by someone else already.
// Returns TRUE if in use, FALSE if NOT in use.
//===============================================================
dcl-s dttm char( 15);
dcl-s Rtn varchar( 256);
dcl-c Fmt const('%b-%d %I:%M %p');
dcl-s timestamp timestamp inz(*sys);

Rtn = dttm_FmtTStamp(timestamp :Fmt);
dttm = Rtn;
gMsgid = utlty_ChkDarea(gDANam :gCorpLib);
if gMsgid = *blanks;
// data area exists, someone else is running this
// get 'who-by' info out of data area, exit baby!
in myda;
return TRUE;
endif;
// Create the data area and put who is using it
// in the data area. Anyone else calling this
// pgm during useage, will know who's using it.
gCmd = 'CRTDTAARA '
+ 'DTAARA(' + gCorpLib + '/' + gDANam + ') '
+ 'TYPE(*CHAR) '
+ 'LEN(' + %trim(%editc(%len(myda):'Z')) + ') '
+ 'VALUE('+apos + psds.User + dttm +apos+') '
+ 'TEXT('+apos+'Used by same program'+apos+') '
+ 'AUT(*ALL)';
gMsgid = utlty_RunCmd(gCmd);
return FALSE;
end-proc;

on exit pgm
// Unlock/Release program for use by others
gCmd = 'DLTDTAARA DTAARA(' + gQDANam + ')';
gMsgid = utlty_RunCmd(gCmd);
<br />
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else is
unauthorized. If you are not the intended recipient, any disclosure, copying,
distribution or any action taken or omitted to be taken in reliance on it, is
prohibited and may be unlawful.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.