Skip to Content
Author's profile photo Raquel Pereira da Cunha

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):

/wp-content/uploads/2013/10/zai_crm_im_full_data_form_299145.jpg

In the Initialization tab, first include the new field in the output parameters:

/wp-content/uploads/2013/10/globaldef_299146.jpg

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).

/wp-content/uploads/2013/10/code_299183.jpg

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
VIRT_IDX = 0
LOCAL    = 1
importing HOSTNAME = lv_host
PORT = lv_port
exceptions
NOT_FOUND
INTERNAL_ERROR.

if not lv_host is initial and
not lv_port is initial.
concatenate lv_host ‘:’ lv_port into lv_hostdata.
else.
lv_hostdata = syhost.
endif.
else.
lv_hostdata = lv_host.
translate lv_hostdata to lower case.
endif.
lv_sguid = lv_header_gui.

if lv_proc_type+1(3) = ‘MCR’.
lv_ob_type = ‘AIC_OB_CMCR’.
else.
lv_ob_type = ‘AIC_OB_CMCD’.
endif.

CONCATENATE http://
lv_hostdata
‘/sap/bc/bsp/sap/crm_ui_start/default.htm?crm-object-type=’
lv_ob_type
‘&crm-object-action=D&crm-object-value=’
lv_sguid
‘&crm-key-name=GUID&sap-client=’
symandt
‘&sap-language=EN’
INTO lv_url.

ENDFORM.                   

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”.

/wp-content/uploads/2013/10/mainpage_299184.jpg

Test the form using en existing document taking the header data from table CRMD_ORDERADM_H:

/wp-content/uploads/2013/10/table_299185.jpg

Parameter ORDERADM_H of the smartform function module:

table entry.jpg

Result:

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:

/wp-content/uploads/2013/10/webui_299196.jpg

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.

Assigned Tags

      21 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Tammy Powlas
      Tammy Powlas

      Thank you for sharing; maybe we can use when we look to implement CHaRM soon.

      Author's profile photo Tobias Hofmann
      Tobias Hofmann

      Definitely a useful feature! Thanks for sharing.

      Author's profile photo Lluis Salvador Suarez
      Lluis Salvador Suarez

      Really interesting Raquel, saved for the near future πŸ˜€

      Author's profile photo Jorge Weiss
      Jorge Weiss

      Very useful. Good writing. Thanks a lot!

      Author's profile photo Raquel Pereira da Cunha
      Raquel Pereira da Cunha
      Blog Post Author

      Thank you Tammy Powlas, Tobias Hofmann, Lluis Salvador Suarez and Jorge Weiss

      for the comments and support.

      Best regards,

      Raquel

      Author's profile photo Tom Cenens
      Tom Cenens

      Hi Raquel

      Thanks for sharing, definitely useful!

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

      Best regards

      Tom

      Author's profile photo Raquel Pereira da Cunha
      Raquel Pereira da Cunha
      Blog Post Author

      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.

      Regards,

      Raquel

      Author's profile photo Jansi Rani Murugesan
      Jansi Rani Murugesan

      Hi Raquel,

      Thanks for sharing, every time I go back to developers to do integration f web link n smart forms, now I hope it could done by my own πŸ™‚

      Regards

      Jansi

      Author's profile photo Raquel Pereira da Cunha
      Raquel Pereira da Cunha
      Blog Post Author

      Hi Jansi,

      That was my initial idea. I am glad I could help πŸ™‚

      Regards,

      Raquel

      Author's profile photo Former Member
      Former Member

      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.

      BR

      Federico Iglesia

      Author's profile photo Raquel Pereira da Cunha
      Raquel Pereira da Cunha
      Blog Post Author

      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.

      /wp-content/uploads/2014/03/img1_421112.jpg

      Best regards,

      Raquel

      Author's profile photo Achmad Dimyati
      Achmad Dimyati

      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,

      Achmad

      Author's profile photo Raquel Pereira da Cunha
      Raquel Pereira da Cunha
      Blog Post Author

      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,

      Raquel

      Author's profile photo Achmad Dimyati
      Achmad Dimyati

      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,

      Achmad

      Author's profile photo Raquel Pereira da Cunha
      Raquel Pereira da Cunha
      Blog Post Author

      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,

      Raquel

      Author's profile photo Former Member
      Former Member

      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 !

      Elena

      Author's profile photo Former Member
      Former Member

      Never mind πŸ™‚ found it !

      Author's profile photo Former Member
      Former Member

      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 ?

      Thanks

      Elena

      Author's profile photo Abhishek Periwal
      Abhishek Periwal

      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?

      Thanks,

      Abhishek

      Author's profile photo Errol Villanueva
      Errol Villanueva

      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.

      >>Errol

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

      Author's profile photo Former Member
      Former Member

      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