Main program

A main program is the program unit that receives control from the system when the executable program is invoked at run time.
Read syntax diagramSkip visual syntax diagram
>>-+-------------------+---------------------------------------><
   '-PROGRAM_statement-'   

Read syntax diagramSkip visual syntax diagram
>>-+--------------------+--------------------------------------><
   '-specification_part-'   

Read syntax diagramSkip visual syntax diagram
>>-+----------------+------------------------------------------><
   '-execution_part-'   

Read syntax diagramSkip visual syntax diagram
>>-+--------------------------+--------------------------------><
   '-internal_subprogram_part-'   

Read syntax diagramSkip visual syntax diagram
>>-END_PROGRAM_statement---------------------------------------><

PROGRAM_statement
See PROGRAM for syntax details
specification_part
is a sequence of statements from the statement groups numbered  2 ,  4 , and  5  in Order of statements and execution sequence
execution_part
is a sequence of statements from the statement groups numbered  4  and  6  in Order of statements and execution sequence, and which must begin with a statement from statement group  6 
internal_subprogram_part
See Internal procedures for details
END_PROGRAM_statement
See END for syntax details

A main program cannot contain an ENTRY statement, nor can it specify an automatic object.

IBM extension begins A RETURN statement can appear in a main program. The execution of a RETURN statement has the same effect as the execution of an END statement. IBM extension ends



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us