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
 

 

COBOL Logic Required

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: COBOL Logic Required
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: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Fri Nov 28, 2008 7:44 pm    Post subject:
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: 6968
Location: porcelain throne

PostPosted: Fri Nov 28, 2008 9:37 pm    Post subject:
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

Site Director


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

PostPosted: Fri Nov 28, 2008 11:05 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts COBOL DB2 program - zIIP eligible vasanthz COBOL Programming 7 Wed May 31, 2017 5:12 am
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm


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