REXX code for pulling up info of a USERID



IBM's Command List programming language & Restructured Extended Executor

REXX code for pulling up info of a USERID

Postby mike may » Mon Sep 22, 2008 8:26 pm

Hi,

I am new to the site and also to REXX (my background is operations/scheduling/data transmissions). Could someone assist me in writing REXX code that would ask for USERID and pull it's pertinent info from a sequential file and display it on current TSO screen? Any help would be much appreciated.

Mike
mike may
 
Posts: 7
Joined: Mon Sep 22, 2008 8:11 pm
Has thanked: 0 time
Been thanked: 0 time

Re: REXX code for pulling up info of a USERID

Postby MrSpock » Mon Sep 22, 2008 8:57 pm

Any USERID, or their own USERID (which TSO should already know)?
User avatar
MrSpock
Global moderator
 
Posts: 809
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 4 times

Re: REXX code for pulling up info of a USERID

Postby mike may » Mon Sep 22, 2008 9:19 pm

The sequential dataset contains all TSO USEID's for my platform so I need to be use any ID to receive info (i.e. name, phone #, dept.).
mike may
 
Posts: 7
Joined: Mon Sep 22, 2008 8:11 pm
Has thanked: 0 time
Been thanked: 0 time

Re: REXX code for pulling up info of a USERID

Postby MrSpock » Mon Sep 22, 2008 9:42 pm

Well, then show us what you've done so far, or where you have a problem or don't know what to do.

Based on your high-level requirements, these are the REXX functions I think you might be using:

DO.

LEAVE.

PARSE.

SAY.

EXECIO.

POS (Position).

WORD.
User avatar
MrSpock
Global moderator
 
Posts: 809
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 4 times

Re: REXX code for pulling up info of a USERID

Postby mike may » Mon Sep 22, 2008 10:23 pm

So far I can ask for the USERID but stuck after that. Like I said, this is new to me but learning slowly. Here is what I have:

/* REXX */
PARSE UPPER ARG PGM

IF (PGM = '') THEN
DO
SAY ' '
SAY ' '
SAY ' '
SAY 'ENTER USERID:'
PULL INPGM
PGM = WORD(INPGM,2)
END
mike may
 
Posts: 7
Joined: Mon Sep 22, 2008 8:11 pm
Has thanked: 0 time
Been thanked: 0 time

Re: REXX code for pulling up info of a USERID

Postby MrSpock » Tue Sep 23, 2008 12:18 am

OK, got it so far. PGM will contain the value for the USERID to search for. You're allowing the user the option of specifying this value when they invoke your exec, otherwise you prompt them for it. Good idea.

Tip: The variable PGM will most likely contain embedded blanks. You should make sure that you get rid of them, or prevent them to begin with. You can either change your code slightly:

PARSE UPPER ARG PGM . <= add the dot
PULL INPGM . <= add the dot

or strip them out with STRIP or SPACE:

PGM = STRIP(PGM) or PGM = SPACE(PGM,0)

At this point, you'll have to read the file. Presuming that this file is relatively small, you can read it into a series of stem variables:

"EXECIO * DISKR INDD (STEM IN. FINIS"

where INDD is the DD name associated with your file and IN. is the stem variable name that the EXECIO function will populate the records into. The stem variables will be automatically incremented (IN.1, IN.2, etc.) and stem variable IN.0 will contain the value for the total number of records processed.

Then, you can search the stem variables until you find a matching entry in a DO loop

DO I = 1 TO IN.0 /* Loop through the entire stem variable array */
X = POS(PGM,IN.I)
IF X <> 0 THEN
DO
SAY IN.I
LEAVE
END
END

or read a single record at a time until a match is found

DO FOREVER
"EXECIO 1 DISKR INDD"
IF RC <> 0 THEN LEAVE
PULL IN
X = POS(PGM,IN)
IF X <> 0 THEN
DO
SAY IN
LEAVE
END
END
"EXECIO 0 DISKR INDD (FINIS"
User avatar
MrSpock
Global moderator
 
Posts: 809
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 4 times

Re: REXX code for pulling up info of a USERID

Postby mike may » Tue Sep 23, 2008 1:26 am

Ok, indd is "my.datase.name", correct? If not how will I tell REXX to search that dataset for USERID record?
mike may
 
Posts: 7
Joined: Mon Sep 22, 2008 8:11 pm
Has thanked: 0 time
Been thanked: 0 time

Re: REXX code for pulling up info of a USERID

Postby MrSpock » Tue Sep 23, 2008 1:07 pm

I'm not sure I'm following your question. REXX, like any other languauge, is not going to deal directly with a dataset. It will deal with the DD Name that you've specified to the system that points to that dataset.

In a batch job, you associate DD Names to the datasets using the DD parameter:

//INDD DD DSN=MY.DATASE.NAME,DISP=SHR

In TSO/E, you accomplish the same task using an ALLOCATE command:

ALLOC DD(INDD) DA('my.datase.name') SHR
User avatar
MrSpock
Global moderator
 
Posts: 809
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 4 times

Re: REXX code for pulling up info of a USERID

Postby mike may » Wed Oct 01, 2008 6:21 pm

I think I am getting closer, I am receiving message - IRX0026I / Line 39: Invalid whole number. Can anyone give me a clue what's wrong with the following:
/* REXX */                                       
PARSE UPPER ARG PGM                               
PULL INPGM                                       
IF (PGM = '') THEN                               
DO                                               
SAY ' '                                           
SAY ' '                                           
SAY ' '                                           
SAY 'ENTER USERID:'                               
PGM = WORD(INPGM,2)                               
"ALLOC FI(INDD) DA('DPMM05M.TSO.NAMES') SHR REUSE"
"EXECIO * DISKR INDD (STEM IN. FINIS"             
DONE = 'NO'                                       
LINENO = 0                                       
ACCT = '   '                                     
LASTNAME = '               '                     
FIRSTNAME = '             '                       
DO WHILE DONE = 'NO'                             
   "EXECIO 1 DISKR INDD"                           
   IF RC = 0 THEN       /* RECORD WAS READ */       
     DO                                             
       PULL RECORD                                 
                                                   
       LINENO = LINENO + 1  /*  COUNT THE RECORD  */
       IF INDEX(RECORD,PGM) ¬= 0 THEN               
         DO                                         
      DONE = 'YES'                                 
      ACCT = SUBSTR(PGM,12,4)                       
      LASTNAME = SUBSTR(RECORD,20,15)               
      FIRSTNAME = SUBSTR(RECORD,36,12)             
         END                                       
   ELSE NOP                                         
    END                                             
  ELSE                                             
    DONE = 'YES'                                   
 "EXECIO 0 DISKR INDD (FINIS"                       
SAY LASTNAME || FIRSTNAME   
RETURN LASTNAME || FIRSTNAME
EXIT 0
mike may
 
Posts: 7
Joined: Mon Sep 22, 2008 8:11 pm
Has thanked: 0 time
Been thanked: 0 time

Re: REXX code for pulling up info of a USERID

Postby MrSpock » Wed Oct 01, 2008 6:29 pm

mike may wrote:Can anyone give me a clue what's wrong with the following:


Could you please post a runtime TRACE listing of your program showing where the error occurs.
User avatar
MrSpock
Global moderator
 
Posts: 809
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 4 times

Next

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post