Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
Hima1985

New User

Joined: 17 Apr 2009
Posts: 70
Location: India

Posted: Thu Aug 18, 2011 12:34 am    Post subject: comvert packed decimal to decimal using sort

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]

Skolusu

Senior Member

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

Posted: Thu Aug 18, 2011 1:08 am    Post subject: Reply to: comvert packed decimal to decimal using sort

 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?
Hima1985

New User

Joined: 17 Apr 2009
Posts: 70
Location: India

 Posted: Thu Aug 18, 2011 1:25 am    Post subject: 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
Skolusu

Senior Member

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

Posted: Thu Aug 18, 2011 2:30 am    Post subject: Reply to: comvert packed decimal to decimal using sort

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=(+,-)))   //*
Hima1985

New User

Joined: 17 Apr 2009
Posts: 70
Location: India

Posted: Thu Aug 18, 2011 5:45 pm    Post subject:

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]
dbzTHEdinosauer

Global Moderator

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

Posted: Thu Aug 18, 2011 8:16 pm    Post subject:

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.
and your first ABCABCXYZ, the 1130 is left shifted one char.

learn to use the preview button.
Skolusu

Senior Member

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

 Posted: Thu Aug 18, 2011 10:11 pm    Post subject: 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.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics SORT BUT RETAIN HIGHEST VALUE ON NON-... leondan22 DFSORT/ICETOOL 2 Thu Dec 14, 2017 8:13 pm Extract record for change in combinat... Trinadh DFSORT/ICETOOL 6 Thu Nov 23, 2017 3:32 pm JOINKEYS Paired and Unpaired Sort on ... MFwhiz DFSORT/ICETOOL 7 Tue Nov 07, 2017 2:46 am Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us