Why I like to code ABAP in Eclipse?
I was receiving this question very often in the past, but I really thought that most of the developers who can use AiE, are using it. But seems that I was wrong. Still a lot of you use SE80. I don’t mind it, I also use it myself in some circumstances, but sooner or later you’ll need to switch to AiE, for example when you work with HANA.
That’s why I’ve decided to write about why I use AiE. What I like in it and what I dislike. AiE is not perfect (yet) but there are some advantages which you should consider.
1. My first touch with ABAP in Eclipse
It was not the love from the first sight. Although I liked very much the idea of using Eclipse for developing in ABAP. When I’ve read about it, I said – “Finally, a proper development environment for ABAP”. But the reality at least for me was not that bright at the moment. Eclipse was working quite slow at the time or at least at the system installation I was using. I’ve been trying Eclipse Juno at that time, and after 2-3 days I gave up.
I’ve return to Eclipse after month or two, when Kepler release was out together with new version of AiE. I’ve said at the time: “I’ll try to work with Eclipse for one month, if it will not convince me, then I’ll not try it at least to the next Eclipse version (they appear regularly each year)”.
But after one week of working with Eclipse and ABAP OO, I was sure that this is the correct way of working, although there were still some improvements to do.
3. AiE Support and development
Before I will write about the tool itself, I’d like to mention whole AiE development team with Thomas Fiedler on the top of it. Whole team is doing really good job and they are really open on all suggestions and remarks. It happened not once that after a suggestion on SCN or Twitter some new option was added. And when you face a bug in Eclipse, they are also there to help and solve the issue.
Please be aware that accessing private or protected data may have unpredictible consequences! Use it at your own risk.
From time to time, it happens that you want to access private data or methods from CL_GUI_ALV_GRID, which is normally not possible.
When you look into the class definition you'll notice that there is only one global friend - interface IF_ALV_RM_GRID_FRIEND which has no attributes or methods declared. Quite strange, isn't it?
When you'll search were this interface is used then you'll notice that it's helping to get access to private grid data. So why not to use it the same way?
Everybody sends mails from SAP, some are still using old FM SO_NEW_DOCUMENT_ATT_SEND_API1 but some CL_BCS class. This class is really powerful but it has one disadvantage - it does commit work, and not only when sending emails but also during adding of attachments. In this case it's really not safe to use this class in BADIs or User-Exits, but there is one replacement for CL_BCS -> CL_BCS_MESSAGE. This class only collects the data, and when send method is run then calling a FM SBCS_SEND with destination NONE, or SBCS_SEND_UPDATE in update task, depending what attributes are passed to the class. It means you can use it also in BADIs or User-Exits where commits are not welcomed.
I was lately trying to find an HTML WYSIWYG editor for ABAP, but I failed. I though or this was not needed so far, or the solution was not posted anywhere. So I've tried several times and thanks to NICEdit and this tread on SCN I found the way to make HTML WYSIWYG editor for ABAP.
My editor use CL_GUI_HTML_VIEWER to display NICEdit in container, and then thanks to POST method I put changes back to SAP. ZCL_HTML_EDITOR class, which is attached to this post, raises an event whenever someone click on save button in the editor, so you can easily handle it and then use new HTML for your purposes. Video bellow shows the demo of usage.
Finally I've finished to work under FALV. You can find FALV classes in attachment and description under the links. But firstly let's go through few following points:
- Why I've created FALV although SALV classes are provided by SAP?
I know SALV classes although I haven't used them often. The main reason was that they don't provide edit mode. So at the end I've always worked with cl_gui_alv_grid class so then whenever users decided that they need one of the field to be editable then I can do it in few seconds/minutes.
- But there is a way to make SALV editable!
Yes, I know the solutions of Naimesh Patel (found here) and Paul Hardy (in his ABAP to the Future book) and some other folks to make SALV editable. But In my own opinion, especially when you're at least on 7.40 with SP5 making SALV editable is not needed as you can fast create ALV Grid which does everything you want. To be clear the big advantage of SALV, to call grid output of table in two, three lines when you goes to the code you'll see it's nothing more than call of REUSE_ALV_GRID_DISPLAY... really old FM, which at the end use CL_GUI_ALV_GRID.
- Direct reasons
As I used CL_GUI_ALV_GRID so often then I came up with an idea to do some class which will make the creation faster, but I never had time to do it at work. You may know it, because of the time pressure you choose to create report/program/solution in the way you're doing from years ... and then comes another task....and another....
So I've decided to do it at home.... yeah I'm crazy. But at least some of you can also use it.
I've worked on this on 7.40 SP8 but this should work also on SP5 as well. Sorry for the users bellow that versions but I'm so used to use new syntax that I couldn't force myself to use old way of coding.
UPDATE: Thanks to Santi Moreno we have now 7.31 version, you can find it here as an attachment ZFALV_V1.1.0.zip. Also GitHub repository is now available here https://github.com/fidley/falv so if you'd like to join us, you're more than welcomed.
The outcome of this work is following:
- Package ZFALV
- Function Group
- ZFALV - screens, GUI STATUSES, TITLE, FMs for ZCL_FALV, local classes
- Demo Programs
- ZDEMO_FALV01 - FALV: Demo Simple Full Screen Call
- ZDEMO_FALV02 - FALV: Demo with Redefinitions
- ZDEMO_FALV03 - FALV: Demo Full Screen GUI Status Dynamic Partly
- ZDEMO_FALV04 - FALV: Demo Full Screen GUI Status Dynamic Fully
- ZDEMO_FALV05 - FALV: Demo Full Screen ALV Toolbar
- ZDEMO_FALV06 - FALV: Demo Full Screen Layout
- ZDEMO_FALV07 - FALV: Demo Full Screen Columns
- ZDEMO_FALV08 - FALV: Demo Mass Replace Function
- ZDEMO_FALV09 - FALV: Demo Cell Settings
- ZDEMO_FALV10 - FALV: Demo Colors
- ZDEMO_FALV11 - FALV: Demo Editable
- ZDEMO_FALV12 - FALV: Demo Error Log
- ZDEMO_FALV13 - FALV: Mix Demo + own screen and container usage
- ZDEMO_FALV14 - FALV: Popup calls
I really encourage you to try it and give me your feedback about FALV.
On one of my last tweets I have mentioned, that I'm working currently on some fast ALV Grid creation class. I know that we have SALV classes which does many of this what I'm trying to achieve here but, many doesn't mean everything. Especially that I really like CL_GUI_ALV_GRID class and this that without any tricks I can make it editable in easy way.
My class in not yet finished but it has already some basic functions available, that's why I'm presenting you just short demo and some screen-shots of the code. I will of course put a nugget here as fast as I'll finish more than alpha release.
Basically what I try to get from this class:
- Fast CL_GUI_ALV_GRID creation
- Replacement of REUSE_ALV_GRID_DISPLAY and REUSE_ALV_GRID_DISPLAY_LVC for a simple editable reports to omit screen creation
- All events should be already handled and with redefinition of method I can faster use it
- Faster setting of layout and field catalog attributes
- Easy switch and copy between popup, full screen and container version
- Easy toolbar handling (in grid and in full screen/popup using Dynamic GUI STATUS & TITLE with ABAP code )
- One place to handle user commands of full screen/popup call -> event user_command
At the end of the work I'll be able to say: "I've made really good, unnecessary work! " :-)
This question seems to be funny as usually you rather read "How can I learn ABAP?". But how to teach? Should we follow any rules ? Should we keep to some path of teaching, special sequences or guides? Well I don't know the answer to all this questions but my experience in teaching ABAP gives me possibility to share with you what and how to do with your "apprentice".
Before I start I'll just mention that persons I've learnt/I'm learning have always at least basic skills in programming but in other languages, therefore I didn't mention here any points about teaching the basic programming stuff here.
1. Start with basic info about ABAP
When you switch to new programming language you firstly check what types are built-in, what is the syntax to create a function or method and this is what you should start with when you teach ABAP. I have created some basic description about types, basic syntax, tables, etc. for my master’s thesis and give it always to newcomers to read it as a first step. I have there also small description about main development transactions. So if you know that you'll learn more than one person, then it's really useful to have such document. If you don't have it, then create it. It will take a while, but once done it's done.
After such lecture your young Padawan should be able to write "Hello World" programs and should be familiar with really basics of the ABAP.
Just as remark, as long as you don't have really trusted and up to date source, don't use ready documents of someone else in here, as this can bring you headache from the beginning of this long way.
I've seen on SCN plenty of question about copying BOM from one plant to other, or from one material to other. Most of them were closed by using LSMW or direct input methods, but there is a really nice way to do it using CEWB function modules. I've been playing with CEWB modules for a long time so I'm not afraid to debug CEWB in case I cannot make it work by myself but when you look on the logic of the sample program to copy BOM then you'll see it's reasonable.
- At the beginning let's clear Function Group memory using FM 'CP_CC_S_REFRESH_DATA'. Just for the safety reasons :-)
- Then let's load BOM header data to FG memory. If you want to do mass transaction then you would probably want to fill selection table i_cpsc_bom_sel with more than one BOM number, it will be then faster than calling FM 'CP_CC_S_LOAD_COMPLEX_BY_BOM' separately many times.
- But header data is not enough, we should do same thing for BOM items using FM 'CP_CC_S_LOAD_COMPLEX_BY_ITM', as Items belongs to different work area in CEWB.
- Once we loaded data to memory we can start copying, firstly we need to call 'CP_CC_S_BOM_PROVIDE_BY_MBM' to get source header data and then use its export parameters in FM 'CS_CL_S_MAT_BOM_CREATE_BY_COPY', which is doing copy of a header data.
- Once it's done we have to get source items from memory using 'CS_CL_P_ITM_PROVIDE', and then use it for copying items to our target BOM in 'CS_CL_S_ITM_CREATE_BY_COPY'.
- At the end, when everything is fine, use FM 'CP_CC_S_SAVE' to save your changes and commit your work.
Bellow and in the NUGG attachment you can find sample program which is using this technique for single BOM copy. It does not have error handling or built-in change number usage but you can do it yourself in your programs if this will be necessary.
When you use QM01/QM02/QM03/IQS1/IQS2/IQS3 transactions then you've noticed that when you have some task defined then you cannot directly go to attachments of notification. Following popup always appears:
But there is a way of getting rid of it. We can add new action box action to call directly attachments of notification.
So go to SPRO and find Define Action Box in QM node.
In my article about cl_progress_indicator I've mentioned that sometimes progress showing is more time consuming than the action which is described by it, so you must be careful when using progress indicator in ABAP. I've said also that it's better to cl_progress_indicator instead of FM SAPGUI_PROGRESS_INDICATOR because of built-in function to show progress only once per 10 seconds. But sometimes when using standard SAP FM we can see that progress showing is taking too much time (like SAP_CONVERT_TO_CSV_FORMAT for example), and as we should not do any modification of the system code then we need to use a small trick to get rid of such progress indicators.
If you look into code of SAPGUI_PROGRESS_INDICATOR then you'll notice that showing of progress depends on parameter called SIN :-)