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
 

 

convert to packed decimal based on condition
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 45
Location: pune

PostPosted: Mon Aug 09, 2010 7:16 pm    Post subject: convert to packed decimal based on condition
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: 45
Location: pune

PostPosted: Mon Aug 09, 2010 7:19 pm    Post subject:
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: 578
Location: USA

PostPosted: Mon Aug 09, 2010 7:30 pm    Post subject:
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: 45
Location: pune

PostPosted: Mon Aug 09, 2010 7:42 pm    Post subject:
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: 45
Location: pune

PostPosted: Mon Aug 09, 2010 7:46 pm    Post subject:
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: 45
Location: pune

PostPosted: Mon Aug 09, 2010 7:46 pm    Post subject:
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: 45
Location: pune

PostPosted: Mon Aug 09, 2010 7:47 pm    Post subject:
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: 578
Location: USA

PostPosted: Mon Aug 09, 2010 8:42 pm    Post subject:
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: 45
Location: pune

PostPosted: Tue Aug 10, 2010 11:03 am    Post subject:
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: 45
Location: pune

PostPosted: Tue Aug 10, 2010 11:53 am    Post subject:
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    Post subject:
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: 578
Location: USA

PostPosted: Tue Aug 10, 2010 3:52 pm    Post subject:
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: 45
Location: pune

PostPosted: Tue Aug 10, 2010 4:22 pm    Post subject:
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: 45
Location: pune

PostPosted: Tue Aug 10, 2010 6:12 pm    Post subject:
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    Post subject:
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: 45
Location: pune

PostPosted: Tue Aug 10, 2010 7:31 pm    Post subject:
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: 578
Location: USA

PostPosted: Tue Aug 10, 2010 7:46 pm    Post subject:
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: 578
Location: USA

PostPosted: Tue Aug 10, 2010 7:48 pm    Post subject:
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: 45
Location: pune

PostPosted: Tue Aug 10, 2010 7:55 pm    Post subject:
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: 578
Location: USA

PostPosted: Tue Aug 10, 2010 8:14 pm    Post subject:
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
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
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm


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