IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

calculate position and offset


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
anirudh1985
Currently Banned

New User


Joined: 22 Aug 2007
Posts: 66
Location: bangalore

PostPosted: Wed Jun 11, 2008 10:34 am
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jun 11, 2008 11:23 am
Reply with quote

depends on if you want cardinal position or relative position.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jun 11, 2008 11:30 am
Reply with quote

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
View user's profile Send private message
anirudh1985
Currently Banned

New User


Joined: 22 Aug 2007
Posts: 66
Location: bangalore

PostPosted: Wed Jun 11, 2008 12:07 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jun 12, 2008 3:43 am
Reply with quote

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
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Thu Jun 12, 2008 6:32 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jun 12, 2008 6:41 am
Reply with quote

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
View user's profile Send private message
rexx77

New User


Joined: 14 Apr 2008
Posts: 78
Location: Mysore

PostPosted: Thu Jun 12, 2008 11:48 am
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Jun 12, 2008 11:56 am
Reply with quote

as already asked,
if the TS would graciously tell what he is trying to achieve we might be able to give better answers

is he trying to parse a cobol copybook, looks like, but who knows?
I asked the same in a different thread from the same, but the gentleman did not care to reply
http://www.ibmmainframes.com/viewtopic.php?t=31488&highlight=


here is a pointer to "a cobol copybook length calculation in rexx"

http://groups.google.be/group/bit.listserv.tsorexx/browse_thread/thread/d60c97b35839e3ff/bdcec8b86fb6ecae?lnk=gst&q=rexx+record+calculation#
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts Printing a dataset in DUMP format wit... ABENDS & Debugging 2
Search our Forums:

Back to Top