Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How can I add fields on particular condition?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: How can I add fields on particular condition?
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 Moderator


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

PostPosted: Thu Sep 18, 2008 8:45 pm    Post subject:
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    Post subject: Reply to: How can I add fields on particular condition?
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 Moderator


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

PostPosted: Fri Sep 19, 2008 9:16 pm    Post subject:
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    Post subject: Reply to: How can I add fields on particular condition?
Reply with quote

how does "SIGNS" work here? plz calrify
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Tue Sep 23, 2008 8:39 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Need help on If condition continuatio... ashok_uddaraju CLIST & REXX 4 Fri May 19, 2017 8:55 am
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Sum Fields ballaswaroop DFSORT/ICETOOL 4 Tue May 02, 2017 11:07 am
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts Joinkeys with condition scdinesh DFSORT/ICETOOL 10 Tue Feb 14, 2017 12:20 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us