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

convert to packed decimal based on condition


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

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Mon Aug 09, 2010 7:16 pm
Reply with quote

Hi Experts,
I have the below proble,
I have a fixed lenght file with different record type.
the first two characers would determine the record type
01 header
02 data
03 different data



09 trailer

now some of the records for eg 02 04 06 may have one decimal fields(15,2)
but in different locations eg 10,20 30.
now based on this first two charecters i need to change the decimal to packed decimal. based on this record type
for ex rec type 01 09 08 needs nothign to be done.
if record type is 02 then decial field starting from position 10 needs to be converted to packed decimal,
if record type is 04 then starting from 20 needs to be converted
Back to top
View user's profile Send private message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Mon Aug 09, 2010 7:19 pm
Reply with quote

the file is a fb with LRECL 54
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Mon Aug 09, 2010 7:30 pm
Reply with quote

pema_yozer,
Quote:
now some of the records for eg 02 04 06 may have one decimal fields(15,2)

What are all the record types and their respective decimal field position mapping? What about record type 03,05,07?

Quote:
now based on this first two charecters i need to change the decimal to packed decimal.

Do you want to overlay decimal with PD? I ask this because your PD Fields will be less in length than your decimal field? Do you want conversion with the same field length?

If possible, show your input with all the conditions covered and expected output.

Thanks,
Back to top
View user's profile Send private message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Mon Aug 09, 2010 7:42 pm
Reply with quote

below is my input data
016UKBADITM003 20100809
02008540003786200808180101ABCDEFGHIKJLMNON
03008540003786201004300000000000645.00
0401096001049920071031000000000100000008001
0500854000378620090305000000000102.000
0601095039440820090221035030000000000000.0000000000000000
070109605376162001020200000000070000000001000.00
99000000813782735000000064120100809


In the output every thing should be as it is except the red coloured ones.
the red coloured ones should be converted to
S9(13)v99 COMP-3 (packed decimal)
Back to top
View user's profile Send private message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Mon Aug 09, 2010 7:46 pm
Reply with quote

think can be converted to PD with the below code,
But can i do the convertion based on the codes ie i want teh convertion for only 03,05,06,07
Back to top
View user's profile Send private message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Mon Aug 09, 2010 7:46 pm
Reply with quote

SORT FIELDS=COPY
OUTREC BUILD=(1,15,UFF,MUL,+100,TO=PD,LENGTH=13)
Back to top
View user's profile Send private message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Mon Aug 09, 2010 7:47 pm
Reply with quote

it wouldn't bother me if the lengthof the pd is less
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Mon Aug 09, 2010 8:42 pm
Reply with quote

pema_yozer,

Use below. You can conditionally check for first 2 bytes using IFTHEN and build or overlay fields at specified position.


Code:

//SORT01   EXEC PGM=SORT                                     
//SORTIN   DD  DISP=SHR,DSN=YOUR.FB.LRECL54                   
//SORTOUT  DD  DSN=YOUR.FB.LRECL54.CNVT,                     
//             DISP=(,CATLG,DELETE),                         
//             UNIT=SYSDA                                     
//SYSIN DD *                                                 
 INREC IFTHEN=(WHEN=(01,02,CH,EQ,C'03'),                     
       OVERLAY=(23:23,16,UFF,TO=PD,LENGTH=16)),               
       IFTHEN=(WHEN=(01,02,CH,EQ,C'05'),                     
       OVERLAY=(32:32,07,UFF,TO=PD,LENGTH=07)),               
       IFTHEN=(WHEN=(01,02,CH,EQ,C'06'),                     
       OVERLAY=(28:28,16,UFF,TO=PD,LENGTH=16)),               
       IFTHEN=(WHEN=(01,02,CH,EQ,C'07'),                     
       OVERLAY=(33:33,16,UFF,TO=PD,LENGTH=16))               
 SORT FIELDS=COPY                                             
/*                                                           
//SYSOUT DD SYSOUT=*                                         
//*                                                           


Thanks,
Back to top
View user's profile Send private message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Tue Aug 10, 2010 11:03 am
Reply with quote

Thanks...
It works like a charm icon_biggrin.gif
Back to top
View user's profile Send private message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Tue Aug 10, 2010 11:53 am
Reply with quote

just one more question just out of curiosity,
if the above file was VB LRECL 80, would this still be possible.
if yes wat chnages would be needed in the above code.
Back to top
View user's profile Send private message
smijoss

Active User


Joined: 30 Aug 2007
Posts: 114
Location: pune

PostPosted: Tue Aug 10, 2010 12:37 pm
Reply with quote

yes .. just increment all the positions by 4
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Tue Aug 10, 2010 3:52 pm
Reply with quote

pema_yozer,
yes it works for VB of 80 bytes. For VB first 4 bytes are RDW and your data starts at position 5.

Please let me know if you still need JCL for that.

Thanks,
Back to top
View user's profile Send private message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Tue Aug 10, 2010 4:22 pm
Reply with quote

one thing i'm getting is that the packed fields record packed field is 15 bytes so S9(27)v99 comp-3 for record type 03,06 and 07 are
ut what is required is s9(15)v99 comp-3
Back to top
View user's profile Send private message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Tue Aug 10, 2010 6:12 pm
Reply with quote

it should be s9(13)v99 comp-3, i think i have got it
OVERLAY=(23:23,16,SFF,TO=PD,LENGTH=08,X8)),
is working but for record type 6
0601095039440820090221035030000000000000.0000000000000000
as it is in the middle i get 8 spaces , how can this be avoided
Back to top
View user's profile Send private message
smijoss

Active User


Joined: 30 Aug 2007
Posts: 114
Location: pune

PostPosted: Tue Aug 10, 2010 6:32 pm
Reply with quote

OVERLAY is used to "OVERLAY" the exisitng data

since your length will change dont use overlay use build

BUILD=(1,4,5,22,23,16,SFF,TO=PD,LENGTH=08,39)
Back to top
View user's profile Send private message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Tue Aug 10, 2010 7:31 pm
Reply with quote

save me a syntax error

ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R10 - 14:57 ON TUE A
INREC IFTHEN=(WHEN=(01,02,CH,EQ,C'03'),
OVERLAY=(23:23,16,SFF,TO=PD,LENGTH=08,8X)),
IFTHEN=(WHEN=(01,02,CH,EQ,C'05'),
OVERLAY=(33:33,06,SFF,TO=PD,LENGTH=03,3X)),
IFTHEN=(WHEN=(01,02,CH,EQ,C'06'),
BUILD=(1,4,5,22,23,16,SFF,TO=PD,LENGTH=08,39),
IFTHEN=(WHEN=(01,02,CH,EQ,C'07'),
£
ICE006A 0 OPERAND DEFINER ERROR
OVERLAY=(33:33,16,SFF,TO=PD,LENGTH=08,8X))
£
ICE005A 0 BLANK NEEDED IN COLUMN 1 OR OPERATION NOT DEFINED CORRECTLY
SORT FIELDS=COPY
ICE751I 0 C5-K48846 C6-K90014 C7-K45047 C8-K46331 E7-K48846
ICE052I 3 END OF DFSORT
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Tue Aug 10, 2010 7:46 pm
Reply with quote

pema_yozer,
It will be really helpful to understand if you could you please ask all your question in single post.
Quote:
one thing i'm getting is that the packed fields record packed field is 15 bytes so S9(27)v99 comp-3 for record type 03,06 and 07 are
ut what is required is s9(15)v99 comp-3
I could hardly understand anything from above.
Quote:

it should be s9(13)v99 comp-3, i think i have got it
OVERLAY=(23:23,16,SFF,TO=PD,LENGTH=08,X8)),
is working but for record type 6
0601095039440820090221035030000000000000.0000000000000000

What is X8, did you mean to add 8 space char. following packed decimal field? Why couldn't you just use LENGTH=16?

smijoss,
Quote:
since your length will change dont use overlay use build

I don't think his length is changing or he ever requested change in the length.

Thanks,
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Tue Aug 10, 2010 7:48 pm
Reply with quote

pema_yozer,
If this is the card you want to execute, start your dfsort statement from 2nd column.

Thanks,
Back to top
View user's profile Send private message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Tue Aug 10, 2010 7:55 pm
Reply with quote

hi sqlcode,
wanted a 8 byte code but your code gave me a 16 byte,so i made it 8 byte and gave 8 blanks in the end.
This was fine for all other record type as the decimal was the last field followed by blank spaces.
How ever for record type 06 this didnt work as it gave blanks in between the records as the decimal was in b/w the recrd so was looking for a build code for it.
got one but it is giving a syntax error.
new to df sort and sorry for the confusion

Need to run the below code on the input record.
the red part must be converted to PD 8 byte and should be followed by remaining data immediately

0601095039440820090221035030000000000000.0000000000000000

BUILD=(1,4,5,22,23,16,SFF,TO=PD,LENGTH=08,39)
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Tue Aug 10, 2010 8:14 pm
Reply with quote

pema_yozer,

You can still use OVERLAY, no need to use BUILD.

Code:
//SORT01   EXEC PGM=SORT                                             
//SORTIN   DD  DISP=SHR,DSN=YOURID..FB.LRECL54                       
//SORTOUT  DD  DSN=YOURID.FB.LRECL54.CNVT,                           
//             DISP=(,CATLG,DELETE),                                 
//             UNIT=SYSDA                                             
//SYSIN DD *                                                         
 INREC IFTHEN=(WHEN=(01,02,CH,EQ,C'03'),                             
        OVERLAY=(23:23,16,UFF,TO=PD,LENGTH=08,8X)),                   
        IFTHEN=(WHEN=(01,02,CH,EQ,C'05'),                             
        OVERLAY=(32:32,07,UFF,TO=PD,LENGTH=03,4X)),                   
        IFTHEN=(WHEN=(01,02,CH,EQ,C'06'),                             
        OVERLAY=(28:28,16,UFF,TO=PD,LENGTH=08,8X)),                   
        IFTHEN=(WHEN=(01,02,CH,EQ,C'07'),                             
        OVERLAY=(33:33,16,UFF,TO=PD,LENGTH=08,8X))                   
  SORT FIELDS=COPY                                                   
/*                                                                   
//SYSOUT DD SYSOUT=*                                                 
//*                                                                   



OUTPUT
Code:

016UKBADITM003 20100809                                 
02008540003786200808180101ABCDEFGHIKJLMNON             
0300854000378620100430.....À&.                         
0401096001049920071031000000000100000008001             
0500854000378620090305000000000...   0                 
060109503944082009022103503........        00000000000 
000                                                     
07010960537616200102020000000007........               
99000000813782735000000064120100809                     


Thanks,
Back to top
View user's profile Send private message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Tue Aug 10, 2010 8:23 pm
Reply with quote

sqlcode1,
i have done the same thing and etting output as

[/code]
060109600104992010010703505 - 0000000000000

but for rec 6 i woul dwant output as

060109600104992010010703505 - 0000000000000
Code:
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Tue Aug 10, 2010 8:29 pm
Reply with quote

pema_yozer,

I don't see any difference in the 2 output you have posted.

Thanks,
Back to top
View user's profile Send private message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Tue Aug 10, 2010 8:34 pm
Reply with quote

the spaces are getting filled when i submit the post
060109600104992010010703505packeddecimalspaces0000000000000
060109600104992010010703505packeddecimal0000000000000
packed decimal = 8 byte packed decimal and the
spaces = 8 spaces
but i would require it as the second one


hope this makes sense
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Tue Aug 10, 2010 9:02 pm
Reply with quote

I hate to keep this post going but are you still using FB? You had mentioned your question relating to VB was out of curiosity.

Please tell us if you are using VB or FB file. Reason I am asking is you are overlaying some of the fields (following your conversion) for record type 06 or may be I am missing some basic information.


Thanks,
Back to top
View user's profile Send private message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Tue Aug 10, 2010 9:26 pm
Reply with quote

i'm using FB.
and want the PD to be 8 bytes
i had used over lay to get the format
060109600104992010010703505packeddecimalspaces0000000000000
but this is incorrect due to the space and would require
060109600104992010010703505packeddecimal0000000000000

i think build should be used for this.
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 Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
No new posts Def PD not working for unsigned packe... JCL & VSAM 3
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
Search our Forums:

Back to Top