GET_MESSAGE Scope

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
jyoung
Posts: 694
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

GET_MESSAGE Scope

Post 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
dannyoorburg
Posts: 177
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

Re: GET_MESSAGE Scope

Post by dannyoorburg »

Hi Joe,

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

Cheers,
Danny
jyoung
Posts: 694
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: GET_MESSAGE Scope

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