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
 

 

using STRING & DELIMITED BY...

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

Active User


Joined: 28 Sep 2005
Posts: 210
Location: St Katherine's Dock London

PostPosted: Fri Dec 19, 2008 5:01 pm    Post subject: using STRING & DELIMITED BY...
Reply with quote

Hi,

I have following requirement.

WS-VAR1 PIC X(10).
WS-VAR2 PIC X(30).
WS-VAR3 PIC X(42).

Now. WS-VAR1 has multiple words in it like 005 IBD or ENT DEAL etc etc...
WS-VAR2 is something like ENTERPRISE DEAL IBD

I want WS-VAR3 to be something like

005 IBD-ENTERPRISE DEAL IBD

When I write STRING with DELIMITED BY SIZE it comes like

005 IBD -ENTERPRISE DEAL IBD icon_sad.gif

Can anyone please help?
Back to top
View user's profile Send private message

dp33770

New User


Joined: 04 Jul 2007
Posts: 92
Location: Hyderabad

PostPosted: Fri Dec 19, 2008 6:05 pm    Post subject:
Reply with quote

Dear genesis786,
You said,

When I write STRING with DELIMITED BY SIZE it comes like

005 IBD -ENTERPRISE DEAL IBD

is it that U get an extra space after IBD and ENTERPRISE .
Do you use the '-' in STRING
Back to top
View user's profile Send private message
hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Fri Dec 19, 2008 6:10 pm    Post subject: Reply to: using STRING & DELIMITED BY...
Reply with quote

Hi,

String statement can be used with 2 verbs :
1)delimited by Size
2)delimitedd by Space

Usually when we concatenate 2 variable contents into 1 variable, we use DELIMITED BY SPACE ( for the type of o/p desired by you).

In your case this doesn't seem to be possible, because space is in between your strings of WS-VAR1. We need some marker to delimit your string, which can tell us the end of your string. If you can somehow insert any marker like '@' or '#', then delimited by '@' or '#' can be used.

Thanks,
-Kapil.
Back to top
View user's profile Send private message
genesis786

Active User


Joined: 28 Sep 2005
Posts: 210
Location: St Katherine's Dock London

PostPosted: Fri Dec 19, 2008 6:17 pm    Post subject:
Reply with quote

dp33770:

this is the STRING instruction:

Code:

MOVE '005 IBD' TO WS-VAR1.             
MOVE 'ENTERPRISE DEAL IBD' TO WS-VAR2.
STRING WS-VAR1 DELIMITED BY SIZE       
       '-' DELIMITED BY SPACE         
       WS-VAR2 DELIMITED BY SIZE       
       INTO WS-VAR3                   
DISPLAY WS-VAR3.                       


hikaps14:

Thanks! will try to find out.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Fri Dec 19, 2008 6:52 pm    Post subject:
Reply with quote

I got this output
Code:
 005 IBD   -ENTERPRISE DEAL IBD           .
 005-ENTERPRISE DEAL IBD                  .
by using this code:
Code:
    MOVE '005 IBD' TO WS-VAR1.
    MOVE 'ENTERPRISE DEAL IBD' TO WS-VAR2.
    STRING WS-VAR1 DELIMITED BY SIZE
           '-'     DELIMITED BY SPACE
           WS-VAR2 DELIMITED BY SIZE
           INTO WS-VAR3
    DISPLAY WS-VAR3.
    STRING WS-VAR1 DELIMITED BY SPACE
           '-'     DELIMITED BY SIZE
           WS-VAR2 DELIMITED BY SIZE
           INTO WS-VAR3
    DISPLAY WS-VAR3.
The second one looks to be what you want.
Back to top
View user's profile Send private message
dp33770

New User


Joined: 04 Jul 2007
Posts: 92
Location: Hyderabad

PostPosted: Fri Dec 19, 2008 6:57 pm    Post subject:
Reply with quote

Robert,
I think genesis786 was looking for somthing like below as o/p
Code:
005 IBD-ENTERPRISE DEAL IBD
Back to top
View user's profile Send private message
genesis786

Active User


Joined: 28 Sep 2005
Posts: 210
Location: St Katherine's Dock London

PostPosted: Fri Dec 19, 2008 7:33 pm    Post subject:
Reply with quote

hi guys, i tried the following piece of code and it worked.

Code:

MOVE '005 IBD' TO WS-VAR1                             
MOVE 'ENTERPRISE DEAL IBD' TO WS-VAR2                 
COMPUTE WS-COUNT1 = LENGTH OF WS-VAR1                 
PERFORM VARYING WS-COUNT1 FROM WS-COUNT1 BY -1 UNTIL   
        WS-VAR1(WS-COUNT1:1) NOT = SPACE               
END-PERFORM                                           
COMPUTE WS-COUNT1 = WS-COUNT1 + 1                     
MOVE '^' TO WS-VAR1(WS-COUNT1:1)                       
STRING WS-VAR1 DELIMITED BY '^'                       
       '-' DELIMITED BY SIZE                           
       WS-VAR2 DELIMITED BY SIZE                       
       INTO WS-VAR3                                   
DISPLAY WS-VAR3.                                       
Back to top
View user's profile Send private message
genesis786

Active User


Joined: 28 Sep 2005
Posts: 210
Location: St Katherine's Dock London

PostPosted: Fri Dec 19, 2008 7:40 pm    Post subject:
Reply with quote

only thing is, how to handle it if my WS-VAR1 was something like 005 IBDXYZ .. occupying all 10 bytes. icon_sad.gif ?
Back to top
View user's profile Send private message
genesis786

Active User


Joined: 28 Sep 2005
Posts: 210
Location: St Katherine's Dock London

PostPosted: Fri Dec 19, 2008 7:51 pm    Post subject:
Reply with quote

now it is working fine icon_smile.gif

Code:

MOVE '005 IBDUUU' TO WS-VAR1                         
MOVE 'ENTERPRISE DEAL IBD' TO WS-VAR2               
COMPUTE WS-COUNT1 = LENGTH OF WS-VAR1               
PERFORM VARYING WS-COUNT1 FROM WS-COUNT1 BY -1 UNTIL
        WS-VAR1(WS-COUNT1:1) NOT = SPACE             
END-PERFORM                                         
COMPUTE WS-COUNT1 = WS-COUNT1 + 1                   
IF WS-COUNT1 < 11                                   
  MOVE '^' TO WS-VAR1(WS-COUNT1:1)                   
END-IF                                               
STRING WS-VAR1 DELIMITED BY '^'                     
       '-' DELIMITED BY SIZE                         
       WS-VAR2 DELIMITED BY SIZE                     
       INTO WS-VAR3                                 
DISPLAY WS-VAR3.                                     
Back to top
View user's profile Send private message
hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Fri Dec 19, 2008 8:07 pm    Post subject: Reply to: using STRING & DELIMITED BY...
Reply with quote

Its good, that your solution worked.

I just came accross another piece of code, which looks simpler to me:

1) MOVE WS-VAR1 to WS-RIGHT-JUST ( variable declared as right justified)
2) INSPECT WS-RIGHT-JUST tallying WS-COUNT for leading spaces.
3)WS-COUNT= 10 - WS-COUNT
4) Now use your string statement
STRING WS-VAR1(1: WS-COUNT)
'-'
WS-VAR2 DELIMITED BY SIZE
INTO WS-VAR3

Just a suggestion.

Thanks,
-Kapil.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Sat Dec 20, 2008 12:28 am    Post subject:
Reply with quote

Move WS-VAR1 to WS-RIGHT-JUST will not right justify the source field if both fields are the same length. It will only right justify the contents of WS-VAR1 into WS-RIGHT-JUST regardless of the presence or absence of spaces.
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 Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Sort Card to Remove Duplicate records... raj4neo SYNCSORT 2 Wed Jan 25, 2017 4:44 am
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 6 Sun Nov 06, 2016 8:11 pm


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