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



Hello,

here are some considerations

If the job is a critical update job, I think that it is better to use the
lock and the content ('1', 'in use', 'active', a job number, etc... ) .
the reason for being that when a critical update job has been ended
abnormally, it could be necessary to check the database and make some fix
before allowing users to make other updates...

Then if the data is allocated ==> it means that the batch job is active
if the data area is free then the content could say if interactive update
is allowed... otherwise a manual intervention could be required...

for the coding style , I have coded GOTO in CL for years because there was
no other solutions (my rules were: only have one GOTO for one label AND
the label must appear in the source before the goto), but now it is a
forbidden verb in CLLE...
what worries me in the proposed loop is that there is only one possibility
to go out and it is not controlled by the program. I would suggest to add
a timeout (a counter for number of retries...) ... So if the batch was in
MSGWAIT during lunch time... the user would not have to end the 5250
session but could be informed by a " please retry "message...

just my 5 cents..

Paul
--





*** NOTE: When replying to this digest message, PLEASE remove all text
unrelated to your reply and change the subject line so it is meaningful.

Today's Topics:

1. Re: [Bulk] Technique critique? (Mark S Waterbury)
2. Re: Technique critique? (JRusling@xxxxxxxxxxx)
3. RE: Technique critique? (Justin Taylor)
4. RE: Technique critique? (Bob Cagle)
5. RE: [Bulk] Technique critique? (Bob Cagle)
6. RE: [Bulk] Technique critique? (Steinmetz, Paul)


----------------------------------------------------------------------

message: 1
date: Wed, 18 May 2016 15:39:25 -0400
from: Mark S Waterbury <mark.s.waterbury@xxxxxxxxxxxxx>
subject: Re: [Bulk] Technique critique?

Hi, Bob:

I think this is a rather "poor design" regardless of how that "loop" is
coded ... for the following reasons:

* what happens if the batch job fails or aborts, and so never resets
the data area?
o (the interactive users will be stuck waiting forever ...)
* a loop like this needlessly ties up the user's interactive session ...
o perhaps it would be better to check the condition and then
notify the user to "Try again later..."

A few related questions may help to point to a better design:

* what is the nature of this batch job? Is it updating some "critical
resources" such as some file(s)?
* what is the nature of the program that is to run interactively, and
why can it not run while that batch job is active?

SUGGESTION
============
Instead of setting a flag value in that data area, you could use that
data area as a "semaphore" (a resource that can be locked) and have the
batch job allocate the *DTAARA for *EXCLusive use ... Then, the
interactive CL program can attempt to issue ALCOBJ against that same
data area, also trying to gain *EXCLusive use, and specify "no wait" and
if it fails to allocate, you can monitor for that message with a MONMSG,
and then notify the user to "please try again later" ... if more than
one interactive user is allowed to run this interactive process at the
same time, then you would want to immediately issue a DLCOBJ to
de-allocate the lock on that data area, when the lock has been obtained.

The main benefit of this approach is that, when the batch job ends,
normally or abnormally, the exclusive lock will be released.

Hope that helps,

Mark S. Waterbury

On 5/18/2016 2:45 PM, Bob Cagle wrote:
This is more of a CL programming question:

Background: I have an interactive program that I need to have NOT run
while a specific batch job is running. Currently the batch job updates a
data area with a flag at the start of the job and then clears it at the
end. Interactive jobs can then check for this flag before running.

I have this code in my CL:

CHECK:
/* Check data area to see if job is running */
Rtvdtaara DataArea rtnvar(&Check)
If (&Check = '1') then( DO )

/* wait 30 seconds and then try again */
Dlyjob dly(30)
Goto CHECK
ENDDO


The GOTO is bothering me, so the question is - would you code this
different? This seems simple and straight-forward, but in your opinion is
there a better way?

Thanks

Bob Cagle
IT Manager
Lynk




------------------------------

message: 2
date: Wed, 18 May 2016 14:43:25 -0500
from: JRusling@xxxxxxxxxxx
subject: Re: Technique critique?

Ditto what Glen said...

By the way, you might consider something more meaningful than '1',
e.g. 'INUSE'.

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


------------------------------

message: 3
date: Wed, 18 May 2016 19:44:05 +0000
from: Justin Taylor <JUSTIN@xxxxxxxxxxxxx>
subject: RE: Technique critique?

My first suggestion would be to have the batch job allocate an object, and
then have the interactive job attempt to allocate the same object. Using
an object lock means that the when the batch job ends for any reason, the
interactive job will be free to go.


-----Original Message-----
From: Bob Cagle [mailto:bcagle@xxxxxxxxxxx]
Sent: Wednesday, May 18, 2016 1:46 PM
To: RPG400-L@xxxxxxxxxxxx
Subject: Technique critique?

This is more of a CL programming question:

Background: I have an interactive program that I need to have NOT run
while a specific batch job is running. Currently the batch job updates a
data area with a flag at the start of the job and then clears it at the
end. Interactive jobs can then check for this flag before running.

I have this code in my CL:

CHECK:
/* Check data area to see if job is running */ Rtvdtaara DataArea
rtnvar(&Check) If (&Check = '1') then( DO )

/* wait 30 seconds and then try again */ Dlyjob dly(30)
Goto CHECK
ENDDO


The GOTO is bothering me, so the question is - would you code this
different? This seems simple and straight-forward, but in your opinion is
there a better way?

Thanks

Bob Cagle
IT Manager
Lynk




------------------------------

message: 4
date: Wed, 18 May 2016 19:58:59 +0000
from: Bob Cagle <bcagle@xxxxxxxxxxx>
subject: RE: Technique critique?

Yes - this. I thought I remembered the DOxx commands being added to CL. I
am on 7.1 so I do have access to these. Definitely changing it to a
DOWHILE.

Thanks
Bob Cagle

-----Original Message-----
From: Glenn Gundermann

Hi Bob,

You could use something like:

CHGVAR &CHECK '1'

DOWHILE COND(&check = '1')
RTVDTAARA DataArea rtnvar(&Check)
IF COND(&CHECK = '1')
DLYJOB DLY(30)
ENDIF
ENDDO

By the way, you might consider something more meaningful than '1', e.g.
'IN USE'.

Yours truly,
Glenn Gundermann


------------------------------

message: 5
date: Wed, 18 May 2016 20:12:00 +0000
from: Bob Cagle <bcagle@xxxxxxxxxxx>
subject: RE: [Bulk] Technique critique?

Mark

All good points. Yes, I have considered adding the message to the user to
"Please try again later" instead of just locking up their session. I am
going to implement this.

I have also considered using the 'lock object' method, but to switch this
one program to that method means also modifying several other programs to
the new paradigm. Not sure if I'm gonna tackle this one yet or not.

As for the nature of this interactive job, a more detailed explanation: it
is creating Advanced Ship Notices in bulk on a JDE system. It is run
once, maybe twice a day as part of our 'day end' process. There are other
interactive processes that can also create the ASN. The batch job in
question is our EDI process that runs every hour which pulls the ASNs,
initiates communications, and then *updates these ASNs as sent*. It's the
last part that I think was causing us a problem. If the user runs the
interactive ASN generation while the EDI job is processing communications,
then the new ASNs will be *updated as sent* before ever being added to the
EDI translator. Earlier this week, we had several ASNs that didn't show
up in the translator like they should. This is the only scenario I could
come up with that would cause this.

Thanks for all the input!
Bob


From: Mark S Waterbury

Hi, Bob:

I think this is a rather "poor design" regardless of how that "loop" is
coded ... for the following reasons:

* what happens if the batch job fails or aborts, and so never resets
the data area?
o (the interactive users will be stuck waiting forever ...)
* a loop like this needlessly ties up the user's interactive session ...
o perhaps it would be better to check the condition and then
notify the user to "Try again later..."

A few related questions may help to point to a better design:

* what is the nature of this batch job? Is it updating some "critical
resources" such as some file(s)?
* what is the nature of the program that is to run interactively, and
why can it not run while that batch job is active?

SUGGESTION
============
Instead of setting a flag value in that data area, you could use that data
area as a "semaphore" (a resource that can be locked) and have the
batch job allocate the *DTAARA for *EXCLusive use ... Then, the
interactive CL program can attempt to issue ALCOBJ against that same data
area, also trying to gain *EXCLusive use, and specify "no wait" and if it
fails to allocate, you can monitor for that message with a MONMSG, and
then notify the user to "please try again later" ... if more than one
interactive user is allowed to run this interactive process at the same
time, then you would want to immediately issue a DLCOBJ to de-allocate the
lock on that data area, when the lock has been obtained.

The main benefit of this approach is that, when the batch job ends,
normally or abnormally, the exclusive lock will be released.

Hope that helps,

Mark S. Waterbury

On 5/18/2016 2:45 PM, Bob Cagle wrote:
This is more of a CL programming question:

Background: I have an interactive program that I need to have NOT run
while a specific batch job is running. Currently the batch job updates a
data area with a flag at the start of the job and then clears it at the
end. Interactive jobs can then check for this flag before running.

I have this code in my CL:

CHECK:
/* Check data area to see if job is running */ Rtvdtaara DataArea
rtnvar(&Check) If (&Check = '1') then( DO )

/* wait 30 seconds and then try again */
Dlyjob dly(30)
Goto CHECK
ENDDO


The GOTO is bothering me, so the question is - would you code this
different? This seems simple and straight-forward, but in your opinion is
there a better way?

Thanks

Bob Cagle
IT Manager
Lynk



------------------------------

message: 6
date: Wed, 18 May 2016 20:42:35 +0000
from: "Steinmetz, Paul" <PSteinmetz@xxxxxxxxxx>
subject: RE: [Bulk] Technique critique?

Bob,

During any of these processes, do you run a daily save.
I found that when using a data area, the process will could/will fail
during the save.
Instead of using a data area, we use a simple PF control file.
A PF can be saved while in use using Save While Active.
Data areas cannot.

Paul


-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Bob
Cagle
Sent: Wednesday, May 18, 2016 4:12 PM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: RE: [Bulk] Technique critique?

Mark

All good points. Yes, I have considered adding the message to the user to
"Please try again later" instead of just locking up their session. I am
going to implement this.

I have also considered using the 'lock object' method, but to switch this
one program to that method means also modifying several other programs to
the new paradigm. Not sure if I'm gonna tackle this one yet or not.

As for the nature of this interactive job, a more detailed explanation: it
is creating Advanced Ship Notices in bulk on a JDE system. It is run
once, maybe twice a day as part of our 'day end' process. There are other
interactive processes that can also create the ASN. The batch job in
question is our EDI process that runs every hour which pulls the ASNs,
initiates communications, and then *updates these ASNs as sent*. It's the
last part that I think was causing us a problem. If the user runs the
interactive ASN generation while the EDI job is processing communications,
then the new ASNs will be *updated as sent* before ever being added to the
EDI translator. Earlier this week, we had several ASNs that didn't show
up in the translator like they should. This is the only scenario I could
come up with that would cause this.

Thanks for all the input!
Bob


From: Mark S Waterbury

Hi, Bob:

I think this is a rather "poor design" regardless of how that "loop" is
coded ... for the following reasons:

* what happens if the batch job fails or aborts, and so never resets
the data area?
o (the interactive users will be stuck waiting forever ...)
* a loop like this needlessly ties up the user's interactive session ...
o perhaps it would be better to check the condition and then
notify the user to "Try again later..."

A few related questions may help to point to a better design:

* what is the nature of this batch job? Is it updating some "critical
resources" such as some file(s)?
* what is the nature of the program that is to run interactively, and
why can it not run while that batch job is active?

SUGGESTION
============
Instead of setting a flag value in that data area, you could use that data
area as a "semaphore" (a resource that can be locked) and have the
batch job allocate the *DTAARA for *EXCLusive use ... Then, the
interactive CL program can attempt to issue ALCOBJ against that same data
area, also trying to gain *EXCLusive use, and specify "no wait" and if it
fails to allocate, you can monitor for that message with a MONMSG, and
then notify the user to "please try again later" ... if more than one
interactive user is allowed to run this interactive process at the same
time, then you would want to immediately issue a DLCOBJ to de-allocate the
lock on that data area, when the lock has been obtained.

The main benefit of this approach is that, when the batch job ends,
normally or abnormally, the exclusive lock will be released.

Hope that helps,

Mark S. Waterbury

On 5/18/2016 2:45 PM, Bob Cagle wrote:
This is more of a CL programming question:

Background: I have an interactive program that I need to have NOT run
while a specific batch job is running. Currently the batch job updates a
data area with a flag at the start of the job and then clears it at the
end. Interactive jobs can then check for this flag before running.

I have this code in my CL:

CHECK:
/* Check data area to see if job is running */ Rtvdtaara DataArea
rtnvar(&Check) If (&Check = '1') then( DO )

/* wait 30 seconds and then try again */
Dlyjob dly(30)
Goto CHECK
ENDDO


The GOTO is bothering me, so the question is - would you code this
different? This seems simple and straight-forward, but in your opinion is
there a better way?

Thanks

Bob Cagle
IT Manager
Lynk

--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.


------------------------------

Subject: Digest Footer


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.