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

How to use IFTHEN and FIELDS in same the INREC


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

New User


Joined: 31 Oct 2006
Posts: 48
Location: Chennai

PostPosted: Tue Oct 31, 2006 6:34 pm
Reply with quote

Hi,

When using inrec in sort, i want to use IFTHEN and INREC fields at the same time.

For example,

If my input file(FB, LRECL=9) is:
UTHHJKADF
GTHMNGAVF
KGHGAJYUN

In the output file it should be as:
1st byte should be:
'1' IF 1,1,CH,EQ,C'U'
'2' IF 2,1,CH,EQ,C'T'
'3' IF 3,1,CH,EQ,C'H'

and the record as in input file will be placed in output file from position 2.
i.e. the output should be
1UTHHJKADF
2GTHMNGAVF
3KGHGAJYUN

The actual conditions i use are so huge, i planned to use
INREC IFTHEN to overlay the TEXT at the 1st position.

Now, HOW can i use INREC to place the input file record from position 2.

Your timely help will be highly appreciated.

Regards,
OP
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 Oct 31, 2006 9:25 pm
Reply with quote

For each IFTHEN clause, you must use BUILD or OVERLAY to specify the action to be taken when the WHEN condition is satisfied. In your case, you would use BUILD in each IFTHEN clause. 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/9)
//SORTOUT DD DSN=...  output file (FB/10)
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'U'),BUILD=(C'1',1,9)),
        IFTHEN=(WHEN=(2,1,CH,EQ,C'T'),BUILD=(C'2',1,9)),
        IFTHEN=(WHEN=(3,1,CH,EQ,C'H'),BUILD=(C'3',1,9))
/*
Back to top
View user's profile Send private message
op

New User


Joined: 31 Oct 2006
Posts: 48
Location: Chennai

PostPosted: Wed Nov 01, 2006 3:16 pm
Reply with quote

Hi Yaeger,

Thanks a lot for the reply.

I want to write all the records that are not selected by any IFTHEN condition to other file. How do i do it?

Please help.

Regards,
OP
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 Nov 01, 2006 9:43 pm
Reply with quote

Quote:
I want to write all the records that are not selected by any IFTHEN condition to other file.


Here's a DFSORT job that will do it:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/9)
//OUT1 DD DSN=...  output file1 (FB/10)
//OUT2 DD DSN=...  output file2 (FB/9)
//SYSIN    DD    *
  OPTION COPY
  INREC IFOUTLEN=11,
        IFTHEN=(WHEN=(1,1,CH,EQ,C'U'),BUILD=(C'1',1,9)),
        IFTHEN=(WHEN=(2,1,CH,EQ,C'T'),BUILD=(C'2',1,9)),
        IFTHEN=(WHEN=(3,1,CH,EQ,C'H'),BUILD=(C'3',1,9)),
        IFTHEN=(WHEN=NONE,BUILD=(1,9,11:C'N'))
  OUTFIL FNAMES=OUT1,INCLUDE=(11,1,CH,NE,C'N'),
    BUILD=(1,10)
  OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,9)
/*
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 Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts INREC PARSE used to sort a CSV file DFSORT/ICETOOL 2
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