‘No Layouts Found’ issue when program run as background job
After several months of crazy time for one tight-schedule project, finally can take a break in the next few days. Start working on regularly and issues keep coming as usual. One customized program can run successfully in the front end but keeps getting the error of ‘No layouts found’ (Message no. 0K017) when set up as a background job.
Find one similar question that provides some tips:
it was because originally when the background job was created user has defined the layout as user-specific. This has made the background job to fail as it was run by a non-personel user id.
1. The root of ‘No Layouts Found’
However, the above answer seems not to work for my case as my layout is not a user-specific one. After debugging with JBDG, the root of this error message comes from the standard program when the system tries to load the variant:
The key function module to fetch the variant is ‘LT_VARIANT_LOAD’ which will call the routine ‘LT_VARIANTS_READ_FROM_LTDX’:
The layout which has no layout found against it is coming from the LTDXD table:
- LTDX is for Generic storage of display variants;
- LTDXD is for Default display variants
Check the entry inside the internal table ‘lt_variants’, I found out the error entry for this layout is from:
The issue is not from the customized program at all, but from the program RM07MLBS(mapping to TCODE: MB52) submitted by this Z program. Be aware of USERNAME here when fetching entry, the filter is current user name or blank only.
2. Display options for MB52
Have to check the layout variant for MB52 which has two options: hierarchical one and non-hierarchical one.
The default layout here is populating automatically inside RM07MLBS which will call FM ‘LT_VARIANT_LOAD‘ as well.
So the question till now is why ‘LT_VARIANT_LOAD’ fetches one entry that does not exist and how to fix this?
After comparing with other entries and finding out the difference:
- Some layout has been created but with FLAT as HANDLE which will be used for non-hierarchical instead of hierarchical one.
- if no layout has been created with the current user, a blank user name will be used to fetch with the default flag.
The key here is to make sure one default layout is available for background job use with the correct HANDLE. Actually, it should be there but somehow it’s been deleted for my case. To fix this issue:
- Delete or recreate this missing variant /SHAHND for MB52 which is not available in the system;
- Set up one variant and hardcode as inputs when submitting RM07MLBS inside this Z Program will do.