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
 

 

usage of STRING in COBOL

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

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Sun Apr 05, 2009 10:42 am    Post subject: usage of STRING in COBOL
Reply with quote

Hi

I have two variable VAR1 and VAR2 which i need to concatenate or string using STRING.

VAR 1 - is of var length (but max is 20)
VAR2 - is of var length (but max is 30)

VAR3 - is o/p and max length is 30.

VAR1 is input . For e.g let there be to cases where VAR1 - can be " Hello" or " Excellent" ..So length in both cases is diferent . It's 5 for 1st case and 9 for 2nd case.

VAR2 - "Good Work,keep it up"

Now when i string VAR1 and VAR2 , i should get o/p as
"Hello Good work,keep it up" with 1st input. and
"Excellent Good work,keep it up" with 2nd input.

My doubt is how should VAR1 and VAR2 be declared and what should be syntax of STRING to get the desired result as data present in VAR1 and VAR2 keep varyng.
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: Sun Apr 05, 2009 7:12 pm    Post subject:
Reply with quote

Assuming that var1 & var2 have double spaces only after the data and not between the words....
Code:
var1 pic x(20)
var2 pic x(30)
var3 pic x(30)

Move whatever to var1
Move whatever-else to var2
Move spaces to var3               (very important)

String var1 delimited by '  '     (two spaces)
       ' ' delimited by size      (single space)
       var2 delimited by size
    into var3

STRING statement
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Tue Apr 07, 2009 11:40 am    Post subject: Reply to: usage of STRING in COBOL
Reply with quote

Ambili S, what if var1 and var2 use their maximum lengths provided.In that case it would certainly exceed the output variable var3 length (i.e. 30).
Its better to increase the length of the output variable to 50 as to avoid data truncation.

WTF
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 Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm


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