IBM REXX Interview Preparation Guide
Download PDF

IBM REXX frequently Asked Questions by expert members with experience in IBM REXX. So get preparation for the IBM REXX job interview

12 IBM REXX Questions and Answers:

1 :: How to access data held on the JES spool?

Held output (JES2 or JES3) can be captured by outtrapping
the output of the following command

"OUTPUT jobname PRINT(*) KEEP".

Use command HELP OUTPUT for more information.

Furthermore there are output tools you can buy like SDSF,
IOF, (E)JES, etc. But not all of these have got a rexx
interface.

2 :: How to access data in control blocks such as jobname?

Use the Storage() function to extract the data from control
blocks.

/* REXX Get taskname from TCB */
cvt = storage(10,4) /* FLCCVT-PSA data area */
tcbp = storage(d2x(c2d(cvt)),4) /* CVTTCBP */
tcb = storage(d2x(c2d(tcbp)+4),4)
tiot = storage(d2x(c2d(tcb)+12),4) /* TCBTIO */
say strip(storage(d2x(c2d(tiot)),8)) /* TIOCNJOB */

3 :: How to find or access the current level of a GDG?

You may use this

CALL BPXWDYN "ALLOC DD(ddn) SHR DSN('"gdg"(0)') RTDSN(GDGN)"

Afterwards GDGD contains the name of the actual gdg data
set.

4 :: How to Run My Rexx Exec?

Make sure the Exec starts with the /* REXX */ comment.
TSO EXEC 'hlq.your.dsn(member)' runs Rexx in exactly the
same way as it would a CLIST.
TSO EX yourlib(member) E uses a suffix of EXEC and the TSO
profile prefix to form a full DSN
of 'your_prefix.yourlib.EXEC(member)'
The SYSEXEC concatenation can be used to run execs using
TSO execname. The SYSPROC concatenation will do just as
well, but is really intended for CLISTS.
TSO %execname parameter_string allows you to pass a
parameter string to the exec, note that this string is only
a single argument, not multiple arguments as can be used
when calling from within an exec. The '%' instructs TSO to
not use loadlib concatenations when constructing the search
path.
For running Rexx in batch:

Create a batch environment for the Exec to run in with
PGM=IRXJCL, PGM=IKJEFT01 or PGM=IKJEFT1B
IRXJCL is a straight batch environment
IKJEFT01 and IKJEFT1B are the TSO in batch programs.
Put the Rexx exec libraries in the SYSEXEC DD
concatenation.
Call your exec via the PARM='yourprog' or as input in the
SYSTSIN DD

5 :: Suppose i want to code a rexx program in order to get the inputfile and output files of jcl. i want code snippet or the coding for this?

If you know the ddnames of the files being used, then you
can get the infor via the LISTDSI function.
rc = LISTDSI( ddname "FILE")
If the rc = 0 then the dsname is in de variable SYSDSNAME.

If you do not know the ddnames of the files allocated to
your program, you can get the information via TSO with:
Address TSO "LISTA" or Address TSO "LISTA STATUS"

Set up OUTTRAP first so you can capture the output and via
REXX scroll through it.

The difference between LISTA and LISTA STATUS is that LISTA
will only give the datasetnames of all allocated datasets.
LISTA STATUS will give you the ddname followed by all
datasets that are allocated to the ddname for all the
datasets.

8 :: Suppose If there are a set of statements and each has a word "value" in it, If I want to display all these statements so that the word "value" is aligned, then how do
I code this in REXX.
e.g - The value of X is Y.
Wot is its value?
Do u know its value?
I want to know its value?

/**REXX**/
ADDRESS TSO
"ALLOC DD(INP1) DA('input-dataset') SHR REUS"
"EXECIO * DISKR INP1 (STEM IN1. FINIS"
MAX_OFFSET = 0
INP_OFFSET = 0
DO I = 1 TO IN1.0
PARSE UPPER VAR IN1.I INP
INP_OFFSET = POS("VALUE",INP)
IF INP_OFFSET > MAX_OFFSET THEN
DO
MAX_OFFSET = INP_OFFSET
END
END
DO I = 1 TO IN1.0
PARSE UPPER VAR IN1.I INP
Z = POS("VALUE",INP)
SAY LEFT(SUBSTR(IN1.I,1,(Z - 1)),(MAX_OFFSET - 1))||,
SUBSTR(IN1.I,Z,20)
END
"FREE DD(INP1)"

9 :: I want to code a REXX Program in order to load many tables in a database simultaneously in a batch fashion. Currently batch codes ar available in which only one job is submitted at a time and this loads only one table. My requirement is that many tables should be loaded at a time when one Job is submitted and can this be done using REXX Tool?

Not exactly sure what you are asking.

Can a REXX exec submit multiple jobs via the internal
reader? Yes.

Can you update multiple tables in a RDBMS? Yes, however
referential integrity could be compromised and RDBMS
overhead could be a serious issue.

Let's assume that you have that you are seeking to load DB
tables from a 100K+ 1NF file which has some 6257 bytes per
recode You would use REXX (CMSPIPES) to split the file while
keeping a common key. You would split this 1nf record in 3nf
tables. You would need to know the data and some aspects on
how it will be used --- Remember Data Privacy is important too.

10 :: How to code the db2 queries using rexx, and also plz send some link and examples using db2 queries?

REXX doesn't have support to DB2. But still you can access
it thru some TSO CPs. One of the commercial CP is
REXXTOOLS/MVS. If your shop has that s/w installed you
could able to access DB2.