Cobol programming standards pdf


















The following commands can be used : Col. When dynamic subprogram calls are present, the sub-programs are loaded at execution time. SUBRTNS Suppose an alphanumeric field that contains a number which is left-justified and padded with trailing blanks needs to be converted to a true numeric field i.

This will allow the JCL to supply the block size. This can produce apparently puzzling results. PIC clause has to be coded from column no. Common paragraphs should start from numbers between to Try to avoid use of negative logic in the IF statements.

Open navigation menu. Close suggestions Search Search. User Settings. Skip carousel. Carousel Previous. Carousel Next. What is Scribd? Explore Ebooks. Bestsellers Editors' Picks All Ebooks. Explore Audiobooks. Bestsellers Editors' Picks All audiobooks. Explore Magazines. Editors' Picks All magazines. Explore Podcasts All podcasts. Difficulty Beginner Intermediate Advanced.

Explore Documents. Cobol Programming Standards. Uploaded by sati Did you find this document useful? Is this content inappropriate? Report this Document. Flag for inappropriate content. Download now. Related titles. Carousel Previous Carousel Next. Jump to Page. Search inside document. These numbers should be Conventions incremented appropriately to allow provision for a new paragraph between two consecutive paragraphs the descriptive name should indicate the function of the process the number and descriptive name should be separated by a dash - the numbers should reflect the top-down, left-to-right relationships of the programs structure i.

Condition Names switches have the same name as the data item they are linked to, except for SW as the prefix. Paragraph No. PIC S9 05 COMP-3 Levels should not be used because a future compiler will not recognize them When a level data item has been copied from a library using the COPY statement , fields that are part of that level cannot be referred without referring to the level. There are several requirements that one can desire from the code; the minimum Desirable Characteristics expected of the code is that it must deliver the functionality stated in its specifications, consistently, efficiently and reliably, and be easily maintainable especially by somebody other than the author.

Indentation and Alignment Paragraph names should begin in column 8. This makes the program easy to understand and modify enhancing cohesion of the program - Tricks or clever code that is not readily apparent should be avoided. IF As explained earlier, nesting several levels anything more than 3 or 4 levels of IF statements should be avoided Whenever possible, negative logic should be avoided; it makes the program difficult to read, and also can result in errors If multiple tests are done in an IF, parentheses and new lines should be liberally used to help enhance readability.

Code to display the PCB Fields can be copied in. Gabriella Feraru. Mark Hiro Nakagawa. Ronald James Condino Reil. Meera Devi. Kalsum Fournier. Viviana Heredia. Ne Bosh. Gheorghe Holtea. Daniel Turner. Lutf Saeed. Fayyaz Ahmad. Simile Rhino Mhlanga. More From sati Subbu Nandigama. Popular in Computer. Irina Duma. Graceann Gocalin. Hammad Ashraf. If it does become necessary to use a separate indicator then please follow these simple guidelines Control can be passed from one point in a program to another by means of the following statements:.

These guidelines are extremely flexible, but without additional guidelines the resulting code can be as manageable as a plate of limp spaghetti - please read on for your elucidation and edification. It is common practice in modern programming to split the code into logical sections or modules.

It is usual to plan the structure of a program at the design stage before writing any code, in order to produce a structure similar to that shown in Figure Each box represents a separate module, and where two boxes are joined together it indicates that the box at the lower level is PERFORMed by the box at the higher level.

In this particular example it shows that module Q can only be processed by passing control through modules A, D, J, O to Q. It is possible for any module to be called from more than one higher- level module, and this should be indicated on the chart. If you have a low-level module which can be called from numerous places eg: an error routine it is permissible to leave it out of the chart completely, as it does nothing but complicate the overall picture.

It should be emphasised that only generalised routines which are common to ALL programs should be regarded as transparent - those which perform a function peculiar to individual programs must appear on the module hierarchy. It is common practice to give each module some sort of mnemonic to denote its position in the module hierarchy, both horizontal and vertical. In the example given in section 5. It is common sense when coding the procedure division to place the sections in mnemonic sequence - this makes it easier to find your way through the listing.

In method b this means that each leg within the program structure forms a contiguous block, whereas in method a the same sections are spread out all over the place.

This is shown more clearly in Figure Using method b it is possible to increase or decrease the number of sections in a particular processing leg without having to rename any other sections in order to maintain the naming sequence.

Another advantage of method b is that when a program becomes too large for a single unit and needs to be segmented or split into subprograms it is easy to identify which modules are logically related and therefore eligible for separation. Compare those modules marked above in method b with the corresponding modules from method a.

In a large, complex program with many modules method b may produce mnemonics which are large and cumbersome - how can this be overcome? Common sense to the rescue - identify a sub-function with a large number of modules and start naming them using a different letter from the alphabet, as shown in Figure For a sorted report which has a large number of control breaks it is acceptable to introduce a number into the mnemonic, and to increment this number for each lower level instead of increasing the length of the mnemonic by adding another character.

This would produce a structure chart something like the one in Figure With this method all the processing for a particular sort level would be held in contiguous sections as the sequence would be as follows Some standards have a rule that if a section has more than one parent ie: can be called from more than one section at a higher level then it should be allocated a prefix which represents a general-purpose routine, usually at the bottom end of the alphabet eg: X, Y or Z.

This is fine if it is a small section with limited processing, but what if it is just the start of a significant piece of coding? Take the following example - A database is comprised of customers who are grouped into countries, which in turn are grouped into regions.

A program processes the details for customers at the end of each month, but the selection criteria can be one of the following:. Notice that the selection processing is handled by modules which have the "C" prefix, while the actual customer processing regardless of the selection method has a separate prefix.

This makes tracing your way through the source code a lot easier, which is more important than conforming to inflexible rules with their artificial restraints. This is where a lot of uneducated programmers come unstuck! There are some basic guidelines which can be applied in order to make the code more readable and easier to maintain. These are:. This example, however, is rapidly approaching the stage at which it becomes too unwieldy to be maintainable.

Don't be afraid to split a complex condition into its component parts, even if it involves the use of the GO TO statement. Don't try to prove how clever you can be - keep it simple and straightforward. This guideline then avoids the possibility that someone may split the paragraph in two, thereby causing the PERFORM to terminate at the new paragraph name.

As there is usually nothing but comments between the section name and the next paragraph it means that no code will actually be executed by that PERFORM statement. This usually causes lots of confusion. This means that the program will go where it thinks it should go, which is probably NOT where it is supposed to go. If you need to change the processing sequence due to a certain condition, then use an alternative set of PERFORM or GO TO statements - trying to debug a program where the instruction as it appears in the listing may not be the actual instruction encountered by the program at run time is a very frustrating experience.

This may seem to be an economical way of writing source code as this single statement will represent several actual MOVE 's. However, in the event of an error caused by an illegal ASCII digit or similar the diagnostic trace will not be able to identify which elementary item within the group of items actually generated the fault, which means that it will take longer to identify and solve the problem.

Be aware that the number of decimal places used in evaluating an arithmetic expression is determined by the maximum number of decimal places within the expression. This has implications when doing any divisions, especially when calculating percentages which have an implied division by For example, to apply a rate of If none of the items within the calculation has at least 4 decimal places then the intermediate result from a above will not be accurate, whereas method b avoids this problem by ensuring that the result of the division is stored in a field which has the correct number of decimal places.

It has always been the standard within Hewlett-Packard's block-mode screen processing that the user either presses the ENTER key to process the current screen of data, or presses one of the other function keys to do something else.

Method a may be the fastest, but it requires the most memory as the data requirements of the input, sort and output procedures are all made available at the same time, which can sometimes cause a stack overflow. This construct should therefore be avoided.

Method b ensures that the input procedure used to extract data onto an intermediate file is completed before the sort is commenced, and that the sort is completed before the output procedure which processes the sorted file is commenced. This is slightly slower than method a , but reduces the risk of a stack overflow. Method c is a further improvement on method b insofar as each of the procedures is a separate program.

This is useful if either of the input or output procedures is especially complex as the code is kept entirely separate. If an error occurs then any of the later steps can be rerun without having to reprocess all the earlier steps. If different options are required in the output procedure then they should be provided in separate programs rather than additional and optional code within a single program.

Problems can occur with print files if they are not defined correctly within the environment division of a COBOL program. An example of the correct definition is as follows This has been known to cause the client great confusion when he streams a job and the expected print file does not appear.

The way out of this predicament is to amend the jobstream s to include a file equate which changes the file's characteristics from a temporary disk file to a spool file. A division is a block of code, which usually contains one or more sections. It starts where the division name is encountered.

It ends with the beginning of the next division. Paragraphs are the portion of a selection which is a user-defined or predefined name which should be followed by a period. This section includes zero or more sentences. Sentences are a combination of single or multiple statements. They should occur only in the procedure division. In COBOL variable is a named location in memory into which a program can put data and from which it can retrieve data.

A data-name or identity. It is the name used to identify the area of memory that is reserved for the variable. Variables must be described in terms of their size and type. To check an alpha number variable for what type of data it holds, we can use if x is number, if x is alphabetic, conditions.



0コメント

  • 1000 / 1000