In this live chat, insiderBOOKS author Faisal Altaf answered questions on using ABAP in real-world scenarios.
If you missed the chat or need a refresher, you may view the chat replay or read the edited transcript below.
Meet the panelist:
Faisal has nine years of experience in IT, seven-and-half years of which have been in SAP Development. Currently he is the SAP Technical Division Head at Al Yamamah Steel Industries in the Kingdom of Saudi Arabia (KSA). In the past he completed an end-to-end implementation of SAP-IS Retail at Serbal Trading in KSA. He has also worked in SAP IS-EC&O at Presson Descon International in Pakistan and Descon Karachi & Lahore Manufacturing Works, also in Pakistan. In 2010 Faisal earned his certification in SAP Application Development, ABAP focus. An experienced author, Faisal has written several articles for SAP Professional Journal and is a frequent contributor on SCN.
Matthew Shea: Thank you for joining today's chat on ABAP development! I am excited to be joined by insiderBOOKS author Faisal Altaf. Please give Faisal a warm welcome!
Faisal is the author of Introduction to ABAP: A Project-Driven Guide. When reading the book, you follow along, step-by-step, as Faisal develops a complete point of sale (POS) project from scratch, and gain a detailed understanding of a complete ABAP development project. It’s a great resource for understanding how to use ABAP in real-world scenarios.
There are already a number of questions in the queue, so let’s get started! Please enter your questions below.
Comment From maithree: When we execute a report in the background, is a spool request compulsory for viewing the output? If yes, how do we know the program was successfully done without check the spool?
Faisal Altaf: If your program is generating an output, then system will automatically create the spool request of your program output, and this spool request is compulsory to view the output. You can monitor the background job in transaction code SM37, which gives you the detailed log of the job.
Comment From Avinash.G: Is it possible to define secondary indexes for an internal table? If yes, what is the use of introducing the secondary indexes for internal tables?
Faisal Altaf: Yes, in the latest version of SAP NetWeaver it is possible to define secondary indexes for an internal table. The purpose of a secondary index in an internal table is the same as it is with the database tables. By using a secondary index in an internal table, we can read data from a sorted internal table more efficiently by non-key fields.
Comment From Amits: What type of objects we can use to create dashboards in SAP?
Faisal Altaf: In my book I use two approaches to designing dashboards. The first one is for those who do not want to pay licensing cost. They can use MS Excel to design a dashboard and then populate data from SAP to this dashboard using OLE (Object Linking and Embedding). The second approach is for those who have a license for SAP BusinessObjects Dashboard. If you are designing a dashboard in SAP BusinessObjects Dashboard, you have to develop a web service in SAP to be used in the dashboard for getting data from SAP. To create a web service I create a function module, and from that function module we can create a web service. After finalizing your dashboard design, you can use this web service to map data in your dashboard.
Comment From maithree: By default, the report variants will not be added to a transport request. So how can we move the SAP ABAP report variants to a quality/production system?
Faisal Altaf: Execute program RSTRANSP using transaction code SA38 or SE38, type the program name in the Program Name field, type the variant in the Variant Name field (if you want to transport all the variants leave the Variant Name field empty), and click the execute icon in the application toolbar or use shortcut key F8. Select the required variants from the Transport Variant pop-up window and click the Continue button. After clicking the Continue button you get a Prompt for Workbench Request pop-up window. Now you can either create a new transport request or add these variants to the old request.
Comment From maithree: How can you edit SAP table entries for which there is no table maintenance without writing any ABAP program?
Faisal Altaf: It is not recommended by SAP to edit any SAP standard table entries even when using an ABAP program, so there is no way to edit SAP standard tables. If you try to do so, SAP will not responsible for data inconsistency or some incomplete business process because one table entry can affect whole business process.
Matthew Shea: Thank you for all the great questions so far! Keep them coming!
Comment From maithree: Why does a dump occur when I put a BREAK-POINT in between SELECT and ENDSELECT?
Faisal Altaf: Normally it should not give you a dump when you are using BREAK-POINT between SELECT and ENDSELECT. I am using the below code for testing and there is no dump.
DATA: it1_zinvh TYPE STANDARD TABLE OF zinvh,
wa1_zinvh TYPE zinvh.
SELECT * UP TO 10 ROWS
INTO CORRESPONDING FIELDS OF wa1_zinvh
APPEND wa1_zinvh TO it1_zinvh.
I think in your case the cause of dump is not BREAK-POINT. Please check another part of the code.
By the way, using SELECT and ENDSELECT is not recommended because it slows down the performance of your system, so it’s better to avoid using SELECT and ENDSELECT.
Comment From SandyA: What is the future of ABAP and it’s relationship to Fiori? How are they different? Will ABAP still be the programming language of choice when all clients are required to move to cloud-based systems in 9 years?
Faisal Altaf: ABAP is always there in the background. When you are talking about Fiori, you are talking about the frontend. We use different oData services to read or write data from or to an SAP system when we are working in Fiori. This oData service uses ABAP in the backend system to read or write data from the database.
Comment From JP Morin: Hi. I have a user requirement for downloading the inventory of 90 stores that we have. The problem is, when we populate z tables with 9 million records, it takes a lot of time. What should I do to reduce that time? Or what technique could I use to fill those z tables? In the end, this information is going to be downloaded into a layout in the file system.
Faisal Altaf: Can you please debug and check at what point system is taking more time, whether it’s when updating the z table or downloading the data to the file system?
Comment From Subrata: How can I start practicing ABAP without paying for SAP NetWeaver AS ABAP?
Faisal Altaf: You can download and install a free version of SAP NetWeaver Application Server ABAP Trial from store.sap.com and start practicing ABAP. This is a trial version. The initial validity of the license is for 90 days, but you can renew the license for free any number of times.
The required operating system for this SAP NetWeaver Application Server is Windows, but in my book I explained how you can use it even if you have Mac OS X, Linux, or Solaris as your operating system.
Comment From Subrata: How can I download and install SAP NetWeaver Application Server ABAP on different operating systems (e.g., Mac OS X, Linux, Solaris) even it supports only Windows?
Faisal Altaf: You can use a virtual machine to achieve this goal. In my case, I have a Mac, but I installed windows in a virtual machine and then installed SAP NetWeaver AS ABAP in the virtual machine. I explained the whole process in detail in my book. Please let me know if you need more details.
Matthew Shea: Hello everyone! The chat is at an end, but Faisal has graciously agreed to stay online and answer the questions already in the queue. Thank you, Faisal!!
Comment From Subrata: What are some best practices for designing a dashboard in Excel and populating data to an Excel dashboard from SAP using OLE?
Faisal Altaf: When developing a dashboard template in Excel, there are two ways you can represent data. The first way is to display data as graphs using different chart types (e.g., column chart, bar chart, pie chart, and line chart). The second method is to represent data in a simple table format. For example, in my book I display the graphs on sheet1 in Excel and display the table on the sheet2 (for the table display I used simple cell borders in Excel) and then make buttons on both sheets to switch between these sheets.
Comment From Alvin: Hello Faisal. I need to migrate a purchase order (transactional data) from one client to another but in the same SAP system. Based on my research, it’s recommended to use ALE/IDoc to send the PO. Now I'm considering 3 approaches for this. 1) Create a standalone program to send an IDoc using an ALE function module. 2) Add output types to the PO documents using RV_MESSAGE FM and then send an IDoc through standard program. 3) Create an LSMW IDoc to extract it through an IDoc. What do you think is the best approach?
Faisal Altaf: I think you can try to read the PO data in the source client using BAPI_PO_GETDETAIL and then use BAPI_PO_CREATE with an RFC destination of the target client to create the PO.
Comment From maithree: What has to be done to the packet decimal fields before submitting to a BDC session?
Faisal Altaf: I think there is no special treatment for submitting the packet decimal field to the BDC session. In some cases you need verify that the values in the upload file are not be in comma (,) style (for example, 1,234.56). In this case system will give an error, so you will have to remove the comma and try again.
Comment From Subrata: How can I write a select query to optimize the system performance?
Faisal Altaf: First of all, try to select data from the database in one go. Don’t use SELECT and ENDSELECT statements and don’t put the select statement inside LOOP and ENDLOOP. Try to provide the full key combination in the where clause. If you are dealing with small text tables, then it’s better to select all the data from the database table, put it into the internal table, and then read from the internal table rather than selecting from the database when required.
Comment From Avinash.G: Why do we need to write a start-of-selection event in local classes for calling the methods of the classes?
Faisal Altaf: Because the system drives the program execution in the procedural way, so we need to write a START-OF-SELECTION event in the local class to call the methods of the class.
Comment From Subrata: How can I design a Smartform for sales or return invoice printouts?
Faisal Altaf: I will give you an overview of creating a Smartform for sales or return invoices. You can find the details in my book.
- First of all, we use transaction code SMARTFORMS for designing a Smartform.
- For displaying a Smartform, we need to have two objects. The first one is the driver program and the second one is the Smartform design.
- In the driver program we select all the data which we want to show in the Smartform. In the case of our sales and return invoice, we need to select the data from Invoice Header and Invoice Details tables, and to display site information we need to select data from the Site Master table. For article description we have to go to the Article Master table as well. After arranging all our data we need to design a Smartform and call this Smartform from our driver program. We also need to export all the required data while calling the sSartform
- While designing the Smartform we have to select the Page Format for invoice and also select the smart styles that we are going to use in the Smartform. (We can use the standard smart style or we can also create our custom smart styles.)
- We need to go to the form interface and add all the data objects we are receiving from the driver program, including the internal table, which we mention in the Tables tab of the Form interface.
- In the Global Definitions tab we have to enter the Currency or Quantity field that we are going to use in our Smartform.
- Than we need to add a table in the main window of our Smartform and arrange the table lines as per requirements. In my example I used three table lines for the heading and one table line for the Main Area of table. This table is used to display all the data in the Smartform.
- Finally, we need to add the different nodes to the table lines as per requirements and map the importing data to these nodes.
Please let me know if you need more details.
Comment From Avinash.G: Does using secondary indexes in report programing lessen the reusability of the report program in other programs such as reports/screens, etc.?
Faisal Altaf: Are you talking about the secondary indexes of internal tables or database tables?
If it’s about internal tables, then the secondary indexes are in memory only and exist only during the program execution.
Comment From maithree: Can we access the protected method within the class(like parent class only)?
Faisal Altaf: We can access the protected method within the same class and also in all the subclasses.