Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Syncsort - Convert PIC S9(12)V99 COMP-3 to PIC 9(7) COMP-3
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: 1717
Location: UK

PostPosted: Mon Jul 04, 2011 11:12 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Tue Jul 05, 2011 4:39 am    Post subject: Reply to: Syncsort - Convert PIC S9(12)V99 COMP-3 to PIC 9(7
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: 2171
Location: @my desk

PostPosted: Wed Jul 06, 2011 3:16 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Wed Jul 06, 2011 7:20 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Fri Jul 08, 2011 7:39 pm    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Sun Jul 10, 2011 1:43 am    Post subject:
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    Post subject:
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: 2171
Location: @my desk

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

Ramanan-R,

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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Mon Jul 11, 2011 4:54 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts convert PD to ZD ram_vizag DFSORT/ICETOOL 5 Sat Nov 05, 2016 3:06 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us