View previous topic :: View next topic
|
Author |
Message |
thesumitk
Active User
Joined: 24 May 2013 Posts: 156 Location: INDIA
|
|
|
|
Hi All,
I have a scenario like below
Code: |
PERFORM 1605-010-DELETE-MCS
VARYING WS-SCRIPT FROM +1 BY +1
UNTIL WS-STOP-DELETE = 'Y' OR
WS-SCRIPT > WS-MAX-CNT
1605-010-DELETE-MCS.
MOVE WS-D1MIOI(WS-SCRIPT) TO WS-MIO-CAT
IF WS-D1MIOI(WS-SCRIPT) NOT EQUAL SPACE AND
(WS-MIO-LOANS OR WS-MIO-SMALL-BUS OR WS-MIO-OVER-DRAFT)
IF WS-MIO-LOANS OR WS-MIO-SMALL-BUS
IF WS-MIO-LOANS
MOVE 'RMSMCS' TO WS-DATASET-NAME
MOVE SPACES TO MCS-KEY
MOVE WS-D1MIOI(WS-SCRIPT) TO WS-LEND-LEVEL
MOVE WS-MCS-FILE-DM-HDR TO WS-FILE-CD
MOVE WS-D1ODMI(WS-SCRIPT) TO WS-DM-TBL-NAME
PERFORM 1602-040-DELETE-MCS THRU 1602-DEL-EXIT
MOVE WS-D1MIOI(WS-SCRIPT) TO WS-LEND-LEVEL
MOVE WS-MCS-FILE-DM-DET TO WS-FILE-CD
MOVE WS-D1ODMI(WS-SCRIPT) TO WS-DM-TBL-NAME
PERFORM 1602-040-DELETE-MCS THRU 1602-DEL-EXIT
VARYING WS-SUB FROM WS-ONE BY WS-ONE
UNTIL WS-STOP-DELETE-MCS = 'Y' . |
Code: |
1602-040-DELETE-MCS.
EXEC CICS DELETE
DATASET(WS-DATASET-NAME)
RIDFLD(WS-PARTIAL-RECORD-KEY)
KEYLENGTH(WS-KEY-LENGTH-15)
GENERIC
NUMREC(WS-DELETE-CNT)
END-EXEC.
EXEC CICS HANDLE CONDITION
NOTFND (1605-020-NOTFND)
END-EXEC.
1602-DEL-EXIT.
EXIT. |
In The Code the first perform is executing the 1605-* Para where we have 1602-040-DELETE-MCS to execute and whenwe go to 1602-040-DELETE-MCS it executes a delete command like above
MY requirement is to delete generic records matching my partial key.. and after deleting when it goes in next iteration then it goes to NOTFND routine 1605-020-NOTFND like below but once it executes the NOTFND routine I expect the control back to the initial perform on TOP while surprisingly it is going to next sentence which is 1700* para in this case.
Code: |
1605-020-NOTFND SECTION.
MOVE 'Y' TO WS-STOP-DELETE-MCS.
1605-020-EXIT.
EXIT.
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
* SEND NOTIFICATION OF SUCCESFULL PROCESS -
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
1700-SEND-MESSAGE.
MOVE WS-DISPLAY-DATE TO D1DATEO.
MOVE COM-USER-LEND-LVL1 TO D1MIOO.
MOVE OLC-VERSION TO D1VERO.
MOVE WS-DISPLAY-TIME TO D1TIMEO.
MOVE COM-USERID TO D1USERO.
|
Can some one please assist.
I hope I am clear above , Please let me know if you need any further info/clarification
Thanks
Sumit Chaturvedi |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
One of the dangers I see in this code, is the DELETE without a previous READ FOR UPDATE, which locks the CI until a REWRITE, UNLOCK and (in your case) a DELETE is issued.
You could wind up with file-integrity issues.
I learned this a long time ago.
HTH.... |
|
Back to top |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
Because 1605-020-NOTFND is a 'SECTION'. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Ah, another case where mixing SECTIONs and paragraphs is dangerous. RahulG31 is saying that SECTIONs end only where the next SECTION begins or end of source code. |
|
Back to top |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
Thanks Terry!
I was just answering Sumit on this:
Quote: |
I expect the control back to the initial perform on TOP while surprisingly it is going to next sentence which is 1700* para in this case. |
So, it's not a surprise. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
That looks like a good old tangle.
Have a look at what is generated by your CICS precompiler or the inline compiler. You'll find a GO TO. If you GO TO out of the range of a PERFORM, you're lost.
Your indentation is shot. Your nested-IF is "interesting" with the repetition of conditions.
I think you should take a step back and do some restructuring. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
And show the definition of WS-PARTIAL-RECORD-KEY, please. |
|
Back to top |
|
|
thesumitk
Active User
Joined: 24 May 2013 Posts: 156 Location: INDIA
|
|
|
|
Thanks for The Reply Bill,
My Scenario is like below
1- I have to read a VSAM file for the given values on the screen
The Key for VSAM is first 54 Character but I have to identify the record on behalf of first 15 character and then replace characters starting from 6th to 15th position and write them again in to the file (with all other values in the record).. SO Duplicate the record by changing the values of position 6th to 15
2- Write the records with replaced value form 6th to 15th position and then delete the original records read from the file by matching the partial(first 15 character) key.
so When I tried them to delete after read with update option then I got an error ( I forgot but that said something about to lock the record) , Hence I opted for option like below
a)- Read all the record requested , take them in to a buffer change the record as required and move in to the next buffer , Now write the file from this next(changed) buffer.
B)- Delete the records by using the original buffer .
so the scenario I mentioned is coming in this approach. The control goes to the next sentence instead of the loop I am performing.
Hope I am clear else Please let me know fro any questions.
Sumit |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3053 Location: NYC,USA
|
|
|
|
Why don't you use RESP instead of HANDLE?
Code: |
HANDLE CONDITION / IGNORE CONDITION / HANDLE ABEND are all extremely old CICS commands; use of the RESP option has been recommended by IBM for many years. The old commands perform implied GO TO statements within the language being used while RESP conditions can be checked immediately after the CICS command execution so no GO TO logic is used. There have been some APARs issued for problems between Language Environment and HANDLE CONDITION (etc) commands; since modern compilers are all LE-compliant, that provides another reason to stay away from HANDLE CONDITION and the others. |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Code: |
PERFORM 1605-010-DELETE-MCS
VARYING WS-SCRIPT FROM +1 BY +1
UNTIL WS-STOP-DELETE = 'Y' OR
WS-SCRIPT > WS-MAX-CNT
1605-010-DELETE-MCS.
MOVE WS-D1MIOI(WS-SCRIPT) TO WS-MIO-CAT
IF WS-D1MIOI(WS-SCRIPT) NOT EQUAL SPACE AND
(WS-MIO-LOANS OR WS-MIO-SMALL-BUS OR WS-MIO-OVER-DRAFT)
IF WS-MIO-LOANS OR WS-MIO-SMALL-BUS
IF WS-MIO-LOANS
MOVE 'RMSMCS' TO WS-DATASET-NAME
MOVE SPACES TO MCS-KEY
MOVE WS-D1MIOI(WS-SCRIPT) TO WS-LEND-LEVEL
MOVE WS-MCS-FILE-DM-HDR TO WS-FILE-CD
MOVE WS-D1ODMI(WS-SCRIPT) TO WS-DM-TBL-NAME
PERFORM 1602-040-DELETE-MCS THRU 1602-DEL-EXIT
MOVE WS-D1MIOI(WS-SCRIPT) TO WS-LEND-LEVEL
MOVE WS-MCS-FILE-DM-DET TO WS-FILE-CD
MOVE WS-D1ODMI(WS-SCRIPT) TO WS-DM-TBL-NAME
PERFORM 1602-040-DELETE-MCS THRU 1602-DEL-EXIT
VARYING WS-SUB FROM WS-ONE BY WS-ONE
UNTIL WS-STOP-DELETE-MCS = 'Y' . |
That's your code as you have shown us.
The IF part is the equivalent of this:
Code: |
IF ( WS-D1MIOI ( WS-SCRIPT )
NOT EQUAL SPACE )
AND ( WS-MIO-LOANS ) |
Code: |
MOVE 'RMSMCS' TO WS-DATASET-NAME
MOVE SPACES TO MCS-KEY
MOVE WS-D1MIOI ( WS-SCRIPT )
TO WS-LEND-LEVEL
MOVE WS-MCS-FILE-DM-HDR TO WS-FILE-CD
MOVE WS-D1ODMI ( WS-SCRIPT )
TO WS-DM-TBL-NAME
PERFORM 1602-040-DELETE-MCS THRU 1602-DEL-EXIT
MOVE WS-D1MIOI ( WS-SCRIPT )
TO WS-LEND-LEVEL
MOVE WS-MCS-FILE-DM-DET TO WS-FILE-CD
MOVE WS-D1ODMI( WS-SCRIPT )
TO WS-DM-TBL-NAME
PERFORM 1602-040-DELETE-MCS THRU 1602-DEL-EXIT
VARYING WS-SUB FROM WS-ONE BY WS-ONE
UNTIL WS-STOP-DELETE-MCS = 'Y'
. |
Not that's a bit tidier, can remove some duplication:
Code: |
MOVE 'RMSMCS' TO WS-DATASET-NAME
MOVE SPACES TO MCS-KEY
MOVE WS-D1MIOI ( WS-SCRIPT )
TO WS-LEND-LEVEL
MOVE WS-MCS-FILE-DM-HDR TO WS-FILE-CD
MOVE WS-D1ODMI ( WS-SCRIPT )
TO WS-DM-TBL-NAME
PERFORM 1602-040-DELETE-MCS THRU 1602-DEL-EXIT
MOVE WS-MCS-FILE-DM-DET TO WS-FILE-CD
PERFORM 1602-040-DELETE-MCS THRU 1602-DEL-EXIT
VARYING WS-SUB FROM WS-ONE BY WS-ONE
UNTIL WS-STOP-DELETE-MCS = 'Y'
. |
Given that 1602-040-DELETE-MCS does not change any data, there is no real point in the FROM 1 BY 1.
Code: |
PERFORM 1602-040-DELETE-MCS THRU 1602-DEL-EXIT |
Then we have this:
Code: |
PERFORM 1605-010-DELETE-MCS
VARYING WS-SCRIPT FROM +1 BY +1
UNTIL WS-STOP-DELETE = 'Y' OR
WS-SCRIPT > WS-MAX-CNT |
So what is WS-STOP-DELETE? It doesn't get set anywhere. There should be some count of how many you actually need to do.
Use RESP has Rohit has suggested. That's a much cleaner way to do it.
Sort out all of these things. Why have a big block of code under an IF? Why not PERFORM something? Why not use 88s instead of testing for literals? Etc.
Changing the SECTION wasn't going to solve that problem, as you were still using the GO TO (in HANDLE) to leave the range of a PERFORM. It is just very poor practice to put a SECTION in an otherwise SECTION-free PROCEDURE DIVISION. |
|
Back to top |
|
|
thesumitk
Active User
Joined: 24 May 2013 Posts: 156 Location: INDIA
|
|
|
|
Thank you So Much Bill and Rahul for your responses .. I have changed the code accordingly and using resp option did work and everything is working fine now ..
Bill: I changed the IF condition also as per your suggestions, Thanks Much for the advice .
Thanks you All !!
Regards
Sumit Chaturvedi |
|
Back to top |
|
|
|