parsing help in IBM rexx 3270 mainframe retain

Ask/Clarify the questions on TSO, CLIST & REXX

Moderators: Veera, Moderator Group

Post Reply
kirk_varra
Member
Posts: 5
Joined: Thu Dec 15, 2011 7:15 am

parsing help in IBM rexx 3270 mainframe retain

Post by kirk_varra » Thu Dec 15, 2011 8:25 am

I am trying to parse a user name that is entered, calculate the amount of characters it is, and then add spaces after the name til it is 22 characters long. Here is my code so far:

Code: Select all

GetInputUserName:
  /*************************************************************************/
  /* Get users UserName.                                                   */
  /*************************************************************************/
  /**************************************************************************/
  DO
    SAY'Enter the new users Name.'
    PARSE UPPER PULL UserName 
    IF (LENGTH(UserName) > 22) THEN
      DO
        UserName = ''
        SAY'User Name cannot be longer than 22 characters.'  
      END
	 IF &#40;LENGTH&#40;UserName&#41; < 22 THEN
	  /** I think a loop needs to go here**/
    ELSE
      NOP
  END  
I think i need to create a loop to add in the spaces and have it check each time to see if it has reached the 22 character mark. However im not sure how to add in a space each time or exactly how to write the loop.
any advise sure would help.

thanks,
Kirk

MrSpock
Active Member
Posts: 273
Joined: Wed Jun 27, 2007 5:37 pm

Post by MrSpock » Thu Dec 15, 2011 2:39 pm

Why not just Left Justify UserName to a length of 22?

kirk_varra
Member
Posts: 5
Joined: Thu Dec 15, 2011 7:15 am

Post by kirk_varra » Thu Dec 15, 2011 6:37 pm

the left justify is a fantastic idea. however I cant get it to work. I get the error 'could not find routine'. I tried both:

Code: Select all

JUSTIFY&#40;UserNamer,22&#41; 
and

Code: Select all

LEFT&#40;UserName,22&#41;
So my changed code looks like this:

Code: Select all

  DO
    SAY'Enter the new users Name.'
    PARSE UPPER PULL UserName 
    IF &#40;LENGTH&#40;NewID&#41; > 22&#41; THEN
      DO
        UserName = ''
        SAY'User Name cannot be longer than 22 characters.'  
      END
	 IF &#40;LENGTH&#40;NewID&#41; < 22&#41; THEN
		DO
			JUSTIFY&#40;UserName,22&#41;
		END
    ELSE
      NOP
  END  
any ideas?

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu Dec 15, 2011 7:44 pm

i'd, personnally, write it this way:

Code: Select all

SAY'Enter the new users Name.'
PARSE UPPER PULL UserName
New_Id = translate&#40;justify&#40;translate&#40;username,'#',' '&#41;,22&#41;,' ','#'&#41;
that way does not matter if the username entered is one or more than one word.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

kirk_varra
Member
Posts: 5
Joined: Thu Dec 15, 2011 7:15 am

Post by kirk_varra » Thu Dec 15, 2011 8:34 pm

I like the way you coded that for more than one word. the agents do need to enter in Lname, Fname. However, the rexx we use i think is pretty basic. I looked into the justify command some more and it looks like its an extended function of rexx so i dont believe we will be able to call it. I still get the error 'could not find routine' "JUSTIFY"

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu Dec 15, 2011 9:43 pm

you need to spend some time reading
the format of your instruction is faulty.

JUSTIFY, just like all other FUNCTIONS, RETURNS SOMETHING.
you have not provided a variable for the value returned by the function.

you have to code VAR = JUSTIFY(string,resultant length of string, pad character)
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

kirk_varra
Member
Posts: 5
Joined: Thu Dec 15, 2011 7:15 am

Post by kirk_varra » Fri Dec 16, 2011 12:55 am

I use a variable before the JUSTIFY function. I used the code you provided exactly. only I changed the New_Id to UserName.

Code: Select all

  DO
    SAY'Enter the new users Name.'
    PARSE UPPER PULL UserName 
	UserName = translate&#40;justify&#40;translate&#40;username,'#',' '&#41;,22&#41;,' ','#'&#41;
    ELSE
      NOP
 END  
My thought was that I could take the variable UserName and convert it. I believe that is right. However im still getting the same error as above.

and I am reading. everything i can. but I dont understand it yet so what im reading makes little sense still.

thanks for the help,
Kirk

kirk_varra
Member
Posts: 5
Joined: Thu Dec 15, 2011 7:15 am

Post by kirk_varra » Fri Dec 16, 2011 1:18 am

Following what you were saying I was able to figure it out with this. I was able to test it and it works. Thank you much for helping along the path i needed to look. I was lost.

Code: Select all

 DO
    SAY'Enter the new users Name.'
    PARSE UPPER PULL UserName 
		DO
			UserName = LEFT&#40;UserName,22, &#41;
		END
 END
The last time I tried the left command I made the mistake of not putting the pad in there after the 22, and also i had messed up the variable.

Thanks again.
Kirk

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Fri Dec 16, 2011 1:27 am

remove the ELSE and the NOP
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others