I'm sorry, I'm not at a terminal so my idea had not been proven.
Il giorno ven 1 ott 2021 alle ore 17:46 Massimo Biancucci <[email protected]> ha scritto: > Bernd, > > AFAIK the SET ADDRESS OF is to set a pointer to address a piece of storage. > This is why Cobol doesn't you allow to do such a command. > > If you want to "grab" the ADDRESS OF your working storage variable, you > should define a POINTER in LINKAGE then set it to the value and then move > it to your commarea pointer. > > CALLING-PROGRAM. > WORKING-STORAGE. > > 01 MY-AREA PIC X(1000) > 01 COMMAREA. > 05 CA-FUNCTION_CODE PIC X(8). > 05 CA-STATUS PIC 99. > 05 CA-AREA-ADDR USAGE POINTER. > 05 CA-AREA-LEN PIC S9(4) COMP. > > LINKAGE-SECTION. > 01 MY-PTR USAGE IS POINTER. > > PROCEDURE DIVISION. > > SET MY-PTR TO ADDRESS OF MY-AREA. > MOVE MY-PTR TO CA-AREA-ADDR. > > Best regards. > Max > > > Il giorno ven 1 ott 2021 alle ore 15:50 Bernd Oppolzer < > [email protected]> ha scritto: > >> Probably asking a COBOL question for the first time :-) >> >> I am thinking about writing a general sub-program using COBOL which does >> several different computations, each of them needing different input and >> output data >> of different size. >> >> Because this should work with Batch and CICS, I am thinking about a >> single communication area >> with fixed size, which points to another communiation area of variable >> size. >> >> The area looks like this: >> >> 01 COMMAREA. >> 05 CA-FUNCTION_CODE PIC X(8). >> 05 CA-STATUS PIC 99. >> 05 CA-AREA-ADDR USAGE POINTER. >> 05 CA-AREA-LEN PIC S9(4) COMP. >> >> I managed to write the called subroutine; the COMMAREA is in the LINKAGE >> SECTION there, >> and I can use the address in the CA-AREA-ADDR and read and write the >> values >> in the variable comm-area, which is linked to the fixed area. No problem >> so far. >> >> But: >> >> in the calling program, when setting up the COMMAREA. >> I cannot put the address of a WORKING-STORAGE FIELD into the >> CA-AREA-ADDR. Because simply it is not allowed to use >> SET CA-AREA-ADDR TO ADDRESS OF field on WS fields. >> >> Why? IMO there is no danger in passing the address of a WS field to a >> subprogram. >> Even if the WS field were in automatic storage (which it is not, IMO), >> there would be no problem. In fact, this is done implicitly using >> call-by-reference, >> but I want to do it now sort of explicitly (this way overcoming some >> restrictions >> with CICS and fixed lengths of COMMAREAs). >> >> I recall having seen the DB2 precompiler generating ASSEMBLER routine >> calls >> to do just this (getting the address of a WS field to feed it into the >> DB2 interface >> DSNHLI). Is this the only possible way to go? >> >> Thank you, kind regards >> >> Bernd >> >> ---------------------------------------------------------------------- >> For IBM-MAIN subscribe / signoff / archive access instructions, >> send email to [email protected] with the message: INFO IBM-MAIN >> > ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
