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

copying file contents with comp-3 field


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

New User


Joined: 15 Feb 2006
Posts: 32

PostPosted: Mon Apr 17, 2006 9:47 pm
Reply with quote

Hi
I have a problem with a sort. I have a input file (Recl=113 and Rec format = FB ) with a S9(05) comp-3 field (position 11-13) in it.
---------------
input file:
11-13 .......
36222
0
45154
*****
34214
---------------

I need to copy the file contents to a output file with 20000 added to the comp-3 fields ( in position 11-13 ) which don't have zero or low values. When i used the sort card,
i got the following output:
---------------
output file:
11-13 .......
56222
0
65154
60404
54214
---------------

It took the value of "*****" or spaces as "40404" and added 20000 to it. I need the output to be like this:
--------------
output file:
11-13 ........
56222
0
65154
*****
54214
--------------

Kindly help me in this.

Thanks
TG
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Apr 17, 2006 10:40 pm
Reply with quote

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=(11,3,PD,NE,+0,AND,11,3,CH,NE,C' '),
         OVERLAY=(11:11,3,PD,ADD,+20000,TO=PD,LENGTH=3))
/*
Back to top
View user's profile Send private message
tusharguptait

New User


Joined: 15 Feb 2006
Posts: 32

PostPosted: Wed Apr 19, 2006 12:10 am
Reply with quote

Thanks Frank. Does this sort will also deal with low values. That is when the comp-3 field in input file is x'000000' , will 20000 will be added to it? I need not add it to low values.

Thanks
TG
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Apr 19, 2006 1:08 am
Reply with quote

When you said
Quote:
which don't have zero or low values
I took "zero" to mean PD'0' (X'00000C') and that's what I coded for. If you want to code for binary zeros (X'000000') instead of PD'0', just use 11,3,BI,NE,X'000000' as follows:

Code:

  INREC IFTHEN=(WHEN=(11,3,BI,NE,X'000000',AND,11,3,CH,NE,C' '),
         OVERLAY=(11:11,3,PD,ADD,+20000,TO=PD,LENGTH=3))
Back to top
View user's profile Send private message
tusharguptait

New User


Joined: 15 Feb 2006
Posts: 32

PostPosted: Wed Apr 19, 2006 1:14 pm
Reply with quote

Thanks again Frank. What I had meant was to add the value to fields which don't have zeros, spaces and low values.

I have one question regarding the addition. In the addition process, only digit "2" is having a impact . The addition of rest of the digits of "20000" that is "00000" is useless. Is it possible to add only "2" to the leftmost digit in packed decimal format.

Thanks
TG
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Apr 19, 2006 8:51 pm
Reply with quote

Quote:
What I had meant was to add the value to fields which don't have zeros, spaces and low values.


zeros as in PD zeros (P'0')? low values as in binary zeros? Did you figure out how to do this based on what I've said previously or do you need me to show you how to do it?

Quote:
I have one question regarding the addition. In the addition process, only digit "2" is having a impact . The addition of rest of the digits of "20000" that is "00000" is useless. Is it possible to add only "2" to the leftmost digit in packed decimal format.


That doesn't make any sense. The addition looks like this:

|12|34|5C|
|20|00|0C|
-------------
|32|34|5C|

These are 3-byte PD values with the sign in the last nibble, so you can add them as PD values. You're asking if you can add just the first nibble - the answer is no because that doesn't represent any valid type of numeric format. But why do you want to do that? What benefit do you think there would be in adding only "2' to the leftmost nibble instead of adding 20000 to the 3-byte PD value?
Back to top
View user's profile Send private message
tusharguptait

New User


Joined: 15 Feb 2006
Posts: 32

PostPosted: Thu Apr 20, 2006 9:38 am
Reply with quote

Quote:
zeros as in PD zeros (P'0')? low values as in binary zeros? Did you figure out how to do this based on what I've said previously or do you need me to show you how to do it??


Frank,
With the help of your input I have figured out the logic to do this. But it seems that I don't have to version of Dfsort to run the sort given by you. When I run the sort I am getting "INVALID INREC OR OUTREC STATEMENT OPERAND" for IFTHEN.And "STATEMENT DEFINER ERROR" for overlay.
ICE000I Message is giving dfsort version as DFSORT REL 14.0.

Quote:

|12|34|5C|
|20|00|0C|
-------------
|32|34|5C|

These are 3-byte PD values with the sign in the last nibble, so you can add them as PD values. You're asking if you can add just the first nibble - the answer is no because that doesn't represent any valid type of numeric format. But why do you want to do that? What benefit do you think there would be in adding only "2' to the leftmost nibble instead of adding 20000 to the 3-byte PD value?


I asked the question because I came to know that I need add "20000" only to comp-3 fields which have values starting with "4" and "3". That is if the field is like "4----c" or "3----c" I should add 20000 to it. The "----" be any value between 0-9 for each digit. In short, apart from zeros,binary zeros and spaces all the values other than "4" or "3" in their first nibble are invalid for addition process.
With the earlier logic I was suggesting I will need back to convert all those comp-3 fields which don't have "6" or "5" ( output file after adding "20000") in their first nibble back to their orginal values .

I am not sure what can be done for this.

Thanks
TG
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Apr 20, 2006 8:48 pm
Reply with quote

TG,

You need DFSORT R14 PTF UQ95213 to use IFTHEN and OVERLAY. This PTF has been available since Dec, 2004. Ask your System Programmer to install it.

If you just want to add 20000 for values that have X'4----C' or X'3----C',
you can use this control statement (of course, you'll need the Dec, 2004 PTF):

Code:

  INREC IFTHEN=(WHEN=(11,3,BI,EQ,B'0100................1100',OR,
          11,3,BI,EQ,B'0011................1100'),             
         OVERLAY=(11:11,3,PD,ADD,+20000,TO=PD,LENGTH=3))       
Back to top
View user's profile Send private message
tusharguptait

New User


Joined: 15 Feb 2006
Posts: 32

PostPosted: Fri Apr 21, 2006 5:33 pm
Reply with quote

Thanks a lot Frank for your help.

Regards
TG
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

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top