Field inside Field



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

Field inside Field

Postby sriraj1122 » Thu Jul 25, 2013 3:00 am

I have a scenario as below.

10 VARIABLE1 PIC X(10)
10 FIELD1 PIC 9(10)

Variable1 = "Field1"
FIELD1 = 1234


In the program I can access only Variable1 but should be able to move 1234 in to another variable using VARIABLE1.
sriraj1122
 
Posts: 19
Joined: Thu Nov 18, 2010 10:04 am
Has thanked: 0 time
Been thanked: 0 time

Re: Field inside Field

 

Re: Field inside Field

Postby prino » Thu Jul 25, 2013 3:31 am

In your dreams!

It's obvious that you completely and utterly mistakenly believe that COBOL, as a compiled language, has the same capabilities as REXX...
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 536
Joined: Wed Mar 11, 2009 12:22 am
Location: Oostende, Belgium
Has thanked: 3 times
Been thanked: 21 times

Re: Field inside Field

Postby Robert Sample » Thu Jul 25, 2013 4:47 am

Sorry, but COBOL does not work that way. You cannot use a variable to define at run-time where to move a value.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: Field inside Field

Postby c62ap90 » Thu Jul 25, 2013 5:25 pm

I'm not exactly sure what you are trying to do.
Are you trying to use the same area for alphanumeric (pic x) and numeric (pic 9) data?


10  VARIABLE1         PIC  X(10). 
10  FIELD1  REDEFINES VARIABLE1
                      PIC  9(10).

MOVE 'Field1'  TO VARIABLE1.
MOVE 1234      TO FIELD1.
 
MOVE '1234'    TO VARIABLE1.
c62ap90
 
Posts: 125
Joined: Thu Oct 11, 2012 10:24 pm
Has thanked: 1 time
Been thanked: 6 times

Re: Field inside Field

Postby Robert Sample » Thu Jul 25, 2013 9:19 pm

c62ap90, the original question had nothing to do with REDEFINES. The original question was about how to use indirect references in COBOL. And COBOL does not support indirect references.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post