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

Build record according subtraction result


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
witsche

New User


Joined: 04 May 2005
Posts: 3

PostPosted: Fri Oct 02, 2015 12:53 pm
Reply with quote

Hi all,
I have to match two datasets (FB200) and:
 - if the key is present only in the first dataset, I have to write the record in AM28.DOP0GF.TS000.CONTRADI.GFMBF manipulating data
 - if the key is present only in the second dataset, I have to write the record as is in AM28.DOP0GF.TS000.CONTRADI.GFMBF
 - if the key is present on both datasets, I have to subtract dataset2.campoA from dataset1.campoA: if the result is >= 0 I have to write a record in AM28.DOP0GF.TS000.CONTRADI.GFMBF inserting the result of subtracting in a certain position; if the result is < 0 I have to write a record in AM28.DOP0GF.TS000.CONTRADI.GFMBF inserting the subtraction result in a certain position.

This is the step that I wrote:

Code:
//P060     EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//*--- INPUT                                                           
//SORTJNF1 DD DISP=SHR,DSN=AM28.DOP0GF.TS000.CONTRADI.GFMBF.OUT20A     
//SORTJNF2 DD DISP=SHR,DSN=AM28.DOP0GF.TS000.CONTRADI.GFMBF.OUT20B     
//*--- OUTPUT                                                           
//F12      DD DSN=AM28.DOP0GF.TS000.CONTRADI.GFMBF,                     
//            DISP=MOD                                                 
//F01      DD DSN=AM28.DOP0GF.TS000.CONTRADI.GFMBF,                     
//            DISP=MOD                                                 
//F02      DD DSN=AM28.DOP0GF.TS000.CONTRADI.GFMBF,                     
//            DISP=MOD                                                 
//*                                                                     
//SYSIN    DD *                                                         
 JOINKEYS FILE=F1,FIELDS=(65,17,CH,A)                                   
 JOINKEYS FILE=F2,FIELDS=(65,17,CH,A)                                   
 JOIN UNPAIRED,F1,F2                                                   
 REFORMAT FIELDS=(F1:01,200,F2:01,200,?)                               
 SORT FIELDS=COPY                                                       
 OUTFIL   FNAMES=F01,INCLUDE=(401,1,CH,EQ,C'1'),                       
          BUILD=(1,145,164,18,C'000000000000000000',182,19)             
 OUTFIL   FNAMES=F02,INCLUDE=(401,1,CH,EQ,C'2'),                       
          BUILD=(201,200)                                               
 OUTFIL   FNAMES=F12,INCLUDE=(401,1,CH,EQ,C'B'),                       
          IFTHEN(WHEN=((164,18,ZD,SUB,364,18,ZD),GE,0),                 
                BUILD=(1,145,164,18,(164,18,ZD,SUB,364,18,ZD),         
                       C'000000000000000000',182,19)),                 
          IFTHEN(WHEN=NONE,                                             
                BUILD=(1,145,164,18,C'000000000000000000',             
                      (164,18,ZD,SUB,364,18,ZD),182,19))               
                                                                       
/*                                                                     

and I get this error:

Code:
  OUTFIL   FNAMES=F12,INCLUDE=(401,1,CH,EQ,C'B'),                               
           IFTHEN(WHEN=((164,18,ZD,SUB,364,18,ZD),GE,0),                       
                                   *                                           
                 BUILD=(1,145,164,18,(164,18,ZD,SUB,364,18,ZD),                 
                        C'000000000000000000',182,19)),                         
           IFTHEN(WHEN=NONE,                                                   
                 BUILD=(1,145,164,18,C'000000000000000000',                     
                       (164,18,ZD,SUB,364,18,ZD),182,19))                       
                                                                               
 WER813I  INSTALLATION OPTIONS IN MFX LOAD LIBRARY WILL BE USED                 
 WER903I  SYNCSORT 2.1.0.0 IS NOT LICENSED FOR SERIAL 31BE7, TYPE 2964 718, LPAR
 WER903I  PRODUCT WILL STOP WORKING IN  44 DAYS UNLESS A VALID KEY IS INSTALLED.
 WER251A  INCLUDE/OMIT INVALID COND                                             
 WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                                 
 WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                                 

is there a syntax error or, with the sort, I can not do what previously described?

the output dataset was previously allocated.

thank you
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 Oct 02, 2015 3:26 pm
Reply with quote

Quote:
is there a syntax error or, with the sort, I can not do what previously described?


Well, both. Because you cannot do that in the manner you are attempting, you obviously are creating a syntax error when you attempt to do so. You can't have an expression in a condition.

You have to do the calculation before the test, storing the result in an extension to the record, and then use that field in the condition. Use IFTHEN=(WHEN=INIT for this.

You have to ensure that the extension does not persist on your output. Since you already have BUILD to get the data from the REFORMAT record, that should not be a problem, you won't need to do anything extra.
Back to top
View user's profile Send private message
witsche

New User


Joined: 04 May 2005
Posts: 3

PostPosted: Fri Oct 02, 2015 6:41 pm
Reply with quote

in effect, to obviate this problem, I modified IFTHEN so that writes the subtraction result in the same position and, in a next job step, I controlled if in that location the value is positive or negative: in the first case I leave everything so while in the second I overturn the value in another field.

thanks for your help
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 Oct 02, 2015 7:16 pm
Reply with quote

There is no need to do anything in a separate step. If you show your working code, we can show how to do it in one step.
Back to top
View user's profile Send private message
witsche

New User


Joined: 04 May 2005
Posts: 3

PostPosted: Fri Oct 02, 2015 7:47 pm
Reply with quote

at the moment I'm fine, eventually I will contact you later
thanks again
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 Oct 02, 2015 8:49 pm
Reply with quote

OK, I'll be eagerly awaiting an opportunity to be of service at your convenience.

Or not.
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 -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top