Hi Deepak,
See program RVSETDAT and variable RV_ACTUAL_MONTH.
1) Create variable RV_ACTUAL_MONTH in STVARV
2) Update variable with previous month value
3) Execute your program or background job
4) Execute a monthly job on last day of month for program RVSETDAT. This will update your variable with current period.
If this does not works, create a Z program based on RVSETDAT logic, with Z variable.
Best regards!