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

COBOL Logic Required


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ashimprodhan

New User


Joined: 08 Dec 2006
Posts: 12
Location: Kolkata

PostPosted: Fri Nov 28, 2008 7:13 pm
Reply with quote

Hi All,


I need to write a program/function say OFFSET which will return a value equal to the number of used bytes that precede the data-name in the logical record in which data-name is defined.

Eg.

01 TEST-VARIABLE1.
02 WS-VAR1 PIC X(2).
02 WS-VAR2 PIC 9(5).
02 WS-VAR3 PIC X(6)
02 WS-VAR4 PIC X(10) VALUE 'ASHIM'.
02 WS-VAR5 PIC S9(2).
02 WS-VAR6 PIC 9(2) COMP.

the OFFSET(WS-VAR1) will return 0
WS-VAR2 will return 2
WS-VAR3 will return 7 like this..

If its an elementary level then it will return zero. Whenever the OFFSET of a variable is to be calculated this function will be called.

Please suggest me the logic or is there any intrisic function which can do that......

True Regards,
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Nov 28, 2008 7:44 pm
Reply with quote

I don't think it can be done in COBOL at all -- COBOL ADDRESS OF only applies to 01 or 77 level items. If you write an Assembler subroutine and pass BY REFERENCE you should be able to use the addresses of the fields to calculate differences, but I haven't tested this so it's not guaranteed.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Nov 28, 2008 9:37 pm
Reply with quote

If COBOL II:
Write a cobol sub-modul that is CALLed USING <FIELD>, <signed Binary 4/8? I forget>
SUB-MODULE:
Code:

PROCEDURE DIV USING <area>, <pointer>
set <pointer> to address of <area>
goback.

If Enterprise COBOL you can set a pointer in working-storage to the address of <something>. Redefine the pointers as <signed Binary 4/8? I forget>.

the fields defined as binary can be used in length calculations.
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: Fri Nov 28, 2008 11:05 pm
Reply with quote

Hello,

Once you have the offset, how will it be used?

How do you plan to handle redefines, renames, and arrays?
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top