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 

Display DATE that is in x(03)

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


Joined: 19 Dec 2002
Posts: 4
Topics: 3

PostPosted: Thu Aug 05, 2010 4:05 pm    Post subject: Display DATE that is in x(03) Reply with quote

We received a vendor flat file and its associated copybook and noticed that all the date fields in the copybook are in X(03) format. When viewed in fileaid it has values showing in hex proper dates. Ex: X'070416' in YY/MM/DD indicates 2007/04/16.

How do I unpack or move it to a proper 9(10) field for display

I need COBOL solution

Thanks
Back to top
View user's profile Send private message Send e-mail
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Thu Aug 05, 2010 4:19 pm    Post subject: Reply with quote

I'm not sure why you want a 9(10) field - you want either a 9(8 ) field or and x(10) field. You also need a rule for which century to use for which year ranges.

One easy way to get what you want is to reference each byte of the x(3) field and convert the value to an "over-under" hex value - so x'07' becomes 2 bytes containing x'F0F7'. There are arithmetic ways to do this, but i've used an array for many, many years.
Code:

      01  HEX-VALUES.                                                 
          05 FILLER PIC X(32) VALUE '000102030405060708090A0B0C0D0E0F'.
          05 FILLER PIC X(32) VALUE '101112131415161718191A1B1C1D1E1F'.
          05 FILLER PIC X(32) VALUE '202122232425262728292A2B2C2D2E2F'.
          05 FILLER PIC X(32) VALUE '303132333435363738393A3B3C3D3E3F'.
          05 FILLER PIC X(32) VALUE '404142434445464748494A4B4C4D4E4F'.
          05 FILLER PIC X(32) VALUE '505152535455565758595A5B5C5D5E5F'.
          05 FILLER PIC X(32) VALUE '606162636465666768696A6B6C6D6E6F'.
          05 FILLER PIC X(32) VALUE '707172737475767778797A7B7C7D7E7F'.
          05 FILLER PIC X(32) VALUE '808182838485868788898A8B8C8D8E8F'.
          05 FILLER PIC X(32) VALUE '909192939495969798999A9B9C9D9E9F'.
          05 FILLER PIC X(32) VALUE 'A0A1A2A3A4A5A6A7A8A9AAABACADAEAF'.
          05 FILLER PIC X(32) VALUE 'B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF'.
          05 FILLER PIC X(32) VALUE 'C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF'.
          05 FILLER PIC X(32) VALUE 'D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF'.
          05 FILLER PIC X(32) VALUE 'E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF'.
          05 FILLER PIC X(32) VALUE 'F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF'.
      01  HEX-VALUES-R REDEFINES HEX-VALUES.       
          05 HEX-CHAR     OCCURS 256 TIMES         
                          INDEXED BY HX-INX.       
             10 HEX-OVER  PIC X.                   
             10 HEX-UNDER PIC X.                   
     *                                             
      01  WORK-CHAR.                               
          05 FILLER PIC X.                         
          05 WC-X   PIC X.                         
      01  WORK-CHAR-N REDEFINES WORK-CHAR.         
          05 WC-N   PIC 99 COMP.                   

Move each individual byte to wc-x and then set hx-inx to this value +1. This could be done in a loop or, as there are only 3, they could be done inline.
_________________
All the best,

di
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Mon Aug 09, 2010 10:42 am    Post subject: Reply with quote

You could also try using a REDEFINEd field with a couple MOVEs and a DIVIDE. I attached the code, a sample of the input file and the results of the DISPLAYs in the SYSOUT. The end result is that you'll have the date sitting in a COMP-3 field.

[code:1:f82f960f00]
01 DATE-CONV-AREA.
05 DATE-PARTS.
10 DATE-PART-1 PIC X(03).
10 DATE-PART-2 PIC S9(01) COMP-3.
05 CONVERTED-DATE REDEFINES DATE-PARTS
PIC S9(07) COMP-3.

01 INFLE-WORK-REC.
03 INFLE-DATE PIC X(10).
03 FILLER PIC X(01).
03 INFLE-DATE-2 PIC X(03).


0300-CONVERT-DATE.
DISPLAY '0300- START'
IF INFLE-DATE-2 > LOW-VALUES AND INFLE-DATE-2 NOT = SPACES
MOVE INFLE-DATE-2 TO DATE-PART-1
MOVE +0 TO DATE-PART-2
IF CONVERTED-DATE NUMERIC
DISPLAY 'DATE BEFORE DIVIDE: ' CONVERTED-DATE
COMPUTE CONVERTED-DATE = CONVERTED-DATE / +10
DISPLAY ' DATE AFTER DIVIDE: ' CONVERTED-DATE
ELSE
DISPLAY 'NON-NUMERIC DATE'
END-IF
ELSE
DISPLAY 'NO DATE VALUE TO CONVERT'
END-IF
DISPLAY '0300- END'
.
0300-EXIT. EXIT.



2007-04-16
FFFF6FF6FF4001444444444444
20070040160746000000000000
--------------------------

0300- START
DATE BEFORE DIVIDE: 0704160
DATE AFTER DIVIDE: 0070416
0300- END



1998-01-01 q
FFFF6FF6FF4900444444444444
19980010010811000000000000
--------------------------

0300- START
DATE BEFORE DIVIDE: 9801010
DATE AFTER DIVIDE: 0980101
0300- END



2010-08-27
FFFF6FF6FF4444444444444444
20100080270000000000000000
--------------------------

0300- START
NO DATE VALUE TO CONVERT
0300- END



2010-08-09
FFFF6FF6FF4000444444444444
20100080090000000000000000
--------------------------

0300- START
NO DATE VALUE TO CONVERT
0300- END



2009-12-31
FFFF6FF6FF4013444444444444
20090120310921000000000000
--------------------------

0300- START
DATE BEFORE DIVIDE: 0912310
DATE AFTER DIVIDE: 0091231
0300- END



2008-10-26
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Aug 09, 2010 12:25 pm    Post subject: Reply with quote

Kamur,


I am late to the party but isn't it a simple tasking of padding binary zeroes infront and a sign at the end?.

Take the 3 digit input date and make it a 5 byte PD field with sign at the end. Now convert the pd field to numeric field of 10 bytes. Now use the function DATE-TO-YYYYMMDD on the numeric field of 6 bytes.

Untested code

Code:

WORKING-STORAGE SECTION.                                   
01  INP-DATE                 PIC X(03) VALUE X'070416'.   
01  MOD-NUM                  PIC X(05).                   
01  PD-NUM REDEFINES MOD-NUM PIC S9(9) COMP-3.             
01  ZD-NUM                   PIC 9(10).                   
01  T1-NUM REDEFINES ZD-NUM.                               
    05 FILLER                PIC X(3).                     
    05 T1-DATE               PIC 9(6).                     
    05 FILLER                PIC X(1).                     
01  OUT-DATE                 PIC 9(08).                   
                                                           
PROCEDURE DIVISION.                                       
                                                           
     MOVE X'000000000C' TO MOD-NUM                         
     MOVE INP-DATE      TO MOD-NUM(2:3)                   
     MOVE PD-NUM        TO ZD-NUM                                 
     COMPUTE OUT-DATE    = FUNCTION DATE-TO-YYYYMMDD(T1-DATE)
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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