Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Reading a COBOL program line by line

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Reading a COBOL program line by line
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10375
Location: italy

PostPosted: Mon Feb 25, 2008 4:58 pm    Post subject: Reply to: Reading a COBOL program line by line
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    Post subject: FETCHING from a file by a COBOL PROGRAM
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: 276
Location: Bang,iflex

PostPosted: Tue Feb 26, 2008 1:00 pm    Post subject: Hi
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: 1439
Location: Bangalore,India

PostPosted: Tue Feb 26, 2008 3:29 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10375
Location: italy

PostPosted: Tue Feb 26, 2008 3:42 pm    Post subject: Reply to: FETCHING from a file by a COBOL PROGRAM
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10375
Location: italy

PostPosted: Tue Feb 26, 2008 3:55 pm    Post subject: Reply to: FETCHING from a file by a COBOL PROGRAM
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    Post subject:
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

Site Director


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

PostPosted: Tue Feb 26, 2008 10:14 pm    Post subject:
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: 757
Location: Germany

PostPosted: Wed Feb 27, 2008 3:39 pm    Post subject:
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

Site Director


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

PostPosted: Wed Feb 27, 2008 10:37 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts The same REXX program doesnt work for... jackzhang75 CLIST & REXX 5 Wed Dec 06, 2017 2:51 am
This topic is locked: you cannot edit posts or make replies. Cobol to fetch the content by using s... arunc55 COBOL Programming 4 Fri Nov 17, 2017 1:25 pm
No new posts Calling IKJEFT01 program from Rexx upendrasri CLIST & REXX 8 Wed Nov 15, 2017 4:27 pm
No new posts VBS and VB, COBOL syntax is the same ... natt.sut COBOL Programming 3 Sun Nov 12, 2017 6:36 am
No new posts COBOL - EXIT statement weird behavior anthony.pangestu COBOL Programming 0 Fri Oct 27, 2017 9:57 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us