Page 1 of 3

TRANSFORM COPYBOOK TO DATA

PostPosted: Fri Sep 05, 2014 7:42 pm
by djanarl
Hello i'm new, and I have a problem. I'm doing a program of conversion of a copybook to data :?

the problem is the calculation of the position and length for these case of PIC: 9(03)V99, 999, S99, V99, 99V999

I hope someone can help me please

thx in advance


PS: Excuse my english

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Fri Sep 05, 2014 8:41 pm
by Ed Goodman
That SEEMS like such a simple question, but you're in for some studying! You're going to have to learn how the mainframe stores data.

The 'V' is an implied decimal. You won't actually see it in the data, but the program will know that's where the decimal goes.

I just spent a few minutes looking for a good example, and can't find one. What I recommend you do it...write a small cobol program. Put all those variable types in it and have it either display them or write them to a record. Then open the sysout or the file and look at how they are formatted.

Don't forget to use COMP and COMP-3 types.

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Fri Sep 05, 2014 8:49 pm
by Terry Heinze
See section 5.3.17 USAGE clause in the Language Reference Manual.

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Fri Sep 05, 2014 8:58 pm
by djanarl
Ed Goodman wrote:That SEEMS like such a simple question, but you're in for some studying! You're going to have to learn how the mainframe stores data.

The 'V' is an implied decimal. You won't actually see it in the data, but the program will know that's where the decimal goes.

I just spent a few minutes looking for a good example, and can't find one. What I recommend you do it...write a small cobol program. Put all those variable types in it and have it either display them or write them to a record. Then open the sysout or the file and look at how they are formatted.

Don't forget to use COMP and COMP-3 types.



I have done something like that
UNSTRING W-ENR-TYPEPIC DELIMITED BY '(' OR ')'   
                       INTO W-PIC               
                            W-LONGUEUR           
                            W-PIC-DEC           
                            W-LONG-DEC     

IF W-ENR-PIC = 'PIC' AND W-ENR-TAB NOT = 'OCCURS'
                                                 
    PERFORM C-POS-LONG                           
    MOVE W-ENR-DONNEE TO DONNEE-DATA             
    PERFORM MEF-DATA                             
    PERFORM ECRITURE-DATA                         
    MOVE SPACES       TO W-ENR-NIVEAU             
    MOVE SPACES       TO W-ENR-DONNEE             
    MOVE SPACES       TO W-ENR-PIC               
    MOVE SPACES       TO W-ENR-TYPEPIC           
    MOVE W-LONGUEUR   TO W-LONG                   
                                                 
 END-IF   


MEF-DATA.                         
--------*                         
                                 
 MISE EN FORME PICTURE D'EDITION 
    EVALUATE W-PIC ALSO W-ENR-TAB
                                 
       WHEN  'X'  ALSO  SPACES   
         MOVE 'C' TO TYPE-DATA   
       WHEN '9'   ALSO  SPACES   
         MOVE 'N' TO TYPE-DATA   
       WHEN 'S9'  ALSO  SPACES   
         MOVE 'Z' TO TYPE-DATA   
       WHEN 'S9'  ALSO  'COMP-3' 
         MOVE 'P' TO TYPE-DATA   
       WHEN 'S9'  ALSO  'COMP'   
         MOVE 'B' TO TYPE-DATA   
       WHEN OTHER                 
         CONTINUE                                                         
     


if someone declares in pic 99 or pic 9(03)v99 instead of pic 9(02) or pic 9(03)v9(02) it won't work


ps: if i have PIC X(10)V9(02)

X(10)V9(02) : W-ENR-TYPEPIC
- X : W-PIC
- 10 : W-LONGUEUR
- V9 : W-PIC-DEC
- 02: W-LONG-DEC

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Fri Sep 05, 2014 10:32 pm
by BillyBoyo
Generate a COBOL program including your copybook. Compile it, sending the sysout to disk. Parse the data map. This may give you enough on its own (depends what you are trying to do) or you use clues (line numbers) to find anything else you need.

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Mon Sep 08, 2014 2:41 pm
by djanarl
I abend on s0c7 because it's declare on pic 9 instead of pix 9(01).

Hope you would understand my problem

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Mon Sep 08, 2014 3:32 pm
by BillyBoyo
PIC 9 and PIC 9(01) (and PIC 9(1) and PIC 9(00000001) etc) are the same.

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Mon Sep 08, 2014 3:39 pm
by djanarl
Thx Billy for you answer, but how to convert pic 9 pic 99 pic 99v999... in pic 9(01) pic 9(02) pic 9(02)v9(03).... ?

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Mon Sep 08, 2014 4:24 pm
by BillyBoyo
You don't need to convert them. They are the same. Just different ways to define the same thing. As in identical. It can be a style thing, or a local-standards thing, but the compiler does not mind, all the definitions and all the generated code will be identical. It will only look "different" to the human reader, and if you "convert" from one written format to the other - 9(2) to 99, 9(3) to 999 or 999 to 9(3) and 99 to 9(2), the human reader should see they are the same as well.

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Mon Sep 08, 2014 4:45 pm
by djanarl
i think there is an incomprehension, i know that pic 99 is pic 9(02). if someone put in his copybook pic 99 or pic 9(01)v99, my program need to convert in something like pic 9(02) or pic p(01)v9(02) to create my data in order to calcul my position and length :oops: