Function that calls trigger
Function that calls trigger
I have a trigger function that checks some fields. If I use *FUNCTION to write out a log file I get the name of the trigger function. Is there a way to get the function that called the OAM?
Thanks
Thanks
Art Tostaine
-
caseywhite
- Posts: 192
- Joined: Thu May 26, 2016 1:17 am
Re: Function that calls trigger
Art, I don't think it will work but you could try the system variable *LASTFUNCTION. Alternatively you could try something like adding a virtual field to the file with a default of *COMPONENT. Not sure if you would need to specify that field in your ADD/UPDATE or just having it as a virtual field would be enough. Then the trigger would receive that component or function that did the update.
Help text on *COMPONENT is the following which makes me think that this works in a function and will return the function name.
Name of the active component when referenced in a component context (i.e. in or from RDMLX logic) or equivalent to *FUNCTION when referenced in a non-component context
Help text on *COMPONENT is the following which makes me think that this works in a function and will return the function name.
Name of the active component when referenced in a component context (i.e. in or from RDMLX logic) or equivalent to *FUNCTION when referenced in a non-component context
-
René Houba
- Posts: 220
- Joined: Thu Nov 26, 2015 7:03 am
Function that calls trigger
Hi Art,
What if your file contains a field with stamping attribute FUNX?
This field will contain the name of the function I think where the INSERT/UPDATE was done.
Kind regards,
René
What if your file contains a field with stamping attribute FUNX?
This field will contain the name of the function I think where the INSERT/UPDATE was done.
Kind regards,
René
Re: Function that calls trigger
Just in case you don't want to change all programs using the trigger or to change that particular file, a TEMPORARY solution could be something like this:
and you will have in your spool the call stack which will show something like these:
Code: Select all
Function Options(*DIRECT *NOMESSAGES *LIGHTUSAGE *MLOPTIMISE) Rcv_List(#TRIG_LIST) Trigger(*FILE BANTAR)
Def_List Name(#TRIG_LIST) Type(*WORKING) Entrys(2)
Change Field(#TRIG_RETC) To('OK')
(....)
Exec_Os400 Command('DSPJOB OPTION(*PGMSTK) OUTPUT(*PRINT)')
(....)
ReturnRe: Function that calls trigger
The file, lets call it "SD", is an other file and I can't add a field to it. I'm thinking of creating another file that I will write a record every time SD is updated. That will have the function system variable. Then in the trigger I will look for that file and update what was changed. If the log file isn't there I'll add the record and know that I missed a place where it's updating.
Users are saying they aren't making mistakes. IBM i journaling shows they are doing something. I need to know which function is making this mess so I can prove to them it's not a coding problem. Very silly.
Dino, I thought of that but the idea but YIKES that's a lot of searching.
Users are saying they aren't making mistakes. IBM i journaling shows they are doing something. I need to know which function is making this mess so I can prove to them it's not a coding problem. Very silly.
Dino, I thought of that but the idea but YIKES that's a lot of searching.
Art Tostaine
Re: Function that calls trigger
I finally got a job stack of a bad job. My trigger is called @YWHSSD, my OAM is WHSSD00. I can't see what's calling them. Attached DSPJOB
I'm downloading my 2 GIG lroute.trc file to start searching it as well.
I'm downloading my 2 GIG lroute.trc file to start searching it as well.
Art Tostaine
Re: Function that calls trigger
looks like a client/server program? if so... what the lroute.trc says for Job . . . : T400000229 at 12/18/20 14:41:37?
Re: Function that calls trigger
I wasn’t able to find that job in the TRC but I did find the date/time the transaction happened.
Couldn’t find the field SDPIECES I was looking for though. Should that be in the TRC? Any tips for searching this 2.5 gig file
Couldn’t find the field SDPIECES I was looking for though. Should that be in the TRC? Any tips for searching this 2.5 gig file
Art Tostaine
Re: Function that calls trigger
I would look first by the date and hour , and use the TP job number to confirm
- Attachments
-
- date.png (11.13 KiB) Viewed 29216 times
Re: Function that calls trigger
My trc doesn't look that nice. But here is the first time that field is in the trc for that job# at that time. Is the hex bytes the value? I'm looking for a value of 24.
| 00000270 01 e2 c4 d7 c9 c5 c3 c5 e2 50 40 00 0c 53 00 0b .SDPIECES& ..ë.. |
| 00000280 00 d7 c6 d5 05 00 03 00 00 00 c2 50 00 00 05 53 .PFN......B&...ë |
| 00000290 00 02 d5 ff 50 00 00 08 53 00 07 01 e2 c4 c4 c9 ..N.&...ë...SDDI |
| 000002a0 c4 7b 50 40 00 0e 53 00 0b 00 e2 c6 d5 08 00 08 D#& ..ë...SFN... |
| 000002b0 00 00 00 c5 50 00 00 05 53 00 02 d5 ff 50 00 00 ...E&...ë..N.&.. |
| 000002c0 08 53 00 07 01 e2 c4 e2 c5 d8 7b 50 40 00 0e 53 .ë...SDSEQ#& ..ë |
| 00000270 01 e2 c4 d7 c9 c5 c3 c5 e2 50 40 00 0c 53 00 0b .SDPIECES& ..ë.. |
| 00000280 00 d7 c6 d5 05 00 03 00 00 00 c2 50 00 00 05 53 .PFN......B&...ë |
| 00000290 00 02 d5 ff 50 00 00 08 53 00 07 01 e2 c4 c4 c9 ..N.&...ë...SDDI |
| 000002a0 c4 7b 50 40 00 0e 53 00 0b 00 e2 c6 d5 08 00 08 D#& ..ë...SFN... |
| 000002b0 00 00 00 c5 50 00 00 05 53 00 02 d5 ff 50 00 00 ...E&...ë..N.&.. |
| 000002c0 08 53 00 07 01 e2 c4 e2 c5 d8 7b 50 40 00 0e 53 .ë...SDSEQ#& ..ë |
Art Tostaine
Re: Function that calls trigger
Doing a quick test in my trace for this code
Function Options(*DIRECT)
Fetch Fields(#address2 #salary) From_File(pslmst) With_Key(A1234)
#salary := 31415
#address2 := 'Oak Brook, Illinois'
#startdter := 010101
Update Fields(#address2 #salary #STARTDTER) In_File(pslmst)
I can see that around row 221 the name of the fields being updated
and about 35 rows more I can see the data been read (Beverly Hills) in the fetch, and another 20 rows the data been updated (Oak Brook, Illinois, 010101 for the date....) the salary which is a packed number, must be some of that hex between the two.
Function Options(*DIRECT)
Fetch Fields(#address2 #salary) From_File(pslmst) With_Key(A1234)
#salary := 31415
#address2 := 'Oak Brook, Illinois'
#startdter := 010101
Update Fields(#address2 #salary #STARTDTER) In_File(pslmst)
I can see that around row 221 the name of the fields being updated
and about 35 rows more I can see the data been read (Beverly Hills) in the fetch, and another 20 rows the data been updated (Oak Brook, Illinois, 010101 for the date....) the salary which is a packed number, must be some of that hex between the two.
Re: Function that calls trigger
I did see the character data but deciphering the numeric has me stumped. Does it show your function name anywhere?
I'm considering changing the call_server_functions temporarily to just call's since I should be able to see that in the job stack.
I'm considering changing the call_server_functions temporarily to just call's since I should be able to see that in the job stack.
Art Tostaine
Re: Function that calls trigger
TESTONE is the name of the test function i was using. I can see that in the second screen.
Looks like not just numbers, but some of the data is encrypted or most likely compressed.
Looks like not just numbers, but some of the data is encrypted or most likely compressed.