Concat String fields delimiter spaces



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Concat String fields delimiter spaces

Postby Irene Ioujanina » Sat Mar 01, 2008 1:29 am

Good afternoon,
May I please ask for the following:
....
07 IN1 PIC X(20) VALUE "701 STREET DR "
07 in2 PIC X(15) value "nEW yORK cITY "
07 in3 PIC X(10) VALUE "SOME "
07 OUT PIC X(60).

I need to do a simple thing: to conc atinate IN1 + spase + IN2 + space + IN3 to receive in OUT
"701 STREET DR nEW yORK cITY SOME "
When I'm using STRING... DELIMITED BY space-> it trimmed all spaces
I can filnd the length od each string and take a substring, for instance
IN1(1:length of IN1) -> DOES NOT GIVE ME A LOT, how to put them all in OUT???...

All IN1,2,3 can not be variable length-they are coming from the Input file,fixed length..

Appreciate your help.
Thanking in advance,
Irene Ioujanina
 
Posts: 27
Joined: Thu Feb 21, 2008 6:42 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Concat String fileds delimiter spaces

Postby CICS Guy » Sat Mar 01, 2008 1:56 am

Try string delimited by two spaces......
CICS Guy
 
Posts: 246
Joined: Wed Jun 20, 2007 4:08 am
Has thanked: 0 time
Been thanked: 0 time

Re: Concat String fileds delimiter spaces

Postby Irene Ioujanina » Sat Mar 01, 2008 2:12 am

Thank you for review..

Tried. It trims all spaces anyway...
STRING
IN1 " "
IN2 " "
IN3 " "
DELIMITED BY SPACE
INTO OUT

gives OUT as
"701STREETDRnEWyORKcITYSOME"
I think ,the keyword is here "DELIMITED BY SPACE " - it just omit all the spaces everywhere in the fields...

Thank you,
Irene Ioujanina
 
Posts: 27
Joined: Thu Feb 21, 2008 6:42 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Concat String fileds delimiter spaces

Postby dick scherrer » Sat Mar 01, 2008 2:23 am

Hello,

Use
DELIMITED BY '  '
Note that there are 2 spaces between the quotes (per CG's suggestion).
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Concat String fileds delimiter spaces

Postby Irene Ioujanina » Sat Mar 01, 2008 2:39 am

Thank you very much, everyone.
Put 2 spaces instead of one-the result is much better (thanks!):
"701 STREET DRnEW yORK cITYSOME"

modified delimiter between fields to ','
STRING
IN1 ", "
IN2 ", "
IN3 ", "
DELIMITED BY ' '
INTO OUT
and got
"701 STREET DR,nEW yORK cITY,SOME" -> looks much better
the only problem now: if first fields are empty-> i would get
,,, ->leading "," - but it could be fixed by programming- need to check before STRING...

Thank you very much, Mr. Cics Guy and Mr. Dick Scherrer
Irene Ioujanina
 
Posts: 27
Joined: Thu Feb 21, 2008 6:42 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Concat String fileds delimiter spaces

Postby dick scherrer » Sat Mar 01, 2008 2:59 am

You're welcome - good luck :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post