Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Debug AS400 program

Posted on 2004-11-23
Medium Priority
Last Modified: 2008-02-01
I am using BPCS405CD on our AS400.
There is a program that often generate errors.
I don't know what language it use. My guess is RPG.
I just wonder whether there is any command that can see what the program does, what files are opened and how many steps; or use any command to generate a report or job log on those information.

Thanks a lot.
Question by:amphastar
LVL 14

Expert Comment

ID: 12656743
There is not a lot you can do with-out the source.
You can see what files and other objects are used by using the DSPPGMREF command

To get the program info you can use the DSPPGM command.

If the program fails you should get a joblog. It is just a case of starting from the bottom and reading back until you find out what has caused it.

Are you getting a joblog?



Author Comment

ID: 12657677
No, I didn't get a joblog.
In fact, the problem is that some records are locked. I don't why the program gave me that message. That is why I want to check how the program check the lock.

Accepted Solution

ShadowProgrammer earned 300 total points
ID: 12667146
When you say the program generates errors, is the program reporting the errors in a summary report or is the program falling over and displaying an error message which needs a reply.
If you get an error message which needs a reply, display the job log before answering the error message and you should be able to identify the cause of the problem - if there is a locked record, there should be a message in the job log just before the error message identifying the record which is locked from which file and the user & job which has the record (you may need to look at the second level text to get all the info).

RPG (and probably the other languages on AS400) by default lock a record when reading from a file opened for update (programmers can stop the record from locking if desired), if another program already has the record locked for update then an error is returned which can be caught by the program to avoid it falling over - it is common for programs not to handle locked records as on the AS400 there is usually a retry option on the record locked message, which does what is says - it retrys to read the record again then either continues happily or falls over again with the record still locked.

I would suggest you look at the job log and identify the record locked, by which job and user, then attempt a retry, if it fails straight away on the same record and same user/job then get in touch with the user and ask them to finish what they are doing, then do another retry and the program should then continue.

If this happens quite often, you may need to identify the trend and maybe schedule the job to a time when the users aren't so active or maybe stop the user from having a coffee break in the middle of an  update.
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.


Expert Comment

ID: 12678500
hi amphastar,

As far as i can remember (I used BPCS around 6-7 years ago), in BPCS, the error of 'record locked' is caused by the record is flagged of being open (there's a flag field in the record).
This may be because previous open was not closed properly like session being ended.
If you're more specific (what transaction), i think your vendor will be able to help

for TOM:
I think you're BPCS user, right? please correct me if i'm wrong.
LVL 27

Assisted Solution

tliotta earned 150 total points
ID: 12712961

Unfortunately in this case, no. I've worked in a large BPCS shop (starting around 7 years ago... hmmm...), but currently have no BPCS environment to review.

However, the flag-field sounds familiar. There might be no "system lock" that can be seen with functions such as WRKOBJLCK, but BPCS might still report the record being in use because of a flag. This is one reason I try to avoid techniques that 'get around' system features -- for me, a "lock" means a specific thing. If an application uses the same word in a message but with a different meaning, it only confuses things.

However, getting a joblog _shouldn't_ be a problem. AFAIK, all that needs to be done is change the job description for a BPCS batch job or run a CHGJOB command for an interactive BPCS job. The change to the jobd would be permanent until changed back later. A change to an interactive job might need to be done every time unless there's a BPCS setting that controls it.



Assisted Solution

ODEION earned 300 total points
ID: 12726024
Do you know what the program is *supposed* to do? In other words, do you have a specification for it, or could you write one? If so, then rewrite the program from scratch. This is often easier and more satisfactory than trying to debug crappy programs even when the source is available.

The problem you face is that even if you could identify the bug(s) in your PGM object, without the source you cannot eliminate it/them.

You give no clue as to the nature of the "errors" that this program throws up. It might not be the program at all but the data that is being fed to it. Although every program should check divisors for zero value before executing a division, few programs do. Check your data.

It is possible to identify any bug by obtaining a hex core dump and translating the machine code at the address pointed to by the error trap. I have done this on an IBM mainframe but I do not know if IBM has published machine codes for the AS/400. However, even if it has, it is a long, laborious task that could take a lot longer than recreating the program as I suggested at top.


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The deadly train derailment that occurred recently in DuPont, Washington, raises a lot of questions. It was a new route, the first trip tested with passengers, and the train was travelling at 50 mph over the zone’s speed limit. Could IoT play a role…
Welcome to 2018! Exciting things lie ahead in the world of tech. To start things off, we compiled great member articles on how to stay safe, ways to learn, and much more! Read on to start your new year right.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question