Using cursor and record

Ask question on - DataBase Concepts, IBM Mainframe DB2, DB2/UDB, DB2 Tools, SQL , DB2 programming with languages like COBOL, PL1.

Moderators: Kalicharan, Moderator Group

Post Reply
Anja
Member
Posts: 6
Joined: Sun Mar 23, 2014 5:16 am
Location: Turkey

Using cursor and record

Post by Anja » Sun May 11, 2014 7:17 am

I am beginner to COBOL and I am trying to learn the COBOL by my self.

I want to call a module so I can get a variable ”LOOK90-CODE ”from the copybook. I want to read the content of the table and check if ”LOOK90-CODE=50”, if true then I want to write the content of the table to a record.
I have declared a cursor for this table, but I don't know how to write this code using a variable from a copybook so that I can check the condition. Can someone please explain to me what to do. My code can print a report and I can fetch the content of the table.

Here is the cursor:

Code: Select all

       WBB-FETCH-F71A01 SECTION.
           MOVE 'A'                    TO SECTION-A-NAME

           EXEC SQL
             FETCH   C_Find
               INTO  :FIND-LIST-NUMBER
                    ,:FIND-DATE-BEFORE
                    ,:FIND-AGREEMENT-PERIOD
                    ,:FIND-DATE-AFTER
                    ,:FIND-REPORT-EMTY-LEVEL
                    ,:FIND-WRITE-Y-N
                    ,:FIND-BIG-STRUCTURE
                    ,:FIND-NO-AGREEMENT
                    ,:FIND-DATE-NEXT
                    ,:FIND-LIST-NUMBER
                    ,:FIND-HELP-NUMBER
                    ,:FIND-DATE-DURATION
           END-EXEC 

Here are some variables in the copybook:

Code: Select all

05 LOOK90-LOT-MODULE	
     10 LOOK90-STRUCT		PIC X
     10 LOOK90-CODE

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Sun May 11, 2014 4:47 pm

”LOOK90-CODE ”from the copybook
Wel, I do not understand what you mean here. Presumably in you WORKINGSTORAGE you have a statement like COPY copybook-member? This tells the (pre)compiler to copy the code from the copybook into your source code before it compiles it as one unit.
Regards
Nic

Anja
Member
Posts: 6
Joined: Sun Mar 23, 2014 5:16 am
Location: Turkey

Post by Anja » Sun May 11, 2014 5:16 pm

[quote="NicC"][quote]”LOOK90-CODE ”from the copybook[/quote]
Wel, I do not understand what you mean here. Presumably in you WORKINGSTORAGE you have a statement like COPY copybook-member? This tells the (pre)compiler to copy the code from the copybook into your source code before it compiles it as one unit.[/quote]

[quote]
Thanks for your answer.
I have ”LOOK90-CODE ” in my copybook in theWORKINGSTORAGE. I want to write the table(the content of the cursor) to a record. Only when "LOOK90-CODE=50"
What I don't understand is how will my table know when "LOOK90-CODE=50" since the varable "LOOK90-CODE" only is in my copybook and not in my table. What are the connections between the two?

[/quote]

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Sun May 11, 2014 11:28 pm

i guess what you are wanting is:

Code: Select all

IF LOOK90-CODE = 50
   MOVE value-in-cursor TO record-variable
but this is so basic I wonder if it is what you are wanting?
Regards
Nic

dhiraj
Member
Posts: 48
Joined: Tue May 06, 2014 11:22 am

Post by dhiraj » Mon May 12, 2014 1:03 pm

according to your first post, I assume that your program is calling a module and after returning from module you are getting value in "LOOK90-CODE" .

If program is watching value "LOOK90-CODE = 50" only, so no need to fetch value before this.

as Nic said you need to put condition (If Look90-Code =50) after that program can "Fetch the data from table".

plz answer the question that " how you want to fetch data?? on the basis of variable LOOK90-CODE or this is only for writing purposes??
Thanks,
--Dhiraj Mishra

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Mon May 12, 2014 1:22 pm

I think you should also forget about "COPYBOOK" - once compiled all the code is in one member per module - all copybook stff is inline. There is nothing special about copybook code except you can include the same code in many modules but only write it once.
Regards
Nic

Anja
Member
Posts: 6
Joined: Sun Mar 23, 2014 5:16 am
Location: Turkey

Post by Anja » Tue May 13, 2014 1:11 am

NicC wrote:I think you should also forget about "COPYBOOK" - once compiled all the code is in one member per module - all copybook stff is inline. There is nothing special about copybook code except you can include the same code in many modules but only write it once.
Thanks so much for your answers.

I am learning COBOL by my own. Sometimes it feels like I lack some basic knowledge.
I have learned a lot of your answers.


Thanks again!

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Wed May 14, 2014 12:53 am

Sometimes it feels like I lack some basic knowledge.
Well, that is most likely considering:
I am beginner to COBOL
Once upon a time we were all beginners :wink:

Good Luck!
Have a good one

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Wed May 14, 2014 1:26 pm

As a beginner myself I have "COBOL for Dummies" sitting on my desk a good basic intro. It also came with free compilers for COBOL on windoze. It may now be out of print but second-hand copies may be available. I have not searched the web for COBOL tutorials but I know such things exist for C and SQL (because I use them!). There are other books on COBOL - Stern and Stern, Murach etc but may be expensive (if new). Free compilers are available on the web. The Open (now GNU) COBOL documentation is supposed to be pretty good. If all else fails - the IBM manuals (language reference and User guide) are freely available.
Regards
Nic

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Thu May 15, 2014 1:41 pm

In addition, there are tutorials at the bottom of every forum page.
Regards
Nic

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others