Field definition input
P1 1 6 N
Value of field is 02236A
Field definition of output
S1 1 1 A
N1 2 6 N
I want the value 022361 by processing as follows
IF P1 < 0
S1 = '-'
N1 = (P1 * -1)
ELSE
N1 = P1
END-IF
But when I proces this field I get
*******A006 PROGRAM INTERRUPT - CODE 7 (DATA EXCP)
Somebody how knows how to handel these kind of fields in easytrieve program
Problem with numeric field with sign in last digit
Moderators: DikDude, Moderator Group
Problem with numeric field with sign in last digit
With kind regards
Cees Post
Cees Post
EASYTRIEVE - MASK
Hi Cees,
What is the value of P1? Is it 02236A or 022361.
If you want to display sign '-' , you can use MASK while defining
target variable. It is not required to multiply with -1.
Let me know, if this is not answered your question.
Regards,
Krishna
http://www.geocities.com/srcsinc
http://www.ibmmainframeguru.com
http://www.jacharya.com
What is the value of P1? Is it 02236A or 022361.
If you want to display sign '-' , you can use MASK while defining
target variable. It is not required to multiply with -1.
Code: Select all
S1 W 7 N 0 MASK('-----99')
OR
S2 W 7 N 0 MASK('ZZZZZ9-')
Let me know, if this is not answered your question.
Regards,
Krishna
http://www.geocities.com/srcsinc
http://www.ibmmainframeguru.com
http://www.jacharya.com
Re: EASYTRIEVE - MASK
Hi Krishna,
As I understand mask is only working when you display it in a report.
What I want is to write a numeric field with a character at the end (representing a sign) to a output file, so in my example is the input P1 value 02236A (where A is standing for -1) and I expect in my output file the value -022361
Thanks for your help
As I understand mask is only working when you display it in a report.
What I want is to write a numeric field with a character at the end (representing a sign) to a output file, so in my example is the input P1 value 02236A (where A is standing for -1) and I expect in my output file the value -022361
Thanks for your help
With kind regards
Cees Post
Cees Post
easytrieve MASK
Hi Cees,
Try with
P1 1 6 N 0 <- Add zero at the end of declaration.
or
Use MASK
Try with
P1 1 6 N 0 <- Add zero at the end of declaration.
or
Use MASK
Last edited by Krishna on Thu Apr 05, 2007 12:54 am, edited 1 time in total.
Regards,
Krishna
Facebook --> http://www.facebook.com/mainframegurukul
Connect with RAMESH KRISHNA REDDY --> http://www.linkedin.com/in/rameshkrishnareddy
Twitter --> https://twitter.com/mainframegurkul
http://www.mainframetutorials.com
Krishna
Facebook --> http://www.facebook.com/mainframegurukul
Connect with RAMESH KRISHNA REDDY --> http://www.linkedin.com/in/rameshkrishnareddy
Twitter --> https://twitter.com/mainframegurkul
http://www.mainframetutorials.com
Cees Post,
I am not clear on few things on ur requirement,
1) P1 1 6 N
Value of field is 02236A ---> How can a variable declared (N ->Numeric) has a alpha numeric value
2) As per ur given data P1 = 02236A
and what are you tryinG to achieve by doing this
N1 = (P1 * -1) ===> you mean N1 = 02236A * (-1) ?????
Well i am not sure what is your requirement correctrly.
But i assumed few things and coded a sample program which will give you what you have asked for in the outputfile, please find below
NOTE : IN THE ABVOE CODE I ASSUME THE VALUE OF A = -1 AND DID THE CODING, IF YOUR REQUIREMNT IN THAT I/P FILE WILL HAVE HEX VALUES FROM 0 -9 , A,B,C,D,E,F,G,H....YOU NEED TO VALIDATE THOSE
AND MOVE THE CORESPONDING VALUES INSTEAD OF -/+ 1 AND -/+ 10...ACCORDINGLY.
P.S = I AM NOT 100% CLEAR REG UR REQUIREMENT, I GUESS I TRIED TO PUT THE CODE THE WAY YOU HAVE TRIED , IF YOU COME UP WITH CLEAR REQUIREMETNS REG THE FILE LAYOUT AND WHAT KIND OF VARAIBLE/DATA COMES FROM I/P FILE MAY BE YOU DONT NEED THE ENTIRE CODE ..A TRICKY DECLARATION OF THE VARAIBLE CAN DO ..THE WORK ...
Thanks,
Veera.
I am not clear on few things on ur requirement,
1) P1 1 6 N
Value of field is 02236A ---> How can a variable declared (N ->Numeric) has a alpha numeric value
2) As per ur given data P1 = 02236A
and what are you tryinG to achieve by doing this
N1 = (P1 * -1) ===> you mean N1 = 02236A * (-1) ?????
Well i am not sure what is your requirement correctrly.
But i assumed few things and coded a sample program which will give you what you have asked for in the outputfile, please find below
Code: Select all
PARM ABEXIT(SNAP) PRESIZE 1024
*
FILE INPFILE FB (6 0)
INPFILE-FIELD 1 6 A ---------------------> I/P FILE HAS A VALUE OF 02236A
*
FILE OUTFILE FB (7 0)
WS-OUTFILE-REC 1 7 A ---------------------> Expected O/P FILE SHOULD VALUE OF -022361
*
WS-INPFILE-FIELD 1 6 A
WS-INP-VALUE 1 5 N
WS-INP-SIGN 6 1 A
*
WS-INP-VALUE-A 1 6 N 0
*
WS-OUTFILE-FIELD 1 7 A
WS-OUT-SIGN 1 1 A
WS-OUT-VALUE 2 6 N
*
**********************************************************************
* PROCESSING *
**********************************************************************
*
JOB INPUT (INPFILE)
*
WS-INPFILE-FIELD = INPFILE-FIELD
WS-INP-VALUE-A = (WS-INP-VALUE * (-10)) - 1
*
IF WS-INP-VALUE-A LT 0
DISPLAY ' LESS THAN ZERO '
WS-OUT-SIGN = '-'
WS-OUT-VALUE = (WS-INP-VALUE * 10) + 1
WS-OUTFILE-REC = WS-OUTFILE-FIELD
PUT OUTFILE
ELSE
DISPLAY ' GREATER THAN ZERO '
WS-OUT-SIGN = '+'
WS-OUT-VALUE = (WS-INP-VALUE * 10) + 1
WS-OUTFILE-REC = WS-OUTFILE-FIELD
PUT OUTFILE
END-IF
NOTE : IN THE ABVOE CODE I ASSUME THE VALUE OF A = -1 AND DID THE CODING, IF YOUR REQUIREMNT IN THAT I/P FILE WILL HAVE HEX VALUES FROM 0 -9 , A,B,C,D,E,F,G,H....YOU NEED TO VALIDATE THOSE
AND MOVE THE CORESPONDING VALUES INSTEAD OF -/+ 1 AND -/+ 10...ACCORDINGLY.
P.S = I AM NOT 100% CLEAR REG UR REQUIREMENT, I GUESS I TRIED TO PUT THE CODE THE WAY YOU HAVE TRIED , IF YOU COME UP WITH CLEAR REQUIREMETNS REG THE FILE LAYOUT AND WHAT KIND OF VARAIBLE/DATA COMES FROM I/P FILE MAY BE YOU DONT NEED THE ENTIRE CODE ..A TRICKY DECLARATION OF THE VARAIBLE CAN DO ..THE WORK ...
Thanks,
Veera.
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page