IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search Log in to check your private messages Log in
 

Retain Leading space


 
IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: :: View next topic  
Author Message
passion_sujesh

New User


Joined: 14 Mar 2008
Posts: 74
Location: India,Chennai

PostPosted: Sat Jan 18, 2014 12:30 am
Reply with quote

Hi,

Iam trying to selecta part of a string using SUBSTR function. This works fine if the string has no leding spaces. If the string has leading spaces, its not working as expected. Can any one help me in retaining the leading spaces while using substr.

My input (variable name - ws-xyz):
Code:
"123456"
"234567"
"   4788"  (two leading spaces)
"564786"


ws-new-data = substr(ws-xyz,3,2)

My expected output:
Code:
34
45
47
47


Output i get:
Code:

34
45
88
47


The third record in the o/p is incorrect.
I think the leading space is removed before the substr, is there any way i can retain the leading space.

Thanks.

Code'd
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1566
Location: Andromeda Galaxy

PostPosted: Sat Jan 18, 2014 1:12 am
Reply with quote

Could you post the trace output within code tags?
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4650
Location: Raleigh, NC, USA

PostPosted: Sat Jan 18, 2014 1:46 am
Reply with quote

First of all, these:

ws-xyz
ws-new-data

are invalid variable names in REXX. Adjusting for that:

ws_new_data = Substr(ws_xyz,3,2)
Say "'"ws_new_data"'"

I get:

'34'
'45'
'47'
'47'

in my output.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2206
Location: Silicon Valley

PostPosted: Mon Jan 20, 2014 8:00 pm
Reply with quote

You have not shown how the values are assigned to the variable.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Fri Jan 31, 2014 6:24 pm
Reply with quote

even though the TS has not returned:
1. REXX is pretty tight. i have not found (in 20 years) any problem
other than my ability to understand the manual.

2. if you think something is not working 'as expected'.
do a little debugging.

use SAY LENGTH(variable)
use SAY variable

use TRACE. I find ?R to be most helpful.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2429
Location: Hampshire, UK

PostPosted: Fri Jan 31, 2014 6:45 pm
Reply with quote

Use:
Code:
Say '>'variable'<'

the number of times I have found trailing blanks when there "weren't" any using this method!
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Fri Jan 31, 2014 8:08 pm
Reply with quote

Nic's suggession of using > and < is valuable for COBOL displays also. Leading or trailing unprintable characters are spotted easily this way.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> CLIST & REXX
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Forum Replies
No new posts DB2 tablespace space limitation DB2 3
No new posts Eliminating blank space in XML parsed... COBOL Programming 0
No new posts Getting space used/allocated for many... CLIST & REXX 10
No new posts What is a table space in db2 for z/os? DB2 13
No new posts VSAM Space allocated and used space ... JCL & VSAM 5

Back to Top