how can we retain intial values



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

how can we retain intial values

Postby kiran_q » Sun Nov 23, 2008 8:21 pm

Hi All,

Actually, I had doudt when we provide intial value to any of variables and Initialize those variable before using in program it gets reset to spaces or zeroes. how actuall can we retain the intial values.

this logic i am trying to implement this in generating C.S.V(comma seperated file) intial all fiels all am seperating with commas by giving intial value (','), however while intializing the group variable before passing the parameter value the commas field is field with spaces, i wanted this field to be reset to commas how can i do that.
kiran_q
 
Posts: 9
Joined: Wed Nov 12, 2008 8:10 pm
Has thanked: 0 time
Been thanked: 0 time

Re: how can we retain intial values

Postby dick scherrer » Sun Nov 23, 2008 10:51 pm

Hello,

If you properly initialized some variables with specific values, the value will remain unless you change it in the code.

From what you posted, it sounds like you "erased" all the values with the "initialize". . . Initialize does not preserve coded values. Here's the link to that part of the cobol manual:
http://publibz.boulder.ibm.com/cgi-bin/ ... r10/6.2.20?

Suggest you also consider something other than a comma for the delimiter - comma is often found as a valid data value. The tab character works quite well (x'05').
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: how can we retain intial values

Postby kiran_q » Mon Nov 24, 2008 10:52 pm

HI Dick,

thank you for providing link.

coming to my query, i need to use with same delimiter since i have to generate the CSV o/p file which need to be transmitted to UNIX environment.

so there is no option for me. moreover my o/p file contain around 500 parameters and 6 different type of records.

if i keep on moving commas after each parameters then it would be 3000 lines of move statements only which is advisable.

so can you suggest best solution to handle this.

man my head is really getting scraped by writing this network programs in mainframe.
kiran_q
 
Posts: 9
Joined: Wed Nov 12, 2008 8:10 pm
Has thanked: 0 time
Been thanked: 0 time

Re: how can we retain intial values

Postby dick scherrer » Tue Nov 25, 2008 3:17 am

Hello,

You could take the record definitions you already have with the initial values established and make a copy with a different name. When you begin each iteration, move the copy to the original and all of the initial values will be there. The INITIALIZE would no longer be needed in the code.

You could get what you want done in one move. You might need to do a bit of editing on the "initial value" definitions to prevent duplicate field names, but that will probably be easier than writing hundreds of statements.
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


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post