Previous Topic Next topic Print topic


Program structure for example 1

The following tables show COBOL statements that relate to performing XML Extensions statements. Some COBOL statements (mostly the DISPLAY statements) have been omitted. The source of this example is in the file, example01.cbl.

Initialization

COBOL Statement

Description

XML INITIALIZE.

Execute the XML INITIALIZE statement (no parameters).

If Not XML-OK Go To Z.

If the statement terminates unsuccessfully, go to the termination logic.

Exporting an XML Document

COBOL Statement

Description

Move … To Time-Stamp.

Populate the Time-Stamp field.

XML EXPORT FILE Address-Struct 
             "address01.xml" "Address-Struct".

Execute the XML EXPORT FILE statement specifying: the data item address, the XML document filename, and the ModelFileName#DataFileName parameter value.

If Not XML-OK Go To Z.

If the statement terminates unsuccessfully, go to the termination logic.

Importing an XML Document

COBOL Statement

Description

Initialize Address-Struct.

Ensure that the Address-Struct item contains no data.

XML IMPORT FILE Address-Struct 
             "address01.xml" "Address-Struct".

Execute the XML IMPORT FILE statement specifying: the data item address, the XML document filename, and the ModelFileName#DataFileName parameter value.

If Not XML-OK Go To Z.

If the statement terminates unsuccessfully, go to the termination logic.

Program Exit Logic

COBOL Statement

Description

Z.

Paragraph-name that is a target of error condition GO TO statements.

Copy "lixmltrm.cpy".

Copy in the termination test logic (see the Termination Test Logic table).

Stop Run.

Terminate the COBOL program.

Copy "lixmldsp.cpy".
Copy in the status display logic (see the Status Display Logic table).

Termination Test Logic

This code is found in the copybook, lixmltrm.cpy.

This code occurs after the paragraph named Z, so that any error condition is obtained here via a GO TO Z statement. If there are no errors, execution "falls through" to these statements.

COBOL Statement

Description

Display "Status: " XML-Status.

Display the most recent return status value (if there are no errors, this should display zero).

Perform Display-Status.

Perform the Display-Status paragraph to display any error messages.

XML TERMINATE.

Terminate the XML interface.

Perform Display-Status.

Perform the Display-Status paragraph again to display any error encountered by the XML TERMINATE statement.

Status Display Logic

This code is found in the copybook, lixmldsp.cpy.

This code is called twice by the termination test logic: the first time to report any error condition that exists, and the second time to report an error (if one occurs) from the XML TERMINATE statement. If there are no errors (the condition XML-IsSuccess is true), this paragraph displays no information.

COBOL Statement

Description

Display-Status.

This is the paragraph-name.

If Not XML-IsSuccess

Do nothing if XML-IsSuccess is true.

Perform With Test After Until XML-NoMore  

Perform as long as there are status lines available to be displayed (until XML-NoMore is true).

XML GET STATUS-TEXT

Get the next line of status information from the XML interface.

Display XML-StatusText 				  

Display the line that was just obtained.

End-Perform  

End of the perform loop.

End-If.

End of the IF statement and the paragraph.

Previous Topic Next topic Print topic