View previous topic :: View next topic
|
Author |
Message |
sandeep kumar302
New User
Joined: 14 Mar 2012 Posts: 81 Location: India
|
|
|
|
Hi,
I am creating a new program where i am using the 88 level to define many values for valid type business.
The valid Type Business (TB) are - 12, 41, 47, 48, 49 and 50.
Since i don't want to test the entire program and i know that the program is working fine as expected but only the 88 level variable logic is not working, so i just took the logic of 88 level variable and tried to test it. The modified small program to test it is below-
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. TESTNFL3.
AUTHOR. SANCTS.
DATE-WRITTEN. JUL 21, 2014.
******************************************************************
* DUMMY PROGRAM TO TEST THE CHANGED PORTION OF THE PROGRAM
******************************************************************
** **
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
*SOURCE-COMPUTER. IBM-370 WITH DEBUGGING MODE.
SOURCE-COMPUTER. IBM-370.
OBJECT-COMPUTER. IBM-370.
INPUT-OUTPUT SECTION.
*
FILE-CONTROL.
*
DATA DIVISION.
FILE SECTION.
******************************************************************
** BEGINNING OF WORKING-STORAGE SECTION **
******************************************************************
WORKING-STORAGE SECTION.
00156 01 WS-VARIABLES.
9412 05 WS-CA-PERISH-TB PIC 9(02).
9412 88 WS-CAPERISH-TBS VALUES 12 41 47 48 49 50.
05 WS-TB-IC-D-PK.
10 WS-ITEM-PARTIAL.
15 WS-TYPE-BUSINESS PIC 9(02) VALUE ZERO.
15 WS-ITEM-CD PIC 9(05) VALUE ZERO.
15 WS-DEAL PIC 9(01) VALUE ZERO.
******************************************************************
** BEGINNING OF PROCEDURE DIVISION **
******************************************************************
PROCEDURE DIVISION.
* INITIALIZE WS-CA-PERISH-TB
ACCEPT WS-TYPE-BUSINESS FROM SYSIN
DISPLAY 'INSIDE PROCEDURE DIV.'.
*
0000-MAIN-PARA.
*------------------*
DISPLAY 'INSIDE MAIN-PARA.'.
PERFORM 100-TEST-CA-PER-TB-PARA THRU
100-TEST-CA-PER-TB-PARA-EXIT.
STOP RUN.
0000-MAIN-PARA-EXIT.
*----------------------*
EXIT.
100-TEST-CA-PER-TB-PARA.
*-------------------------------*
DISPLAY '100-TEST-CA-PER-TB-PARA.'.
* MOVE 12 TO WS-TYPE-BUSINESS
9412 DISPLAY 'WS-CA-PERISH-TB BEF: ' WS-CA-PERISH-TB
9412 DISPLAY 'WS-TYPE-BUSINESS BEF: ' WS-TYPE-BUSINESS
9412 IF WS-TYPE-BUSINESS = WS-CA-PERISH-TB
9412 DISPLAY 'TESTING TB12: '
9412 DISPLAY 'WS-CA-PERISH-TB: ' WS-CA-PERISH-TB
9412 DISPLAY 'WS-TYPE-BUSINESS: ' WS-TYPE-BUSINESS
* MOVE 41 TO WS-TYPE-BUSINESS
9412 IF WS-TYPE-BUSINESS = WS-CA-PERISH-TB
9412 DISPLAY 'TESTING TB41: '
9412 DISPLAY 'WS-CA-PERISH-TB: ' WS-CA-PERISH-TB
9412 DISPLAY 'WS-TYPE-BUSINESS: ' WS-TYPE-BUSINESS
* MOVE 47 TO WS-TYPE-BUSINESS
9412 IF WS-TYPE-BUSINESS = WS-CA-PERISH-TB
9412 DISPLAY 'TESTING TB47: '
9412 DISPLAY 'WS-CA-PERISH-TB: ' WS-CA-PERISH-TB
9412 DISPLAY 'WS-TYPE-BUSINESS: ' WS-TYPE-BUSINESS
* MOVE 48 TO WS-TYPE-BUSINESS
9412 IF WS-TYPE-BUSINESS = WS-CA-PERISH-TB
9412 DISPLAY 'TESTING TB48: '
9412 DISPLAY 'WS-CA-PERISH-TB: ' WS-CA-PERISH-TB
9412 DISPLAY 'WS-TYPE-BUSINESS: ' WS-TYPE-BUSINESS
* MOVE 49 TO WS-TYPE-BUSINESS
9412 IF WS-TYPE-BUSINESS = WS-CA-PERISH-TB
9412 DISPLAY 'TESTING TB49: '
9412 DISPLAY 'WS-CA-PERISH-TB: ' WS-CA-PERISH-TB
9412 DISPLAY 'WS-TYPE-BUSINESS: ' WS-TYPE-BUSINESS
* MOVE 50 TO WS-TYPE-BUSINESS
9412 IF WS-TYPE-BUSINESS = WS-CA-PERISH-TB
9412 DISPLAY 'TESTING TB50: '
9412 DISPLAY 'WS-CA-PERISH-TB: ' WS-CA-PERISH-TB
9412 DISPLAY 'WS-TYPE-BUSINESS: ' WS-TYPE-BUSINESS
.
100-TEST-CA-PER-TB-PARA-EXIT.
*-----------------------------------*
EXIT.
|
I am passing the value 12 from SYSIN of the JCL and since 12 is a valid value, the program sould go to 100-TEST-CA-PER-TB-PARA and
the values:
TESTING TB12:
WS-CA-PERISH-TB: 12
WS-TYPE-BUSINESS: 12
should be displayed
but when i am running the program, WS-CA-PERISH-TB is either spaces(if unitialized) or 0( if initillized).
Can someone please help me how i can set the valid values for WS-CA-PERISH-TB.
Also, please help me on acheiving this without 88 level variable also.
Please help me on both the cases, one with 88 level and one without 88 level variable used.
thanks |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You cannot test a program by taking parts out and testing those parts in isolation.
You might not want to test the program, but you have to. You might think you know that it is working, but from the code you've shown the chance of it working is zero.
You have no clue of how an 88 works, do you? I thought it was just a naming problem in the title, but you do seem to believe that an 88 is some type of magical variable which holds several values in a space where only one can be held.
That's not how it works. Read the Enterprise COBOL Language Reference and Programming Guide and come back if you have problems in understanding. At the moment you have simply made no attempt at understanding it yourself. |
|
Back to top |
|
|
sandeep kumar302
New User
Joined: 14 Mar 2012 Posts: 81 Location: India
|
|
|
|
Hi Bill,
Thanks for your reply.
The program before the addition of 88 level logic is working fine and that is already tested. The changed part only needs to be tested as told to me as requirement. We don't have the sufficient data to test the entire program.
since i am not setting the variable or not moving any value to it so its not working and its taking junk values.
Now it is working fine. modified code is-
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. TESTNFL3.
AUTHOR. SANCTS.
DATE-WRITTEN. JUL 21, 2014.
******************************************************************
* DUMMY PROGRAM TO TEST THE CHANGED PORTION OF THE PROGRAM
******************************************************************
** **
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
*SOURCE-COMPUTER. IBM-370 WITH DEBUGGING MODE.
SOURCE-COMPUTER. IBM-370.
OBJECT-COMPUTER. IBM-370.
INPUT-OUTPUT SECTION.
*
FILE-CONTROL.
*
DATA DIVISION.
FILE SECTION.
******************************************************************
** BEGINNING OF WORKING-STORAGE SECTION **
******************************************************************
WORKING-STORAGE SECTION.
00156 01 WS-VARIABLES.
9412 05 WS-CA-PERISH-TB PIC 9(02).
9412 88 WS-CAPERISH-TBS VALUES 12 41 47 48 49 50.
05 WS-TB-IC-D-PK.
10 WS-ITEM-PARTIAL.
15 WS-TYPE-BUSINESS PIC 9(02) VALUE ZERO.
15 WS-ITEM-CD PIC 9(05) VALUE ZERO.
15 WS-DEAL PIC 9(01) VALUE ZERO.
******************************************************************
** BEGINNING OF PROCEDURE DIVISION **
******************************************************************
PROCEDURE DIVISION.
* INITIALIZE WS-CA-PERISH-TB
ACCEPT WS-TYPE-BUSINESS FROM SYSIN
DISPLAY 'INSIDE PROCEDURE DIV.'.
*
0000-MAIN-PARA.
*------------------*
DISPLAY 'INSIDE MAIN-PARA.'.
PERFORM 100-TEST-CA-PER-TB-PARA THRU
100-TEST-CA-PER-TB-PARA-EXIT.
STOP RUN.
0000-MAIN-PARA-EXIT.
*----------------------*
EXIT.
100-TEST-CA-PER-TB-PARA.
*-------------------------------*
DISPLAY '100-TEST-CA-PER-TB-PARA.'.
* MOVE 12 TO WS-TYPE-BUSINESS
MOVE WS-TYPE-BUSINESS TO WS-CA-PERISH-TB
9412 DISPLAY 'WS-CA-PERISH-TB BEF: ' WS-CA-PERISH-TB
9412 DISPLAY 'WS-TYPE-BUSINESS BEF: ' WS-TYPE-BUSINESS
9412 * IF WS-TYPE-BUSINESS = WS-CA-PERISH-TB
9412 IF WS-CAPERISH-TBS
9412 DISPLAY 'TESTING TB12: '
9412 DISPLAY 'WS-CA-PERISH-TB: ' WS-CA-PERISH-TB
9412 DISPLAY 'WS-TYPE-BUSINESS: ' WS-TYPE-BUSINESS
* MOVE 41 TO WS-TYPE-BUSINESS
9412 * IF WS-TYPE-BUSINESS = WS-CA-PERISH-TB
9412 IF WS-CAPERISH-TBS
9412 DISPLAY 'TESTING TB41: '
9412 DISPLAY 'WS-CA-PERISH-TB: ' WS-CA-PERISH-TB
9412 DISPLAY 'WS-TYPE-BUSINESS: ' WS-TYPE-BUSINESS
* MOVE 47 TO WS-TYPE-BUSINESS
9412 * IF WS-TYPE-BUSINESS = WS-CA-PERISH-TB
9412 IF WS-CAPERISH-TBS
9412 DISPLAY 'TESTING TB47: '
9412 DISPLAY 'WS-CA-PERISH-TB: ' WS-CA-PERISH-TB
9412 DISPLAY 'WS-TYPE-BUSINESS: ' WS-TYPE-BUSINESS
* MOVE 48 TO WS-TYPE-BUSINESS
9412 * IF WS-TYPE-BUSINESS = WS-CA-PERISH-TB
9412 IF WS-CAPERISH-TBS
9412 DISPLAY 'TESTING TB48: '
9412 DISPLAY 'WS-CA-PERISH-TB: ' WS-CA-PERISH-TB
9412 DISPLAY 'WS-TYPE-BUSINESS: ' WS-TYPE-BUSINESS
* MOVE 49 TO WS-TYPE-BUSINESS
9412 * IF WS-TYPE-BUSINESS = WS-CA-PERISH-TB
9412 IF WS-CAPERISH-TBS
9412 DISPLAY 'TESTING TB49: '
9412 DISPLAY 'WS-CA-PERISH-TB: ' WS-CA-PERISH-TB
9412 DISPLAY 'WS-TYPE-BUSINESS: ' WS-TYPE-BUSINESS
* MOVE 50 TO WS-TYPE-BUSINESS
9412 * IF WS-TYPE-BUSINESS = WS-CA-PERISH-TB
9412 IF WS-CAPERISH-TBS
9412 DISPLAY 'TESTING TB50: '
9412 DISPLAY 'WS-CA-PERISH-TB: ' WS-CA-PERISH-TB
9412 DISPLAY 'WS-TYPE-BUSINESS: ' WS-TYPE-BUSINESS
.
100-TEST-CA-PER-TB-PARA-EXIT.
*-----------------------------------*
EXIT.
|
|
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
Are you sure your program is working fine? Did you test it for all the values (12,41,47,48,49,50)? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
mistah kurtz,
If a person doesn't feel like testing a program, they pick a single value and if that one works, they move on:
Quote: |
I am passing the value 12 from SYSIN |
Unfortunately (for their systems/clients) 97.38% of the time they choose a value which works, either the only value, or one of the few values.
You are absolutely correct. The program is far from fine, even the little noddy program put together to "test" how 88s work. The chance that the actual, fine, program actually works (in any meaningful sense beyond finishing with a CC of zero) I still regard as very small on the evidence shown so far. The massive nested-IF, with no list of END-IFs in sight shows at best bad practice and and worst a failure to grasp what is occurring and how to deal with it.
Presumably we will soon receive another justification for this. One thing that winds me up is justifications for idiocies. Anyone notice that? |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
When you have this:
Code: |
9412 05 WS-CA-PERISH-TB PIC 9(02).
9412 88 WS-CAPERISH-TBS VALUES 12 41 47 48 49 50. |
and you do this:
Code: |
9412 IF WS-CAPERISH-TBS |
it is exactly as if you did this:
Code: |
9412 IF WS-CA-PERISH-TB = 12 OR 41 OR 47 OR 48 OR 49 OR 50 |
Return to your small program and check if you are really doing what you think you are doing.
Now, about this:
sandeep kumar302 wrote: |
i don't want to test the entire program |
I highly recommend to run the full tests and double check all the results!
(I also kindly recommend not to say this sentence out loud when you are in the office, somebody may hear you...) |
|
Back to top |
|
|
sandeep kumar302
New User
Joined: 14 Mar 2012 Posts: 81 Location: India
|
|
|
|
Hi Marso,
Yes, it is exactly doing
IF WS-CA-PERISH-TB = 12 OR 41 OR 47 OR 48 OR 49 OR 50
but i do not have to hard code it so i am following 88 level logic.
I have modified the JCL also where i am not passing 12 now.
The values are directly moved in the program.
Here is my output-
Code: |
INSIDE PROCEDURE DIV.
INSIDE MAIN-PARA.
100-TEST-CA-PER-TB-PARA.
WS-CA-PERISH-TB BEF: 12
WS-TYPE-BUSINESS BEF: 12
TESTING TB12:
WS-CA-PERISH-TB: 12
WS-TYPE-BUSINESS: 12
TESTING TB41:
WS-CA-PERISH-TB: 41
WS-TYPE-BUSINESS: 41
TESTING TB47:
WS-CA-PERISH-TB: 47
WS-TYPE-BUSINESS: 47
TESTING TB48:
WS-CA-PERISH-TB: 48
WS-TYPE-BUSINESS: 48
TESTING TB49:
WS-CA-PERISH-TB: 49
WS-TYPE-BUSINESS: 49
TESTING TB50:
WS-CA-PERISH-TB: 50
WS-TYPE-BUSINESS: 50
|
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
And you are MOVEing each value immediately before the code for that value. Do you feel that is testing? Try changing all your MOVEs, as they are now, to 49. All of them. Then show us the results. Happy? |
|
Back to top |
|
|
sandeep kumar302
New User
Joined: 14 Mar 2012 Posts: 81 Location: India
|
|
|
|
Hi Bill,
Thanks for the suggestions.
May be this is not the optimized way of testing.
But in actual program, could you please help me to code in a better way using 88 level clause.
Since i am still in my learning curve, it will be great if you can tell me the best way to achieve this. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Make the name of the 88 meaningful.
Test the 88, and PERFORM a procedure which deals with those types of things.
Within that procedure, deal with each item as is necessary:
Code: |
10 DELIVERY-TYPE PIC XX.
88 PERISHABLE-GOODS VALUE "10" "14" "20" "30" "80".
88 PERISHABLE-FRESH VALUE "10" "14".
88 PERISHABLE-CHILLED VALUE "20".
88 PERISHABLE-DEEP-FROZEN VALUE "30".
88 PERISHABLE-ON-SITE-SALES VALUE "80".
...
IF PERISHABLE-GOODS
PERFORM PRODUCE-PICK-FIRST-NOTES
END-IF
.
...
PRODUCE-PICK-FIRST-NOTES.
EVALUATE TRUE
WHEN PERISHABLE-FRESH
PERFORM some-meaningfully-named-procedure-1
WHEN PERISHABLE-CHILLED
PERFORM some-meaningfully-named-procedure-2
WHEN PERISHABLE-DEEP-FROZEN
PERFORM some-meaningfully-named-procedure-3
WHEN PERISHABLE-ON-SITE-SALES
PERFORM some-meaningfully-named-procedure-4
WHEN OTHER
abend, unclassified perishable
END-EVALUATE
.
some-meaningfully-named-procedure-1.
some-meaningfully-named-procedure-2.
some-meaningfully-named-procedure-3.
some-meaningfully-named-procedure-4.
|
|
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
@ sandeep kumar302
You think your small independent program that you have shown us here is working fine, but it's not.
The way you are using 88 level conditionals is wrong. Try it like this:
Code: |
9412 05 WS-CA-PERISH-TB PIC 9(02).
9412 88 WS-CAPERISH-TBS-12 VALUE 12.
9412 88 WS-CAPERISH-TBS-41 VALUE 41.
........................................
........................................
9412 MOVE WS-TYPE-BUSINESS TO WS-CA-PERISH-TB.
9412 IF WS-CAPERISH-TBS-12
9412 DISPLAY 'TESTING TB12: '
9412 DISPLAY 'WS-CA-PERISH-TB: ' WS-CA-PERISH-TB
9412 DISPLAY 'WS-TYPE-BUSINESS: ' WS-TYPE-BUSINESS
9412 END-IF
9412 IF WS-CAPERISH-TBS-41
9412 DISPLAY 'TESTING TB41: '
9412 DISPLAY 'WS-CA-PERISH-TB: ' WS-CA-PERISH-TB
9412 DISPLAY 'WS-TYPE-BUSINESS: ' WS-TYPE-BUSINESS
9412 END-IF
........................................
........................................
|
I would suggest use EVALUATE rather than so many nested IFs. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3051 Location: NYC,USA
|
|
|
|
Where did you
Code: |
set WS-CAPERISH-TBS to true |
? anyways I now see that you modified code ( from the second post of your's ) you have added
Code: |
MOVE WS-TYPE-BUSINESS TO WS-CA-PERISH-TB |
statement. So now it should work fine. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Rohit,
OP is getting data from a record. Why would they use SET?
Why do you think the program is now working? A literal is being coded immediately before each test. If the literal were coded before the group of tests, then any value which matched the 88 would be processed as though it were a "12". |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3051 Location: NYC,USA
|
|
|
|
OMG, I don't Know how did I miss that to watch. thanks.
TS exactly needs to change to what you or Mr.Kurtz has suggested. |
|
Back to top |
|
|
sandeep kumar302
New User
Joined: 14 Mar 2012 Posts: 81 Location: India
|
|
|
|
Hi Bill,
Thanks a lot for your suggestin and i do agree that the piece you gave is the optimized one and the time i started using this forum, i value your suggestion and eagerly waits for your comment on my questions.
Now, Let me again make my requirement clear so that i do not confuse you all-
Currently i have a list of programs which does the processing of items if the Type Business is equal to 12.
Now, the new requirement is like the program should do processing of items if the Type Business is equal to either 12,41,47,48,49 or 50.
If the Type Business is equal to any of these 6 values, the program will perform the same functionality.
Now, Please note that many times, the program is directly checking like below-
Code: |
IF WS-TYPE-BUSINESS = 12
NEXT SENTENCE
ELSE
...
...
|
Now, we can directly do hardcoding like:
Code: |
IF WS-TYPE-BUSINESS = 12 or 41 or 47 or 48 or 49 or 50
NEXT SENTENCE
ELSE
...
...
|
But our main aim is not to do hard coding. Now the new approach what we are follwing is:
We will create a new control file whose FD section will be like this:
Code: |
FD PERISH-TB-FILE
BLOCK CONTAINS 0 RECORDS
RECORDING MODE F.
01 WS-PERISH-TB-REC.
05 WS-PERISH-COMMENT PIC X(01).
05 WS-PERISH-TB PIC 9(02).
05 FILLER PIC X(77).
|
The SELECT clause will be like this:
Code: |
SELECT PERISH-TB-FILE ASSIGN TO RPPERISH
FILE STATUS IS WS-PERISH-FS.
|
The initialization is the logic to load the PERISHABLE TB into the internal array will be like below:
Code: |
INITIALIZE WS-PERISH-TB-TBL
OPEN INPUT PERISH-TB-FILE
IF WS-PERISH-OK
PERFORM UNTIL WS-PERISH-EOF
READ PERISH-TB-FILE
NOT AT END
IF WS-PERISH-COMMENT = SPACES
MOVE 'Y' TO WS-PERISH-TB-FLG(WS-PERISH-TB)
END-IF
END-READ
END-PERFORM
END-IF
CLOSE PERISH-TB-FILE
|
Working storage variable will be like below-
Code: |
01 WS-PERISH-FIELDS.
05 WS-PERISH-FS PIC X(02) VALUE SPACES.
88 WS-PERISH-OK VALUE '00'.
88 WS-PERISH-EOF VALUE '10'.
05 WS-PERISH-TB-TBL.
10 WS-PERISH-TB-DATA OCCURS 99 TIMES.
15 WS-PERISH-TB-FLG PIC X(01) VALUE SPACES.
|
Now, our program will read the control file
(which will contain the Type business as:
12, 41, 47, 48, 49 and 50 in the above given format).
Now, instead of:
Code: |
IF WS-TYPE-BUSINESS = 12
NEXT SENTENCE
ELSE
...
...
|
We will get use the flag from control file like below:
Code: |
IF WS-PERISH-TB-FLG(WS-TYPE-BUSINESS) = 'Y'
NEXT SENTENCE
ELSE
...
...
|
Please share your thoughts on this and please guide me if this is a good approach or not.
We have almost finalized this approach. Please tell me if this approach is good or not?
Please guide me if i am doing anything wrong here or any bug is present. Please guide me if the new program will take care of all the new Type business or not.After 1 day, 1 will receive the actual test file with which i will test the full program including the new changes.
Thanks. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3051 Location: NYC,USA
|
|
|
|
I did not get
Code: |
IF WS-PERISH-TB-FLG(WS-TYPE-BUSINESS) = 'Y' |
condition. This can never be equals to "Y" unless you make that occurance populated.
However, if you are getting 2 bytes value in WS-PERISH-TB variable then follow exactly the same approach as Bill suggested, like
Code: |
10 DELIVERY-TYPE PIC XX.
88 PERISHABLE-VALID VALUE '12' , '41' ,'47' , '48', '49', '50'.
.
.
.
MOVE WS-PERISH-TB TO DELIVERY-TYPE
Evaluate TRUE
WHEN PERISHABLE-VALID
then follow your current logic
WHEN OTHER
error out
End-Evaluate |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Rohit,
I think the plan has changed to now make the selection of what is to be processed "dynamic".
sandeep kumar302,
There is nothing essentially wrong with doing it how you describe, but there are some important things to consider: you have now extended the processing of the system beyond the code. That has benefits (reduced maintenance when things change) but you have to ensure that the benefits don't cloud the issues of security, auditability and suchlike.
How you implement it in the code is not as important as making sure you don't make it easy to mess the system up, and that you cover all legal issues. That file is effectively code, and has to be treated like code.
When your company/client produces their Accounts, your systems have to be audited (and auditable). You may also have other legal and compliance requirements. The file that you outline must comply with all of that.
I think you've probably still got quite a bit of work to do with people at your site, as I suspect this is something which has come out of Systems in isolation.
If this code is being used in multiple programs, consider a sub-program which returns an indication that "yes, it is one of these". The sub-program is then the only thing which needs to know about the file, so if the file changes, there's only one place you need to do it. It would not be a good idea to have multiple programs actually reading the file.
Don't use NEXT SENTENCE with END-IF/END-SEARCH/END-anything else. It is an accident waiting to happen. Use CONTINUE instead, if necessary, but what is wrong with IF .... PERFORM ...? |
|
Back to top |
|
|
sandeep kumar302
New User
Joined: 14 Mar 2012 Posts: 81 Location: India
|
|
|
|
Hi Bill/Rohit,
Thanks for your suggestions. Yes, the code will be used in multiple programs. Yes the plan got changed now
Bill,
Regarding this, could you please tell me in detail(logic)
Quote: |
If this code is being used in multiple programs, consider a sub-program which returns an indication that "yes, it is one of these". The sub-program is then the only thing which needs to know about the file, so if the file changes, there's only one place you need to do it. It would not be a good idea to have multiple programs actually reading the file.
|
Is it also possible to simply change something in my previous logic presented below to do everything for me without actually creating a subroutine?
Code: |
IF WS-PERISH-TB-FLG(WS-TYPE-BUSINESS) = 'Y'
NEXT SENTENCE
ELSE
|
If yes, can you please tell me what are the changes I have to do.
Also, I also don't like "NEXT SENTENCE" but this sentence is present in the old code and we are advised not to touch them unnecessarily. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Not touching old code is not the same as not applying the bad practice in old code to new code. If you are changing an IF, change the NEXT SENTENCE to CONTINUE.
The code you have outlined should work. It just means that everywhere you use it, you have to change the program to have the new file, load the table, and then use it. Then when you come to wanting to change something with it, you have 20 programs to change, instead of one sub-program. With one sub-program, you get the logic right in one place, and simply use the result in your program.
CALL the sub-program with an "open" and a "close". CALL the sub-program with a "do the stuff for me". Interrogate a value returned (say "Y").
The sub-program you can test in isolation, and then pretty much plug it into your however-many programs (which you then test).
Since you are getting the data from a file, I'd make the numeric value binary, I wouldn't call a one-byte field a "comment", but it may mean something specific to your application. I'd always test the FILE STATUS after a any IO, even in that PERFORM loop that you have. It is easier to pay more attention to the code in a sub-routine, and if you find you have performance problems with the look-up, you only have one place to fix it in.
I'd do a sub-program, as I know it'll save time in understanding, maintaining and all those types of things. Easier. |
|
Back to top |
|
|
madprasy
New User
Joined: 08 Apr 2008 Posts: 34 Location: Chennai
|
|
|
|
Rather...
You can store all the valid codes in ur lookup file and just check against WS-TYPE-BUSINESS . |
|
Back to top |
|
|
|