|
Blogs
Preamble The history of this blog series: Back again from my vacation, I will go on in the implementation of our ZROL transaction type for authority role transports. You can code how many working lists you like, users will always prefer to react to e-mail notifications. Did I say prefer? Users react solely to e-mails. All other tools you give them will be diligently overseen. But normal PPF customizing will create only ugly text-only or bulky PDF messages, depending upon your SAPConnect customizing (transaction SCOT, selection of node SMTP, in the group "Supported address types" select "Internet" and press the "Set" button). Here you can choose the output format for SmartForms. Obviously you would like to select "HTM", but this is not offered for SmartForms). My users have many additional wishes (users without wishes are probably ill - wishes are like pigeons: the more you feed them, the more they come):
I love to be a good Santa to my users, so I coded these wishes for them. Here I will show you how. The last two blogs did have much pictures, this one will carry a heavy abap load. This is the mail notification that is sent to the tester when the security team gives it's approval as an example of the result: But let's begin! PreparationFor the SAP Gui shortcut to open the right business transaction number we need a dedicated transaction. First we create a mini report to open CRMD_ORDER with the right business transaction number:
By the way, these coding text areas look best when viewd with firefox under linux because in this environmen they are displayed with a fixed font, so all formatting is well preserved. Then create with SE93 a "Program and screen (dialog transaction)" which calls this report: PPF SmartForm Mail MethodsThe main methodWe will now code the main static method which has to be inserted into the PPF-Customizing as Processing Method of the Smartform Action (please see Part 1 of this series). We call it EXEC_SMARTFORMS_ZROL_MAIL because it has a special status handling that is unique for this ZROL transaction type. For this method we exploited two other methods which can be both found in the standard class CL_DOC_PROCESSING_CRM_ORDER:
Further we adopted the technique explained in SAP Note 616383 to dynamically call the active smart form. The coding of CRM_ISA_AUCTION_SMART_FORM has a little drawback: when your Smartform contains graphics, some stupid mail agents implementing a proprietary version of the standard (RFC 2387) will display the html mail as an attachment and not inline as defined in the mail header (see SAP notes 730534, 810594, 927439), which dismantles the poor e-mail notification. Our solution will be to simply avoid the parameter "filename" when creating the MIME part (see down, method set_main_html). We have also streamlined the smartform and it's corresponding function and thrown out all useless crmd_order parameters. Our coding doesn't use customer tables or dictionary objects, so it should be correct as is. You have only to create with SE80 the checkpoint group ZOG_CHARM_OUT, which is useful for debugging (switch on with transaction SAAB) At first we have to create with the class builder (SE24) our class
ZCL_IM_SV2I_OG_SMARTFORMS_MAIL
inheriting from CL_SF_PROCESSING_PPF: Then we insert these needed local types (see screen shot above how to find the right place): Now we are ready to create the static public method EXEC_SMARTFORMS_ZROL_MAIL; instead of screen shots of the signature I have copied the signature coding from the public or private sections as a commentary into the method itself, you will have to insert them without the explanation mark into the method definiton of the class builder: I have done some re-engineering of the original method and eliminated some bugs. I hope that the in-line comments are enough explanation. The helper methods To enhance the readability of the coding I have sourced out some of it into dedicated private (static) methods. First we need the method PARTNER_MAIL_ADDRESS_GET to determine a) the address of the root org because we want to use it's generic mail address as sender instead of the user which is logged into and, when needed, also b) the address of the role administrator: With the method PREPARE_HTML we transform the Smartform output so that it can be used as multipart MIME (we have only Unicode, so I can't test if the coding works also in non unicode environments): *class-methods PREPARE_HTML REPLACE ALL OCCURRENCES OF '<IMG' The wysiwyg editor of this blog is too intelligent, so he destroys the html hack coding when inserted as text area. So we had to insert the coding as preformatted inline. With the method PREPARE_GRAPHICS we do the same for the graphical elements which might be part of the smartform: With the method CHARM_CREATE_GUI_SHORTCUT we create the SAP Gui shortcut that will jump into the transaction:
Finally with the method SMARTFORM_MAIL_SEND we build the MIME e-mail, attach the Gui Shortcut and send it to one or more recipients: Usually I insert constants like 'MYGRAPHICS/' as class attributes, so I can find all references where they are used. But for this blog I have left them in the coding to make this blog more readable. Epilogue Hopefully the magic done to the e-mail notifications will boost the acceptance of the ChaRM also in your company! Enjoy! And hoist some of you solutions in the SDN too, to share them brotherly.
Riccardo Escher since 1992 SAP basis developer, always interested in new technologies and without any reluctance in helping SAP to improve their products (messages, user group)
| |||||||||||||||||||||||