MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Is there any variable of dynamic size in cobol

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
sajinpattath
Beginner


Joined: 27 Aug 2006
Posts: 1
Topics: 1
Location: india

PostPosted: Sun Aug 27, 2006 1:42 am    Post subject: Is there any variable of dynamic size in cobol Reply with quote

I want to remove the unwanted space of a variable which is declared with size x(20) and put a pipe delimiter at the end while writing to a PS file.
For example.

Input copy book

Name pic X(20)
Address pic x(20)

Output copy book
Name max length pic X(20)
Filler pic X(1) value '|'
Address max length pic X(20)
Filler pic X(1) value '|'



Suppose Name contains - 'sajin pattath s' which occupies only 15 bytes.
and Address contains-'company,India' which occupies only 13 bytes.

When we write to the out put PS file of variable length record
The output file should contain

sajin pattath s|company,India|

instead of

sajin pattath s'5spaces'|company,india'7spaces'|

Is there any variable of dynamic size in cobol to do this so that i can give it in the output copy book?
I dont want to use
'unstring delimited by spaces' as it is prone to alot of bugs in my case.

Could any one specify a method to do this. Question
_________________
Thanks,
Sajin Pattath.
Back to top
View user's profile Send private message Yahoo Messenger
ofer71
Intermediate


Joined: 12 Feb 2003
Posts: 358
Topics: 4
Location: Israel

PostPosted: Sun Aug 27, 2006 1:55 am    Post subject: Reply with quote

There is no variable. You will have to do it yourself, using UNSTRING or INSPECT TALLYING.

O.
________
Mercury Topaz picture


Last edited by ofer71 on Sat Feb 05, 2011 11:43 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Aug 29, 2006 9:50 am    Post subject: Reply with quote

sajinpattath,

Try this

[code:1:0b0b1f33b2]
WORKING-STORAGE SECTION.

01 NAME PIC X(20).
01 CUST-ADDR PIC X(20).
01 WS-OUT-SUB PIC S9(04) COMP VALUE 1.
01 WS-OUT-STRING PIC X(80) VALUE SPACES.

01 WS-TEMP-VAR.
05 WS-STRING PIC X(20) VALUE SPACES.
05 WS-LENGTH PIC S9(04) COMP.
05 WS-TALLY PIC S9(04) COMP.

PROCEDURE DIVISION.

INITIALIZE WS-TEMP-VAR
MOVE 'SAJIN PATTATH S' TO NAME
MOVE NAME TO WS-STRING
PERFORM 0500-FORMAT-DATA

INITIALIZE WS-TEMP-VAR
MOVE 'COMPANY,INDIA' TO CUST-ADDR
MOVE CUST-ADDR TO WS-STRING
PERFORM 0500-FORMAT-DATA

DISPLAY 'OUT-STRING : ' WS-OUT-STRING
GOBACK
.

0500-FORMAT-DATA.

PERFORM 1000-GET-EXACT-LENGTH
PERFORM 1500-MOVE-TO-OUTPUT
PERFORM 2000-MOVE-DELIMITER
.

1000-GET-EXACT-LENGTH.

INSPECT FUNCTION REVERSE(WS-STRING) TALLYING WS-TALLY
FOR LEADING SPACES
COMPUTE WS-LENGTH = LENGTH OF WS-STRING - WS-TALLY
.
1500-MOVE-TO-OUTPUT.

MOVE WS-STRING(1: WS-LENGTH) TO
WS-OUT-STRING(WS-OUT-SUB : WS-LENGTH)
COMPUTE WS-OUT-SUB = WS-OUT-SUB + WS-LENGTH
.
2000-MOVE-DELIMITER.

MOVE '
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group