View previous topic :: View next topic
|
Author |
Message |
vijayamadhuri
Active User
Joined: 06 Apr 2005 Posts: 180
|
|
|
|
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 |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
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 |
|
|
vijayamadhuri
Active User
Joined: 06 Apr 2005 Posts: 180
|
|
|
|
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 |
|
|
sudhaaa
New User
Joined: 24 Mar 2005 Posts: 51
|
|
|
|
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 |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
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 |
|
|
Karthikt
New User
Joined: 15 Aug 2005 Posts: 51
|
|
|
|
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 |
|
|
shivavarmak Warnings : 1 New User
Joined: 08 Jun 2006 Posts: 1
|
|
Back to top |
|
|
subramaniabharathi
New User
Joined: 09 Mar 2006 Posts: 9
|
|
|
|
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 |
|
|
subramaniabharathi
New User
Joined: 09 Mar 2006 Posts: 9
|
|
|
|
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 |
|
|
rajendrakumar20
New User
Joined: 22 May 2005 Posts: 1
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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
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 |
|
|
|