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

Reading a COBOL program line by line


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
parthasaha

New User


Joined: 25 Feb 2008
Posts: 3
Location: bangalore

PostPosted: Mon Feb 25, 2008 4:31 pm
Reply with quote

How can i read line by line in cobol and check any clause/words are there or not??? if there then how can I fetch that clause from that program and write in a PS file????give a program as example
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Mon Feb 25, 2008 4:58 pm
Reply with quote

Your requirement, is certainly clear to You, but was not described properly,

pleas post a few lines of cobol code ( use the code tag )
and Your expected result.

somebody will come up with suggestions
Back to top
View user's profile Send private message
parthasaha

New User


Joined: 25 Feb 2008
Posts: 3
Location: bangalore

PostPosted: Tue Feb 26, 2008 12:00 pm
Reply with quote

PSFILE1:
-----------------------------

IDENTIFICATION DIVISION.
PROGRAM-ID. PROG1.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL INCLUDE SQLCA END-EXEC.
EXEC SQL INCLUDE EMPDCL END-EXEC.
PROCEDURE DIVISION.
001PROG1.
EXEC SQL
SELECT EMPNO FROM EMP WHERE EMPNO='EMP001'
END-EXEC.
STOP RUN.
IDENTIFICATION DIVISION.
PROGRAM-ID. PROG2.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL INCLUDE SQLCA END-EXEC.
EXEC SQL INCLUDE SALDCL END-EXEC.
EXEC SQL INCLUDE DEPTDCL END-EXEC.
PROCEDURE DIVISION.
001PROG2.
EXEC SQL
SELECT SALARY,EMPNO FROM SAL WHERE EMPNO='EMP002'
END-EXEC.
EXEC SQL
SELECT DEPTNO,DEPTNM FROM DEPT WHERE DEPTNO='DEPT1'
END-EXEC.
STOP RUN.
//////////////////////////////////////////////////////////////
PSFILE2.
----------------------------------------

PROGRAM-ID. PROG1.
EXEC SQL
SELECT EMPNO FROM EMP WHERE EMPNO='EMP001'
END-EXEC.
PROGRAM-ID. PROG2.
EXEC SQL
SELECT SALARY,EMPNO FROM SAL WHERE EMPNO='EMP002'
END-EXEC.
EXEC SQL
SELECT DEPTNO,DEPTNM FROM DEPT WHERE DEPTNO='DEPT1'
END-EXEC.

////////////////////////////////////////////////////////////////////////

NOW PSFILE1 IS THE INPUT OF A COBOL PROGRAM AND PSFILE2 IS THE OUTPUT OF THAT PROGRAM.
SO HOW CAN I DO THIS.....

Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Tue Feb 26, 2008 1:00 pm
Reply with quote

HELLO,

What is your question?
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Tue Feb 26, 2008 3:29 pm
Reply with quote

Partha,

Quote:
NOW PSFILE1 IS THE INPUT OF A COBOL PROGRAM AND PSFILE2 IS THE OUTPUT OF THAT PROGRAM.
SO HOW CAN I DO THIS.....

Genrally asking/posting in 'caps' is treated as aggressive. Don't be when are seeking some1s help.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Tue Feb 26, 2008 3:42 pm
Reply with quote

I understand Your question as ...

given as input a cobol program, extract the "EXEC SQL " clauses

if the understanding is right,
the topic has already been discussed
http://ibmmainframes.com/viewtopic.php?t=28179&highlight=extract+cobol
Back to top
View user's profile Send private message
parthasaha

New User


Joined: 25 Feb 2008
Posts: 3
Location: bangalore

PostPosted: Tue Feb 26, 2008 3:47 pm
Reply with quote

question :how can i write a program in cobol so that program will take the PSFILE1 as input and fetch the program-id and exec sql part from the PSFILE1 and it will be written into another file (PSFILE2) as shown in the above example.........
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Tue Feb 26, 2008 3:55 pm
Reply with quote

I guess that nobody will give You an answer...

COBOL might not be the best choice for string handling and syntax analysis
especially if You need help to do it

the link I gave You shows how to do it in rexx
( even if it has some glitches )

it' s the second post on the subject, I wonder what is the business need icon_question.gif
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Feb 26, 2008 6:16 pm
Reply with quote

Quote:
it' s the second post on the subject, I wonder what is the business need


I think a customer wants more documentation then the project team maintained or the system is slow. All of the sql statements are available in the DBRM, they may require some manipulation but it is easier then trying to extract it from the source code.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Tue Feb 26, 2008 10:14 pm
Reply with quote

Hello,

IMHO - a major problem with writing this kind of code (and having it be complete, rather than a mere skeleton), is that the "program" needs to be almost as smart as the compiler.

The sql examples posted are among the simplest possible and even those could present a bit of a coding challange (doesn't matter which programming language) icon_smile.gif If one was to use COBOL, thank goodness for reference modification. . .

Quote:
I think a customer wants more documentation
Even if someone documented all of the initial sql, as the system was maintained/enhanced, it is likely that the external documentation for the sql was not maintained. . .

Quote:
All of the sql statements are available in the DBRM, they may require some manipulation but it is easier then trying to extract it from the source code.
If it was my task, i'd invest in code to use the DBRM info rather than the COBOL source.
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Wed Feb 27, 2008 3:39 pm
Reply with quote

Hi parthasaha !

question :how can i write a program in cobol so that program will take the PSFILE1 as input and fetch the program-id and exec sql part from the PSFILE1 and it will be written into another file (PSFILE2) as shown in the above example.........

My answer: The same old way, as you do in every cobol programm.
Reading input file line by line, checking against a condition, moving strings to output sentence and writing output file. So what.

Or am i such a fool, that i could not understand your question ???

Regards, UmeySan
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Wed Feb 27, 2008 10:37 pm
Reply with quote

Hello,

Quote:
Reading input file line by line, checking against a condition, moving strings to output sentence and writing output file. So what.
A bit of an oversimplification perhaps. . . icon_cool.gif
Back to top
View user's profile Send private message
Itanium

Active User


Joined: 22 Jan 2006
Posts: 114
Location: India

PostPosted: Sat Mar 01, 2008 8:50 pm
Reply with quote

icon_rolleyes.gif
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL sorting, with input GDG base COBOL Programming 7
No new posts Need help with ADABAS query (COBOL-AD... All Other Mainframe Topics 0
No new posts Replacing FILLER with FILLER<SeqNu... DFSORT/ICETOOL 2
No new posts Error to invoke MPP program through B... IMS DB/DC 3
No new posts Compile Sp Cobol base COBOL Programming 1
Search our Forums:

Back to Top