View previous topic :: View next topic
|
Author |
Message |
anirudh1985 Currently Banned New User
Joined: 22 Aug 2007 Posts: 66 Location: bangalore
|
|
|
|
hi, i have a copybook declaration as follows:
id pic x(5)
name pic x(10)
city pic x(10)
how do i calculate the position and offset of the values id,name,city .My out put shud be:
field pos off
id 1 5
name 6 10
city 16 10
can any body help me.... |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
depends on if you want cardinal position or relative position. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Suggest you change terms to position or displacement and length.
This is most likely a task you do not want to undertake. . .
Your code would need to replicate much of the data division functionality of the cobol compiler and that is usually not reasonable.
Depending on how you want to use this info, you can probably get these values from a compile listing. |
|
Back to top |
|
|
anirudh1985 Currently Banned New User
Joined: 22 Aug 2007 Posts: 66 Location: bangalore
|
|
|
|
for example i need to calulate for pic x(5) as follows
start pos is:1 and offset is :5
now for pic x (10)
start pos is 5(previous offset)+1=6 and offset:10...i hope its clear now |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello Anirudh,
I believe we understand what you want to do. What is not clear is how the "output values" will be used once calculated.
Quote: |
start pos is 5(previous offset)+1=6 and offset:10...i hope its clear now |
Please correct the terminology. The length of a field is typically not called the offset. . . The offset is typically the first positon of some field.
As i mentioned before, you would need to implement compiler-like data division code to calculate the output you want. I suspect that the magnititude of that requirement is not yet understood.
If you explain what you will use the calculated values to do, we may be able to offer alternatives. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
1. read your cobol copy file into a rexx stem.
2. starting offset is 1
3. using your basic logic, loop through your stem array parsing the variable name and meanwhile calculating the cumulative offset from start of record.
5(previous offset)+1=6
----
4. read your data records and use names and offsets you figured out earlier. You looked and know the record will be parsed something like this:
Code: |
parse var data.x id 5 name 16 city 26 . |
but apparently, you want your rexx program to figure it out dynamically, so it has to do something like this using the values from step 3 above.
Code: |
INTERPRET "parse var data.x " myname.1 myoffset.2 myname.2 myoffset.3 myname.3 |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
And don't forget to allow for repeating groups (arrays, even multi-dimensional), redefines (and nested redefines), and the various calculations to determine actual byte length from binary and packed-decimal field definitions. . . |
|
Back to top |
|
|
rexx77
New User
Joined: 14 Apr 2008 Posts: 78 Location: Mysore
|
|
|
|
i feel File aid will help a little bit in this issue. i worked some time back the for a requirement similar to this.
Invoke file aid in Batch mode for the copybook and store the output file in sequential dataset, then take the file for processing using REXX.
File aid will give you in a format like below
Variable datatype length start end
Extract information from the file using simple rexx functions.
Hope this piece of info will help you
Regards |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
Back to top |
|
|
|