trigger programs

pts.
Tags:
Development
RPG
Is there a way to determine which program/job updated the file from a trigger program?

Answer Wiki

Thanks. We'll let you know when a new response is added.

Two options that immediately come to mind but that are not directly linked to a trigger program are: 1) start journalling on the file OR 2)force the program(s) that update the file to generate joblogs either by selecting an appropriate job description or by using the CHGJOBA (Change Job Attributes)command.

==================================================

Determining the job is easy — if the trigger is CL, use RTVJOBA JOB(); if RPG, retrieve job name from the PSDS… in other words, have the trigger retrieve the name of the current job.

Determining the program is trickier. You need to process the call stack. There are three general ways to do this — use the Retrieve Call Stack (QWVRCSTK) API (at V5R4 & above), send/receive messages to/from entries higher in the call stack or use the Qp0zDumpStack()–Dump Formatted Stack Trace Data–API. In short, walk the call stack, eliminating entries above the trigger that can be determined are data management entries. When you reach a call stack entry that’s not data management, you’ve at least reached a procedure in the program you’re looking for.

Better idea is to journal the changes and simply read the resulting journal entries.

Tom

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • BurtNoir
    I use the program data structure to get stuff while in a trigger program: * * Program status data structure to get the JOB & user id. * ------------------------------------------------------- D SDS D JOB 244 253 D USER 254 263
    0 pointsBadges:
    report
  • Byimw02
    The method I have used to view who initiates a trigger program is to utilize the logging information in the table associated with the trigger. All our tables contain information noting who, how and when a record was inserted or changed. As noted in the other reply, journalling will collect detail information of all actions on a specific DB. You will have to construct a mechanism to retrieve the information in a readable format. The journal management reference manual should help if you choose this method. Good luck.
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following