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
 

 

String Handling problem.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
tosaurabh20

New User


Joined: 08 Jun 2007
Posts: 26
Location: Noida

PostPosted: Fri Jul 13, 2007 10:47 am    Post subject: String Handling problem.
Reply with quote

Hi,

I have a program in which i am accepting input from the file.
Now there is a field in file record which gets a value of client ID from the file. It is usually of 5 characters. But if sometimes it is less than 5 characters then there exists trailing spaces.

Now My doubt is how to remove such trailing spaces ?
Is this can be done through any string handling commands?

I will provide you an example.

Client ID- A -------50768
Client ID- B -------123

Now for A there is no need of touching the record fields but for client B i have to remove two trailing spaces.


Thanks
Saurabh Gupta
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Jul 13, 2007 11:27 am    Post subject: Re: String Handling problem.
Reply with quote

tosaurabh20 wrote:
Now My doubt is how to remove such trailing spaces ?
Is this can be done through any string handling commands?

I will provide you an example.

Client ID- A -------50768
Client ID- B -------123

Now for A there is no need of touching the record fields but for client B i have to remove two trailing spaces.
What are you going to replace the trailing spaces with?
What size is the field you want to move client B into?
Or do you want the trailing spaces with leading spaces?
Like:
Code:

Client ID- B -------123
Client ID- B -------  123
Back to top
View user's profile Send private message
tosaurabh20

New User


Joined: 08 Jun 2007
Posts: 26
Location: Noida

PostPosted: Fri Jul 13, 2007 11:33 am    Post subject: Re: String Handling problem.
Reply with quote

William Thompson wrote:
tosaurabh20 wrote:
Now My doubt is how to remove such trailing spaces ?
Is this can be done through any string handling commands?

I will provide you an example.

Client ID- A -------50768
Client ID- B -------123

Now for A there is no need of touching the record fields but for client B i have to remove two trailing spaces.
What are you going to replace the trailing spaces with?
What size is the field you want to move client B into?
Or do you want the trailing spaces with leading spaces?
Like:
Code:

Client ID- B -------123
Client ID- B -------  123


Hi William,

I just wish to remove the spaces.
There is nothing through which i can replace them, actually this program does some reformatting of the string and prpare reformatted output file.this is the requirement from the client side.

let me know in case of any issues.

Thanks
Saurabh Gupta
Back to top
View user's profile Send private message
ParagChouguley

Active User


Joined: 03 Feb 2007
Posts: 175
Location: PUNE(INDIA)

PostPosted: Fri Jul 13, 2007 11:50 am    Post subject:
Reply with quote

Quote:
Hi William,

I just wish to remove the spaces.
There is nothing through which i can replace them,


Hi tosaurabh20,

William asked right question. You have to clearly tell what the spaces are to be replaced with. There is no concept of "Removing spaces from variables" in COBOL. You can count leading/ trailing spaces and shift your value to right or left accordingly.

--Parag
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Jul 13, 2007 11:51 am    Post subject:
Reply with quote

What size is the field you want to move client B into?

If the value is going to be reformatted to an output, that is when the trailing spaces will best be ignored is that string command by delimiting by those spaces.
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 Jul 13, 2007 11:48 pm    Post subject:
Reply with quote

Hello,

What process do you need to implement that requires their "removal"?

As has been mentioned, the bytes are there and they will contain something.
Back to top
View user's profile Send private message
wicked1925

New User


Joined: 12 Mar 2007
Posts: 15
Location: Philippines

PostPosted: Sat Jul 14, 2007 12:18 pm    Post subject:
Reply with quote

Hi tosaurabh20,

You can validate each character in your Client ID field until you reach the last byte (5th char) and store each character in a variable. Now if in any instance you encountered a space you must immediately terminate the validation process. The only problem is you must know the minimum size that the Client ID field can have for you to eliminate the space when you store the validated characters in your variable.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Sat Jul 14, 2007 7:54 pm    Post subject:
Reply with quote

You could define

10 WS-STRING-LEN pic 9(1).
10 WS-STRING OCCURS DEPENDING ON WS-STRING-LEN
15 STRING-CHAR PIC X(1).

Unstring using SPACE into the ws-string field and put the length in the proper place..... You have a variable lenght string then (well sort of)
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: Sat Jul 14, 2007 10:53 pm    Post subject:
Reply with quote

Hello,

If a better requirement definition is posted, we will be better able to offer suggestions.
Back to top
View user's profile Send private message
eHorizon.Andrew

New User


Joined: 18 Jan 2007
Posts: 28
Location: Bank of communications

PostPosted: Wed Jul 18, 2007 2:39 pm    Post subject:
Reply with quote

stodolas wrote:
You could define

10 WS-STRING-LEN pic 9(1).
10 WS-STRING OCCURS DEPENDING ON WS-STRING-LEN
15 STRING-CHAR PIC X(1).

Unstring using SPACE into the ws-string field and put the length in the proper place..... You have a variable lenght string then (well sort of)


hi stodolas,

could you pls explain more exactly? Sorry for bothering you! I am green hand on COBOL! icon_sad.gif
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: Wed Jul 18, 2007 9:05 pm    Post subject:
Reply with quote

Hello,

As was mentioned earlier, if you describe how you will use the "output" field, we will be better able to help.

Keep in mind that your meaning is quite clear to you, but not to everyone else.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Jul 18, 2007 9:17 pm    Post subject:
Reply with quote

I gave a possible thing to do, but as Dick infers variable length strings just don't make sense in COBOL.

Variable length strings are a hack and could cause many problems with copybooks and file layouts.
Back to top
View user's profile Send private message
SHAILESH OZA

New User


Joined: 10 Jun 2005
Posts: 21
Location: Mumbai

PostPosted: Mon Jul 23, 2007 10:16 pm    Post subject: Re: String Handling problem.
Reply with quote

Hi

i am suggesting one code which will not use string or unstring but what you want will get solve ?

declare variables

01 WS-CLIENTID1 PIC X(10).
01 WS-CLIENTID2 PIC X(10).
01 J PIC 9(1) VALUE 1.

PERFORM PARA1 VARYING I FROM 1 BY 1 UNTIL I>= 10.

PARA1.

IF WS-CLIENTID1(I) IS ALPHANUMERIC
MOVE WS-CLIENTID(I) TO WS-CLIENTID2(J)
COMPUTE J = J + 1
ELSE
NEXT SENTENCE
END-IF.

After completion of this upto the lengh , i hope the space or any other special charecters are removed IN WS-CLIENTID2.

I am writing this code on trial and error basis. you can please check it.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Mon Jul 23, 2007 10:31 pm    Post subject:
Reply with quote

SHAILESH OZA:

You aren't going to be trimming spaces from the end of the WS-CLIENTID1 when you move it to WS-CLIENTID2, you are preserving the string as is. The original requirement from what we can gather is a variable length string without the trailing spaces.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Jul 23, 2007 11:54 pm    Post subject:
Reply with quote

Hi Saurabh,

I think the confusion stems from our not knowing how the receiving data will look after you move 123 there without the spaces.

Will it be a report line that shows the ID, name and address of a worker, for example:

123 John Doe 10 Last Place, New York, National League (or some such).

Or will it be in a 50 byte field with similar info.

Give us an example of what it will look like afer it's "moved".
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Tue Jul 24, 2007 1:25 am    Post subject:
Reply with quote

After my last project, I can see it could be something a simple as building a XML output, eliminating the trailing spaces before plugging in the closing tag.....

But Saurabh Gupta has been in&out at least once without bothering to clear up the general confusion about his/her request/requirement....

As a systems person, is "software engineer" a synonym for programmer?
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Tue Jul 24, 2007 1:49 am    Post subject:
Reply with quote

William, doesn't the XML GENERATE automagically remove trailing spaces for you?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Tue Jul 24, 2007 1:55 am    Post subject:
Reply with quote

Usually, but not always, and sometimes those "small boxen" people choose tags that exceed the COBOL max length....grumble.....
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: Tue Jul 24, 2007 2:19 am    Post subject:
Reply with quote

Also, it has now been around 10 days since TS posted any follow-up.
Back to top
View user's profile Send private message
chintan

New User


Joined: 01 Jun 2007
Posts: 2
Location: banglore

PostPosted: Wed Jul 25, 2007 10:38 am    Post subject: String Handling problem.
Reply with quote

u try for justify right it is synax.......i m not sure but it will solve your problem......
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
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
No new posts DB2 Streaming Batch Processing Problem Manshadi DB2 4 Sat Sep 24, 2016 12:14 pm
No new posts Problem with GETMAIN command amitc23 CICS 6 Thu Sep 01, 2016 1:01 pm


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