Using the output of a Standard/Already Developed ALV report
So Recently, in one of my Objects that a member of my team was supposed to develop an ABAP Report which had to have an output that was exactly same as the one of the standard Transactions(IE05) .
Here’s what i ended up doing:
- We need to call the SET method of the class CL_SALV_BS_RUNTIME_INFO as shown below :
-
cl_salv_bs_runtime_info=>set(
-
EXPORTING
display = abap_false
metadata = abap_false
data = abap_true
) .
- What this does is to tell the system that the report has to be running with no DISPLAY no METADATA on only get the ALV DATA.
2. Z* report where i used the used the SUBMIT Statement so call the standard report .
SUBMIT riequi20 AND RETURN .
- The AND RETURN addition ensures that the the control is returned to the calling program .
- You can use the various other additions of the SUBMIT statement to pass on the selection screen parameters .
3. Next use the GetDataRef method of the class CL_SALV_BS_RUNTIME_INFO to get the actual data into a local object type ref’ed to DATA.
DATA obj_data TYPE REF TO data .
FIELD-SYMBOL <fs_data> TYPE any .
TRY.
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING
r_data = obj_data
) .
ASSIGN obj_data->* TO <fs_data>.
CATCH cx_salv_bs_sc_runtime_info.
Write : / data not captured.
ENDTRY.
4. The data from the ALV should now be in the fs_data Field-Symbol. We can now change or do any further validations on it.
Thanks to Glen Simpsons Blog for this, it saved me lot of time .
I ran into one tiny little problem. Some of the fields like the System Status and the User Status and others did not have any values in them. This was very Weird as when i Ran the Standard report with the same selection screen parameters the values were populated.
So as mentioned in my SCN discussion.
I had the complete set of data that the Standard report outputs in my internal table and i just the ALV Class to output it to my screen.
PROBLEM:
But after checking the data (100+ fields) in the ALV report my Z program creates, I found that some of the Fields which the Standard report does have values for are not populated.
Debugging:
So, i decided to debug the Standard program so see why i didn’t get some of the fields into my output.
Turned out that the internal table that was being fed into the REUSE_ALV_GRID_DISPLAY( Location: RIEQUI20 > MIEQUI20 > MIOLXF14 line 108 of include ) FM in the Standard report also does not have the values for the same fields when the FM for ALV is called. (PFA image of the point where the FM is being called.(in case some of you want to debug it yourselves )
e.g. : the value of the table OBJECT_TAB-STTXT is Empty when the REUSE_ALV_GRID_DISPLAY is called ,
but in the final ALV output the fields System Status (STTXT) has the corresponding values . This was very troubling and as with all such situations it had avery simple solution.
Solution and Reason
What was happening was that the there was a default LAYOUT on the ALV screen that was set based on which the standard program did not fetch some of the fields that it did not have to display.
So i went into the standard Report output, click on the change layout button (Ctrl + F8 ) and create a New Default Layout with all the fields i wanted an output for .
Hope this helps some save some time.
Have a Good day.
Amarpreet.
Thanks for the blog. Nicley put. Pretty similar to this though
http://scn.sap.com/community/abap/blog/2011/07/07/gain-programmatic-access-to-data-of-sapgui-alv-reports
Regards,
Ravi
Thanks 🙂 .
Yes , I've mentioned glen's blog in my post specifically,
The Reason i created this was because i wanted to document the problem i ran into .
Hi Amarpreet,
I have a small query on this topic.
If there are any changes made to standard/already existing alv report , wouldn't that affect the our program which is making use of this ??
Regards,
Shruti D
If by changes you mean enhancements to the standard objects, then sure it would.
But since we are only using the output i don't see how it would have a negative impact on the output that we are using.
Either way the only alternative would be either to create a new report from scratch which would take a lot of effort or to create a z* copy to the standard report which won't be a very good idea as it includes a lot of code in the enhancement spot which i not copied to the custom report and it would play well with any future upgrades.
What do you think !!
Amarpreet.
Yes, by changes, I mean modification in the output of the standard/already existing ALV report. As you explained the issue you had encountered related to LAYOUT and the solution you implemented for that, then it is a definitely a concern for developer to go with the standard report alv. However my query is answered.
And whether to copy the standard code or to develop it from scratch or to make use of standard output using SUBMIT and RETURN depends on the volume of the development and left to developer.
Thank you.
Shruti
Thanks for figuring out / posting the issue when callling reports RIEQUI20, as I expercienced just now the missing Output as well ... This is a great timesaver for me.
Greetings
Nic
Nevertheless, if you'd like to get the data directly as it's defined by the layout, you should use metadata and convert the table based on fieldcat and dynamic table generation:
You need to implement the ABAP2XLSX package from abapGit webpage