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 

PL1 Data Conversion

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


Joined: 29 Jun 2004
Posts: 170
Topics: 73

PostPosted: Mon Oct 18, 2010 1:22 pm    Post subject: PL1 Data Conversion Reply with quote

Variable Cal_year is a four characters digits. I want to add 1 to Cal_Year and return the last 2 digits. In REXX:
Code:

Cal_Year = '2008'
Next_Year = substr(Cal_Year+1,3,2)

    Result: Next_Year = '09'

How is it being implemented in PL1?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Oct 18, 2010 3:03 pm    Post subject: Reply with quote

danm,

Unless I am missing something isn't it a simple redefine? Untested code

Code:

DCL 1 DATAREC,                     
    3 CHARFLD     CHAR(4);         
DCL 1 NUMFLD BASED(ADDR(DATAREC)),
    3 NUMA,                       
      5 NUMFLD1  PICTURE '99',     
      5 NUMFLD2  PICTURE '99';     
DCL 1 RESULT      CHAR(4);         
                                   
CHARFLD = '2008';                 
NUMFLD2 = NUMFLD2 + 1;             
RESULT  = CHARFLD;                 


Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Tue Oct 19, 2010 12:04 am    Post subject: Reply with quote

ccyy = '2008';
ccyy= ccyy + 1;
yy = substr(ccyy,3)

If your characters are integers then integer arithmetic is allowed in PL/1. However, a redefine as follows:

dcl yy pic '99' def ccyy pos(3);

would be preferable.
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
danm
Intermediate


Joined: 29 Jun 2004
Posts: 170
Topics: 73

PostPosted: Tue Oct 19, 2010 9:57 am    Post subject: Reply with quote

Thanks. Declaring Cal_Year as PIC '9999' solve the problem.
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Tue Oct 19, 2010 4:15 pm    Post subject: Reply with quote

Quote:
If your characters are integers then integer arithmetic is allowed in PL/1.


True in V1 and V2 but not in V3
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
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