Accessing I/O Feedback Area of DSPF from within CL program

250 pts.
Tags:
AS/400
CL
CL Program
Display File
DSPF
I/O feedback
Is it possible from within a CL program to retrieve/access the I/O feedback area of a display file (the equivalent of retrieving INFDS (positions 401-404) from within an RPG program)?

Software/Hardware used:
AS400 V6R1
ASKED: May 19, 2011  8:34 AM
UPDATED: June 29, 2011  2:13 AM

Answer Wiki

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

I finally got a few free minutes on my system and thought I would answer your original question — Can you access the I/O feedback area for a *DSPF from a CL program?

The answer is Yes (though as I suggested earlier, it’s not exactly direct). Create a *DSPF with SHARE(*YES) specified. If the *DSPF is named CLSHARE then the following code will give you access to the I/O feedback area (with the sample code giving you the aidkey, the cursor location, and the major/minor values).

<pre>
Pgm

DclF File(CLShare2)

Dcl Var(&DspF) Type(*Char) Len(11)
Dcl Var(&ReadWrite) Type(*Char) Len(4)

Dcl Var(&File_Ptr) Type(*Ptr)

Dcl Var(&Cmn_Ptr) Type(*Ptr)
Dcl Var(&Cmn_Fdbk) Type(*Char) Stg(*Based) +
Len(144) BasPtr(&Cmn_Ptr)
Dcl Var(&Dev_Ofs) Type(*Int) Stg(*Defined) +
Len(2) DefVar(&Cmn_Fdbk)

Dcl Var(&Dev_Ptr) Type(*Ptr)
Dcl Var(&Dev_Fdbk) Type(*Char) Stg(*Based) +
Len(80) BasPtr(&Dev_Ptr)
Dcl Var(&AidKey) Type(*Char) Stg(*Defined) +
Len(1) DefVar(&Dev_Fdbk 3)
Dcl Var(&CsrLoc) Type(*Char) Stg(*Defined) +
Len(2) DefVar(&Dev_Fdbk 4)
Dcl Var(&Maj_Code) Type(*Char) Stg(*Defined) +
Len(2) DefVar(&Dev_Fdbk 35)
Dcl Var(&Mnr_Code) Type(*Char) Stg(*Defined) +
Len(2) DefVar(&Dev_Fdbk 37)

Dcl Var(&Null) Type(*Char) Len(1) Value(x’00′)

ChgVar Var(&DspF) Value(‘CLSHARE’ *Cat &Null)
ChgVar Var(&ReadWrite) Value(‘ar+’ *Cat &Null)
CallPrc Prc(‘_Ropen’) Parm((&DspF) (&ReadWrite)) +
RtnVal(&File_Ptr)

Loop: DoWhile Cond(*Not &IN03)
SndRcvF RcdFmt(Record)

CallPrc Prc(‘_Riofbk’) Parm((&File_Ptr *ByVal)) +
RtnVal(&Cmn_Ptr)
ChgVar Var(&Dev_Ptr) Value(&Cmn_Ptr)
ChgVar Var(%Ofs(&Dev_Ptr)) Value(%Ofs(&Dev_Ptr) + +
&Dev_Ofs)

EndDo

CallPrc Prc(‘_Rclose’) Parm((&File_Ptr *ByVal))
Return

EndPgm
</pre>

Basically the CL program opens the shared file twice. Once impliciitly and once explicitly using the _Ropen API (which is provided with the operating system and often thought of as being part of C run time). After the user hits enter (or whatever) the program calls the _Riofbk API to access the shared IO feedback area. When you hit the EndDo after this API call you will find that &AidKey holds the aid key value, &CsrLoc the cursor coordinates, etc. The program then simply loops until F3 is used to exit. When exiting the program calls _Rclose to close one instance of the file, and CL implicitly closes the other instance.

Now to go onto your followup clarification on waiting for 60 seconds. You don’t need the IO feedback area for that. If you invite the device and no data is available in WAITRCD seconds then the program will receive escape message CPF0889. Monitor for the message and then do whatever you want to do every 60 seconds. The following program still has the code imbedded for IO feedback access, but the MONMSG will get control when the timer expires. To run simply add INVITE to your display file and create the *DSPF with WAITRCD(60) SHARE(*YES). You’ll get the time out (and run the UpdateDsp subroutine) or do the normal processing (in this case accessing the IO feedback area).

<pre>
Pgm

DclF File(CLShare)

Dcl Var(&DspF) Type(*Char) Len(11)
Dcl Var(&ReadWrite) Type(*Char) Len(4)

Dcl Var(&File_Ptr) Type(*Ptr)

Dcl Var(&Cmn_Ptr) Type(*Ptr)
Dcl Var(&Cmn_Fdbk) Type(*Char) Stg(*Based) +
Len(144) BasPtr(&Cmn_Ptr)
Dcl Var(&Dev_Ofs) Type(*Int) Stg(*Defined) +
Len(2) DefVar(&Cmn_Fdbk)

Dcl Var(&Dev_Ptr) Type(*Ptr)
Dcl Var(&Dev_Fdbk) Type(*Char) Stg(*Based) +
Len(80) BasPtr(&Dev_Ptr)
Dcl Var(&AidKey) Type(*Char) Stg(*Defined) +
Len(1) DefVar(&Dev_Fdbk 3)
Dcl Var(&CsrLoc) Type(*Char) Stg(*Defined) +
Len(2) DefVar(&Dev_Fdbk 4)
Dcl Var(&Maj_Code) Type(*Char) Stg(*Defined) +
Len(2) DefVar(&Dev_Fdbk 35)
Dcl Var(&Mnr_Code) Type(*Char) Stg(*Defined) +
Len(2) DefVar(&Dev_Fdbk 37)

Dcl Var(&Null) Type(*Char) Len(1) Value(x’00′)

ChgVar Var(&DspF) Value(‘CLSHARE’ *Cat &Null)
ChgVar Var(&ReadWrite) Value(‘ar+’ *Cat &Null)
CallPrc Prc(‘_Ropen’) Parm((&DspF) (&ReadWrite)) +
RtnVal(&File_Ptr)

Loop: DoWhile Cond(*Not &IN03)
SndF RcdFmt(Record)
Wait
MonMsg MsgID(CPF0889) Exec(Do)
CallSubr Subr(UpdateDsp)
Iterate CmdLbl(Loop)
EndDo

CallPrc Prc(‘_Riofbk’) Parm((&File_Ptr *ByVal)) +
RtnVal(&Cmn_Ptr)
ChgVar Var(&Dev_Ptr) Value(&Cmn_Ptr)
ChgVar Var(%Ofs(&Dev_Ptr)) Value(%Ofs(&Dev_Ptr) + +
&Dev_Ofs)

EndDo

CallPrc Prc(‘_Rclose’) Parm((&File_Ptr *ByVal))
Return

Subr Subr(UpdateDsp)
EndSubr

EndPgm
</pre>

On V5R4 you will need to create the program with two steps:

CRTCLMOD
CRTPGM … BNDDIR(QC2LE)

When your system goes to V6R1 you can just use CRTBNDCL

Bruce Vining

Discuss This Question: 10  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
  • TomLiotta
    As far as I know, in order for CL to access the I/O feedback area, you would have to rewrite the program in RPG, COBOL or other HLL. The CL compiler doesn't provide any pointer or linkage to the I/O feedback area. Is there specific information that you need from the feedback area? There might be methods of getting the info through other means. Tom
    125,585 pointsBadges:
    report
  • Yorkshireman
    CL - aka 'Control Language' is intended for use in controlling the flow of work / jobs in the machine. If you are using screens - UIM or dspfs pretty much all you need to know at a CL level is reported as a message (MONMSG) or as a data field. As Tom asked - what is your *real* problem we need to solve?
    5,520 pointsBadges:
    report
  • Zack
    Hi Tom and Yorkshireman, The dspf in question is one that displays the statuses (active, inactive, msgw, etc.) of approximately 40 batch jobs that run continuously and concurrently throughout the day. Unless the user/operator makes an entry from the keyboard, the screen refreshes itself automatically every 60 seconds. What is wanted from the feedback area (major and minor status codes) is the indication that return of control to the CL program is the result of the timeout (and not a keyed-in entry by the user/operator). Zack
    250 pointsBadges:
    report
  • bvining
    An alternative solution you might consider would be to create the display file using the DTAQ parameter and specify a data queue that is to be sent a message when input is available from the user. Your program can SND to the *DSPF (not SNDRCV) and then call the QRCVDTAQ API to receive a message from the data queue specifying a 60 second wait time. If the user presses a key QRCVDTAQ will return a message with the value '*DSPF in positions 1 - 10. If sixty seconds pass with no operator input then the Length of data parameter returned by QRCVDTAQ will be 0. If the operator did something, RCV the record format, process the request, SND, and go back to reading from the *DTAQ. If a timeout occured, SND the normal update and go back to reading from the *DTAQ (again with a sixty second wait time). I do have an idea of how CL might be able to access the *DSPF IO feedback information but haven't had an opportunity to try it out. It would be more involved though than using a *DTAQ approach. Bruce Vining
    6,240 pointsBadges:
    report
  • bvining
    I should clarify that "a key" in my earlier append means an AID key (Enter, enabled CF key, enabled Roll key, etc).
    6,240 pointsBadges:
    report
  • Zack
    Thank you Bruce for your useful suggestion. Your solution would indeed appear to meet the requirement I'm looking for. I will modify the DSPF and CL program accordingly, and try it out. Will come back with an update on its success (or otherwise). Zack
    250 pointsBadges:
    report
  • Zack
    Thanks again, Bruce. Your suggestion works and was easy to implement. Zack
    250 pointsBadges:
    report
  • Zack
    [...] Accessing I/O Feedback Area of DSPF from within CL program [...]
    0 pointsBadges:
    report
  • Zack
    Bruce, Only today, a month after you apparently posted your additional response with a CL program to retrieve the I/O feedback area, did I actually see your response. At the moment, we are using the DTAQ implementation but I will save your example and when I get the chance will see that I can make that work as well. Thanks, Zack
    250 pointsBadges:
    report
  • TomLiotta
    Bruce deserves kudos not just for providing an answer, but also for having the courage to post it. I couldn't convince myself to go with _Riofbk, et al., when the question seemed to be basic. The vagaries of *PTR variables alone had me thinking the thread could go a long way. I sometimes forget that systems do exist without HLL compilers. Bruce never does. Tom
    125,585 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