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

Converting unpacked fields to pack using SORT.


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
chillmo

New User


Joined: 31 Aug 2017
Posts: 39
Location: USA

PostPosted: Sun Sep 12, 2021 5:50 am
Reply with quote

I have a requirement to convert an unpacked file to packed (sounds simple enough); however, there are three fields that I must interrogate the signage to produced the desired results.....this is where I'm running into issues. So, if there is a negative sign ('-') in positions 65, 73, and 85, I need to multiply the next field by -1 and convert it to a packed number. Only the first field has been, w/negative sign, has the correct value....the subsequent fields are all positive.

Code:

 IFTHEN=(WHEN=(65,1,CH,EQ,C'-'),                         
 BUILD=(1:1,25,                                         
       26:26,3,ZD,TO=PD,LENGTH=2,                       
       28:29,10,                                       
       38:39,10,                                       
       48:49,3,ZD,TO=PD,LENGTH=2,                       
       50:52,8,                                         
       58:60,5,ZD,TO=PD,LENGTH=3,                       
       61:66,7,ZD,MUL,-1,TO=PDC,LENGTH=4,               
       65:74,11,ZD,TO=PDC,LENGTH=6,                     
       71:86,11,ZD,TO=PDC,LENGTH=6,                     
       77:97,35,                                       
      112:132,1,                                       
      113:133,35,                                       
      148:168,33),HIT=NEXT),                           
IFTHEN=(WHEN=(73,1,CH,EQ,C'-'),                         
 OVERLAY=(65:74,11,ZD,MUL,-1,TO=PDC,LENGTH=6),HIT=NEXT),
IFTHEN=(WHEN=(85,1,CH,EQ,C'-'),                         
 OVERLAY=(71:86,11,ZD,MUL,-1,TO=PDC,LENGTH=6))         


Here's my input file:

Code:

99999-1234567-11111111100-22222222200MO
99999-1234567+22222222234-33333333300MO
99999-1234567-55555555500+44444444422MO
99999+1119999-13344441100+99999999900MO
99999+1234567+11111111100+22222222200MO
99999-1234567+44554545400-22222666200MO



Any assistance would be greatly appreciated!
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2142
Location: USA

PostPosted: Sun Sep 12, 2021 6:49 pm
Reply with quote

Use format SFF instead of ZD, because your input is not ZD.
Then, you don’t need to multiply by -1, or whatever else.

The rule:
Simple task needs to be done in a simple way!
Back to top
View user's profile Send private message
chillmo

New User


Joined: 31 Aug 2017
Posts: 39
Location: USA

PostPosted: Sun Sep 12, 2021 10:42 pm
Reply with quote

Sergeyken,

Thanks for the prompt response. It worked as I was overthinking this.

You're the best!
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2142
Location: USA

PostPosted: Mon Sep 13, 2021 5:45 pm
Reply with quote

I recommend you not to use hundreds of IF-s and MUL-s where it is not needed.
Format SFF is supposed to do all your job for you.

BTW: your input sample is not related anyhow to your conversion code sample. There are no input fields in your sample with offsets like 60, 66, 74, 86, 97, 132, 133, 168.
Back to top
View user's profile Send private message
chillmo

New User


Joined: 31 Aug 2017
Posts: 39
Location: USA

PostPosted: Mon Sep 13, 2021 8:36 pm
Reply with quote

Yes, sorry for the confusion....I copied my input field staring at position 60 (as these were the fields I was concerned with). Yes, SFF was all I needed and it works perfectly.

I'm a COBOL mainframe by trade, so I thought I had to interrogate the negative signs ("-"), but SFF handle that.

Thanks again!
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 -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Help with SORT - I need to validate d... DFSORT/ICETOOL 1
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts Is this possible via sort (in one pass)? SYNCSORT 4
No new posts GDG generation name to GDG Base name ... DFSORT/ICETOOL 3
No new posts SORT on detail record, then repeat he... DFSORT/ICETOOL 3
Search our Forums:

Back to Top