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

Editing COMP-3 data using SORT


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

New User


Joined: 02 Sep 2010
Posts: 50
Location: Pune

PostPosted: Fri Nov 15, 2013 2:34 pm
Reply with quote

Hi,
I need to edit the price in the input dataset based on product code and payment type
Product code - starting position 30 and length is 5 (Ex: 00003)
Payment type - starting position 49 and length is 3 (Ex: ADD)
Price - Starting position 43 - S9(9)V99 COMP-3

Input dataset:
Code:

----+----1----+----2----+----3----+----4----+----5-
001000000000000000123456789AB0000220131107      ADD
001000000000000000123456789AB0000220131107      ADD
001000000000000000123456789AB0000320131107      ADD
001000000000000000123456789AB0000320131107      ADD
001000000000000000123456789AB0000320131107      NEW
001000000000000000123456789AB0000320131107   &  NEW
001000000000000000123456789AB0000320131105     %NEW


Req:
1. If product code is not '00003' then copy the all the fields to output dataset with payment as blank
2. If product code is '00003'
- If Payment type is NEW then copy all the fields to output dataset with payment as blank
- If Payment type is ADD then copy all the fields to output dataset with price as ZERO and payment type as blank

JCL Code:
Code:

//SYSIN    DD *                                                 
 SORT FIELDS=COPY                                               
 INREC IFTHEN=(WHEN=(30,5,CH,NE,C'00003'),OVERLAY=(49:C'   ')),
       IFTHEN=(WHEN=(30,5,CH,EQ,C'00003'),OVERLAY=(30:C'00003'),
               HIT=NEXT),                                       
       IFTHEN=(WHEN=(49,3,CH,NE,C'ADD'),OVERLAY=(49:C'   '),   
               HIT=NEXT),                                       
       IFTHEN=(WHEN=(49,3,CH,EQ,C'ADD'),                       
               OVERLAY=(43:+0,TO=ZDC,LENGTH=6,49:C'   '))       
/*                                                             


Output dataset:
Code:

----+----1----+----2----+----3----+----4----+----5-
001000000000000000123456789AB0000220131107         
001000000000000000123456789AB0000220131107         
001000000000000000123456789AB000032013110700000{   
001000000000000000123456789AB000032013110700000{   
001000000000000000123456789AB0000320131107         
001000000000000000123456789AB0000320131107   &     
001000000000000000123456789AB0000320131105     %   
001000000000000000123456789AB0000320131107         


The issue here is, I am getting '00000{' instead of COMP-3 data. I want to mention ZERO price in COMP-3 format. Can you please let me know what exactly I need to mention in the OVERLAY field?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Nov 15, 2013 2:48 pm
Reply with quote

You are getting zero in packed-decimal. the curly brace is telling you that it is a positive zero at that digit. The other curly brace would tell you it is a negative zero at the same position. A-I will be positive 1-9 and J-R negative 1-9.
Back to top
View user's profile Send private message
pullaiah.cts

New User


Joined: 02 Sep 2010
Posts: 50
Location: Pune

PostPosted: Fri Nov 15, 2013 3:08 pm
Reply with quote

Hi Bill,
But when I give o/p dataset as input to my COBOL program, it is getting failed with SOC 7 error. Below is the declaration for price filed in COBOL program

Code:

10    TR00-CSTAMT PICTURE  S9(9)V99  COMPUTATIONAL-3


What's the issue with the data in the output dataset? Please clarify
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Nov 15, 2013 3:23 pm
Reply with quote

I believe you are actually specifying Zoned Decimal output not Packed Decimal output. These are the values for DISPLAY values that are negative:
Code:
0} = -0
0J = -1
0K = -2
0L = -3
0M = -4
0N = -5
0O = -6
0P = -7
0Q = -8
0R = -9
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Nov 15, 2013 3:27 pm
Reply with quote

Good spot NicC. TO=ZDC is zoned-decimal. Try TO=PD.
Back to top
View user's profile Send private message
pullaiah.cts

New User


Joined: 02 Sep 2010
Posts: 50
Location: Pune

PostPosted: Fri Nov 15, 2013 3:28 pm
Reply with quote

Yeah, you are right Nic. I have changed it to PD an everything is working fine now

Code:

OVERLAY=(43:+0,TO=PD,LENGTH=6,49:C'   '))


Thanks a lot for your response.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Nov 15, 2013 3:31 pm
Reply with quote

sometimes I do NOT muck it up icon_smile.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Nov 15, 2013 4:54 pm
Reply with quote

Code:
 SORT FIELDS=COPY                                               
 INREC IFTHEN=(WHEN=(30,5,CH,NE,C'00003'),OVERLAY=(49:C'   ')),
       IFTHEN=(WHEN=(30,5,CH,EQ,C'00003'),OVERLAY=(30:C'00003'),
               HIT=NEXT),                                       
       IFTHEN=(WHEN=(49,3,CH,NE,C'ADD'),OVERLAY=(49:C'   '),   
               HIT=NEXT),                                       
       IFTHEN=(WHEN=(49,3,CH,EQ,C'ADD'),                       
               OVERLAY=(43:+0,TO=PD,LENGTH=6,49:C'   '))       
/*


pullaiah.cts,

Are you sure the above is correct?

When 30,5 is equal to C'00003' you set 30: to C'00003', which is the value you know it already has.

What you seem to by trying to do is to set a field to zero if C'00003' and ADD. You can do that in on IFTHEN=(WHEN=(logical-expression. Put the zero and blat the ADD in the OVERLAY. Then have an IFTHEN=(WHEN=NONE to blat the field which sometimes contains ADD to space for all the other records.
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 How to split large record length file... DFSORT/ICETOOL 7
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top