Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

calculate position and offset

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: calculate position and offset
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    Post subject:
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

Site Director


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

PostPosted: Wed Jun 11, 2008 11:30 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Thu Jun 12, 2008 3:43 am    Post subject:
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

Senior Member


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

PostPosted: Thu Jun 12, 2008 6:32 am    Post subject: Reply to: calculate position and offset
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

Site Director


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

PostPosted: Thu Jun 12, 2008 6:41 am    Post subject:
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: 73
Location: Mysore

PostPosted: Thu Jun 12, 2008 11:48 am    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Thu Jun 12, 2008 11:56 am    Post subject: Reply to: calculate position and offset
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to calculate an specific transact... lind sh CICS 2 Tue Sep 13, 2016 9:20 pm
No new posts ISREDIT - Position Cursor on the Comm... Tarique Anwer TSO/ISPF 5 Wed Feb 03, 2016 12:44 pm
No new posts Calculate a timeframe with DFsort Gerd Hofmans DFSORT/ICETOOL 6 Thu Jan 14, 2016 5:30 pm
No new posts Adjust Heading Position in Easytrieve thesumitk CA Products 4 Mon Dec 21, 2015 3:26 pm
No new posts set column position record? italo_pm CLIST & REXX 3 Wed May 27, 2015 2:18 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us