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
 

 

Trim the spaces of month field using COBOL

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

New User


Joined: 23 Oct 2006
Posts: 24
Location: India

PostPosted: Mon May 16, 2011 4:16 pm    Post subject: Trim the spaces of month field using COBOL
Reply with quote

Hi All,

Could you please help me out to fix the issue currently i am facing on my development.

I need to print the date as below format
Code:

10 FOOT-01-FROM-DATE.                                   
   15 FILLER                 PIC X(02) VALUE SPACES.
   15 FROM-DATE-DD           PIC X(02) VALUE SPACES.
   15 FILLER                 PIC X(01) VALUE SPACE.   
   15 FROM-DATE-MMM          PIC X(10) VALUE SPACES.       
   15 FILLER                 PIC X(01) VALUE ",".       
   15 FILLER                 PIC X(01) VALUE SPACE.     
   15 FROM-DATE-YYYY         PIC X(04) VALUE SPACES.     
   15 FILLER                 PIC X(02) VALUE SPACES. 


The output is looking like
Code:

"DATE RANGE FROM:  25        APRIL, 2011  TO:  01           MAY, 2011" 


But my actual requirement is to trim the spaces in the month field and write as
Code:

"DATE RANGE FROM:  25 APRIL, 2011         TO: 01 MAY, 2011          "



Thanks in advance for suggesting me any idea.

Regards,

Jegan S
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7254

PostPosted: Mon May 16, 2011 4:23 pm    Post subject:
Reply with quote

Your months seem to be "right justified". The month names are different sizes, MAY, SEPTEMBER. If you want to get them together nicely in all cases, look at STRING/UNSTRING with SPACES delimiter.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7933
Location: Bellevue, IA

PostPosted: Mon May 16, 2011 4:23 pm    Post subject:
Reply with quote

Use reference modification or the STRING verb.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon May 16, 2011 4:24 pm    Post subject:
Reply with quote

read about the STRING statement.
Back to top
View user's profile Send private message
jegan_selvan

New User


Joined: 23 Oct 2006
Posts: 24
Location: India

PostPosted: Mon May 16, 2011 4:33 pm    Post subject: Reply to: Trim the spaces of month field using COBOL
Reply with quote

Thanks for your quick reply.
Please correct me if my understand is correct.

1.Unstring the variable with spaces.

2.Get the length of month field ( This may vary between 9 characters)

3. Move the date value to first two characters of output field using reference modification.

4. Move the Month value obtained from the Unstring with 3: Length of Month using refernence modification.

5. calculate the starting length for year xx=( Date + Month +Comma)

6. Move the year value of Year to (xx:4) using refernce modification.

If my logic looks worse, Please correct me.

Thanks

Jegan S
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7254

PostPosted: Mon May 16, 2011 4:44 pm    Post subject: Reply to: Trim the spaces of month field using COBOL
Reply with quote

One STRING for each date should do it. The only "tricky" bit is the month, to be "DELIMITED BY SPACE". Don't forget the comma.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7933
Location: Bellevue, IA

PostPosted: Mon May 16, 2011 5:51 pm    Post subject:
Reply with quote

Do you notice in difference in
Quote:
Use reference modification or the STRING verb.
Quote:
read about the STRING statement.
Quote:
One STRING for each date should do it.
and your approach
Quote:
Unstring the variable with spaces.


Hint: STRING and UNSTRING are both COBOL verbs.
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 743
Location: Germany

PostPosted: Tue May 17, 2011 4:26 pm    Post subject:
Reply with quote

@ jegan_selvan

>> Unstring the variable with spaces


No, Bill Woodger said UNSTRING Variable-Name with Space-Delimeter.
Means unstring the content of a field until first space appears.

Example

F1 = 'SEPTEMBER '

Move F1 to F2
So transportation-string would be 'SEPTEMBER '

Unstring F1 into F2 delimited by space
So transportation-string would be 'SEPTEMBER'

You could string/unstring several fields together in one receiving field.
Plse check the manual for details.
Back to top
View user's profile Send private message
jegan_selvan

New User


Joined: 23 Oct 2006
Posts: 24
Location: India

PostPosted: Tue May 17, 2011 6:12 pm    Post subject: Reply to: Trim the spaces of month field using COBOL
Reply with quote

Thanks for all your suggestions.
I used String verb and completd the task.
Once again thanks for all your support.
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 INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
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


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