|
View previous topic :: View next topic
|
| Author |
Message |
Hima1985
New User
Joined: 17 Apr 2009 Posts: 70 Location: India
|
|
|
|
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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| 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 |
|
 |
Hima1985
New User
Joined: 17 Apr 2009 Posts: 70 Location: India
|
|
|
|
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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
Hima1985
New User
Joined: 17 Apr 2009 Posts: 70 Location: India
|
|
|
|
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 |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
|
|
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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|