Application Development 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: 

How to insert hyperlinks in email generated from Workflow

former_member184390
Participant
0 Kudos

Hi Friends,

We have a requierement where in we need to send an email to approver based on status change in the transaction. For eg, when the status is changed from Inprogress to "to be approved, an email should be sent automatically to the approver.

Approver should have the flexibility to approve/reject the request by selecting the hyperlinks in the email.

Can some ohe guide us on how to achieve this functionality.

Regards,

Udaya

1 ACCEPTED SOLUTION

Former Member
0 Kudos

constants : lc_htm type string value 'HTM',

lc_x(1) type c value 'X'.

DATA: lw_document_data TYPE sodocchgi1,

lw_object_content TYPE solisti1,

lw_packing_list TYPE sopcklsti1.

DATA: li_object_content TYPE STANDARD TABLE OF solisti1,

li_packing_list TYPE STANDARD TABLE OF sopcklsti1.

*"Packing list for main document

CLEAR lw_packing_list.

FREE li_packing_list.

MOVE: 1 TO lw_packing_list-head_start,

0 TO lw_packing_list-head_num,

1 TO lw_packing_list-body_start,

lw_tab_lines TO lw_packing_list-body_num,

lc_htm TO lw_packing_list-doc_type.

APPEND lw_packing_list TO li_packing_list.

*"Function module to send email

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

document_data = lw_document_data

put_in_outbox = lc_x

commit_work = lc_x

TABLES

packing_list = li_packing_list

contents_txt = li_object_content

receivers = it_receivers

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8.

IF sy-subrc NE 0.

  • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Edited by: Harpreet Singh Bhuee on Sep 17, 2009 12:54 PM

3 REPLIES 3

Former Member
0 Kudos

Hi

First of all you need to create custom function module to send mail that contains HTML data for that you can function module SO_DOCUMENT_SEND_API1.

Steps

1. Create the HTML page for the email format for your reference.

for eg

<html>

<body>

60001226 has submitted Purchase Order 4500169047 for your Approval.

</body>

</html>

2. Code the above created HTML page format in the ABAP as shown below

for eg

*"Body of mail

<html> TO li_object_content.

<body> TO li_object_content.

CLEAR lw_object_content.

CONCATENATE iv_buyer_id text-003 iv_buyer_name text-004 INTO lw_object_content SEPARATED BY space.

APPEND lw_object_content TO li_object_content.

iv_buyer_id is a variable for dynamic data

Code the complete page like this.

In the packing list pass doc type as HTM.

3. Call the above created funcition module with receivers using workflow step.

4. For implementing approval or rejection by clicking you need to create the function module with webservice.

When user clicks the hyperlink the webservice is called for approval or rejection.

Regards,

Harpreet Singh

Edited by: Harpreet Singh Bhuee on Sep 17, 2009 12:47 PM

Former Member
0 Kudos

constants : lc_htm type string value 'HTM',

lc_x(1) type c value 'X'.

DATA: lw_document_data TYPE sodocchgi1,

lw_object_content TYPE solisti1,

lw_packing_list TYPE sopcklsti1.

DATA: li_object_content TYPE STANDARD TABLE OF solisti1,

li_packing_list TYPE STANDARD TABLE OF sopcklsti1.

*"Packing list for main document

CLEAR lw_packing_list.

FREE li_packing_list.

MOVE: 1 TO lw_packing_list-head_start,

0 TO lw_packing_list-head_num,

1 TO lw_packing_list-body_start,

lw_tab_lines TO lw_packing_list-body_num,

lc_htm TO lw_packing_list-doc_type.

APPEND lw_packing_list TO li_packing_list.

*"Function module to send email

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

document_data = lw_document_data

put_in_outbox = lc_x

commit_work = lc_x

TABLES

packing_list = li_packing_list

contents_txt = li_object_content

receivers = it_receivers

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8.

IF sy-subrc NE 0.

  • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Edited by: Harpreet Singh Bhuee on Sep 17, 2009 12:54 PM

0 Kudos

thank you!

wa_objpack-doc_type = 'HTM'."'RAW'.