Avoid recursive calls in LANSA functions when using ATTN-key

Date:Archived
Product/Release:LANSA for the AS/400
Abstract:LANSA ATTN program for LANSA
Submitted By:LANSA Technical Support

A common practice in the AS/400 world is to attach a menu to the ATTN-key. This makes it then very simple for users to start up various procedures from no matter which screen they are using. However a small problem occurs if the screen is displayed from a LANSA function and the user would like to start up another LANSA function from the ATTN-key menu, resulting in a recursive call. There is a way of avoiding this recursive call by using a couple of CL programs to transfer the job between groups.

The first CL program (PGM1) should be called from the ATTN-key menu where the call to the LANSA function would normally be placed. This program then calls the second program which actually calls the LANSA function.

PGM1

PGM
DCL VAR(&GRPJOB) TYPE(*CHAR) LEN(10)
RTVGRPA GRPJOB(&GRPJOB)
MONMSG MSGID(CPF0000)
/* Start a separate group task and call program 2 */
IF COND(&GRPJOB *NE ‘A') THEN(DO)
CHGGRPA GRPJOB(A)
TFRGRPJOB GRPJOB(B) INLGRPPGM(PGM2)
ENDDO
TFRGRPJOB GRPJOB(B)
/* If transfer failed, try again */
MONMSG MSGID(CPF1310) EXEC(TFRGRPJOB GRPJOB(B) INLGRPPGM(PGM2)
ENDPGM

PGM2

PGM
MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(END))
LANSA REQUEST(RUN) PROCESS(pppppp) FUNCTION(fffff) PARTITION(ppp)
DEVELOPER(N)
TFRGRPJOB GRPJOB(*PRV)
END: ENDPGM

Be sure to remove LANSA's own attention key program by setting position 462 of data area ‘DC@A01' to N.