Page 1 of 1

Function that calls trigger

Posted: Tue Dec 15, 2020 9:31 am
by atostaine
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

Re: Function that calls trigger

Posted: Tue Dec 15, 2020 10:18 am
by caseywhite
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

Function that calls trigger

Posted: Tue Dec 15, 2020 9:36 pm
by René Houba
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é

Re: Function that calls trigger

Posted: Wed Dec 16, 2020 12:04 am
by Dino
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:

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)')
(....)
Return
and you will have in your spool the call stack which will show something like these:
testtrg.png
testtrg.png (11.52 KiB) Viewed 29297 times

Re: Function that calls trigger

Posted: Wed Dec 16, 2020 2:20 am
by atostaine
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.

Re: Function that calls trigger

Posted: Wed Dec 23, 2020 8:48 am
by atostaine
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
ACS.splf-3986127716986736972.pdf
(5.87 KiB) Downloaded 2533 times

I'm downloading my 2 GIG lroute.trc file to start searching it as well.

Re: Function that calls trigger

Posted: Wed Dec 23, 2020 9:07 am
by Dino
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

Posted: Wed Dec 23, 2020 3:14 pm
by atostaine
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

Re: Function that calls trigger

Posted: Wed Dec 23, 2020 3:34 pm
by Dino
I would look first by the date and hour , and use the TP job number to confirm

Re: Function that calls trigger

Posted: Wed Dec 23, 2020 11:12 pm
by atostaine
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#& ..ë |

Re: Function that calls trigger

Posted: Thu Dec 24, 2020 1:24 am
by Dino
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
rows0.png
rows0.png (29.43 KiB) Viewed 28874 times
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.
rows1.png
rows1.png (145.32 KiB) Viewed 28874 times

Re: Function that calls trigger

Posted: Thu Dec 24, 2020 2:30 am
by atostaine
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.

Re: Function that calls trigger

Posted: Thu Dec 24, 2020 2:34 am
by Dino
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.