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

Regarding length of function in COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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: 3156
Location: Tucson AZ

PostPosted: Wed May 30, 2007 2:38 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
Search our Forums:

Back to Top