Adding an URL to a Work Item - Sample Code

Sue Doughty Sue.Doughty at odfl.com
Mon Apr 2 14:22:28 EDT 2007


Dimitri,
 
It looks to me that ZMBO_GET_URL_LINK builds the URL.  What does this
function module do - it looks like a module you built?  I can't figure
out how the URL gets into the attachment.  I want to add an internal web
address. 
 

________________________________

From: sap-wug-bounces at mit.edu [mailto:sap-wug-bounces at mit.edu] On Behalf
Of Dimitri Dupont
Sent: Friday, March 30, 2007 4:38 AM
To: SAP Workflow Users' Group
Subject: Adding an URL to a Work Item - Sample Code



Hello what we did here is following  for the purists it is maybe not the
cleanest code but it does the trick ;-)


1 Create a background task to create the attachement object 
The code is here below 
I did this for an appraisal process thus the 'APPR_DOC' object used but
just replace it with your object 

begin_method insertattachement changing container. 
DATA: p_botype LIKE borident-objtype   VALUE 'APPR_DOC', " 
      p_bo_id  LIKE borident-objkey, 
*" Key e.g. PO No. 
*  Object_b 
     p_msgtyp  LIKE sofm-doctp         VALUE 'URL', 
     p_docty   LIKE borident-objtype   VALUE 'MESSAGE', 
*  Relationship 
     p_reltyp  LIKE breltyp-reltype    VALUE 'URL'. 

p_bo_id = object-key. 

TYPES: BEGIN OF ty_message_key, 
      foltp TYPE so_fol_tp, 
      folyr TYPE so_fol_yr, 
      folno TYPE so_fol_no, 
      doctp TYPE so_doc_tp, 
      docyr TYPE so_doc_yr, 
      docno TYPE so_doc_no, 
      fortp TYPE so_for_tp, 
      foryr TYPE so_for_yr, 
      forno TYPE so_for_no, 
     END OF ty_message_key. 
DATA : lv_message_key TYPE ty_message_key. 
DATA : lo_message TYPE swc_object. 
DATA : lt_doc_content TYPE STANDARD TABLE OF soli-line 
                           WITH HEADER LINE. 
*----------------------------------------------------------------------*

* First derive the Attachment's ( MESSAGE )document type. 
p_docty = 'MESSAGE'. 
p_msgtyp = 'URL'. 
*----------------------------------------------------------------* 

* Create an initial instance of BO 'MESSAGE' - to call the 
* instance-independent method 'Create'. 
swc_create_object lo_message 'MESSAGE' lv_message_key. 
* define container to pass the parameter values to the method call 
* in next step. 
swc_container lt_message_container. 
* Populate container with parameters for method 
swc_set_element lt_message_container 'DOCUMENTTITLE' 'MBO Portal'. "
title of your attachement 
swc_set_element lt_message_container 'DOCUMENTLANGU' 'E'. 
swc_set_element lt_message_container 'NO_DIALOG'     'X'. 
swc_set_element lt_message_container 'DOCUMENTNAME'   p_docty. 
swc_set_element lt_message_container 'DOCUMENTTYPE'   p_msgtyp. 

* In case of URLs..it should be concatenated with &KEY& in the begining.

DATA: ilen TYPE i. 
DATA: l_url1(255). 
CASE p_msgtyp. 
  WHEN 'URL'. 
*   fill link 
    DATA: l_url TYPE string. 
    CALL FUNCTION 'ZMBO_GET_URL_LINK' 
      EXPORTING 
        PLAN_VERSION = OBJECT-KEY-PLANVERSION 
        APPRAISAL_ID = OBJECT-KEY-ID 
        PART_AP_ID   = OBJECT-KEY-PARTID 
      IMPORTING 
        L_URL        = L_URL. 
    CONCATENATE '&KEY&' l_url INTO lt_doc_content. 
**    lt_doc_content = '&KEY&http://www.google.com'
<http://www.google.com'>  . 
    APPEND lt_doc_content. 

* In case of Notes or Private Notes, get the data from files on appl 
* server or from wherever(? - remember background). 
  WHEN 'RAW'. 
    lt_doc_content = 'Hi How r u?' . 
    APPEND lt_doc_content. 
* In case of PC File attachments 
  WHEN OTHERS. 
ENDCASE. 

 

* 'DocumentContent' is a multi-line element ( itab ). 
swc_set_table lt_message_container 'DocumentContent' lt_doc_content. 
* Size is required in case of File attachments 
DATA : lv_doc_size TYPE i. 
DATA : l_file_lines TYPE i. 
DESCRIBE TABLE lt_doc_content LINES l_file_lines. 
READ TABLE lt_doc_content INDEX l_file_lines. 
lv_doc_size = ( 255 * ( l_file_lines - 1 ) ) + 
            STRLEN( lt_doc_content ). 
swc_set_element lt_message_container 'DOCUMENTSIZE'   lv_doc_size . 
* Refresh to get the reference of create 'MESSAGE' object for attachment

swc_refresh_object lo_message. 
swc_call_method lo_message 'CREATE' lt_message_container. 
* Get Key of new object 
swc_get_object_key lo_message lv_message_key. 

COMMIT WORK. 

swc_create_object lo_message 'SOFM' lv_message_key. 
swc_set_element container 'LinkAttachement' lo_message. 

end_method. 

2. Bind the task contaienr element to the workflow container element
&_ATTACH_OBJECTS& 

3. In your dialog task bind this &_ATTACH_OBJECTS& of the WF COntainer
to the Task COntainer and voila 
the trick is done 

 

Dimitri Dupont 

 



****************************
CONFIDENTIALITY NOTICE: The information contained in this message may be confidential, privileged, proprietary, or otherwise legally exempt from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that you are not authorized to read, print, retain, copy or disseminate this message, any part of it, or any attachments. If you have received this message in error, please delete this message and any attachments from your system without reading the content and notify the sender immediately of the inadvertent transmission. Thank you for your cooperation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/sap-wug/attachments/20070402/a88e11f4/attachment.htm


More information about the SAP-WUG mailing list