INDICATORS- Can function keys be defined and looked for in a CL program

5 pts.
Tags:
AS/400
CL
Can function keys be defined and looked for in a CL program. IF a CL program is used to run a Query with a prompted select, and the user presses F3, Can I trap this?

Answer Wiki

Thanks. We'll let you know when a new response is added.

The <a href=”http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/apis/qusrjobi.htm”>Retrieve Job Information API (QUSRJOBI)</a> format JOBI0600 returns information on the status of the Cancel key and Exit key. This <b>might</b> be set by Query. Right now I’m at a conference with no access to a system — so I can’t test whether or not Query actually informs the system when a Cancel or Exit key is used.

This API can certainly be called by your CL program.

Bruce Vining

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Sloopy
    In your display DDS, define the function keys you want to use and assign them indicators. Like this: CF03(03 'Exit') Then in the CL, the indicators you specified are available as variables. Indicator 03 is &IN03. Its value will be '1' if the F3 key was pressed, or '0' if F3 was not pressed. So, for example: SNDRCVF RCDFMT(PROMPT) IF (&IN03 *EQ '1') THEN(RETURN) Regards. Sloopy
    2,195 pointsBadges:
    report
  • Sloopy
    Just re-read your question, and it may be that you want to trap the F3 from the RUNQRY command itself. My original answer if for display formats you yourself have created. Following Bruce's suggestion, I DO have a bit of time to check out the API. Here is some sample code:
                 PGM                                                               
                                                                                   
                 DCL        VAR(&FMAT) TYPE(*CHAR) LEN(104)                        
                  DCL        VAR(&EXIT) TYPE(*CHAR) LEN(1)                         
                  DCL        VAR(&CANC) TYPE(*CHAR) LEN(1)                         
                 DCL        VAR(&FLEN) TYPE(*CHAR) LEN(4)  VALUE(X'0068')          
                 DCL        VAR(&FNAM) TYPE(*CHAR) LEN(8)  VALUE('JOBI0600')       
                 DCL        VAR(&JOBN) TYPE(*CHAR) LEN(26) VALUE('*')              
                 DCL        VAR(&JOBI) TYPE(*CHAR) LEN(16)                         
                                                                                   
                 RUNQRY     QRY(TESTQRY) RCDSLT(*YES)                              
                                                                                   
                 CALL       PGM(QUSRJOBI) PARM(&FMAT &FLEN &FNAM &JOBN +           
                              &JOBI)                                               
                                                                                   
                 CHGVAR     VAR(&EXIT) VALUE(%SST(&FMAT 103 1))                    
                 CHGVAR     VAR(&CANC) VALUE(%SST(&FMAT 104 1))                    
                                                                                   
                 IF         COND(&EXIT = '1' *OR &CANC = '1') THEN(DO)             
                 SNDPGMMSG  MSG('User is being naughty. Please slap his +           
                              wrist.') MSGTYPE(*DIAG)                               
                 RETURN                                                             
                 ENDDO                                                              
                                                                                    
                 ENDPGM                                                             
    
    You need to check both the Exit and the Cancel values - exit is the state of the F3 key, and Cancel is the state of the F12 key. Regards, Sloopy
    2,195 pointsBadges:
    report
  • NarasimhaReddy
    I was also searching for this kind of solution. Very good solution I got from this. Regards Reddy
    225 pointsBadges:
    report
  • bvining
    I'm still without access to a system, but the line:
    DCL        VAR(&FLEN) TYPE(*CHAR) LEN(4)  VALUE(X’0068′)
    
    should be changed to:
    DCL        VAR(&FLEN) TYPE(*CHAR) LEN(4)  VALUE(X’00000068′)
    
    to reflect that only 104 bytes are allocated for &FMAT. The current use of x'0068' is causing inadvertent overwriting of storage by the API as the length of receiver variable is being processed as a 4-byte value. Bruce
    6,485 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following