COBOL

FUNCTION

To introduce COBOL sentences directly into the generated program.

FORMAT

COBOL COBOL-text;

for example

COBOL UNSTRING w.in DELIMITED BY ALL W.SepC INTO W.AParts(1) W.AParts(2);

FUNCTION

The COBOL-text is inserted into the generated program at the point in the Procedure Division at which the COBOL statement appears. There is no provision to insert Identification, Environment or Data Division COBOL.  The keyword COBOL and the terminal semicolon are dropped: references are converted from their Jazz form to COBOL (e.g. w.in becomes JZ-in OF W ), other text is inserted into your COBOL program without change.  COBOL reserved words are recognised and coloured blue, but Jazz does not check that they are valid in this context, or that the resulting COBOL statement makes sense. 

 

WARNING:   COBOL is intended for relatively simple situations like UNSTRING and INSPECT.  It should only be used after all other alternatives have been considered and found wanting. It is very easy to interfere with the logic that Jazz generates, introducing errors into your program that Jazz can’t detect. If you’re lucky these errors will cause an immediate abend when the program runs and no real harm will be done, but you could end up updating or deleting records in ways that you didn’t intend. To use this feature you need to be an experienced COBOL programmer as well as an experienced Jazz programmer, and you should examine the COBOL code produced by Jazz before running it to ensure that it will produce the results that you want.  If you can, find a Jazz solution, or CALL a separately-written COBOL subprogram.

 

The COBOL-text is assumed to be a COBOL sentence. Within this text Jazz will look for, and substitute, references to fields and groups defined within the rest of the program.  For example, the example above generates this COBOL code: -

002230*    COBOL UNSTRING w.in DELIMITED BY ALL W.SepC INTO W.AParts(1) JZDTVS

002240*                                                     W.AParts(2);JZDTVS

002250     UNSTRING JZ-in OF W DELIMITED BY ALL SepC OF W INTO AParts   JZDTVS

002260         OF W(1) AParts OF W(2) .                                 JZDTVS

 

Jazz recognises that references like w.in are Jazz references simply because there is no valid COBOL syntax of

            Word Period Word

without intervening spaces. Jazz will therefore look up w.in and, if it finds it, it will replace this with the equivalent COBOL-form reference, JZ-in OF W.  As this example shows, you can use COBOL reserved words as Jazz item names, and when you refer to them in COBOL text from a Jazz-format reference Jazz prefixes the reference with JZ to make it valid.

 

If the reference cannot be found then there will be one or more messages produced by Jazz when the program is checked, and if COBOL generation is forced Jazz will insert the Jazz reference and a comment “** Not found **”.  For example with Jazz configured to generate COBOL even with S-level message,

COBOL UNSTRING w.xxx DELIMITED BY ALL W.SepC

#033 S w.xxx Field not found

    INTO W.AParts(1) W.AParts(2) W.AParts(3);

generates: -

002240*    COBOL UNSTRING w.xx DELIMITED BY ALL W.SepC                  JZDTVS

002250*    #033 S w.xx Field not found                                  JZDTVS

002260*    INTO W.AParts(1) W.AParts(2) W.AParts(3);                    JZDTVS

002270     UNSTRING w.xx ** Not found **  DELIMITED BY ALL SepC OF W    JZDTVS

002280         INTO AParts OF W(1) AParts OF W(2) AParts OF W(3) .      JZDTVS

 

Jazz performs no other analysis or checking of this text to ensure that it is valid COBOL, or that makes sense and is valid within its context. It is very easy to make errors:

 

1.        There is no check that the COBOL-text consists of one or more complete COBOL sentences.  Errors are not detected by Jazz, but left to the following COBOL compile step.

2.        You might refer directly to Jazz-generated COBOL variables (not using a reference like w.in). If you do, be especially careful that you don’t interfere with Jazz logic, and be aware that any such references will not be included in the Jazz data dictionary database.

3.        You have to be especially careful if you include periods in your text.  The code might be inserted within nested logic and you might not only be terminating your IF statement, but also a stack of nested IF statements that Jazz has generated that you didn’t realise were there.

 

Be careful: you’re on your own!   COBOL is provided for situations where statements like UNSTRING and INSPECT provide simpler solutions than Jazz, but do not use this statement to try to change the logic of a Jazz program.