View previous topic :: View next topic |
Author |
Message |
ST Beginner
Joined: 04 Jan 2003 Posts: 24 Topics: 12
|
Posted: Sat Jan 04, 2003 6:07 pm Post subject: Expand field length in cobol pgm |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Sat Jan 04, 2003 6:33 pm Post subject: |
|
|
ST,
Code: |
01 FIELD1 PIC 9(05).
02 FIELD2 PIC X(10).
MOVE FIELD1 TO FIELD2
|
Hope this helps..
cheers
kolusu |
|
Back to top |
|
|
ST Beginner
Joined: 04 Jan 2003 Posts: 24 Topics: 12
|
Posted: Sun Jan 05, 2003 5:23 pm Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Sun Jan 05, 2003 5:39 pm Post subject: |
|
|
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 |
|
|
ST Beginner
Joined: 04 Jan 2003 Posts: 24 Topics: 12
|
Posted: Sun Jan 05, 2003 6:34 pm Post subject: |
|
|
Kolusu,
Thanks......
ST |
|
Back to top |
|
|
zatlas Beginner
Joined: 17 Dec 2002 Posts: 43 Topics: 4
|
Posted: Sun Jan 05, 2003 7:19 pm Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Sun Jan 05, 2003 7:28 pm Post subject: |
|
|
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 |
|
|
zatlas Beginner
Joined: 17 Dec 2002 Posts: 43 Topics: 4
|
Posted: Sun Jan 05, 2003 7:41 pm Post subject: |
|
|
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 |
|
|
ST Beginner
Joined: 04 Jan 2003 Posts: 24 Topics: 12
|
Posted: Sun Jan 05, 2003 11:01 pm Post subject: |
|
|
Yes, In COBOL85 we can redefine a smaller length field ..
ST |
|
Back to top |
|
|
vallishar Beginner
Joined: 17 Dec 2002 Posts: 53 Topics: 14 Location: BengaLuru
|
Posted: Tue Jan 07, 2003 5:14 pm Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Tue Jan 07, 2003 5:29 pm Post subject: |
|
|
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 |
|
|
|
|