Page 2 of 3

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Mon Sep 08, 2014 5:24 pm
by BillyBoyo
Which is why I'd always start with the compile listing. Let the compiler worry about all things, because the compiler does it exactly as the compiler does it. For you to get code to work exactly as the compiler does is 1) difficult and 2) silly, because of 1).

The compiler will "normalise" everything. No matter how coded, the compiler will produce what work it out and produce one single format, for PICture clauses, level-numbers, starting position of data-names, etc.

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Tue Sep 09, 2014 8:28 pm
by djanarl
what i call data is a file that take things from the copybook. the first column is the name of every variable declared in the copybook the second is the type of the variable (i.e N for variable declare in PIC 9 in the copybook) the third is the position (from where position the variable start, p.s the first variable start at 1) and the last column is the length of the variable.

I hope things will be clear for you, so you can help me. Because i still block on convert in something like pic 9(02) or pic p(01)v9(02) to create my data in order to calculate my position and length :oops: :oops:

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Tue Sep 09, 2014 10:07 pm
by NicC
Please do not use attachments - a simple cut and paste using the code tags would have been much easier and use fewer bytes.

Is that dataset an input to your program or an output from it?

What is your block? PIC 9 is one byte, PIC 9(2) is 2 bytes PIC 9V9(2) is 3 bytes etc. Fairly simple.

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Tue Sep 09, 2014 10:31 pm
by BillyBoyo
 1  D-PIC . . .BLW=00000  018  DS 8C           Disp-Num-Edit
 1  E-PIC . . .BLW=00000  020  DS 8C           Disp-Num-Edit
 1  F-PIC . . .BLW=00000  028  DS 9C           Disp-Num-Edit
 1  A . . . . .BLW=00000  038  DS 5C           Disp-Num     
 1  B . . . . .BLW=00000  040  DS 5P           Packed-Dec


I've chopped and pasted this from the "data-map" in a compile listing. First column is the level-number, second the data-name, sixth is the length and type and last is a better description of the type. If look at a data-map for your record-layout, you'll find you can get the start positions.

Try it. Have a look in the Enterprise COBOL Programming Guide for a description of the data-map, and how to get it. Then let the compiler do all the work.

You may need extra, but if you look at the full thing you'll see it has the source line-number on, and the source line-number of the next field, so if you want to know the number of decimals or the number of occurs you only need to look for exactly those things.

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Wed Sep 10, 2014 12:59 pm
by djanarl
NicC wrote:Please do not use attachments - a simple cut and paste using the code tags would have been much easier and use fewer bytes.

Is that dataset an input to your program or an output from it?

What is your block? PIC 9 is one byte, PIC 9(2) is 2 bytes PIC 9V9(2) is 3 bytes etc. Fairly simple.


ok. the dataset is the output of my program. the input is the copybook; i'm trying to convert pic 99 or something like pic 9(02)v99 into pic 9(02) or pic 9(02)v9(02). Can U help please?

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Wed Sep 10, 2014 1:07 pm
by enrico-sorichetti
Can U help please?

the chances of getting help are pretty slim ...
You were already told to process the output of a compilation.
to properly parse a copybook You will have to rewrite a small part of the cobol compiler

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Wed Sep 10, 2014 1:38 pm
by djanarl
I dont know how to put and image, but my program abend on s0c7 because of consecutive 9 in the definition of the copybook

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Wed Sep 10, 2014 1:41 pm
by BillyBoyo
Probably even better, though it didn't exist when I started processing copybooks this way, would be to look at the SYSADATA. Consult the Programming Guide as a starting point on that. Probably gives you the decimals and occurs that way as well.

Unless your copybooks are very formally defined (and they're not, you've got mixed PICture definitions already) then you are piling up a whole amount of work that, as enrico has said, duplicates, probably poorly, what the compiler does.

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Wed Sep 10, 2014 1:51 pm
by enrico-sorichetti
why not use a bit of lateral thinking an try to build on what somebody else has already done ???

see here

ftp://ftp.software.ibm.com/storage/dfso ... rttrck.pdf

PAGE 84

the task of creating DFSORT SYMNAMES is pretty similar to what You are trying to do

Re: TRANSFORM COPYBOOK TO DATA

PostPosted: Wed Sep 10, 2014 2:48 pm
by djanarl
i don't want to do my processing in jcl but in COBOL. and i would like to know if dfsort work for a copybook in input?