View previous topic :: View next topic
|
Author |
Message |
SANDEEPAN DEY
New User
Joined: 26 Feb 2008 Posts: 4 Location: INDIA
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
Back to top |
|
|
SANDEEPAN DEY
New User
Joined: 26 Feb 2008 Posts: 4 Location: INDIA
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
SANDEEPAN DEY
New User
Joined: 26 Feb 2008 Posts: 4 Location: INDIA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
SANDEEPAN DEY
New User
Joined: 26 Feb 2008 Posts: 4 Location: INDIA
|
|
|
|
Thanks Guys ! Especially CICS GUY and BIll for your valuable insights. |
|
Back to top |
|
|
|