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
 

 

Splitting a file using a string

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Splitting a file using a string
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    Post subject:
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    Post subject: Splitting a file using a string
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    Post subject:
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    Post subject: Splitting a file using a string
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    Post subject:
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    Post subject: Splitting a file using a string
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    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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 11 Tue May 16, 2017 2:20 pm
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am


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