|
View previous topic :: View next topic
|
| Author |
Message |
chillmo
New User
Joined: 31 Aug 2017 Posts: 54 Location: USA
|
|
|
|
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 |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2288 Location: USA
|
|
|
|
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 |
|
 |
chillmo
New User
Joined: 31 Aug 2017 Posts: 54 Location: USA
|
|
|
|
Sergeyken,
Thanks for the prompt response. It worked as I was overthinking this.
You're the best! |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2288 Location: USA
|
|
|
|
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 |
|
 |
chillmo
New User
Joined: 31 Aug 2017 Posts: 54 Location: USA
|
|
|
|
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|