Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Email withe HyperLink

Former Member
0 Likes
10,716

Hi,

I am trying to send an email using the class CL_BCS. And I am successful. Now my requirement is to put a hyperlink in the body of the email and on clicking that hyperlink SAPGUI should be opened. Is this possible? Is yes how can I do that?

Regards,

Rahul Muraleedharan.

17 REPLIES 17
Read only

rahul_mb
Active Participant
0 Likes
4,406

Hi all,

Please provide a suitable solution,

TIA,

Rahul Muraleedharan

Edited by: Rahul Muraleedharan on May 7, 2011 7:07 AM

Read only

Kiran_Valluru
Active Contributor
0 Likes
4,406

Hi.,

Yes., It is possible., use document types as HTML and in message body send html tags., like .,

<a href='<url to be opened>'> Text to display</a>

hope this helsp u.,

Thanks & Regards

Kiran

Read only

0 Likes
4,406

Hi Kiran,

Thanks for the reply.

But that is not my requirement. I dont want to open an HTML page, instead I want to open an SAP session. Please give a suggestion.

TIA,

Rahul Muraleedharan.

Read only

0 Likes
4,406

Hi Rahul,

in SAP, you can click SAGUI Icon on Top to create a shortcut. It saves a .SAP file which is a text file.

Check the text file contents, create it as attachment, put a reference to the attachment in the html mail body.

Regards,

Clemens

Read only

0 Likes
4,406

Hi Clemens,

Thank you for the reply.

I have attached the shortcut file as an attachment. Now as you have mentioned I want to put a reference of that file in the HTML body, so please show some more light on this.

TIA,

Rahul Muraleedharan.

Read only

0 Likes
4,406

Hi all,

Can anybody throw some light on giving a reference of the attachment in the body of an email?

Thanks,

Rahul Muraleedharan.

Read only

0 Likes
4,406

I'm not sure why you would want to do it this way...it's not a very elegant solution and you're still going to get prompted to 'save' or 'open'. Why not use a web-based transaction or service?

Anyway, after you have uploaded and attached the SAP shortcut in binary format, embed an anchor tag in your html code with a content identifier based URI ("cid:"). The CID link must match the name of your attachment.

Read only

0 Likes
4,406

Hi Brad,

Thanks for the suggestion.

The end user requirement is like, they want to open the SAP GUI, not a web based transaction or service, that is why I particulary wanted to do this. Is there any other way to open SAP GUI on clicking a hyperlink other than creating a refernce to the attachment? As you said the main disadvantage of this method is that it will again prompt to 'SAVE', 'OPEN' etc., I want to avoid this also.

Regards,

Rahul Muraleedharan.

Read only

0 Likes
4,406

No, without a web transaction, you need the reference to the attachment and the "CID:" content identifier. Once you have hit the link though, the user can 'turn off' the prompting and open the shortcut automatically.

Read only

0 Likes
4,406

Hi Brad,

I am stuck at the part where we have to give the reference of the attachment in the body of email.

it_objtxt = '<a href="CID://DisplayAddress.SAP" > SAP GUI </a>.'.
APPEND it_objtxt.

it_objpack-obj_name   = 'SAPSHORTCUTMAIL'.
it_objpack-obj_descr  = 'DisplayAddress.SAP'.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
  EXPORTING
    document_data              = doc_chng
    put_in_outbox              = 'X'
    commit_work                = 'X'
  TABLES
    packing_list               = it_objpack[]
    contents_bin               = it_objbin[]
    contents_txt               = it_objtxt[]
    receivers                  = it_reclist[]
  EXCEPTIONS
    too_many_receivers         = 1
    document_not_sent          = 2
    operation_no_authorization = 4
    OTHERS                     = 99.

This is what I have done. Can you please tell the mistake that I am doing?

Read only

0 Likes
4,406

Hi Rahul,

First: Do not use FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'. Refer to my [favorite Unknown thus unloved?|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/3443] [original link is broken] [original link is broken] [original link is broken]; and [Sending attachment using cl_bcs classes|http://wiki.sdn.sap.com/wiki/display/Snippets/Sending+attachmentusingcl_bcsclasses].

I remember we received mails with attachments from SAP SOLMAN system by workflow: In the internet mail you could double-click the attachment file to go directly to the linked order. If you were not logged in at the respective SAP system, a SAPGUI logon came up first.

I remember it was a simple .SAP text file but unfortunately I did not keep it for reference.

If someone knows such attachment, she may post the contents here.

Regards

Clemens

Read only

0 Likes
4,406

Hi Rahul,

Leverage the code on the blog specified by Clemens and add the below lines of code and try, the below attachment will help you open up VA01 in SAP GUI, and will prompt the user to login if he/she isn't logged in.


DATA: lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL,
      li_soli_tab TYPE soli_tab,
      lw_soli_tab TYPE soli.

CONCATENATE '[System]' cl_abap_char_utilities=>cr_lf INTO lw_soli_tab-line.
APPEND lw_soli_tab TO li_soli_tab.
CONCATENATE 'Name=B64' cl_abap_char_utilities=>cr_lf INTO lw_soli_tab-line.
APPEND lw_soli_tab TO li_soli_tab.
CONCATENATE 'Client=731' cl_abap_char_utilities=>cr_lf INTO lw_soli_tab-line.
APPEND lw_soli_tab TO li_soli_tab.
CONCATENATE '[User]' cl_abap_char_utilities=>cr_lf INTO lw_soli_tab-line.
APPEND lw_soli_tab TO li_soli_tab.
CONCATENATE 'Name= UNAME' cl_abap_char_utilities=>cr_lf INTO lw_soli_tab-line.
APPEND lw_soli_tab TO li_soli_tab.
CONCATENATE 'Language=E' cl_abap_char_utilities=>cr_lf INTO lw_soli_tab-line.
APPEND lw_soli_tab TO li_soli_tab.
CONCATENATE '[Function]' cl_abap_char_utilities=>cr_lf INTO lw_soli_tab-line.
APPEND lw_soli_tab TO li_soli_tab.
CONCATENATE 'Command=VA01' cl_abap_char_utilities=>cr_lf INTO lw_soli_tab-line.
APPEND lw_soli_tab TO li_soli_tab.
CONCATENATE 'Title=Create Sales Order' cl_abap_char_utilities=>cr_lf INTO lw_soli_tab-line.
APPEND lw_soli_tab TO li_soli_tab.
CONCATENATE 'Type=Transaction' cl_abap_char_utilities=>cr_lf INTO lw_soli_tab-line.
APPEND lw_soli_tab TO li_soli_tab.

Also, you will have to change the parameters of the add_attachment method as below,


TRY.
    lo_document->add_attachment(
    EXPORTING
    i_attachment_type = 'EXT'
    i_attachment_subject = 'SAP_LINK.SAP'
     i_att_content_text = li_soli_tab ).
  CATCH cx_document_bcs INTO lx_document_bcs.
ENDTRY.

Read only

0 Likes
4,406

Use CL_BCS as Clemens suggested. Attach the shortcut file (either built manually or uploaded) as follows:


    lr_document->add_attachment( i_attachment_type    = 'BIN'
                                 i_attachment_subject = 'VA01.sap'
                                 i_att_content_hex   = lt_bin ).

Your anchor tag needs to look like this (use the proper angle brackets - adjustments made here so as not to foul up the post):

{a href="cid:VA01.sap"}Click here to execute VA01{/a}

Read only

Former Member
0 Likes
4,406

Hi Rahul,

I have the same requirement as this, Could you please share your experience or knowledge regarding this. I have successfully attached the shortcut file but when I click on the attachment it opens a dialog window to save the file or attachment. My query here is, can we skip that save file dialog window and open the logon pad directly by clicking on the attachment or link and how you done the referencing to the attachment. Please educate regarding this.

Thanking you.

Regards,

Siva Shankar

Read only

former_member192050
Participant
0 Likes
4,406

Hi Rahul,

i an also in the same situation like when the end user click on the attachment it should open sap session directly with out asking save

Hope u achieved this

please give me some suggession

Read only

rosenberg_eitan
Active Contributor
0 Likes
4,406

Hi,

May I share my 2 cents worth of code:

This is based on what I have learned from this post.

I just added to program Y_R_EITAN_TEST_10_02 (attached program) some code to open MM03 from mail link.


* See FORM mail_1_prep_8

  CALL METHOD ob_string->append_htm

    EXPORTING

      fragment = : '<P><U><a href="cid:MM03.sap">Click here to execute MM03</a></U></P>' .


FORM mail_1_prep_8

  CHANGING

    ob_document_bcs TYPE REF TO cl_document_bcs .



* A link to open SAP transaction



  DATA: big_string TYPE string .



  CONCATENATE big_string '[System]' cl_abap_char_utilities=>cr_lf INTO big_string.

  CONCATENATE big_string 'Name=' sy-sysid cl_abap_char_utilities=>cr_lf INTO big_string.

  CONCATENATE big_string 'Client=' sy-mandt cl_abap_char_utilities=>cr_lf INTO big_string.

  CONCATENATE big_string '[User]' cl_abap_char_utilities=>cr_lf INTO big_string.

  CONCATENATE big_string 'Name=' sy-uname cl_abap_char_utilities=>cr_lf INTO big_string.

  CONCATENATE big_string 'Language=E' cl_abap_char_utilities=>cr_lf INTO big_string.

  CONCATENATE big_string '[Function]' cl_abap_char_utilities=>cr_lf INTO big_string.

  CONCATENATE big_string 'Command=MM03' cl_abap_char_utilities=>cr_lf INTO big_string.

  CONCATENATE big_string 'Title=MM03' cl_abap_char_utilities=>cr_lf INTO big_string.

  CONCATENATE big_string 'Type=Transaction' cl_abap_char_utilities=>cr_lf INTO big_string.



  DATA: it_solix TYPE solix_tab .



  CALL METHOD cl_bcs_convert=>string_to_solix

    EXPORTING

      iv_string = big_string

    IMPORTING

      et_solix  = it_solix.



  DATA: attachment_subject TYPE so_obj_des .



  MESSAGE s000(oo) WITH 'MM03.SAP' space INTO attachment_subject .



  TRY.

      CALL METHOD ob_document_bcs->add_attachment

        EXPORTING

          i_attachment_type    = 'EXT'

          i_attachment_subject = attachment_subject

          i_att_content_hex    = it_solix.

    CATCH cx_document_bcs .

  ENDTRY.



ENDFORM .                    "mail_1_prep_8


Regards.

Read only

0 Likes
4,406

Hi ,

How we link sap short cut attachment and hyperlink in mail body ,

attachment successfully attached , but when i click on that its dispalying pop up window for save ,

how we avoid this .

Thanks

Raghav