Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Regarding length of function in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
dipanshu

New User


Joined: 16 Jan 2006
Posts: 53
Location: pune

PostPosted: Wed May 30, 2007 10:07 am    Post subject: Regarding length of function in COBOL
Reply with quote

Hi All,

Code:


FD PPICSV
01 PPICSV-REC.
      03 FILLER                         PIC X OCCURS 0 TO 120
                  DEPENDING ON X04-OUTREC-LENGTH.
Working....
77 L pic 9(2)
77 X pic 9(2)

PROCEDURE DIVISION.

Move 'ABCDE' to PPICSV-REC.
COMPUTE L = Length(PPICSV-REC)
Move 5 to X04-OUTREC-LENGTH
COMPUTE X = Length(PPICSV-REC)


What would be the value of L & X?

Regards,
Dip..
Back to top
View user's profile Send private message

Raphael Bacay

New User


Joined: 04 May 2007
Posts: 58
Location: Manila, Philippines

PostPosted: Wed May 30, 2007 10:54 am    Post subject:
Reply with quote

You might find the following example interesting:

Example 1

77 CITY PIC X(9) VALUE "CHICAGO".
77 ID-LENGTH PIC 99 VALUE ZERO.
:
COMPUTE ID-LENGTH = FUNCTION LENGTH (CITY).
DISPLAY CITY.
DISPLAY ID-LENGTH.

The above example displays the following:

CHICAGO__
09

Example 2

77 SIZER PIC 99.
77 NUM PIC 999.
01 TAB-REC.
05 TAB-ELEMENT OCCURS 1 TO 10 TIMES
DEPENDING ON SIZER.
10 TAB-ITEM-1 PIC X(3).
10 TAB-ITEM-2 PIC S9(9) COMP SYNC.
PROCEDURE DIVISION.
010-PARA.
MOVE 5 TO SIZER.
COMPUTE NUM = FUNCTION LENGTH (TAB-ELEMENT (1)).
DISPLAY "TAB-ELEMENT LENGTH = " NUM.
COMPUTE NUM = FUNCTION LENGTH (TAB-REC).
DISPLAY "TAB-REC LENGTH = " NUM.
STOP RUN.

The above example displays the following:

TAB-ELEMENT LENGTH = 008
TAB-REC LENGTH = 040

The length of TAB-ELEMENT is 8 because of the implicit 1-byte filler
between TAB-ITEM-1 and TAB-ITEM-2. If SYNC is removed from TAB-ITEM-2,
the length of TAB-ELEMENT is 7.


Thanks.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Wed May 30, 2007 2:38 pm    Post subject:
Reply with quote

L = X04-OUTREC-LENGTH
X = 5
Back to top
View user's profile Send private message
dipanshu

New User


Joined: 16 Jan 2006
Posts: 53
Location: pune

PostPosted: Wed May 30, 2007 2:59 pm    Post subject:
Reply with quote

Many Thanks!
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
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
This topic is locked: you cannot edit posts or make replies. Selecting two copybooks of different ... Vignesh Sid COBOL Programming 8 Tue Sep 05, 2017 7:28 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us