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.

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.

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.

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.

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.