Function that calls trigger

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Function that calls trigger

Post 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
Art Tostaine
caseywhite
Posts: 192
Joined: Thu May 26, 2016 1:17 am

Re: Function that calls trigger

Post 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
René Houba
Posts: 220
Joined: Thu Nov 26, 2015 7:03 am

Function that calls trigger

Post 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é
User avatar
Dino
Posts: 477
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: Function that calls trigger

Post 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 29292 times
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Function that calls trigger

Post 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.
Art Tostaine
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Function that calls trigger

Post 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.
Art Tostaine
User avatar
Dino
Posts: 477
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: Function that calls trigger

Post 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?
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Function that calls trigger

Post 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
Art Tostaine
User avatar
Dino
Posts: 477
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: Function that calls trigger

Post by Dino »

I would look first by the date and hour , and use the TP job number to confirm
Attachments
date.png
date.png (11.13 KiB) Viewed 29225 times
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Function that calls trigger

Post 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#& ..ë |
Art Tostaine
User avatar
Dino
Posts: 477
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: Function that calls trigger

Post 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 28869 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 28869 times
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Function that calls trigger

Post 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.
Art Tostaine
User avatar
Dino
Posts: 477
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: Function that calls trigger

Post 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.
Post Reply