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 

comp sync to char & back to comp sync

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


Joined: 24 Dec 2002
Posts: 189
Topics: 60

PostPosted: Mon Dec 22, 2003 6:38 pm    Post subject: comp sync to char & back to comp sync Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Dec 23, 2003 6:06 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Anand_R
Intermediate


Joined: 24 Dec 2002
Posts: 189
Topics: 60

PostPosted: Tue Dec 23, 2003 11:23 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Dec 23, 2003 1:00 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Anand_R
Intermediate


Joined: 24 Dec 2002
Posts: 189
Topics: 60

PostPosted: Tue Dec 23, 2003 3:20 pm    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Dec 23, 2003 4:23 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
RobertL
Beginner


Joined: 18 Nov 2003
Posts: 22
Topics: 0
Location: Lisbon, Portugal

PostPosted: Tue Dec 30, 2003 9:37 am    Post subject: Reply with quote

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
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