Debug AS400 program

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.
amphastarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

daveslaterCommented:
Hi
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?

Dave

0
amphastarAuthor Commented:
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.
0
ShadowProgrammerCommented:
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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

dedy_djajapermanaCommented:
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.
0
tliottaCommented:
Dedy:

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.

Tom

0
ODEIONCommented:
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.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
IBM System i

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.