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
 

 

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. Full Time COBOL Software Development ... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:24 am
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm


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