Page 1 of 1

GET_MESSAGE Scope

Posted: Thu Apr 18, 2019 7:13 am
by jyoung
Is getting a message with GET_MESSAGE scoped to the routine that issued the message?

I have an insert statement as such

Code: Select all

insert fields(#EP0001F1Fields) to_file(EP0001F1) io_error(*NEXT) val_error(*NEXT)
if_status is(*OKAY)
#SYS_APPLN.TraceMessageData( 'CreateWorkforceLink - Link Created - Location: &1' #pContext.Request.Path )
#APIContext.Created( #pContext #pContext.Request.Path )
return
else
#SYS_APPLN.TraceMessageData( 'CreateWorkforceLink - Link Insert Failed - Status: &1' #IO$STS )

use builtin(GET_MESSAGE) to_get(#wk_ReturnCode #wk_Message)
#SYS_APPLN.TraceMessageData( 'GetMessage - ReturnCode:&1' #wk_ReturnCode )
dowhile (#wk_ReturnCode = 'OK')
#SYS_APPLN.TraceMessageData( 'GetMessage - ReturnCode:&1 Message:&2' #wk_ReturnCode #wk_Message )

use builtin(GET_MESSAGE) to_get(#wk_ReturnCode #wk_Message)
endwhile

#APIContext.Error( #pContext #PostWorkforceLinkv1)
return
endif
This works as expected, however, if I move the tracing of messages to a separate method routine, I don't get any messages.

Here is the GetMessages method

Code: Select all

mthroutine name(GetMessages) access(*PRIVATE)

use builtin(GET_MESSAGE) to_get(#wk_ReturnCode #wk_Message)
#SYS_APPLN.TraceMessageData( 'GetMessage - ReturnCode:&1' #wk_ReturnCode )
dowhile (#wk_ReturnCode = 'OK')

#SYS_APPLN.TraceMessageData( 'GetMessage - ReturnCode:&1 Message:&2' #wk_ReturnCode #wk_Message )

use builtin(GET_MESSAGE) to_get(#wk_ReturnCode #wk_Message)
endwhile
endroutine
Its the same logic as before, only done inside a method.
If I change the above insert code to

Code: Select all

if_status is(*OKAY)
#SYS_APPLN.TraceMessageData( 'CreateWorkforceLink - Link Created - Location: &1' #pContext.Request.Path )
#APIContext.Created( #pContext #pContext.Request.Path )
return
else
#SYS_APPLN.TraceMessageData( 'CreateWorkforceLink - Link Insert Failed - Status: &1' #IO$STS )

#COM_OWNER.GetMessages

#APIContext.Error( #pContext #PostWorkforceLinkv1)
return
endif
The GET_MESSAGE return code comes back as NO.

Thanks,
Joe

Re: GET_MESSAGE Scope

Posted: Thu Apr 18, 2019 3:58 pm
by dannyoorburg
Hi Joe,

Have a play with the available Options on the MthRoutine command.

Cheers,
Danny

Re: GET_MESSAGE Scope

Posted: Thu Apr 18, 2019 11:45 pm
by jyoung
Thanks Danny!

Using the *RECEIVES_MESSAGES on the GetMessages method solves it. Never used those particular options before. Still have a lot to learn. :D

Thanks again.
Joe