‎2022 Jan 26 8:44 PM
Hi,
I have internal table data in a module/dialog pool that is required on a report. The report should be displayed on the screen and possibly can be printed. In an executable program, this would be done with WRITE or ALV. What to do in a module pool? I was considering passing the data into a sapscript/smartform but was wondering if there are other approaches to consider. Some processing will be required on the data as it gets outputted, i.e. "IF data = this THEN change data to display" etc.
Thanks.
‎2022 Jan 26 8:50 PM
If you really want to stick with the old WRITE commands then you can use the ABAP command:
LEAVE TO LIST-PROCESSING [AND RETURN TO SCREEN dynnr].
Afterwards you can output your data with WRITE statements.
That should be a last alternative. You can probably determine what data you want to output up front, put it into an internal table and then use the ALV to display it.
‎2022 Jan 27 1:06 PM
I want to display the data like a PDF in a popup for example, that can be displayed and/or printed off.
That's why I mentioned sapscripts/smartforms - it's that type of report I need to generate.
Imagine the module program is an ALV containing a list of orders. Then I want a button that will format the data as an invoice, for example.
‎2022 Jan 27 2:14 PM
Hello,
you can generate a smartform, invoke it to get the PDF and then show the PDF.
It's something already debated and explained around.
About "processing the data", you can do it before calling the smartform or inside the smartform itself if it's not too complex.
‎2022 Jan 27 5:06 PM
Split your module pool program into three. The module pool itself, a model class that does stuff (reads from the database, updates, gets information etc.) and a view class that is called from the module pool every time there's a user interaction (including starting and finishing the program).
The model class is only called by the view class. Never from the module pool.
This is essentially the MVC pattern for developing UIs.
Once you've done that. You can now easily write your report using the method class.
DATA(model) = NEW z_my_model_class( ).
DATA(report_data) = model->get_data( ).
" Processing to output the report data
‎2022 Jan 27 7:00 PM
The program is already written in MVC structure. That's not the question though.
The question is what functionality should be used to generate the report.
Example: imagine the module program is an ALV containing a list of orders. Then I want a button that will format the data as an invoice. How should the invoice be generated is the question - sapscript, smartform, adobe form, WRITE, etc. etc.
‎2022 Jan 27 7:00 PM
Thanks, yes it's something I've done many times before, however never from a module pool.
I wanted to hear other people's experiences of generating this type of output from an ALV/dialog program.
Since sapscripts & smartforms are no longer supported by SAP, I should use Adobe Forms.
But anyway if no one has other suggestions, I'll assume this is the de facto best approach! 🙂