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

Splitting a file using a string


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

New User


Joined: 15 Jun 2009
Posts: 4
Location: India

PostPosted: Mon Jun 15, 2009 6:35 pm
Reply with quote

Hi,

I have a source code and need to split the source code file in to 2 files.

1 containg all the records from the source code until procedure division and the other has to contain all the records after procedure division.

From the first file need to extarct the program name and from the second file i need to extarct all the paragraph names and write the PGM name as the first record and the paragraph names following it in to single file.

Kindly help me to resolve this issue.

Regards,
RRealities.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Jun 15, 2009 10:26 pm
Reply with quote

RRealities,

why do you need 2 intermediate files? It can be done in 1 step. I assumed that all your paragraph names start in pos 8.

Code:

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DSN=your.COBOL.PGM.SOURCE,DISP=SHR                 
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  OMIT COND=(8,1,CH,EQ,C' ',OR,7,1,CH,EQ,C'*')                     
  SORT FIELDS=COPY                                                 
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(8,16,CH,EQ,C'PROCEDURE DIVISION'),
  PUSH=(81:ID=1))                                                   
  OUTFIL BUILD=(1,80),                                             
  INCLUDE=(8,10,CH,EQ,C'PROGRAM-ID',OR,81,1,ZD,EQ,1)               
/*
Back to top
View user's profile Send private message
RRealities

New User


Joined: 15 Jun 2009
Posts: 4
Location: India

PostPosted: Tue Jun 16, 2009 10:25 am
Reply with quote

Hi Kolusu,

Thanks for your response and it works fine.

I have some more modification to the same requirement.kindly help me in resolving this.

The requirement is as below.

I have a source code pgm as an I/P.

In one o/P file the entire source code has to be modified by introducing display statements of the paragraph name in to the source code after the start of each paragraph.

In other o/P file, have to extract the PGM name and all the paragraph names from the source PGM.

For eg:

Source code:

Id division
program-id PGMNAM
.
Data division
.
working storage
.
Procedure division
.
.
Main-Para
..
Initialize-para
..
sub-routine-para

O/P File 1:

Id division
program-id PGMNAM
.
Data division
.
working storage
.
Procedure division
.
.
Main-Para
Display 'MAIN-PARA'
..
Initialize-para
DISPLAY 'INITIALIZE-PARA'
..
sub-routine-para
DISPLAY 'SUB-ROUTINE-PARA'

O/P File 2:
PGMNAM
MAIN-PARA
INITIALIZE-PARA
SUB-ROUTINE-PARA


The resolution which I have is completing the requirement in 3 steps

Step 1:
splitting the source I/P file in to 2 ( file 1 all the statements before PROCEDURE division and file 2 statements after PROCEDURE DIVISION) and getting the PGM name and Paragraphs name (as you suggested that it can be done with out splitting the file).

Step 2:
Introducing display statements in the splitted second file by using '/' operator.

Step 3:
Merging the file 1 from step 1 and output file of step 3.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jun 16, 2009 8:51 pm
Reply with quote

Rrealities,

The following DFSORT JCL will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=your.COBOL.PGM.SOURCE,DISP=SHR
//OUT1     DD SYSOUT=*                                             
//OUT2     DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                 
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(8,16,CH,EQ,C'PROCEDURE DIVISION'),
  PUSH=(81:ID=1,SEQ=8))                                             
  OUTFIL FNAMES=OUT1,IFOUTLEN=80,                                   
  IFTHEN=(WHEN=(81,1,ZD,EQ,1,AND,82,8,ZD,GT,1,AND,                 
                8,1,CH,GT,C' ',AND,7,1,CH,NE,C'*'),                 
  BUILD=(1,80,/,12:C'DISPLAY ''',8,30,C'''',80:X))                 
                                                                   
  OUTFIL FNAMES=OUT2,BUILD=(1,80),                                 
  INCLUDE=(8,10,CH,EQ,C'PROGRAM-ID',OR,                             
          (81,1,ZD,EQ,1,AND,8,1,CH,GT,C' ',AND,7,1,CH,NE,C'*'))     
/*
Back to top
View user's profile Send private message
RRealities

New User


Joined: 15 Jun 2009
Posts: 4
Location: India

PostPosted: Wed Jun 17, 2009 4:17 pm
Reply with quote

Hi,

Thanks for the reply.

when i tried to run this in our installation it throws syntax error as below


Code:
********************************* TOP OF DATA **********************************
ICE143I 0 BLOCKSET     COPY  TECHNIQUE SELECTED                                 
ICE000I 1 - CONTROL STATEMENTS FOR 5740-SM1, DFSORT REL 14.0 - 15:46 ON WED JUN
            SORT FIELDS=COPY                                                   
            INREC IFTHEN=(WHEN=GROUP,BEGIN=(8,16,CH,EQ,C'PROCEDURE DIVISION'), 
                               $                                               
ICE007A 0 SYNTAX ERROR                                                         
            PUSH=(81:ID=1,SEQ=8))                                               
            $                                                                   
ICE005A 0 STATEMENT DEFINER ERROR                                               
            OUTFIL FNAMES=OUT1,IFOUTLEN=80,                                     
            IFTHEN=(WHEN=(81,1,ZD,EQ,1,AND,82,8,ZD,GT,1,AND, -                 
                            8,1,CH,GT,C' ',AND,7,1,CH,NE,C'*'),                 
              BUILD=(1,80,/,12:C'DISPLAY ''',8,30,C'''',80:X))                 
                                                                               
              OUTFIL FNAMES=OUT2,BUILD=(1,80),                                 
              INCLUDE=(8,10,CH,EQ,C'PROGRAM-ID',OR, -                           
                      (81,1,ZD,EQ,1,AND,8,1,CH,GT,C' ',AND,7,1,CH,NE,C'*'))     
            /*                                                                 
            $                                                                   
ICE007A 1 SYNTAX ERROR                                                         
ICE052I 3 END OF DFSORT                                                         
******************************** BOTTOM OF DATA ********************************


Not sure whether it is patch updation problem.

Kindly provide inputs on how to install the logic in our instalation(with lower versions of sort).

Doesn't mind if it takes more than one step.

kindly help me in solving this.

Regards,
RRealities.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jun 17, 2009 9:18 pm
Reply with quote

RRealities,

You are getting a syntax error because you don't have the latest PTF which supports GROUP function. Use the following JCL

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=your.COBOL.PGM.SOURCE,DISP=SHR
//OUT1     DD SYSOUT=*
//OUT2     DD SYSOUT=*
//SYSIN    DD *
  SORT FIELDS=COPY                                             
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),           
  IFTHEN=(WHEN=(8,16,CH,EQ,C'PROCEDURE DIVISION'),             
  OVERLAY=(81:SEQNUM,8,ZD)),                                   
  IFTHEN=(WHEN=NONE,OVERLAY=(89:SEQNUM,8,ZD,                   
          81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))               
                                                               
  OUTFIL FNAMES=OUT1,IFOUTLEN=80,                             
  IFTHEN=(WHEN=(81,8,ZD,EQ,1,AND,89,8,ZD,GT,1,AND,             
                8,1,CH,GT,C' ',AND,7,1,CH,NE,C'*'),           
  BUILD=(1,80,/,12:C'DISPLAY ''',8,30,C'''',80:X))             
                                                               
  OUTFIL FNAMES=OUT2,BUILD=(1,80),                             
  INCLUDE=(8,10,CH,EQ,C'PROGRAM-ID',OR,                       
          (81,8,ZD,EQ,1,AND,8,1,CH,GT,C' ',AND,7,1,CH,NE,C'*'))
//*
Back to top
View user's profile Send private message
RRealities

New User


Joined: 15 Jun 2009
Posts: 4
Location: India

PostPosted: Thu Jun 18, 2009 9:17 am
Reply with quote

Hi SKolusu,

Thanks a lot , its working fine.

Regards,
RRealities.
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top