Question

I have a PIC 9(14).9(2) variable that receives data from an incoming file. I wish to pass it into a report variable that is a PIC 9(14)V9(2). The format of incoming data can't be altered. Is there any way I can pass one value into another?

Was it helpful?

Solution

The pic 9(14).9(2) is essentially a Pic X field. You could set up redefine fields or use reference modification

i.e.

       03 F1                 PIC 9(14).9(2).
       03 filler redefines F1.
          05 F1-Int          pic 9(14).
          05 filler          pic X.
          05 F1-decimal      pic 9(2).

       03 F2                 PIC 9(14)V9(2).
       03 filler redefines F2.
          05 F2-Int          pic 9(14).
          05 F2-decimal      pic 9(2).

       Move F1-int          to f2-int.
       Move F1-decimal      to f2-decimal.

or    
       Move F1(1:14)        to F2(1:14).   
       Move F1(16:2)        to F2(15:2).   // Forgoten the correct format for cobol

OTHER TIPS

You could also look here: How to REDEFINE and perform arithmetic on a PIC X clause in COBOL, which is (possibly) a similar topic (although the format of the input data was never confirmed)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top