MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Expand field length in cobol pgm

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
ST
Beginner


Joined: 04 Jan 2003
Posts: 24
Topics: 12

PostPosted: Sat Jan 04, 2003 6:07 pm    Post subject: Expand field length in cobol pgm Reply with quote

Hi,
A cobol pgm uses FILE1 which has field say FIELD1 which is 5 bytes NUM.
So,how can we expand its length from 5 bytes(NUM) to 10Bytes(CHAR) ?

I want to use cobol Pgm only and not by using any JCL Sort utilities etc..

Can we do like this:
field1 pic 9(5) and define a new field as
field2 as pic X(10) in a different file say FILE2

and we move field1 to field2 and write FILE2 instead of FILE1?

I think it might not be a good way but if anybody has good solution,pls let me know..

Thanks in adv
ST
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Sat Jan 04, 2003 6:33 pm    Post subject: Reply with quote

ST,

Code:


01 FIELD1         PIC 9(05).
02 FIELD2         PIC X(10).

MOVE FIELD1       TO FIELD2



Hope this helps..

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ST
Beginner


Joined: 04 Jan 2003
Posts: 24
Topics: 12

PostPosted: Sun Jan 05, 2003 5:23 pm    Post subject: Reply with quote

Kolusu,

Thanks for ur reply... i was also thinking the same and said in my question..but wondering if therez any other way to do that?


Rgds,
ST
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Sun Jan 05, 2003 5:39 pm    Post subject: Reply with quote

ST,

Well you can redefine the field like as shown below.
Code:


01  FIELD1                         PIC 9(5). 
01  FIELD2   REDEFINES  FIELD1     PIC X(10).

MOVE 13481 TO FIELD1.


Hope this helps...

cheers

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ST
Beginner


Joined: 04 Jan 2003
Posts: 24
Topics: 12

PostPosted: Sun Jan 05, 2003 6:34 pm    Post subject: Reply with quote

Kolusu,

Thanks......

ST
Back to top
View user's profile Send private message
zatlas
Beginner


Joined: 17 Dec 2002
Posts: 43
Topics: 4

PostPosted: Sun Jan 05, 2003 7:19 pm    Post subject: Reply with quote

Hi
Koluso, the redefines will definitely not work. You may not redefine a smaller object. Also, I would be more comfortable doing this in the MOVE:

05 FIELD1 PIC 9(5).
:
:
05 FIELD2 PIC 9(10).
05 FIELD2-X REDEFINES FIELD2 PIC X(10).
:
:
MOVE FIELD1 TO FIELD2.
now you may use FIELD2-X padded with leading zeroes, etc.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Sun Jan 05, 2003 7:28 pm    Post subject: Reply with quote

Zatlas,

You can redefine a smaller item also. The above posted code using redefines works fine with IBM COBOL for OS/390 & VM 2.2.1

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
zatlas
Beginner


Joined: 17 Dec 2002
Posts: 43
Topics: 4

PostPosted: Sun Jan 05, 2003 7:41 pm    Post subject: Reply with quote

i am standing corrected...
but beware if you are using that feature too much within structures and records because of the maintainability issue.
ZA
Back to top
View user's profile Send private message
ST
Beginner


Joined: 04 Jan 2003
Posts: 24
Topics: 12

PostPosted: Sun Jan 05, 2003 11:01 pm    Post subject: Reply with quote

Yes, In COBOL85 we can redefine a smaller length field ..

ST
Back to top
View user's profile Send private message
vallishar
Beginner


Joined: 17 Dec 2002
Posts: 53
Topics: 14
Location: BengaLuru

PostPosted: Tue Jan 07, 2003 5:14 pm    Post subject: Reply with quote

Kolusu,

Will the same work in COBOL 2 ?

Vallish
_________________
If you're not failing every now and again, it's a sign you're not doing anything very innovative.
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Tue Jan 07, 2003 5:29 pm    Post subject: Reply with quote

Vallishar,

Yes it works with IBM VS COBOL II Release 4.0.

Kolusu

PS: VS COBOL II is no longer supported by IBM
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group