View previous topic :: View next topic |
Author |
Message |
Anand_R Intermediate
Joined: 24 Dec 2002 Posts: 189 Topics: 60
|
Posted: Mon Dec 22, 2003 6:38 pm Post subject: comp sync to char & back to comp sync |
|
|
Hi,
I have requirement to convert the comp sync variable to character and then finally convert the character variable to comp sync variable.
Example :
01 ws-db-key pic s9(08 ) comp sync.
I want to conver this to the variable defined as
01 ws-temp-hold-variable pic x(10).
And then finally I should able to conver the ws-temp-hold-variable back to
01 ws-db-key-final pic s9(08 ) comp sync.
Please suggest me..
Thx
Anand |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Tue Dec 23, 2003 6:06 am Post subject: |
|
|
Anand,
I don't quite understand as to what you are trying to do.Can you please explain in detail with examples?
Btw the SYNC is not really required and comes in handy to improve performance on some systems for binary items used in arithmetic.
Thanks
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Anand_R Intermediate
Joined: 24 Dec 2002 Posts: 189 Topics: 60
|
Posted: Tue Dec 23, 2003 11:23 am Post subject: |
|
|
Kolusu,
I have to write the IDMS db-key into output file as non comp value(either character or as signed numeric) which is defined as follows
db-key definition : 01 ws-db-key pic s9(08 ) comp sync.
In the out put file I need it as : 01 ws-db-key-non-comp pic x(10) or s9(08). (I need ur input in deciding the picture clause)
And that output file again, I will use as input in the other program and use that dbkey(which is in non comp format) to get the record using that db-key. But we cannot use the non comp db-key to get the record. So I have to convert the non comp db-key again back to s9(08 ) comp sync.
I just wanted to know, is it feasible.. Please let me know if I am not clear .
And this I need to do, b'coz MQ does not accept the comp values. So I have to do this way.
Thanks
Anand |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Tue Dec 23, 2003 1:00 pm Post subject: |
|
|
Anand,
Try this
Code: |
WORKING-STORAGE SECTION.
01 WS-DB-KEY PIC S9(08) COMP SYNC.
01 WS-TEMP-HOLD-VARIABLE PIC X(10).
01 WS-DB-KEY-FINAL PIC S9(08) COMP SYNC.
|
Code: |
PROCEDURE DIVISION.
MOVE 100 TO WS-DB-KEY
MOVE '00' TO WS-TEMP-HOLD-VARIABLE (1 : 2)
MOVE WS-DB-KEY TO WS-TEMP-HOLD-VARIABLE (3 : 8)
DISPLAY 'THE CHAR VALUE :' WS-TEMP-HOLD-VARIABLE
MOVE WS-TEMP-HOLD-VARIABLE TO WS-DB-KEY-FINAL
DISPLAY 'THE COMP VALUE :' WS-DB-KEY-FINAL
GOBACK.
|
Hope this helps...
cheers
kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Anand_R Intermediate
Joined: 24 Dec 2002 Posts: 189 Topics: 60
|
Posted: Tue Dec 23, 2003 3:20 pm Post subject: |
|
|
We tried the following logic as suggested:-
01 WS-DBKEY-HOLD PIC S9(08 ) COMP.
01 WS-DB-KEY PIC S9(08 ) COMP
01 WS-TEMP-HOLD-VARIABLE PIC X(10 ).
01 WS-DB-KEY-FINAL PIC S9(08 ) COMP SYNC.
-------
Accept WS-DBKEY-HOLD FROM R7270-ACCT-SCHED CURRENCY
Move WS-DBKEY-HOLD to WS-DB-KEY
MOVE '00' To WS-TEMP-HOLD-VARIABLE (1 : 2 )
MOVE WS-DB-KEY TO WS-TEMP-HOLD-VARIABLE (3 : 8 )
DISPLAY 'THE CHAR VALUE :' WS-TEMP-HOLD-VARIABLE
MOVE WS-TEMP-HOLD-VARIABLE TO WS-DB-KEY-FINAL
DISPLAY 'THE COMP VALUE :' WS-DB-KEY-FINAL
As an example,one of the actual DBKEY value should be 1374284548 in display format.
But with above logic the following o/p is obtained:-
CHAR VALUE 0074284548
THE COMP VALUE :74284548.
Its truncating the first 2 digits which in our case is '13'.
Please assist.
Thanks,
Anand. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Tue Dec 23, 2003 4:23 pm Post subject: |
|
|
Anand,
If the DBKEY is always 10 bytes then you can eliminate the zero padding to the char field. Move the DBKEY directly to the char filed
Code: |
MOVE WS-DB-KEY TO WS-TEMP-HOLD-VARIABLE
|
Hope this helps..
cheers
kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
RobertL Beginner
Joined: 18 Nov 2003 Posts: 22 Topics: 0 Location: Lisbon, Portugal
|
Posted: Tue Dec 30, 2003 9:37 am Post subject: |
|
|
Anand,
Simply use the following code and let COBOL do the conversion for you.
Code: |
01 WS-DB-KEY PIC S9(08) COMP
01 WS-TEMP-HOLD-VARIABLE-X.
05 WS-TEMP-HOLD-VARIABLE PIC 9(10).
01 WS-DB-KEY-FINAL PIC S9(08) COMP SYNC.
...
* The following will convert WS-DB-KEY to DISPLAY format
* variable WS-TEMP-HOLD-VARIABLE-X will be in CHAR format
* Note: it will have leading zeros
MOVE WS-DB-KEY TO WS-TEMP-HOLD-VARIABLE.
* The following will convert the value back to COMP format.
MOVE WS-TEMP-HOLD-VARIABLE TO WS-DB-KEY.
|
Hope this helps.
Regards,
Robert |
|
Back to top |
|
|
|
|