ABAP capture result of submitted program using cl_salv_bs_runtime_info

Let's talk about a hypothetical scenario,

You are meditating in your fortress of solitude. A wild customer appears virtually/physically.The person shows you a report output and wants you to fetch exact data as the report displays in your current development.

Scared, you begin to analyse the code of the report to reuse its logic only to see your fear come out alive i.e. the report has all the logic embedded.

Proudly, you suggest refactoring the report, extracting the logic globally, and using it for your objects.

Swiftly, your hope helicopter is shot down by the customer's stinger missile of an increase in testing efforts and with support troops of "nearing the deadline" hand a lack of super users to confirm the original report works as intended post refactor.

Now, If the above scenario is not so much hypothetical in your experience, you are left with some limited choices.

1. Copy the logic ( Hello dark side)

2. Somehow get the output of the report.

  In today's post, I wanted to talk about an easy way to capture the result of a submitted program as long as the program uses ALV .

There is a class that can be very helpful in this scenario:cl_salv_bs_runtime_info

You can use this class to:

 - Set ALV output to false using SET method.

 - Submit your target program.

 - Get the output using GET_DATA_REF method.

- Set ALV output to true using SET method if you want to display your own ALV.

Here is a simple demo using the ALV demo report: BALSD02_GRID.

Executing the report gives you the below output.

Now, let's submit this report inside our program.   

Executing the report gives the below output which is the same dataset including Client field which the above program suppressed in display.


As always, hope this information helps you in your day to day work.




Popular posts from this blog

ABAP read excel(.XLSX) file to internal table in ABAP using CL_FDT_XL_SPREADSHEET

ABAP convert internal table to excel (.xlsx) format and Send email or download

Application Logging in ABAP