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 :-)
Today I've got a question from Custodio de Oliveira (hope you don't mind mentioning) about Dark Eclipse settings which I'm using. As I know that settings colors in Eclipse for ADT is a pain, then I want to share with you my settings and the steps to achieve the same look like I have on my installation. Of course you can update it by your own, but at least you have a starting point.
Probably this is how your Eclipse looks like, or if not then the default settings for ADT. White and eye-killing.
When you're used to create buttons in ALV Grid dynamically then you think why SAP doesn't allow create dynamically buttons on GUI STATUS. You can change icon or text if you defined that function has dynamic text but you cannot create buttons at runtime and you always have to create GUI STATUS and GUI TITLE in SE41, which personally I don't like, as in most small reports you have to create usually one to five buttons.
So what I want to present to you today is a way to create buttons dynamically at program runtime without a need to create GUI STATUS and GUI TITLE for each program. In fact whole trick is to create firstly a GUI STATUS in empty program which will contain only functions with dynamic texts, and then to fill properly static class attribute.
So let's begin with creating our program to keep GUI STATUS and GUI TITLE. I will call it ZAB_DYNAMIC_GUI_STATUS. In the source code you do not need to put anything beside report keyword.
"! Dummy program for keeping GUI STATUS and TITLE
"! Used by ZCA_AB_DYNAMIC_GUI
"! Do not delete it!!!
Yes, that's all from the code point of view in this program. As said it's only to keep GUI STATUS and GUI TITLE.
Lets create GUI STATUS firstly and call it DYNAMIC_STATUS. Items on application toolbar will have the same naming pattern Fxx, so F01, F02 etc. Each of this function code should have dynamic function text with pattern ZCA_AB_DYNAMIC_GUI=>BUTTONS-Fxx where Fxx you have to replace by current function code.
Additionally to application toolbar, fill also function keys for save, up, back, exit, print... etc so you can also use it in your programs.