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

comvert packed decimal to decimal using sort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Hima1985

New User


Joined: 17 Apr 2009
Posts: 70
Location: India

PostPosted: Thu Aug 18, 2011 12:34 am
Reply with quote

Hi All

Can we convert packed decimal value to decimal value using sort? If yes can you please tell me how can I do it.

My requirement is,

I have a FB file of length 400 bytes.
1) First 30. Bytes is name
2) 31st to 35 bytes is key
3) 36th byte to 45th byte packed decimal amount value

I need to check the key value at 31st position and copy packed decimal value to 36th position if key value is 1130 and if key value is 1131 I need to copy packed decimal value to 46th position and if key value 1132 I need to copy packed decimal value to 55th position, depending on key value I need to copy the packed decimal value after converting it to decimal

Ex
Input
Code:

XYZXYZXYZ.                    113000@@@@@@
XYZXYZXYZ.                    113100@@@@@@
XYZXYZXYZ.                    113200@@@@@@
ABCABCXYZ.                   113000@@@@@@
ABCABCXYZ.                    113000@@@@@@
ABCABCXYZ.                    113100@@@@@@
ABCABCXYZ.                    113100@@@@@@


Output should be

Code:

XYZXYZXYZ.                    11300012345.30
XYZXYZXYZ.                    113100.                       12345.30                     
XYZXYZXYZ.                    113200.                                            12345.30
ABCABCXYZ.                   11300012345.30
ABCABCXYZ.                    11300012345.30
ABCABCXYZ.                    113100                       12345.30
ABCABCXYZ.                    113100                       12345.30

[/code]
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Aug 18, 2011 1:08 am
Reply with quote

Hima1985 wrote:
3) 36th byte to 45th byte packed decimal amount value
I need to copy packed decimal value to 46th position and if key value 1132 I need to copy packed decimal value to 55th position, depending on key value I need to copy the packed decimal value after converting it to decimal


Hima 1985,

36-45 byte packed decimal field is 10 bytes. A readable format of that require at least 22 bytes ( 20 bytes of numeric 1 byte sign and 1 byte decimal point ). How are you planning to accommodate 22 bytes in 10 bytes?
Back to top
View user's profile Send private message
Hima1985

New User


Joined: 17 Apr 2009
Posts: 70
Location: India

PostPosted: Thu Aug 18, 2011 1:25 am
Reply with quote

Kolusu,

Thank You for the reply, its 10bytes PD means needs 22 bytes decimal. I was wrong in post, please provide me solution for this
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Aug 18, 2011 2:30 am
Reply with quote

Hima1985,

Use the following control cards.

Code:

//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                 
  OUTREC IFTHEN=(WHEN=(31,4,CH,EQ,C'1130'),                         
  OVERLAY=(36:36,10,PD,EDIT=(STTTTTTTTTTTTTTTTTTT.TT),SIGNS=(+,-))),
  IFTHEN=(WHEN=(31,4,CH,EQ,C'1131'),                               
  OVERLAY=(46:36,10,PD,EDIT=(STTTTTTTTTTTTTTTTTTT.TT),SIGNS=(+,-))),
  IFTHEN=(WHEN=(31,4,CH,EQ,C'1132'),                               
  OVERLAY=(55:36,10,PD,EDIT=(STTTTTTTTTTTTTTTTTTT.TT),SIGNS=(+,-)))
 
//*
Back to top
View user's profile Send private message
Hima1985

New User


Joined: 17 Apr 2009
Posts: 70
Location: India

PostPosted: Thu Aug 18, 2011 5:45 pm
Reply with quote

Kokusu,

Thank you, it worked. But one small problem ifthen. 1131 and 1132 its converting packed decimal to decimal and placing the value in 46th position and 55th position but, the packed decimal value at 35th position is remaining same there in output record.

I am getting output like this

Code:

XYZXYZXYZ.                    11300012345.30
XYZXYZXYZ.                    113100@@@@@.      12345.30                     
XYZXYZXYZ.                    113200.@@@@@                                            12345.30
ABCABCXYZ.                   11300012345.30
ABCABCXYZ.                    11300012345.30
ABCABCXYZ.                    113100@@@@@       12345.30
ABCABCXYZ.                    113100 @@@@@       12345.30      


I should not have packed decimal values in output.please sugget[/code]
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 18, 2011 8:16 pm
Reply with quote

you can solve the problem of 36 not being spaced out for 1131 and 1132
by this:
Code:

IFTHEN=(WHEN=(31,4,CH,EQ,C'1131'),
OVERLAY=(46:36,10,PD,EDIT=(STTTTTTTTTTTTTTTTTTT.TT),SIGNS=(+,-),
         36:10X)),
IFTHEN=(WHEN=(31,4,CH,EQ,C'1132'),
OVERLAY=(55:36,10,PD,EDIT=(STTTTTTTTTTTTTTTTTTT.TT),SIGNS=(+,-),
         36:10X))


but there is no way your output is as you show it.
Kolusu's edit mask does not suppress leading zeros,
and your first ABCABCXYZ, the 1130 is left shifted one char.

learn to use the preview button.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Aug 18, 2011 10:11 pm
Reply with quote

Hima1985,

It is Kolusu and NOT Kokusu. The least you can do is spell the names of the people trying to help you.

You haven't explained that you need to space out the original PD field at 36. As DBZ mentioned you can use 36:10x after the edit mask.
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top