TRANSFORM COPYBOOK TO DATA



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

TRANSFORM COPYBOOK TO DATA

Postby djanarl » Fri Sep 05, 2014 7:42 pm

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
djanarl
 
Posts: 9
Joined: Fri Sep 05, 2014 7:28 pm
Has thanked: 0 time
Been thanked: 0 time

Re: TRANSFORM COPYBOOK TO DATA

 

Re: TRANSFORM COPYBOOK TO DATA

Postby Ed Goodman » Fri Sep 05, 2014 8:41 pm

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.
Ed Goodman
 
Posts: 342
Joined: Thu Feb 24, 2011 12:05 am
Has thanked: 3 times
Been thanked: 17 times

Re: TRANSFORM COPYBOOK TO DATA

Postby Terry Heinze » Fri Sep 05, 2014 8:49 pm

See section 5.3.17 USAGE clause in the Language Reference Manual.
.... Terry
Terry Heinze
 
Posts: 193
Joined: Wed Dec 04, 2013 11:08 pm
Location: Richfield, MN, USA
Has thanked: 10 times
Been thanked: 11 times

Re: TRANSFORM COPYBOOK TO DATA

Postby djanarl » Fri Sep 05, 2014 8:58 pm

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
djanarl
 
Posts: 9
Joined: Fri Sep 05, 2014 7:28 pm
Has thanked: 0 time
Been thanked: 0 time

Re: TRANSFORM COPYBOOK TO DATA

Postby BillyBoyo » Fri Sep 05, 2014 10:32 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: TRANSFORM COPYBOOK TO DATA

Postby djanarl » Mon Sep 08, 2014 2:41 pm

I abend on s0c7 because it's declare on pic 9 instead of pix 9(01).

Hope you would understand my problem
You do not have the required permissions to view the files attached to this post.
djanarl
 
Posts: 9
Joined: Fri Sep 05, 2014 7:28 pm
Has thanked: 0 time
Been thanked: 0 time

Re: TRANSFORM COPYBOOK TO DATA

Postby BillyBoyo » Mon Sep 08, 2014 3:32 pm

PIC 9 and PIC 9(01) (and PIC 9(1) and PIC 9(00000001) etc) are the same.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: TRANSFORM COPYBOOK TO DATA

Postby djanarl » Mon Sep 08, 2014 3:39 pm

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).... ?
djanarl
 
Posts: 9
Joined: Fri Sep 05, 2014 7:28 pm
Has thanked: 0 time
Been thanked: 0 time

Re: TRANSFORM COPYBOOK TO DATA

Postby BillyBoyo » Mon Sep 08, 2014 4:24 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: TRANSFORM COPYBOOK TO DATA

Postby djanarl » Mon Sep 08, 2014 4:45 pm

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:
djanarl
 
Posts: 9
Joined: Fri Sep 05, 2014 7:28 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post