IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Syncsort - Convert PIC S9(12)V99 COMP-3 to PIC 9(7) COMP-3


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Ramanan-R

New User


Joined: 21 Mar 2007
Posts: 66
Location: Chennai, Tamilnadu, India

PostPosted: Mon Jul 04, 2011 7:57 pm
Reply with quote

Hello All icon_smile.gif

Using Syncsort, i need to convert PIC S9(12)V99 COMP-3 to PIC 9(7) COMP-3.

Though the field was originally declared as PIC S9(12)V99 COMP-3 it has value only for first 7 integer values so i was told, no need to worry about data truncation. Also the decimal part needs to be stripped off...

Please help me to write a Syncsort code for this...

Thanks!
Ramanan R
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Mon Jul 04, 2011 11:12 pm
Reply with quote

First of all...what have you tried?
Also, you have been around long enough to know that lots of other information is required for sort queries and you have supplied absolutely none of it.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jul 05, 2011 4:39 am
Reply with quote

As Nic has said, there is not a lot to go on.

So let's assume the only problem you have is this one.

You have an 8-byte Packed Decimal which you want to relocate into a 4-byte Packed Decimal. You have two decimal places to drop. If you can't define decimal places in SYNCSORT (I have no idea) then hopefully you can divide by 100 and put the result in your 4-byte field. If you can define the decimal places on the first field, then they will "fall off" as you put the data in the second location. Truncation, but truncating zeros should be OK.

The fun is in the checking. Not difficult. If you can subtract your new field from your old field and put the result in a new field that is the same size as the old field, and SUM on that, then you will be able to confirm no loss of data (or produce a value of how much, if decimals are being knowingly truncated).

You do mention signs in your definition, so you do have the outside chance, but you have to code for it, that you have +ve and -ve difference that will offset each other giving you a sum of zero when there are actually differences. So, either SUM +ve and -ve seperately or SUM on an unsigned field.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Jul 06, 2011 3:16 pm
Reply with quote

Ramanan-R,

The below Syncsort does what I think you're trying to achieve.
Code:
//SYSIN     DD *                               
  OPTION COPY                                   
  INREC BUILD=(1,8,PD,DIV,+100,TO=PDF,LENGTH=4)
SORTIN
Code:
8/PS             
(1-8)           
1----------------
*****************
            13.00
            23.12
            33.34
          1024.85
       1234567.89
SORTOUT
Code:
4/P     
(1-4)   
1-------
********
      13
      23
      33
    1024
 1234567
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jul 06, 2011 7:20 pm
Reply with quote

Ramanan,

Are you going to have a go at the automatic checking yourself?

Another way would be to check the first six bytes of the old field for x'000000' (say, OMIT the records, check that all are omitted, and then you even have a file of those that are non-zero truncation).

For the decimals, define the last integer and the decimals as two bytes packed, multiply by 10 (to kill off the integer), divide by 10 to put things back in the right place (unless SYNCSHORT has "shifting" or "anding") and then do either SUM (if the decimals have values, so you know how much is lost - I'll PM you my bank details, just so all the accounts are tidy if it is a help) or do another OMIT if they are supposed to be zero.
Back to top
View user's profile Send private message
purusothaman

New User


Joined: 17 Feb 2007
Posts: 39
Location: Chennai

PostPosted: Fri Jul 08, 2011 3:40 pm
Reply with quote

Hi,

After reading this post, I was wondering how to convert S9(3)v9(2) COMP-3 to S9(3)V9(12) COMP-3?

Input file is of just 3 bytes PD field.

I tried the following thing and it was fine. But I feel this is like a workaround. Please let me know if some other better solution is available.

Code:
SORT FIELDS=COPY
INREC FIELDS=(1,3,PD,EDIT=(TTT.TT),C'0000000000')
OUTREC FIELDS=(1,16,SFF,TO=PD,LENGTH=8)
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Jul 08, 2011 7:39 pm
Reply with quote

Hello,

If it works correctly every time, why might you believe this a "workaround"?

What might you prefer?
Back to top
View user's profile Send private message
Ramanan-R

New User


Joined: 21 Mar 2007
Posts: 66
Location: Chennai, Tamilnadu, India

PostPosted: Fri Jul 08, 2011 11:53 pm
Reply with quote

Thanks Arun icon_smile.gif, Your code worked great...

Bill,

Thanks for your inputs... icon_smile.gif
Back to top
View user's profile Send private message
purusothaman

New User


Joined: 17 Feb 2007
Posts: 39
Location: Chennai

PostPosted: Sat Jul 09, 2011 11:19 am
Reply with quote

HI Dick,

I was wondering will there be any other better approach which can convert instead of using those hard coded zeros?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sun Jul 10, 2011 1:43 am
Reply with quote

Hello,

Why did you feel the need to use something other than what Arun suggested? That solution has none of the zeros you don't want anyway?
Back to top
View user's profile Send private message
purusothaman

New User


Joined: 17 Feb 2007
Posts: 39
Location: Chennai

PostPosted: Mon Jul 11, 2011 9:28 am
Reply with quote

Dick,

Thanks. I would be happy with this. icon_smile.gif
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Jul 11, 2011 11:05 am
Reply with quote

Ramanan-R,

You're welcome icon_smile.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jul 11, 2011 4:54 pm
Reply with quote

Ramanan-R,

No problem.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
Search our Forums:

Back to Top