|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
CASTING CHARACTER to INTEGER for COMP-3 fields |
« View previous topic :: View next topic » |
Author |
Message
|
rdw |
Posted: Thu Jan 16, 2003 10:56 am Post subject: CASTING CHARACTER to INTEGER for COMP-3 fields |
|
|
Newbie
Joined: 16 Jan 2003 Posts: 3
|
PROB
We are expected to handle a COBOL field that comes in a spaces or comes in COMP-3, because the program is using the INITIALIZE function in the COBOL program. Our strategy was to create a MRM layout of all CHARACTER datatypes, TRIM the field replacing spaces with zero then CAST to an INTEGER. CASTING is not working for us on the very first field that happens to be a valid number and not spaces.
Are the control characters causing the problem? If so, how should we handle these control character? Or do we have to go thru this byte by byte to handle High and Low byte values?
OS/390
XRF-SEG-LGTH-CD PIC S9(04) COMP.
MQSI 2.0.1 MRM type
MRM1
ALT-XRF-SEG-LGTH-CD PIC X(2). <----CHARACTER
MRM2
XRF-SEG-LGTH-CD PIC S9(04) COMP. <----INTEGER
ESQL
IF (LENGTH(TRIM(
InputRoot.MRM.WCIF103_ALT_XRF_AREA.ALT_XRF_ROOT_SEG.ALT_XRF_SEG_LGTH_CD)) > 0)
THEN
SET
OutputRoot.MRM.WCIF103_XRF_AREA.XRF_ROOT_SEG.XRF_SEG_LGTH_CD = CAST (TRIM(InputRoot.MRM.WCIF103_ALT_XRF_AREA.ALT_XRF_ROOT_SEG.ALT_XRF_SEG_LGTH_CD) AS INTEGER);
ELSE
SET OutputRoot.MRM.WCIF103_XRF_AREA.XRF_ROOT_SEG.XRF_SEG_LGTH_CD = 0;
END IF;
ERROR
2003-01-16 11:01:19.152274 18 RecoverableException BIP2521E: (66, 73) : Error casting a value from CHARACTER to INTEGER.
An error occurred when casting a value of data type CHARACTER to a value of data type INTEGER.
Subsequent messages will indicate the context of the error.
2003-01-16 11:01:19.152386 18 ConversionException BIP2595E: Error casting character string '^A00000000^B' to an integer.
An attempt was made to cast the character string '^A00000000^B' to an integer, but the string was of the wrong format. _________________ rdw |
|
Back to top |
|
 |
yaakovd |
Posted: Mon Jan 20, 2003 5:29 am Post subject: |
|
|
Partisan
Joined: 20 Jan 2003 Posts: 319 Location: Israel
|
You can try to define local integer variable before - in this case you can remove TRIM, CASTING and IF from your code:
DEFINE ALT_XRF INT;
SET ALT_XRF = 0;
SET ALT_XRF = InputRoot.MRM.WCIF103_ALT_XRF_AREA.ALT_XRF_ROOT_SEG.ALT_XRF_SEG_LGTH_CD;
SET OutputRoot.MRM.WCIF103_XRF_AREA.XRF_ROOT_SEG.XRF_SEG_LGTH_CD = 0;
I didn't tested it with MRM, but it working when select from DB. But I guess it working same. _________________ Best regards.
Yaakov
SWG, IBM Commerce, Israel |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|