TRANSFORM COPYBOOK TO DATA



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

Re: TRANSFORM COPYBOOK TO DATA

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

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

Re: Re: TRANSFORM COPYBOOK TO DATA

 

Re: TRANSFORM COPYBOOK TO DATA

Postby djanarl » Tue Sep 09, 2014 8:28 pm

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:
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 NicC » Tue Sep 09, 2014 10:07 pm

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: TRANSFORM COPYBOOK TO DATA

Postby BillyBoyo » Tue Sep 09, 2014 10:31 pm

 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.
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 » Wed Sep 10, 2014 12:59 pm

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?
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 enrico-sorichetti » Wed Sep 10, 2014 1:07 pm

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: TRANSFORM COPYBOOK TO DATA

Postby djanarl » Wed Sep 10, 2014 1:38 pm

I dont know how to put and image, but my program abend on s0c7 because of consecutive 9 in the definition of the copybook
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 » Wed Sep 10, 2014 1:41 pm

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.
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 enrico-sorichetti » Wed Sep 10, 2014 1:51 pm

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: TRANSFORM COPYBOOK TO DATA

Postby djanarl » Wed Sep 10, 2014 2:48 pm

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

PreviousNext

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post