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
 

 

Insert values in between the file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Insert values in between the file
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: 1703
Location: Australia

PostPosted: Fri Oct 18, 2013 5:24 am    Post subject: Reply to: Insert values in between the file
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    Post subject:
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: 1703
Location: Australia

PostPosted: Fri Oct 18, 2013 5:42 am    Post subject:
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    Post subject:
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: 1703
Location: Australia

PostPosted: Fri Oct 18, 2013 5:56 am    Post subject:
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Fri Oct 18, 2013 1:53 pm    Post subject: Reply to: Insert values in between the file
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: 31
Location: Chennai

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

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

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Mon Oct 21, 2013 2:49 am    Post subject: Reply to: Insert values in between the file
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Oct 21, 2013 5:07 am    Post subject: Reply to: Insert values in between the file
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: 1703
Location: Australia

PostPosted: Tue Oct 22, 2013 2:55 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Oct 22, 2013 4:09 am    Post subject: Reply to: Insert values in between the file
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Oct 22, 2013 4:32 am    Post subject: Reply to: Insert values in between the file
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: 1703
Location: Australia

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

Hi Bill,

check this


http://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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Oct 22, 2013 11:50 am    Post subject: Reply to: Insert values in between the file
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    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
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


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