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 field in COBOL

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


Joined: 26 Sep 2003
Posts: 130
Topics: 36

PostPosted: Mon May 05, 2008 3:53 pm    Post subject: COMP field in COBOL Reply with quote

Hi All,

I have a copy book in assembler as follows
Code:

CBNMLEN  DS    XL1                      NAME OR ADDR LENGTH
CBNMID   DS    CL1                      NAME OR ADDR ID
CBNMDATA DS    0C                     NAME OR ADDR (VARIABLE LENGTH)
         SPACE 1
CBVNMEND EQU   *
         ORG   CBNMLEN
CBVNMLEN DS    CL(CBVNMEND-CBNMLEN)


I want to declare a similar copy book in my COBOL program. I have declared as follows.
Code:

05  WS-NAME-PART.
    10 WS-NAME-PART-LENGTH     PIC 9(2) COMP.
    10 WS-NAME-PART-ID             PIC X(1).
    10 WS-NAME-PART-NAME         PIC X(78).

In assembler copy book the CBNMLEN is one byte. I don't know how to declare variable with one byte containing binary data.

For example:

If CBNMLEN has X'18' it will be store in one byte as follows
Code:

 0
 8


but the variable WS-NAME-PART-LENGTH that I have defined is storing as follows
Code:

 00
 08


Could you please let me know how to define correctly in COBOL.
_________________
Regards,
Chandra
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon May 05, 2008 5:18 pm    Post subject: Reply with quote

chandra,

The equivalent COBOL definition for X data type in Assembler is Character. So define as

Code:

WS-NAME-PART-LENGTH     PIC X(1).


Hope this helps...

Cheers

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Mon May 05, 2008 7:39 pm    Post subject: Reply with quote

If you need to populate that byte with a binary number, define it as PIC S9(4) COMP-5 and redefine it as a group name with 2 elementary names of PIC X each.
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
chandra
Beginner


Joined: 26 Sep 2003
Posts: 130
Topics: 36

PostPosted: Mon May 05, 2008 10:45 pm    Post subject: Reply with quote

Hi Kolusu,

Thanks for your reply... I need to use this field in computation.

Terry,

I tried your solution by defining as follows
Code:

01 OUT1-REC.
   05 OUT-CNTR-NBR            PIC S9(4) COMP-5.
   05 OUT-CNTR REDEFINES OUT-CNTR-NBR.
       15  FRST-BYTE              PIC X(01).
       15  SEC-BYTE               PIC X(01).
   05  FILLER                        PIC X(78).

And try to move the X'18' into OUT-CNTR-NBR but it moved as X'0008'.

Can you please suggest me what I am doing wrong.
_________________
Regards,
Chandra
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue May 06, 2008 12:48 am    Post subject: Reply with quote

MOVE ZERO TO OUT-CNTR-NBR
MOVE X'18' TO SEC-BYTE

sorry, no time or desire to explain. RTFM.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Tue May 06, 2008 9:10 am    Post subject: Reply with quote

MOVE 24 TO OUT-CNTR-NBR
SEC-BYTE should contain X'18' after the move. Dick's method will have the same result as mine. See Language Reference Manual for valid types of MOVE statements.
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
chandra
Beginner


Joined: 26 Sep 2003
Posts: 130
Topics: 36

PostPosted: Tue May 06, 2008 9:27 am    Post subject: Reply with quote

Thank Dick and Terry.

Both your solutions worked.
_________________
Regards,
Chandra
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