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
 

 

How to strip the spaces in COBOL program.

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

New User


Joined: 14 Sep 2005
Posts: 16

PostPosted: Wed Oct 26, 2005 7:43 pm    Post subject: How to strip the spaces in COBOL program.
Reply with quote

Hi,
I have to strip the values and should cancatenate them.
The Problem is :

I have the two fields

ws-fullname pic x(32)
ws-lastname pic x(32)

Resultant field:
ws-name pix x(64).

Here the Values in the fileds are
ws-fullname = 'A FULLNAME'
ws-lastname = 'LASTNAME'

here the resulatnat value should be 'A FULLNAME LASTNAME'

Here i need to strip the values and then concatenate like what we will do in feching the fields from db2 tru strip function, but in COBOL i couldnt able to use this.
So any one can suggest me how to strip the fileds and concatenate.
It would be grate if you provide some piece of code.
Thanks in Advance.

Regards,
Kiran.
Back to top
View user's profile Send private message

tdsvamsidhar

New User


Joined: 03 Oct 2005
Posts: 7

PostPosted: Thu Oct 27, 2005 9:21 am    Post subject: Re: How to strip the spaces in COBOL program.
Reply with quote

Try doing the following.

Iniitalize your variables with some character which you think does not come in the ws-firstname or secondname.

WS-FIRSTNAME pic X(32) value '////////////////////////'
WS-SECONDNAME pic X(32) value '////////////////////////'


move 'A FIRSTNAME' to WS-FIRSTNAME
move 'SECONDNAME' to WS-SECONDNAME

INSPECT WS-FIRSTNAME TALLYING WS-COUNT FOR CHARACTERS AFTER
INITIAL '/'.

COMPUTE WS-COUNT1 = 32 - WS-COUNT

MOVE ws-firstname(1:WS-COUNT1) to NEWVAR(1:WS-COUNT1)

Do the same for the second variable..

Hope this helps..Please somebdoy correct me if I am wrong.
Back to top
View user's profile Send private message
k_kirru
Currently Banned

New User


Joined: 14 Sep 2005
Posts: 16

PostPosted: Thu Oct 27, 2005 10:58 am    Post subject: Re: How to strip the spaces in COBOL program.
Reply with quote

Hi, Thanks....
What you have told is correct, but the filed names are coming from file, so when we move from the file to initialzed variables (/), here in the file itselef there might be some spaces so it over writes the initialized variables, hence its not working in my case. can you suggest me in any way..
Back to top
View user's profile Send private message
tdsvamsidhar

New User


Joined: 03 Oct 2005
Posts: 7

PostPosted: Thu Oct 27, 2005 11:08 am    Post subject: You can do the following
Reply with quote

You can declare two other temp variables which receives the values from file variables and you can inspect the temp variables like I said earlier. Is that OK. Let me know.
Back to top
View user's profile Send private message
ikumar

New User


Joined: 02 Aug 2005
Posts: 81

PostPosted: Thu Oct 27, 2005 8:58 pm    Post subject: Re: How to strip the spaces in COBOL program.
Reply with quote

Hi,

check the below solution, you can implement it if you like the same...

1) using inspect fill all the SPACES in your first field to some delimiter that you would not face in your data, for example, '~'
2) Reverse the string using FUNCTION
for ex, MOVE FUNCTION REVERSE(WS-STRING) TO WS-STRING
3) using inspect fill all the leading delimiter '~' with spaces.
4) Do the reverse of the string again and
5) STRING WS-FIRSTNAME DELIMITED By ws-space and one space and WS-LASTNAME.


INSPECT WS-FIRSTNAME REPLACING ALL " " BY "~"
MOVE FUNCTION REVERSE(WS-FIRSTNAME) TO WS-FIRSTNAME
INSPECT WS-FIRSTNAME REPLACING ALL LEADING "~" BY " "
MOVE FUNCTION REVERSE(WS-FIRSTNAME) TO WS-FIRSTNAME
STRING WS-FIRSTNAME DELIMITED By ws-space
SPACE
WS-LASTNAME

just correct yourself if any syntax errors are there in the above code...and please let me know whether it has worked or not...

Hope this helps...

Cheers,
Kumar.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Oct 30, 2005 7:39 am    Post subject:
Reply with quote

Hi Kiran,

You can try something like this (untested):
Code:

MOVE ZERO TO L
INSPECT FUNCTION REVERSE(ws-fullname) TALLYING L FOR LEADING SPACES
COMPUTE L1 = LENGTH OF ws-fullname - L

MOVE ZERO TO L
INSPECT FUNCTION REVERSE(ws-lastname) TALLYING L FOR LEADING SPACES
COMPUTE L2 = LENGTH OF ws-lastname - L

STRING ws-fullname(1:L1) ' ' ws-lastname(1:L2) DELIMITED BY SIZE
  INTO ws-name
END-STRING
Back to top
View user's profile Send private message
ss.vijaysb1984

New User


Joined: 25 Jul 2008
Posts: 2
Location: India-Chennai

PostPosted: Wed Nov 12, 2008 3:29 pm    Post subject: Reply to: How to strip the spaces in COBOL program.
Reply with quote

Thisi is Very usefull for me...
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu Nov 13, 2008 2:09 am    Post subject:
Reply with quote

Now that's the adventure of Forums..you find something very handy. And thanks for letting us know that yeah..some one is using the "Search" facility of this site.

-Ad
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu Nov 13, 2008 2:10 am    Post subject:
Reply with quote

Mcmillian,

Can't we get a count of "how many times the search button was hit" for a given day.. icon_razz.gif
Back to top
View user's profile Send private message
mcmillan

Site Admin


Joined: 18 May 2003
Posts: 1202
Location: India

PostPosted: Thu Nov 13, 2008 2:39 am    Post subject:
Reply with quote

Quote:
Can't we get a count of "how many times the search button was hit" for a given day..


Yes, we can get it from the server access_log, if needed icon_smile.gif
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 XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm
No new posts pre-compiler for program in an HFS Pedro DB2 0 Fri Jun 23, 2017 11:13 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm


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