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 remove spaces while performing STRING operation
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
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Thu Jan 15, 2009 12:51 pm    Post subject: How to remove spaces while performing STRING operation
Reply with quote

Hi,

I am stringing the below 2 fields into W-OUTPUT-REC.

77 VENDOR PIC X(20).
77 LOCATION PIC X(20).

77 W-OUTPUT-REC PIC X(60).

If VENDOR and LOCATION has contains the data as below

VENDOR: FIRST DATA
LOCATION: BOMBAY

After i execute

STRING VENDOR DELIMITED BY SIZE
LOCATION DELIMITED BY SIZE
INTO W-OUTPUT-REC.

o/p : FIRST DATA BOMBAY

after BOMBY i am getting 20 dots, i want to remove the dots also

I want o/p should be FIRST DATABOMBAY

Could any one help in this.

Regards
Suneel
Back to top
View user's profile Send private message

technut

New User


Joined: 27 Dec 2007
Posts: 73
Location: India

PostPosted: Thu Jan 15, 2009 3:34 pm    Post subject: Reply to: How to remove spaces while performing STRING opera
Reply with quote

Hi,

You can try this..

MOVE SPACES TO ERROR-RECORD.

STRING VENDOR DELIMITED BY SIZE
LOCATION DELIMITED BY SIZE
INTO ERROR-RECORD

OR .............

01 ERROR-RECORD.
05 ERROR-REC1 PIC X(40).
05 FILLER PIC X(20) VALUE SPACES.

STRING WS-VENDOR DELIMITED BY SIZE
WS-LOCATION DELIMITED BY SIZE
INTO ERROR-REC1

Let me know if this works for you.
Back to top
View user's profile Send private message
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Thu Jan 15, 2009 5:35 pm    Post subject: Reply to: How to remove spaces while performing STRING opera
Reply with quote

Hi,

Its not working.

Regards
Suneel
Back to top
View user's profile Send private message
technut

New User


Joined: 27 Dec 2007
Posts: 73
Location: India

PostPosted: Thu Jan 15, 2009 5:51 pm    Post subject: Reply to: How to remove spaces while performing STRING opera
Reply with quote

It had worked for me when I did a test. Are you getting null values now also at the end of the file?

Which option you tried of both? More details would help!
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Thu Jan 15, 2009 6:48 pm    Post subject:
Reply with quote

The dots are probably LOW-VALUES from not initializing the output field before you use it. Move spaces to it before the STRING or add VALUE SPACES to its definition.

As far as what you want,
Code:
           05  VENDOR                  PIC X(20) VALUE 'FIRST DATA'.
           05  SEP                     PIC X(01) VALUE SPACE.
           05  LOCATION                PIC X(20) VALUE 'BOMBAY'.
           05  WS-VAR-OUT              PIC X(60).

       LINKAGE SECTION.
      /
       PROCEDURE DIVISION.
       S1000-MAIN       SECTION.
           MOVE SPACES                 TO  WS-VAR-OUT.
           STRING VENDOR   DELIMITED BY '  '
                  SEP      DELIMITED BY SIZE
                  LOCATION DELIMITED BY SPACE
             INTO WS-VAR-OUT.
           DISPLAY 'VENDOR:    ' VENDOR.
           DISPLAY 'LOCATION:  ' LOCATION.
           DISPLAY 'COMBINED:  ' WS-VAR-OUT.
gives me this output:
Code:
 VENDOR:    FIRST DATA
 LOCATION:  BOMBAY
 COMBINED:  FIRST DATA BOMBAY
However if the vendor field has 19 characters in it there's an extra space between the fields. This could be checked for via reference modification; it depends on how critical the spacing is for you.
Back to top
View user's profile Send private message
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Thu Jan 15, 2009 7:31 pm    Post subject: Reply to: How to remove spaces while performing STRING opera
Reply with quote

Hi,

But after FIRST DATA iam getting 10 spaces and since VENDOR is of length 20
After BOMBAY also there are 14 bytes of space since LOCATION is of length 20

I want to remove the spaces after FIRST DATA and BOMBAY

Regards
Suneel
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Thu Jan 15, 2009 8:18 pm    Post subject:
Reply with quote

If you use DELIMITED BY SIZE the entire field is moved via STRING. SIZE refers to the variable PIC, not the actual number of non-blank characters in the variable.
Back to top
View user's profile Send private message
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Thu Jan 15, 2009 10:32 pm    Post subject: Reply to: How to remove spaces while performing STRING opera
Reply with quote

Hi,

But i want o/p should be FIRST DATA without spaces after FIRST DATA

same should be for LOCATION

without spaces after BOMBAY

Regards
Suneel
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Thu Jan 15, 2009 10:44 pm    Post subject:
Reply with quote

How about:
Code:
STRING VENDOR DELIMITED BY x'4040'
     LOCATION DELIMITED BY x'4040'
  INTO W-OUTPUT-REC.

or:
Code:
STRING VENDOR DELIMITED BY x'4040'
        x'40' DELIMITED BY SIZE
     LOCATION DELIMITED BY x'4040'
  INTO W-OUTPUT-REC.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Thu Jan 15, 2009 11:55 pm    Post subject:
Reply with quote

Your recent post:
Quote:

But i want o/p should be FIRST DATA without spaces after FIRST DATA

same should be for LOCATION

without spaces after BOMBAY
conflicts with your original request, where you wanted a space after the vendor before the location. Furthermore, you need to be aware that you are stringing 2 20-bytes fields into a 60-byte field. A minimum of 20 bytes and a maximum of 57 bytes of the output variable will not be coming from the STRING variables. What do you want these 20 to 57 bytes to be? They are going to be something -- spaces, LOW-VALUES, HIGH-VALUES, periods, or anything else in the collating sequence. You can pick the character but you cannot opt for them not to exist as they will exist, period.

The code I provided you has output that matches precisely what your last post says you want -- so what's the problem with it?
Back to top
View user's profile Send private message
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Fri Jan 16, 2009 12:10 am    Post subject: Reply to: How to remove spaces while performing STRING opera
Reply with quote

Hi,

Each field is of 20 bytes each and stringing into 60 bytes.

If the fields VENDOR or LOCATION contains less than 20 bytes the remaing are filled with spaces but i want to remove the spaces.

After 40 bytes stringing into 60 bytes ,still 20 bytes left they are filled with
dots.

I want to remove the dots in last 20 bytes from 41 to 60.

This is my requirement.


I tried the below code:

STRING VENDOR DELIMITED BY x'4040'
x'40' DELIMITED BY SIZE
LOCATION DELIMITED BY x'4040'
INTO W-OUTPUT-REC

but still 1 space is coming after VENDOR.

why 1 space is coming i am looking into this one.

Could any one help on this.

Regards
Suneel
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Fri Jan 16, 2009 12:14 am    Post subject:
Reply with quote

Remove the dots by
Code:
MOVE SPACES TO W-OUTPUT-REC
before your STRING statement. Have you tried the
Code:
DELIMITED BY '  '
instead of SIZE as I specified?
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 16, 2009 12:14 am    Post subject:
Reply with quote

Reread Robert's reply. He just explained the situation in detail.
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 Jan 16, 2009 12:21 am    Post subject:
Reply with quote

Quote:
why 1 space is coming i am looking into this one.

x'40' DELIMITED BY SIZE!
Back to top
View user's profile Send private message
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Fri Jan 16, 2009 12:35 am    Post subject: Reply to: How to remove spaces while performing STRING opera
Reply with quote

Hi,


I moved spaces to W-OUPUT-REC before string statement but one space is removed after VENDOR and LOCATION.

Regards
Suneel
Back to top
View user's profile Send private message
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Fri Jan 16, 2009 12:41 am    Post subject: Reply to: How to remove spaces while performing STRING opera
Reply with quote

Hi,

But dots are not removed after stringing vendor,location into W-output-rec. Dots are present from 41 to 60.

Regards
Suneel
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 16, 2009 12:45 am    Post subject:
Reply with quote

Suneel,
I repeat: Reread Robert's post of 12:25 PM.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Fri Jan 16, 2009 1:30 am    Post subject:
Reply with quote

Post exactly what your code looks like (with BBCode) and the output as it is generated by this code, and also post what you want done differently.
Back to top
View user's profile Send private message
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Fri Jan 16, 2009 6:36 pm    Post subject:
Reply with quote

Hi,

WS varibles:

77 VENDOR PIC X(20).
77 LOCATION PIC X(20).
77 W-OUTPUT-REC PIC X(60).

Code:

MOVE SPACES TO W-OUTPUT-REC.

STRING C-QUOTE DELIMITED BY SIZE
VENDOR DELIMITED BY X'4040'
X'40' DELIMITED BY " "
INTO W-OUTPUT-REC.

O/P generated by above code

FIRST DATABOMBAY..........................................

o/p should be : FIRST DATABOMBAY

Regards
Suneel
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 Jan 16, 2009 11:41 pm    Post subject:
Reply with quote

Hello,

Did you copy/paste the generated output or did you type it? Have you ensured that BOMBAY is actually followed by spaces, not some strange hex value?

What is in this field (C-QUOTE)? Make sure it is not blank and run again. When doing this, also display the individual input fields in hex and post that.

As requested earlier, use the "Code" tag for readability (do not use screenshots).
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 Joinkeys operation when key1 and key2... Susanta DFSORT/ICETOOL 5 Wed Nov 02, 2016 5:35 pm
No new posts To trim spaces in a pipe delimited da... Nish84 COBOL Programming 16 Mon Oct 10, 2016 1:54 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 Joinkeys operation betwen VB and FB file Susanta SYNCSORT 4 Sun Sep 25, 2016 9:49 pm
No new posts Removing Extra Spaces in a comma sepa... Puspojit DFSORT/ICETOOL 3 Tue Sep 13, 2016 7:46 am


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