Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Error in moving value to COMP variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
SANDEEPAN DEY

New User


Joined: 26 Feb 2008
Posts: 4
Location: INDIA

PostPosted: Tue Jul 06, 2010 5:59 pm    Post subject: Error in moving value to COMP variable
Reply with quote

I am having problem in moving a PIC X value to PIC s9 COMP varaible .
The value is a date in CCYY-MM-DD format and I need to move it to CCYYMMDD format in COMP . I use below code .

The code I have tried to use :

Code:
 03 WS-DUEDATE-NUM-N.                             
    05 WS-CCYY-N                  PIC X(4).       
    05 FILLER                     PIC X.           
    05 WS-MM-N                    PIC X(2).       
    05 FILLER                     PIC X.           
    05 WS-DD-N                    PIC X(2).       
    05 FILLER                     PIC X(9).       
 03 WS-HOST-DUEDATE               PIC S9(9)  COMP.
 03 WS-DUEDATE-NUM.                     -----------------> I have tried changing this to PIC 9 . Still its not working                         
    05 FILLER                     PIC X.           .
    05 WS-CCYY-NUM                PIC X(4).         
    05 WS-MM-NUM                  PIC X(2).       
    05 WS-DD-NUM                  PIC X(2).       


 MOVE DEM-DUE-DATE                 TO WS-DUEDATE-NUM-N. 
  MOVE WS-CCYY-N                    TO WS-CCYY-NUM.
  MOVE WS-MM-N                      TO WS-MM-NUM.
  MOVE WS-DD-N                      TO WS-DD-NUM.
 MOVE WS-DUEDATE-NUM               TO WS-HOST-DUEDATE

Error message I am getting :

WS-DUEDATE-NUM-N :2010-07-31
WS-CCYY-NUM :2010
WS-MM-NUM :07
WS-DD-NUM :31
WS-DUEDATE-NUM : 20100731
DEM-DUE-DATE: 2010-07-31
WS-HOST-DUEDATE 15921393 ---> I was moving WS-DUEDATE-NUM to WS-HOST-DUEDATE ( PIC S9(9) comp ) . Although WS-DUEDATE-NUM is getting populated correctly
DEM-WORKS-ORDER(1:2): 48 the WS-HOST-DUEDATE value is coming junk.
WS-WKPLANRO: 48

Guys please help .

Thanks,
Sandeep
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Tue Jul 06, 2010 6:44 pm    Post subject:
Reply with quote

15921393 is X'F2F0F1'

A group move is treated as though it were an alphanumeric-to-alphanumeric elementary move, except that there is no conversion of data from one form of internal representation to another.

Try:
Code:
 03 WS-DUEDATE-NUM PIC 9(8).
 03 FILLER REDEFINES WS-DUEDATE-NUM.
    05 WS-CCYY-NUM                PIC X(4).         
    05 WS-MM-NUM                  PIC X(2).       
    05 WS-DD-NUM                  PIC X(2).       
Back to top
View user's profile Send private message
SANDEEPAN DEY

New User


Joined: 26 Feb 2008
Posts: 4
Location: INDIA

PostPosted: Tue Jul 06, 2010 7:19 pm    Post subject:
Reply with quote

ok I will try that out . Do u want me to keep the MOVE statements as it is . Any why it is giving that particular value :

15921393 is X'F2F0F1'


Thanks,
Sandeep
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Tue Jul 06, 2010 7:33 pm    Post subject:
Reply with quote

Since S9(9) is a four byte field and 15921393 is actually X'00F2F0F1' and the from field is a nine byte field containing '20100731', truncation occurred.
I can only assume the the leading FILLER contained low values.....
Back to top
View user's profile Send private message
SANDEEPAN DEY

New User


Joined: 26 Feb 2008
Posts: 4
Location: INDIA

PostPosted: Wed Jul 07, 2010 12:18 am    Post subject:
Reply with quote

It worked ! Thanks a lot .

However I am still confused what was wrong in my initial code . Was it because of the additional filler ? Can you tell me how should I populate a comp variable from a PIC X variable . Do I need to move it through a PIC 9 variable always ? What measures should I take regard to size ?

Sandeep
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Jul 07, 2010 12:28 am    Post subject:
Reply with quote

Hello,

Quote:
However I am still confused what was wrong in my initial code .


Code:
WS-DUEDATE-NUM-N :2010-07-31
is not a numeric value. . .
It is a group alphanumeric. To move part of the content (which is what you wanted to do) create a valid elementary numeric field from the numbers in the "input" field.

Then move this valid number to the comp variable.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 07, 2010 12:41 am    Post subject: Reply to: Error in moving value to COMP variable
Reply with quote

COBOL will move data as-is, if it's defined explicitly or implicitly as PIC X. So, if you have a field which contains only numerics and you need to populate a COMP-3 or COMP field, the sending field must be defined as PIC 9.

Moving PIC 9 to COMP-3, involves 2-3 instructions, which PACKS and then ensures a packed-decimal "C" or "D" sign-nibble or an "F" neutral-nibble.

However, moving PIC 9 to COMP adds several more instructions after the PACK, such as a CVB (Convert To Binary) and a ST (Store).

IMHO, understanding the underlying Assembler instructions would benefit you in the long run.

Compiling your program using the LIST,NOOFFSET compile options and the associated Assembler instructions will be generated.

Bill
Back to top
View user's profile Send private message
SANDEEPAN DEY

New User


Joined: 26 Feb 2008
Posts: 4
Location: INDIA

PostPosted: Wed Jul 07, 2010 11:41 am    Post subject:
Reply with quote

Thanks Guys ! Especially CICS GUY and BIll for your valuable insights.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts FUSE - IBM MQ - CICS integration error Kevin Vaz CICS 1 Mon Sep 18, 2017 4:31 pm
No new posts Reply MQ open error Vignesh Sid COBOL Programming 5 Thu Sep 07, 2017 6:02 pm
No new posts Error in SQL-PLIST3 'Above value tru... rikdeb DB2 4 Wed Sep 06, 2017 1:34 pm
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us