If you need to concatenate GDG generations in JCL, Mainframe developers have a straightforward way to reference all datasets within a Generation Data Group at once. However, it is critical to know exactly which generation the system reads first when you specify a GDG base as input. Because of this tricky nature, it is also one of the most common, tricky mainframe interview questions.
To control the processing sequence, IBM introduces the GDGORDER keyword. By default, the system catalog entry specifies LIFO (Last In, First Out).
In this tutorial, we will execute a JCL job using IEBGENER to process these multiple generations and demonstrate how to change the processing sequence to FIFO (First In, First Out).
Concatenate GDG Generations in JCL Using LIFO Order(Default)
When you reference a GDG base without any specific keywords, the system defaults to LIFO. This means the newest generation is read first, followed sequentially by older versions.
To see this in action, we can use an IEBGENER step to print the output to SYSUT2 in the spool.
Important Pro Tip: You must use MSGLEVEL=(1,1) in your JOB card. This ensures the system prints all allocation and termination messages. Without it, you will not be able to verify the exact order of the GDG versions used in JESYSMSG.

When you check the JESYSMSG output for a default run, the system allocation shows the sequence XX91V00 to XX87V00.
As evident in the log messages, the sequence goes from New to Old (LIFO).

Concatenate GDG Generations in JCL Using FIFO Order
The same Job with the keyword GDGORDER=FIFO will reverse the order of concatenation of the GDG versions.

The output shows the following, ie the order of concatenation is Old to New, FIFO

Best Practices for Successful GDG Concatenation
Understanding how to control GDG concatenation order ensures your batch programs process sequential historical data in the correct chronological order. Whether you rely on the default LIFO behavior or override it with GDGORDER=FIFO, always check your JESYSMSG with MSGLEVEL=(1,1) to verify the execution.
Hope this helps!