View previous topic :: View next topic
|
Author |
Message |
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi All,
First of all thank you very much for all you support.
Existing functionality is input BRKRNO is PIC'99999' is getting converted to output BRKRNO as BIT(24)
My requirement is, I have BKRNO is CHAR (5) which I need to covert to BIT(40).
Could you please guide me how to achieve this?
Thanks in advance. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Quote: |
BRKRNO is PIC'99999'
BKRNO is CHAR (5) |
bad start...
Please rephrase your question so we can understand something... |
|
Back to top |
|
|
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
I am very very sorry for creating confusion with question,
Existing:
Input BRKRNO is PIC '999999' is conveted as output BRKRNO is BIT(24).
Change is:
Input BRKRNO is CHAR(6) need to convert as BIT(24).
Please help me.[/code] |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
You do realize that 6-Bytes is 48-Bits?
Bill |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
Quote: |
I am very very sorry for creating confusion with question,
Existing:
Input BRKRNO is PIC '999999' is conveted as output BRKRNO is BIT(24).
|
this hasn't clarified - can you show how the conversion is achieved? The PIC'999999' is 48bits, so how is it 'converted' to 24bits? Perhaps if you show the existing code that's doing the conversion.....
Garry. |
|
Back to top |
|
|
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Now we have,
Declaration:
Code: |
DCL
BRKRNO CHAR(06),
OVER_CHAR CHAR(6) STATIC INIT(' '),
OVER_PIC PIC'999999' DEFINED OVER_CHAR,
BINRY FIXED BIN(24) STATIC INIT(0),
OBRKRNO BIT(24); |
Code:
Code: |
OVER_CHAR = BRKRNO;
BINARY24 = OVER_PIC;
OBRKRNO = BINRY; |
Currently we are getting numeric values as only to BRKRNO field.
Ex: BRKRNO=12345 is stored to OBRKRNO in Binary.
Next month onwards we will be receiving as BRKRNO=A2345 which we need to pass to OBRKRNO.
Is this possible? if yes, suggest me how can we do this?
Thanks in advance. |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
First, this is not a CHAR to BIT conversion. What you have is a simple assignment of a numeric (PIC) value to a binary field.
The character 'A' in next month's value is not numeric. The picture specification overlaid will likely force the left nibble to 'F', leaving you with an apparent value of 12345.
I suggest you put together a small program with the values coded to see what happens.
Garry. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
the best thing to do in order to get reasonable help is to show the expectyed hex representation of Your field
for example as ...
Code: |
char hex
123456 ...
ffffff 135
123456 246
a23456 ...
cfffff a35
123456 246
|
|
|
Back to top |
|
|
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
All of you thank you very much for your quick reply.
We got some info regarding input value,
if the input value is 'A23456' it will be stored in file
Could you sugget me how can I read this value as 'A23456' in pli?
Thanks in advance. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
do the application analysts realize that the char set will be limited to hex digits only ???
0 - 9 and A-F |
|
Back to top |
|
|
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi Enrico,
Yes, Analysts confirms that first position will have A-F and rest will have 0-9 only.
Thanks! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Analysts confirms that first position will have A-F and rest will have 0-9 only. |
Sounds like someone got way too "cute". . .
Is this a new process or has this been in production for a while?
If this is new, suggest the first position be limited to 1-6 rather than A-F.
If you really must get the x'A23456' value to A23456, one way is to define an array with values from '00' thru 'FF' and use each individual byte as the displacement into the array. Keep in mind that this "output" value is not a number, but is alphanumeric. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
I've done this in COBOL and (of course) Assembler, but I'm not familiar with the nuances of the PL/I compiler, especially what it does after a PACK instruction. If it then does a ZAP, then you're out of luck if you have other than numerics.
Bill |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
My PL/I is rudimentary (too many years) and I'm unsure how to express a hex-literal (IE: X'FAFBFCFDFEFF'). The TRANSLATE converts 'ABCDEF' to X'FAFBFCFDFEFF', before moving DISPLAY_V9 to PACKED_V9.
Code: |
DCL BRKRNO CHAR(06) INIT ‘A23456’;
DCL WORK_AREA CHAR(06).
DCL PACKED_V9 FIXED DEC(7,1);
DCL PACKED_UNSIGNED CHAR(04) DEFINED PACKED_V9;
DCL DISPLAY_V9 PIC ‘999999V9’ INIT(0).
DCL DISPLAY_CHAR CHAR(07) DEFINED DISPLAY_V9;
WORK_AREA = BRKRNO;
SUBSTR(DISPLAY_CHAR,1,6) = TRANSLATE(WORK_AREA,’ABCDEF’,X’FAFBFCFDFEFF’);
PACKED_V9 = DISPLAY_V9;
|
Theoretically, at this point, SUBSTR(PACKED_UNSIGNED,1,3) equals X'A23456'. But, I'm unsure what Assembler is generated by PL/I. So, if a decimal instruction, such as a ZAP, is generated by the compiler, after the internal PACK instruction, such as the PACKED-V9 Zapping itself (for sign-bit assurance), then this will raise a S0C7.
Bill |
|
Back to top |
|
|
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Thank you all,
I will try all your suggestions and get back to you.
If I have any issues/updates I will come back to you. |
|
Back to top |
|
|
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi Dick,
This is new process, as of now we are getting BRKRNO as ,numeric value, alphanumeric and it is getting stored in 3 Byte binary format.
Example:
787878 is comming as C'787878' and saved as 3 Byte binary value.
New process will send C'7A7878' and this value need to store in 3 Bytes.
We planned to store X'7A7878' which will fit in 3 bytes.
Now I want to know how to read X'7A7878' as C'7A7878' in my program.
Thanks, |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
Quote: |
787878 is comming as C'787878' and saved as 3 Byte binary value.
|
So, the 787878 is coming as C'787878' which is X'F7F8F7F8F7F8'.
Now, the new process will send C'7A7878' which is X'F7C1F7F8F7F8' which you want to store as X'7A7878' ?
What genius came up with this idea ?? I'd suggest revisiting the design....
One approach, though, might be to loop through the 6 bytes performing a TRANSLATE of each byte, treating in pairs. For example, the first byte's X'F7' would translate to X'07' which you then multiply to give X'70'. The 2nd byte would translate X'C1' to X'0A'. Next, you OR these two values to get X'7A' as your 1st bytye to store. Do the same for the other pairs of bytes and you have your result.
You could also decide to do the TRANSLATE using differeent tables for odd and even bytes. This would let you TRANSLATE the X'F7' directly to X'70'.....
A lot of work to circumvent poor design.....
Garry. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
A lot of work to circumvent poor design..... |
Definitely. And this will cause more "adventures" when someone insists on being able to use more than A-F. . .
However:
Code: |
01 HEX-VALUES.
05 FILLER PIC X(32) VALUE '000102030405060708090A0B0C0D0E0F'.
05 FILLER PIC X(32) VALUE '101112131415161718191A1B1C1D1E1F'.
05 FILLER PIC X(32) VALUE '202122232425262728292A2B2C2D2E2F'.
05 FILLER PIC X(32) VALUE '303132333435363738393A3B3C3D3E3F'.
05 FILLER PIC X(32) VALUE '404142434445464748494A4B4C4D4E4F'.
05 FILLER PIC X(32) VALUE '505152535455565758595A5B5C5D5E5F'.
05 FILLER PIC X(32) VALUE '606162636465666768696A6B6C6D6E6F'.
05 FILLER PIC X(32) VALUE '707172737475767778797A7B7C7D7E7F'.
05 FILLER PIC X(32) VALUE '808182838485868788898A8B8C8D8E8F'.
05 FILLER PIC X(32) VALUE '909192939495969798999A9B9C9D9E9F'.
05 FILLER PIC X(32) VALUE 'A0A1A2A3A4A5A6A7A8A9AAABACADAEAF'.
05 FILLER PIC X(32) VALUE 'B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF'.
05 FILLER PIC X(32) VALUE 'C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF'.
05 FILLER PIC X(32) VALUE 'D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF'.
05 FILLER PIC X(32) VALUE 'E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF'.
05 FILLER PIC X(32) VALUE 'F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF'.
01 HEX-VALUES-R REDEFINES HEX-VALUES.
05 HEX-CHAR OCCURS 256 TIMES
INDEXED BY HX-INX.
10 HEX-OVER PIC X.
10 HEX-UNDER PIC X.
*
01 WORK-CHAR.
05 FILLER PIC X.
05 WC-X PIC X.
01 WORK-CHAR-N REDEFINES WORK-CHAR.
05 WC-N PIC 99 COMP.
* |
Moving the "hex byte" (to be translated to 2-bytes) to WC-X and using (WC-N +1) as the displacement into the array will do what you are looking for. |
|
Back to top |
|
|
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi Garry,
C'787878' is converted to PIC'(6)9' then it assigned to FIX BIN filed then it assigned to BIT(24) field. This field is the output field which will occupy 3 Bytes.
New C'7A7878' value also need to fit in 3 bytes, for this change we are working now.
Thanks, |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
Quote: |
Hi Garry,
C'787878' is converted to PIC'(6)9' then it assigned to FIX BIN filed then it assigned to BIT(24) field. This field is the output field which will occupy 3 Bytes.
New C'7A7878' value also need to fit in 3 bytes, for this change we are working now.
|
I understand what you are trying to do, but you can't use a PIC representation of a non-numeric character field and retain its value.
A blank(X'40') is seen in a PIC field as a zero (X'F0'), so the high-order nibble is effectively changed.
Garry. |
|
Back to top |
|
|
|