Skip to Content

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 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 sysubrc ne 0 or lv_host is initial.

call function ‘TH_GET_VIRT_HOST_DATA’
exporting PROTOCOL = 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 = syhost.
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’.

INTO lv_url.


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:

table entry.jpg


email ex.jpg

Exemple with a change document:

table change doc.jpg

email ex2.jpg

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.

You must be Logged on to comment or reply to a post.
  • Hi Raquel

    Thanks for sharing, definitely useful!

    Love the attention for details, we need more of these quality blog posts on SCN.

    Best regards


    • Thank you Tom!

      Tried to use some Human-Centered approach πŸ™‚

      Not all ChaRM users have development skills, it could be difficult for some people to sort out how to create the code and test the the form.



  • Hi Raquel, Thank you!

    I've a question.

    If i use this smart form (ZAI_CRM_IM_FULL_DATA_FORM) in ZMAD and I've created a Z text type in ZMAD, a Z01.

    I want to add this type in the smarform.

    Do you have the specific code and customising to do that.


    Federico Iglesia

    • Hi Federico,

      please see below where you need to edit the code to include your new text types. The 2 standard text types are hard coded in this smartform, so you need to edit your Z.

      Go to Global Definitions->Form Routines.


      Best regards,


  • Hi Raquel,

    I just found out this very helpful article today and thanks a lot for that. Only I have one question and I think it's shown in the image of generated URL inside the email.

    The generated URL has been cut by line, so the hyperlink isn't working. I have the same issue, do you know how to force the whole URL to be inside on the hyperlink?

    Thanks a lot,

    Best Regards,


    • Hi Achmad,

      thanks for your comment.

      I think I didn't understand your question, since the link is working fine in all the customers  where I implemented it, the URL is complete. How is the URL for you?

      Best regards,


      • Hi Raquel,

        Sorry for late reply. There is additional step which put the URL parameter as URL link. I forgot to assign it. Perhaps it good idea to add it in your guide.

        Thanks a lot. Your guide was helping me a lot.

        Best Regards,


        • Hi Achmad,

          I am happy to know it helped you πŸ˜‰

          Please feel free to add any info that you think it's important here as a comment.

          Thank you and best regards,


        • Hi Achmad, I am having same problem at my customer now - the link is broken into several lines and spaces are added in between, so the link would not work, because it now looks like string rather than an URL.

          Could you please share details of how you corrected it ? Which parameter and where to add it ?

          Thank you so much !


  • Hi Raquel,

    your coding works fine in Smartform - just tried. All my clients wanted to include the link in an email, but I was always saying : it's too much work and ABAP code is needed.

    You put it all together and it looks so simple even for non-abaper ...amazing !

    And Thank you !

    Question though.... πŸ™‚

    Do you have something similar to include the Request For Change link into an approval workflow email ?



  • Hi Raquel,

    Thanks for the logic.

    I used your steps and was able to generate the link for ChaRM. Also when I test the form it shows me the URL. However when I send the email in TXT format it doesnt show the URL. Its probably due to the URL being too long. I truncated it while debugging and it appeared on the mail. Although I need to see the full URL in the email.

    Is there a way to shorten the URL?



  • Hi Raquel,

    Thanks for this write up, very helpful.

    I have a question/requirement from a customer....they wanted the email link to open up the slimmed-down version of an incident ticket--> very much like the version you see if you use the SOLMANREQU profile.

    How is this done?
    Thank you in advance.


    6-16-2016 9-58-14 PM.jpg

    6-16-2016 9-58-14 PM.jpg
  • Hi Raquel,

    I have a question regarding URL being sent to the reporter in email notification.

    P.S. This is for Incident Management.

    The problem is that the link that comes in the email is starting from "HTTP" and port 8002, but actually the incident management tab is integrated to a customer's portal and even though the status change is done on that portal's url (which is secured HTTPS and port 443), email does not embedΒ the correct link. End users get an error while clinking on the link provided in the email.

    How can i correct this?

    Thanks in advance!

    Best Regards,

    Shivani Vyas