Changing the Smartform to show the link of ChaRM documents
As I have seen in the Discussion Forum that some people need to send the link of the ChaRM documents inside the e-mails that are sent by the ChaRM actions, I decided to publish my guide that I created some time ago and have been using it very often, as it can help everybody.
Dolores has already mentioned what to do in her blog http://scn.sap.com/docs/DOC-35291 but here I am showing in more details in case someone still has doubts after reading her instructions.
Screenshots from SP6.
I used standard smartform AI_CRM_IM_FULL_DATA_FORM and copied it to a Z, but I have also done it in SP08 copying AI_CRM_IM_SHORT_TEXT_LINK_FORM.
If you use AI_CRM_IM_FULL_DATA_FORM, please take a look at Dolores’s blog since she mentions an error that may happen and how to solve it.
In Global Definitions, enter a variable for the link as below (in this example GV_LINK_TO_CM):
In the Initialization tab, first include the new field in the output parameters:
Then go down to the end of code and insert a new form get_link_to_cm as below (if you use AI_CRM_IM_SHORT_TEXT_LINK_FORM as a base for your new smartform, there is already a form called get_link_to_im, but this form is prepared for the Incident link, so you can replace it with the new form for ChaRM).
In the form routines tab, include this code:
form get_link_to_cm using lv_header_gui TYPE crmt_object_guid
lv_proc_type TYPE crmt_process_type
changing lv_url type string.
data: lv_sguid type guid_32,
lv_ob_type type string,
lv_host type string,
lv_port type string,
lv_hostdata type string.
select single host into lv_host from httpurlloc
where sort_key = ‘0001’
and protocol = ‘HTTP’.
if sy–subrc ne 0 or lv_host is initial.
call function ‘TH_GET_VIRT_HOST_DATA’
exporting PROTOCOL = 0
VIRT_IDX = 0
LOCAL = 1
importing HOSTNAME = lv_host
PORT = lv_port
if not lv_host is initial and
not lv_port is initial.
concatenate lv_host ‘:’ lv_port into lv_hostdata.
lv_hostdata = sy–host.
lv_hostdata = lv_host.
translate lv_hostdata to lower case.
lv_sguid = lv_header_gui.
if lv_proc_type+1(3) = ‘MCR’.
lv_ob_type = ‘AIC_OB_CMCR’.
lv_ob_type = ‘AIC_OB_CMCD’.
I did not use sy-host directly because it did not bring me the complete hostname, and the link didn’t work. Port is not always 8000 because if the system number is not 00, but for instance it’s 01, or 02 or 20, port is 8001, 8002 or 8020. If the user knows the complete address and port and want to set as hard code I think it’s ok too.
The code can be better, we should read dynamically the object type for the process type instead of hard coding it (I don’t like hard coding at all), but this example works. I am assuming many readers are not ABAP Developers, so it would be more complicated.
Go to MAIN Page and in the TEXT insert the new field. Use the + icon for that and write &GV_LINK_TO_CM&
Include the field wherever you want the link to be shown in the main Page. Here I just included in the first line before the title “Long Texts”.
Test the form using en existing document taking the header data from table CRMD_ORDERADM_H:
Parameter ORDERADM_H of the smartform function module:
Exemple with a change document:
Clicking the link of the e-mail, the Urgent Change is shown in Web client UI:
This was a very simple example just to show how to generate the link. You can change the rest of the smartform as much as you need and delete/insert information.