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

How can I add fields on particular condition?


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

New User


Joined: 30 Nov 2007
Posts: 15
Location: India

PostPosted: Thu Sep 18, 2008 9:57 am
Reply with quote

Hi all,

My input file is FB, Lrec=20

Code:

2222  I      500.00
2222  D      200.00
2222  I      300.00
3333  I      500.00
3333  D      200.00
3333  R      300.00
2222  I      500.00
4444  D      200.00
3333  I      300.00


My output should come as:

Code:

2222  I      1100.00
3333  I      0600.00
3333  R      0300.00
4444  D      0200.00-


Starting 4 bytes is the key. If 7th byte is 'I', we need to add. If it is 'D' we need to subtract. If 'R' We need to left record as it is. In output file it doesn't matter whether we are showing 'I' or 'D'. But it should show 'R' correctly.
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 Sep 18, 2008 8:45 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 (FB/20)
//SORTOUT DD DSN=...  output file (FB/21)
//SYSIN    DD    *
   INREC IFTHEN=(WHEN=INIT,OVERLAY=(22:14,6)),
         IFTHEN=(WHEN=(7,1,CH,EQ,C'D'),OVERLAY=(7:C'I',21:C'-'))
   SORT FIELDS=(1,7,CH,A,7,1,CH,A)
   OUTFIL REMOVECC,NODETAIL,
     BUILD=(1,21),
     SECTIONS=(1,7,
       TRAILER3=(1,7,14:TOT=(21,7,SFF,EDIT=(TTTT.TTS),SIGNS=(,,,-))))
/*


For your input example, SORTOUT will have:

Code:

2222  I      1100.00         
3333  I      0600.00         
3333  R      0300.00         
4444  I      0200.00-       


Quote:
In output file it doesn't matter whether we are showing 'I' or 'D'. But it should show 'R' correctly.


'I' or 'R' will be shown as appropriate.
Back to top
View user's profile Send private message
karthikr44

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Fri Sep 19, 2008 3:31 pm
Reply with quote

HI,

I had executed your code.

Quote:

If 'R' We need to left record as it is.


But for R case also, it add the records.

Input:
Code:

2222  I      500.00     
2222  D      200.00     
2222  I      300.00     
3333  I      500.00     
3333  D      200.00     
3333  R      300.00     
3333  R      500.00     


Output:
Code:

2222  I      0600.00 
3333  I      0300.00 
3333  R      0800.00 


Kindly suggest any way to avoid this scenario.

Regards
R KARTHIK
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: Fri Sep 19, 2008 9:16 pm
Reply with quote

Karthik,

I didn't realize you could have more than 1 R record for a given key (you didn't show that in your example), so I didn't code for it. Here's a new version of the DFSORT job that will take care of that:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/20)
//SORTOUT DD DSN=...  output file (FB/21)
//SYSIN    DD    *
   INREC IFTHEN=(WHEN=INIT,
     OVERLAY=(22:14,6,28:1,5,33:SEQNUM,8,ZD)),
    IFTHEN=(WHEN=(7,1,CH,EQ,C'D'),
      OVERLAY=(7:C'I',21:C'-',33:8C'0')),
    IFTHEN=(WHEN=(7,1,CH,EQ,C'I'),OVERLAY=(33:8C'0'))
   SORT FIELDS=(28,13,CH,A)
   OUTFIL REMOVECC,NODETAIL,
     BUILD=(1,21),
     SECTIONS=(28,13,
       TRAILER3=(1,7,14:TOT=(21,7,SFF,EDIT=(TTTT.TTS),SIGNS=(,,,-))))
/*
Back to top
View user's profile Send private message
vivekkodan

New User


Joined: 18 Sep 2008
Posts: 3
Location: India

PostPosted: Tue Sep 23, 2008 12:22 pm
Reply with quote

how does "SIGNS" work here? plz calrify
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: Tue Sep 23, 2008 8:39 pm
Reply with quote

SIGNS(a,b,c,d)

a is the leading positive sign.
b is the trailing positive sign.
c is the leading negative sign.
d is the trailing negative sign.

EDIT=(TTTT.TTS) has a trailing sign (S), so a and b are not relevant.

SIGNS(,,,-)

Specifies the trailing positive sign (c) is a blank and the trailing negative sign (d) is a minus sign.
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 Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts How to give complex condition in JCL . CLIST & REXX 30
No new posts selectively copy based on condition DFSORT/ICETOOL 3
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
No new posts Converting unpacked fields to pack us... SYNCSORT 4
Search our Forums:

Back to Top