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

Insert values in between the file


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

New User


Joined: 11 Sep 2007
Posts: 65
Location: Gurgaon

PostPosted: Fri Oct 18, 2013 4:52 am
Reply with quote

I am trying to work on following

Expand the 3rd byte from 1 to 3 bytes and if in the input file at the 3rd position its 0 or * then put 000 or ***

For example

Input file
Code:

AB0CD
ABCDE
AB*CD



Output file should be

Code:

AB000CD
ABC  DE
AB***CD


I can do that in 2 steps

Step 1 SORT card. This will insert 2 spaces after position 3
Code:

OPTION COPY               
INREC FIELDS=(1:1,3,6:4,2)


Step2
Code:

SORT FIELDS=COPY                                       
INREC IFTHEN=(WHEN=(3,1,CH,EQ,C'0'),OVERLAY=(4:C'00')),
IFTHEN=(WHEN=(3,1,CH,EQ,C'*'),OVERLAY=(4:C'**'))       


Can this be done in one step? May be through icetool or DFSORT. Please advice
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Oct 18, 2013 5:24 am
Reply with quote

Hi,

just run step2 and use build instead of overlay.


Gerry
Back to top
View user's profile Send private message
raj_mainframe08

New User


Joined: 11 Sep 2007
Posts: 65
Location: Gurgaon

PostPosted: Fri Oct 18, 2013 5:35 am
Reply with quote

Hi,

If i used only BUILD as below without running STEP 1 as below


Code:


SORT FIELDS=COPY                                     
OUTREC IFTHEN=(WHEN=(3,1,CH,EQ,C'0'),BUILD=(4:C'00')),
IFTHEN=(WHEN=(3,1,CH,EQ,C'*'),BUILD=(4:C'**'))       


I am getting following
Code:

   00
   **
11111
22222
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Oct 18, 2013 5:42 am
Reply with quote

Hi,

try this
Code:

 SORT FIELDS=COPY                                                     
 OUTREC IFTHEN=(WHEN=(3,1,CH,EQ,C'0'),BUILD=(1,3,4:C'00',4,2)),       
        IFTHEN=(WHEN=(3,1,CH,EQ,C'*'),BUILD=(1,3,4:C'**',4,2)),       
        IFTHEN=(WHEN=NONE,                                           
                BUILD=(1,3,4:C'  ',4,2))                             


Gerry
Back to top
View user's profile Send private message
raj_mainframe08

New User


Joined: 11 Sep 2007
Posts: 65
Location: Gurgaon

PostPosted: Fri Oct 18, 2013 5:48 am
Reply with quote

Hi,

Thanks for this. This is working but its not working on records having values not equal to * or 0. Example

Code:

AB0CD
ABCDE
AB*CD


should give i.e 2 spaces in the 2nd record
Code:

AB000CD
ABC  DE
AB***CD


But with the above code, i am getting i.e. no spaces in the 2nd record
Code:

AB000CD
ABCDE
AB***CD


Can there be Not equal to * or 0 condition that can be put[/code]
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Oct 18, 2013 5:56 am
Reply with quote

Hi,

check my code again.


Gerry
Back to top
View user's profile Send private message
raj_mainframe08

New User


Joined: 11 Sep 2007
Posts: 65
Location: Gurgaon

PostPosted: Fri Oct 18, 2013 5:59 am
Reply with quote

Hi Gerry,

Many many thanks. Its worked. I learned about BUILD today. I also tried with following code and i am getting the same results

Code:

SORT FIELDS=COPY                                                   
  OUTREC IFTHEN=(WHEN=(3,1,CH,EQ,C'0'),BUILD=(1,3,4:C'00',4,2)),   
         IFTHEN=(WHEN=(3,1,CH,EQ,C'*'),BUILD=(1,3,4:C'**',4,2)),   
         IFTHEN=(WHEN=(3,1,CH,NE,C'*',OR,3,1,CH,NE,C'0'),         
                BUILD=(1,3,4:C'  ',4,2))                           
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 18, 2013 1:53 pm
Reply with quote

You could try this. For each record it repeats the third byte to positions four and five. Then using SS it tests for not 0 or * and puts two blanks in positions four and five for all but 0 and *.


Code:
  SORT FIELDS=COPY                                                     
       
  INREC IFTHEN=(WHEN=INIT,
                     BUILD=(1,3,3,1,3,1,4,2)),
        IFTHEN=(WHEN=(3,1,SS,NE,C'0,*'),
                     OVERLAY=(4:2X))


There is now only one reference to 0 or * and if the values have to be changed/extended the changes to the code are minimal.

Using symbols/SYMNAMES would clarify what it is doing and reduce potential maintenance issues.
Back to top
View user's profile Send private message
madprasy

New User


Joined: 08 Apr 2008
Posts: 34
Location: Chennai

PostPosted: Sat Oct 19, 2013 11:54 am
Reply with quote

Bill Woodger - Superb..!!
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Mon Oct 21, 2013 2:49 am
Reply with quote

Hi,

Quote:
Then using SS it tests for not 0 or * and puts two blanks in positions four and five for all but 0 and *.



this should really read
Quote:
Then using SS it tests for not 0 or * or , and puts two blanks in positions four and five for all but 0 and * and ,.



Personally I'm against using SS with multiple selections in the same statement.


Gerry
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: Mon Oct 21, 2013 5:07 am
Reply with quote

Hi,

I'm not sure what you think it should be saying.

(x,1,SS,EQ,C'0,*') will be true for 0 or *.

(x,1,SS,NE,C'0,*') will be true for everything except 0 or *.

The comma is just a separator for the values.

For me the SS with multiple values is poweful. Multiple values can be tested for without worry about OR or AND or multiple IF statements. Like an 88 in COBOL with multiple values. Simplifies things.

The simplification attempted here was different: to only have the "0" or "*" appear once in the code. When the code is changed, it is much more difficult to get it wrong - as it remove the chance of testing for one value and setting another.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Oct 22, 2013 2:55 am
Reply with quote

Hi Bill,

SS doesn't really use the separator as a separator. It's just another character

Code:
  SORT FIELDS=COPY                                                     
       
  INREC IFTHEN=(WHEN=INIT,
                     BUILD=(1,3,3,1,3,1,4,2)),
        IFTHEN=(WHEN=(3,1,SS,NE,C'0,*'),
                     OVERLAY=(4:2X))

The above code equates to
Code:
   SORT FIELDS=COPY                                     
                                                       
   INREC IFTHEN=(WHEN=INIT,                             
                      BUILD=(1,3,3,1,3,1,4,2)),         
         IFTHEN=(WHEN=(3,1,CH,NE,C'0',&,               
                       3,1,CH,NE,C',',&,               
                       3,1,CH,NE,C'*'),                 
                              OVERLAY=(4:2X))           



Gerry
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: Tue Oct 22, 2013 4:09 am
Reply with quote

Hi Gerry,

Do you have a reference for that? The sperator needn't be a comma, it can be anything which is not required in the test. But a seperator is needed as a separator, otherwise the orther SS test will be done.
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: Tue Oct 22, 2013 4:32 am
Reply with quote

Arriving slowly at what you mean Gerry. Some interesting effects.

The separator used can be any character - just make sure it cannot appear in the data being searched.


If the separator does/can exist in the data being searched, you can/will get unintended results. It is in the manual, under INCLUDE.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Oct 22, 2013 4:49 am
Reply with quote

Hi Bill,

check this


ibmmainframes.com/viewtopic.php?t=40901&highlight=separator



Gerry

PS. Additional tests are being carried out when using multiple values
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: Tue Oct 22, 2013 11:50 am
Reply with quote

Hi Gerry,

Thanks. Good to see an explanation. I wad hondered about the results I had found at your prompting.
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
Search our Forums:

Back to Top