MainframeSupports
tip week 48/2004:

In my daily work on the IBM mainframe PL/1 is my favourite programming language. PL/1 is far more elegant than COBOL will ever be all though I must admit that there are parts of PL/1 I don't like at all. I will now show you how smart it is to access main storage with PL/1 compared to COBOL. The tip from week 24/2002 shows the COBOL way of accessing main storage and explains a little about the control blocks being used.

In this tip I will show you how to find the name of the main LOAD module of the running task. You need to make the following declarations:

DCL psa_address FIXED BIN(31) INIT(0);
DCL psa_pointer POINTER BASED(ADDR(psa_address));
DCL 1 psa BASED(psa_pointer)
  , 2 filler CHAR(536)
  , 2 tcb_pointer POINTER
  ;
DCL 1 tcb BASED(tcb_pointer)
  , 2 rb_pointer POINTER
  ;
DCL 1 rb BASED(rb_pointer)
  , 2 filler CHAR(12)
  , 2 cde_pointer POINTER
  ;
DCL 1 cde BASED(cde_pointer)
  , 2 filler CHAR(8)
  , 2 loadmodule_name CHAR(8)
  ;

So far it doesn't look very smart. Compared to COBOL you can make all your declarations at the same spot in your source code. When you need to access the data in the declared structures PL/1 is far more elegant. Let us display the data:

PUT SKIP LIST('PSA = ' !! string(psa));
PUT SKIP LIST('TCB = ' !! string(tcb));
PUT SKIP LIST('RB = ' !! string(rb));
PUT SKIP LIST('CDE = ' !! string(cde));
PUT SKIP LIST('LOADMODULE = ' !! loadmodule_name);

This is all it takes. No need to set up addresses. You can address the declared variables directly. I only display the first part of the different control blocks. If you want to see more you can add a filler. Filler is not a special variable as it is in COBOL so you have to use different filler names at the same level in the same structure.

All though PL/1 has a display statement like COBOL I am not using it because a PL/1 display works like a COBOL "display upon console" and puts the data in the MVS log. The PUT statement writes data to DD name SYSPRINT.

Previous tip in english        Sidste danske tip        Tip list