Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Retain Leading space

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: Retain Leading space
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: 1529
Location: Andromeda Galaxy

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

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

Moderator Team Head


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

PostPosted: Sat Jan 18, 2014 1:46 am    Post subject: Reply to: Retain Leading space
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

Senior Member


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

PostPosted: Mon Jan 20, 2014 8:00 pm    Post subject: Reply to: Retain Leading space
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: 6966
Location: porcelain throne

PostPosted: Fri Jan 31, 2014 6:24 pm    Post subject:
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: 1715
Location: UK

PostPosted: Fri Jan 31, 2014 6:45 pm    Post subject: Reply to: Retain Leading space
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: 1238
Location: Richfield, MN, USA

PostPosted: Fri Jan 31, 2014 8:08 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Difference space showed for TS and it... autobox DB2 1 Thu Apr 14, 2016 1:07 pm
No new posts How to find Table-space and Index-spa... venksiv DB2 5 Wed Feb 03, 2016 6:16 pm
No new posts SAS - RETAIN statement Musab Ahmed IBM Tools 2 Thu Jan 28, 2016 1:02 pm
No new posts VTS and space BobGilbert All Other Mainframe Topics 2 Mon Jan 11, 2016 5:08 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us