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
 

 

space suppression

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
mf_karthik

New User


Joined: 26 Jul 2005
Posts: 55

PostPosted: Thu Nov 05, 2009 8:47 pm    Post subject: space suppression
Reply with quote

hi,

here is my query

01 HS PIC X(50)

MOVE a-3 TO HS(1:30)
MOVE a-4 TO HS(31:20)

O/P
203 E...............................114 ABCD.

But i need the o/p as

203 E, 114 ABCD.

if there are less than 30 characters i don't need spaces sometimes i'll get value for tht 30 characters also.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Thu Nov 05, 2009 8:56 pm    Post subject:
Reply with quote

Starting at the 30th character of HS and going backwards, find the first non-space AFTER you've done the MOVE a-3 statement. Add 1 to that location, then move in the comma, add 1 and use this as the starting location of HS for the MOVE a-4 statement.
Back to top
View user's profile Send private message
mf_karthik

New User


Joined: 26 Jul 2005
Posts: 55

PostPosted: Fri Nov 06, 2009 9:24 am    Post subject: Reply to: space suppression
Reply with quote

thnks for your reply..can u explain it little more..

any suggestions.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Nov 06, 2009 9:39 am    Post subject:
Reply with quote

Hello,

Quote:
any suggestions.

Suggest you write code such as Robert described. . .

What is not clear? What have you coded so far?

Move spaces to HS. Then, there should be a move (a-3), a loop to find the last position in the HS field, and another move (a-4) to the position that is one greater than the last position filled with a non-space by the first move.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Fri Nov 06, 2009 3:46 pm    Post subject:
Reply with quote

This is a HELP forum, not a WRITE-THE-CODE-FOR-YOU forum. Once you post code that you're having a problem with, we can help you more. But unless you're showing some initiative in writing code, we won't write it for you.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Nov 06, 2009 5:04 pm    Post subject:
Reply with quote

how many times have we seen this homework assignment?

tally reverse, move (xx:xx)

search the forum for 'reverse', there are many posts where the TS needed to concatenate strings that had spaces at the end.
Back to top
View user's profile Send private message
k.junaid83

New User


Joined: 19 Apr 2006
Posts: 22
Location: bangalore

PostPosted: Fri Nov 06, 2009 7:16 pm    Post subject:
Reply with quote

Another option is

STRING a-3 DELIMITED BY SPACES,
a-4 DELIMITED BY SPACES,
INTO HS
END-STRING.
Back to top
View user's profile Send private message
k.junaid83

New User


Joined: 19 Apr 2006
Posts: 22
Location: bangalore

PostPosted: Fri Nov 06, 2009 7:20 pm    Post subject:
Reply with quote

Oh I forgot the statement to add comma, My apologies

STRING a-3 DELIMITED BY SPACES,
',' DELIMITED BY SIZE,
a-4 DELIMITED BY SPACES,
INTO HS
END-STRING.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Nov 06, 2009 8:16 pm    Post subject:
Reply with quote

k.junaid83,

problem with your solution is that the initial strings contain spaces.

203 E...............................114 ABCD

so, the end result of your solution would be:

203,114

instead of:
203 E, 114 ABCD

and before you step on yourself, and suggest that the delimiter be two spaces,

if the initial string were 29 chars, with intervening spaces, you would still end up with a 30 char move.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Fri Nov 06, 2009 8:27 pm    Post subject:
Reply with quote

Dick: BTDTGTTS? icon_biggrin.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Nov 06, 2009 9:13 pm    Post subject:
Reply with quote

took me a couple of times but finally learned how and when to use UNSTRING
Back to top
View user's profile Send private message
mf_karthik

New User


Joined: 26 Jul 2005
Posts: 55

PostPosted: Sat Nov 07, 2009 3:23 pm    Post subject: Reply to: space suppression
Reply with quote

robert,

i don't need the code,i asked for the explanation of reverse syntax..i know the basic commaon sense tht need to search the forum before posting the question..i searched but did'nt get the answer...

thanks for all the replies
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Sat Nov 07, 2009 6:21 pm    Post subject:
Reply with quote

Method 1:
FUNCTION REVERSE is documented in the COBOL Language Reference manual (link at the top of the page), coupled with INSPECT and moves using reference modification.

Method 2:
Run a loop from 30 to 1 checking each character (using reference modification) of HS to be spaces. Exit the loop when you find one that isn't. Add 1 to the position and that tells you where to move the comma (and the other data field).
Back to top
View user's profile Send private message
dchristensen

New User


Joined: 26 Jul 2006
Posts: 30
Location: Des Moines, Iowa

PostPosted: Mon Nov 09, 2009 9:54 pm    Post subject: ALso with the string syntax
Reply with quote

If you would also include a WITH POINTER in the string statement, you would have a length you could use for a move that would strip off the trailing spaces.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
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 VTS and space BobGilbert All Other Mainframe Topics 2 Mon Jan 11, 2016 5:08 am
No new posts DFSORT - Space issue santosh_g DFSORT/ICETOOL 3 Fri Sep 04, 2015 7:44 am
No new posts How to read the db2 table space statu... cmsmoon DB2 3 Fri Apr 17, 2015 2:29 am


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