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
 

 

Sample cobol Ims pgm

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> IMS DB/DC
View previous topic :: :: View next topic  
Author Message
vijayamadhuri

Active User


Joined: 06 Apr 2005
Posts: 180

PostPosted: Thu Jul 07, 2005 2:59 am    Post subject: Sample cobol Ims pgm
Reply with quote

Hi,


I am learning IMS.Please could someone send me a sample program of how we are giving the ims database from a cobol pgm.
Back to top
View user's profile Send private message

priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Thu Jul 07, 2005 3:33 pm    Post subject: Re: sample cobol-ims pgm
Reply with quote

Hi vijayamadhuri,

Quote:
sample program of how we are giving the ims database from a cobol pgm.


Will you please elaborate what you actually wanna do.......

Regards,

Priyesh.
Back to top
View user's profile Send private message
vijayamadhuri

Active User


Joined: 06 Apr 2005
Posts: 180

PostPosted: Fri Jul 08, 2005 12:00 am    Post subject: Hi
Reply with quote

I want to basically know how we code a pgm for accessing data from the ims database thru DL/1.I have rea the theory part but would like to have the practical aspect of it.
Back to top
View user's profile Send private message
sudhaaa

New User


Joined: 24 Mar 2005
Posts: 51

PostPosted: Fri Jul 08, 2005 11:28 am    Post subject: Re: sample cobol-ims pgm
Reply with quote

Hi,

First in your COBOL-IMS program you can issue DL/I calls to retrive the segment fields from the IMS database.

In your DL/I call, you specify PCB-MASK, which is relates to your Linkage section of the program, through ENTRY statement, which you coded as first statement in your procedure division.

IMS take care of retriving the database for your DL/I call. In PSB, you have to specify the PCB field and SEGM( also FIELD SENSEG) fields.

Still I have to explain more to reach you.
I hope other folks can help me in this regard.
I can give you one example in the next reply.

Regards,
Sudhaaa
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Fri Jul 08, 2005 3:26 pm    Post subject: Re: sample cobol-ims pgm
Reply with quote

Hi vijayamadhuri,

Sudhaa already given you the picture. I'll give u an example.

Suppose Parent segment contain Student Rec & child is having course details.

First stmt in procedure division will be ENTRY stmt mentioning PCB's.

Then Suppose you want to access rec for some perticular stuadent.

You have to give a GU call after moving that perticular Student ID to KEY VALUE Field of that PCB. If RC from Call is SPACES you got that rec.

in same way, If you want to access Courses rec.,.......you will issue an GNP Call....P represents PARENTAGE.....which means all value of child linked to the parent. again if you get SPACES as RC...you retrieved a child for that STUDENT ID....similar way you can give continue GNP calls to access all the child.

Hope it clears.......

Regards,

Priyesh.
Back to top
View user's profile Send private message
Karthikt

New User


Joined: 15 Aug 2005
Posts: 51

PostPosted: Tue Aug 16, 2005 1:38 pm    Post subject:
Reply with quote

To add to this, the following are the items you have to specify in your cobol program.

WORKING STORAGE SECTION


Declartions for I/O area, SSA

COPY DL/I calls.

LINKAGE SECTION
Copybooks for PCB.

PROCEDURE DIVISION.

ENTRY 'DLITCBL' USING PCB-NAME1
PCB-NAME2 etc.

DL/I calls to be issued for the function of the program.

These are the things that differntiates an IMS program from ordinary COBOL program.

Please note that an IMS program is always an sub-routine of DL/I hence, you have to give GO BACK statment to return control back to the DL/I system.
Back to top
View user's profile Send private message
shivavarmak
Warnings : 1

New User


Joined: 08 Jun 2006
Posts: 1

PostPosted: Thu Jun 08, 2006 12:58 pm    Post subject: material
Reply with quote

Hi ,

Can anyone send me the material to go through for some one who has just started learning IMS DB. U can send the material at

***EMail ID REMOVED... Use CODE tag to include mail id***

Thanks in advance
Shiva.
Back to top
View user's profile Send private message
subramaniabharathi

New User


Joined: 09 Mar 2006
Posts: 9

PostPosted: Sun Jul 16, 2006 3:01 pm    Post subject:
Reply with quote

Vijay madhuri,
Here is a small program which performs gu call on a root and retrieves the root segments and displays some info in the root segment
IDENTIFICATION DIVISION.
PROGRAM-ID. CAAVCM04.
DATE-COMPILED.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-370.
OBJECT-COMPUTER. IBM-370.
INPUT-OUTPUT SECTION.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
DL/I CALL FUNCTIONS
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

01 WS-GU PIC X(04) VALUE 'GU '.
01 WS-GN PIC X(04) VALUE 'GN '.
01 WS-GNP PIC X(04) VALUE 'GNP '.
01 WS-GHU PIC X(04) VALUE 'GHU '.
01 WS-GHN PIC X(04) VALUE 'GHN '.
01 WS-GHNP PIC X(04) VALUE 'GHNP'.
01 WS-REPL PIC X(04) VALUE 'REPL'.
01 WS-ISRT PIC X(04) VALUE 'ISRT'.
01 WS-INIT PIC X(04) VALUE 'INIT'.
01 WS-ROLB PIC X(04) VALUE 'ROLB'.
01 WS-DLET PIC X(04) VALUE 'DLET'.
01 WS-CHKP PIC X(04) VALUE 'CHKP'.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SEGMENT LAYOUTS - USED AS IOAREAS IN CALLS
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

01 CA01-SEGMENT.
10 CA01-CS0694 PICTURE S9(4)
COMPUTATIONAL
VALUE +179.
10 CA01-KYCA01.
15 CA01-WS0001.
20 CA01-FI0178 PICTURE X(10)
VALUE SPACE.
20 CA01-CS0189 PICTURE X(20)
VALUE SPACE.
20 filler picture x(2000)
01 CADB-AIB.
02 CADB-AIBID PIC X(8) VALUE
02 CADB-AIBLEN PIC 9(9) COMP.
02 CADB-AIBRSFUNC PIC X(8).
02 CADB-AIBRSNM1-PCB-NAME PIC X(8).
02 CADB-AIBRSNM2 PIC X(8).
02 CADB-AIBRESV1 PIC X(8).
02 CADB-AIBOALEN PIC 9(9) COMP.
02 CADB-AIBOAUSE PIC 9(9) COMP.
02 CADB-AIBRESV2 PIC X(12).
02 CADB-AIBRETRN PIC 9(9) COMP.
02 CADB-AIBREASN PIC 9(9) COMP.
02 CADB-AIBERRXT PIC 9(9) COMP.
02 CADB-AIBRESA1-PCB-ADDR POINTER.
LINKAGE SECTION.
01 CADB-PCB.
02 CADB-PCB-DBDNAME PIC X(08).
02 CADB-PCB-SEGMENT-LEVEL PIC X(02).
02 CADB-PCB-STATUS-CODE PIC X(02).
02 CADB-PCB-PROCOPT PIC X(04).
02 CADB-PCB-RESERVED PIC S9(05)
02 CADB-PCB-SEGMENT-NAME PIC X(08).
02 CADB-PCB-KEY-LEN PIC S9(05)
02 CADB-PCB-NUMBER-OF-SENSEGS PIC S9(05)
02 CADB-PCB-KFBAREA.
03 CADB-PCB-KEY OCCURS 0 TO 128
DEPENDING ON CADB-PCB-KEY-LEN
PIC X.
PROCEDURE DIVISION USING CADB-PCB.

A-MAINLINE SECTION.

DISPLAY 'SAMPLE COBOL IMS CODE'
DISPLAY 'CODE BEGINS'
MOVE 'CADBP01' TO CADB-AIBRSNM1-PCB-NAM
MOVE LENGTH OF CADB-AIB TO CADB-AIBLEN
MOVE LENGTH OF CA01-SEGMENT TO CADB-AIBOALEN
MOVE 'keyvalue' TO CA01-Q-BANK-NUM
MOVE 'keyvalue'' TO CA01-Q-CUST-NUM
DISPLAY 'CA01-SSA-ROOT....'
DISPLAY CA01-SSA-ROOT
CALL 'CEETDLI' USING WS-GU
CADB-AIB
CA01-SEGMENT
CA01-SSA-ROOT
MOVE CADB-AIBRETRN TO WS-AIBRETRN
MOVE CADB-AIBREASN TO WS-AIBREASN
DISPLAY 'CADB-AIBRETRN..' WS-AIBRETRN
DISPLAY 'CADB-AIBREASN..' WS-AIBREASN
DISPLAY 'CADB-PCB-STATUS-CODE..' CADB-PCB-STATUS-COD
DISPLAY 'CA01-FI0178...' CA01-FI0178
DISPLAY 'CA01-CS0189...' CA01-CS0189
DISPLAY 'CA01-LN3174...' CA01-LN3174
if WS-AIBRETRN = spaces
display'found'
else
display 'not found'
end-if



CALL 'CEETDLI' USING WS-ROLB
CADB-PCB
.


DISPLAY 'CODE ENDS'
GOBACK



These are the important things to make note of
CALL 'CEETDLI' USING WS-GU
CADB-AIB
CA01-SEGMENT
CA01-SSA-ROOT
1.parameter 1 what type of call are u going to provide
2.parameter 2 your aibparameters if the cadb-AIBRETRN is 2304 the the segment which you are searching is not found.
3.the receivable segement and its layout
4.ssa root is the place where u define the segement and its key this should be same format as above.

CEETDLI dli call is same as CBLTDLI
call
Back to top
View user's profile Send private message
subramaniabharathi

New User


Joined: 09 Mar 2006
Posts: 9

PostPosted: Sun Jul 16, 2006 3:04 pm    Post subject: Re: sample cobol-ims pgm
Reply with quote

I have left ca01 ssa root definition
01 CA01-SSA-ROOT.
02 PIC X(08) VALUE 'CA01
02 PIC X(01) VALUE '*'.
02 PIC X(04) VALUE '----'.
02 PIC X(01) VALUE '('.
02 PIC X(08) VALUE 'KYCA01
02 PIC X(02) VALUE ' ='.
02 CA01-Q-KEY-VALUE.
03 CA01-Q-BANK-NUM PIC X(10).
03 CA01-Q-CUST-NUM PIC X(20).
02 PIC X(01) VALUE ')'.
this is the format for ssa root declaration
Back to top
View user's profile Send private message
rajendrakumar20

New User


Joined: 22 May 2005
Posts: 1

PostPosted: Sun Jul 31, 2011 2:19 pm    Post subject: Reply to: sample cobol-ims pgm
Reply with quote

Sample Coding Inserting the segment into the IMS database:

3 Steps:

 Read
 Prepare Load Data
 Insert


Code:
WORKING STORAGE SECTION.

01   DLI-FUNCTION-CODE
        05 GU      PIC  X(04) VALUE   ‘GU’
        05 GHU      PIC  X(04) VALUE   ‘GHU’
        05 GN             PIC  X(04)   VALUE    'GN’
        05 GHN        PIC  X(04)   VALUE    ‘GHN’
        05 GNP        PIC X(04)   VALUE    ‘GNP’
        05 GHNP      PIC X(04)   VALUE    ‘GHNP’
        05  ISRT            PIC X(04)   VALUE    ‘ISRT’
        05  DLET            PIC X(04)   VALUE    ‘DLET’
        05  REPL            PIC X(04)   VALUE    ‘REPL’
        05  XRST           PIC X(04)   VALUE    ‘XRST’
        05 CKPT            PIC X(04)   VALUE    ‘CKPT’
        05  PCB             PIC X(04)   VALUE    ‘PCB’
 

01 SEGMENT-IO-AREA     PIC    X(130).
     
* QUALIFIED SSA
01   INV-SSA.
        05   INVSEG                PIC   X(8)    VALUES  ‘        ’
        05   COMMANDCODE        PIC   X(4)    VALUES   ‘*---’
        05   OPEN PARA                PIC    X        VALUES   ‘(‘
        05   KEY NAME               PIC   X(11)   VALUES  ‘INVNO’
        05   REL OP                    PIC    XX       VALUES   ‘ =’
        15   FVALUE                PIC    X.
        15   CLOSE PARAN        PIC    X        VALUES  ‘)’

SSAS


LINKAGE SECTION.
01  INV-MASK.
      05 DBD-NAME                     PIC X(08).
      05 SGM-LEVEL                     PIC X(02).
      05 STATUS-CODE                PIC X(02)
      05 PROC-OPT                      PIC  X(04)
      05  FILLER                           S9(05) COMP.
      05  SEGMENT-NAME              PIC X(08)
      05  KEY LENGTH                   S9(05) COMP
      05  NUMBER-SENS-SEGM   S9(05) COMP
      05  KEY                               PIC X(11).

PROCEDURE DIVISION.

001-ENTRY.

        ENTRY   'DLITCBL' USING  INV-MASK.

300-INPUT.
   OPEN INPUT INPUT-FILE.

310-READ-INPUT.
   READ INPUT-FILE AT END
SET AT-END TO TRUE.
      GO TO 320-PROCESSING-EXIT
   END-READ.
320-PREPARED-LOAD-DATA.
   INITIALIZE SEGMENT-IO-AREA.
   MOVE DATA-AREA TO SEGMENT-IO-AREA.

   EVALUATE TRANSACTION-CODE
      WHEN ‘V’
         MOVE VENSEG TO USSA.
      WHEN ‘I’
         MOVE ITEMSEG TO USSA
      WHEN ‘S’
         MOVE STOCKSEG TO USSA
   END-EVALUATE.

      
330-ISRT-INVDB.
   CALL ‘CBLTDLI’ TO  ISRT
           INV-PCB-MASK
           SEGMENT-IO-AREA
           USSA.
   IF STATUS-CODE=’ ‘
      DISPLAY ‘SUCCESSFULLY INSERERTED ‘ SEGMENT-IO-AREA
   ELSE
      DISPLAY ‘INSERT FAILED ‘ SEGMENT-IO-AREA
      DISPLAY ‘DL STATUS CODE’   INV-STATUS-CODE
   END-IF.   

340-CLOSE-INPUT-FILES.
   CLOSE INPUT-FILE.

"Code'd"
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7307

PostPosted: Sun Jul 31, 2011 3:03 pm    Post subject: Reply to: sample cobol-ims pgm
Reply with quote

Why are you replying to a topic which is six years old and hasn't seen any activity for five years? It is unlikely that someone learning IMS at the time would still require assistance, don't you think?

Also,

You have expended effort to space out your code/data, and then wasted it all by not use the Code tags.

When posting, highlight the text whose formatting you want to retain and click the Code button (grey oblong above the the text input box, says "Code").

Click on Preview (below input box) to check that the formatting is how you want.

If "coded", it is much easier to understand, as we see it how you wanted us to see it. For more information on formatting your post, click on FAQ on the blue line twoards the top of the screen and look for BBCode.
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: Sun Jul 31, 2011 3:56 pm    Post subject:
Reply with quote

Hello and welcome to the forum,

As mentioned, it better to reply to current, active topics rather than those that have been inactive for years icon_smile.gif

Your COBOL has been "Coded", but the space count was off.

One easy way to make sure your post is aligned is to copy/paste from the mainframe terminal window, highlight the copied info and click the "Code" tag. Use Preview to see how your post will appear to the forum and then Submit when your post appears the way you want.
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 -> IMS DB/DC All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am


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