Long Shot - SOFM from Workitem to BSP

Breslavets Sergey sergey.breslavets at volvo.com
Fri Jun 29 13:55:57 EDT 2007


Yes, they both type xstring. The statement is a leftover from my
previous experiments - content was of a different type, hence the
assignment. 
You'd also need to include smt like this in the beginning of your html
page to display it but you probably already know it. I have it displayed
in a new window here, but you can use <iframe> as well to have it on the
same page.
---------------------------------------------------------
<%  IF pe->display_url IS NOT INITIAL.
      %>
      <script language="Javascript">
        window.open("<%= pe->display_url%>").focus();
      </script>
      <%
  ENDIF.
%>
--------------------------------------------------------

Regards,
Serge


-----Original Message-----
From: sap-wug-bounces at mit.edu [mailto:sap-wug-bounces at mit.edu] On Behalf
Of Alon Raskin
Sent: Friday, June 29, 2007 4:23 AM
To: SAP Workflow Users' Group
Subject: RE: Long Shot - SOFM from Workitem to BSP

Sergey, this is awesome. 

In your code below you have the following statements

  content = x_content.

How is 'content' declared? I assume x_content is of type xstring?

Alon Raskin
e: araskin at 3i-consulting.com

-----Original Message-----
From: sap-wug-bounces at mit.edu [mailto:sap-wug-bounces at mit.edu] On Behalf
Of Breslavets Sergey
Sent: Friday, June 29, 2007 12:47 AM
To: SAP Workflow Users' Group
Subject: RE: Long Shot - SOFM from Workitem to BSP

Hi Alon, 
 
that's what i use (I got a weblog on that) - works for any type of
attachments configured in R/3 box. Hope this helps..

Regards,
Serge
 
------------------- DO HANDLE EVENT ------------------

  CALL FUNCTION 'SO_DOCUMENT_READ_API1'
    EXPORTING
      DOCUMENT_ID                       = l_docid
   IMPORTING
     DOCUMENT_DATA                      = ls_docdata
   TABLES
     OBJECT_CONTENT                     = lt_content
   EXCEPTIONS
     DOCUMENT_ID_NOT_EXIST            = 1
     OPERATION_NO_AUTHORIZATION       = 2
     X_ERROR                          = 3
     OTHERS                           = 4
            .
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  describe table lt_content lines l_size.
  multiply l_size by 255.

  CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
    EXPORTING
      INPUT_LENGTH       = l_size
*     FIRST_LINE         = 0
*     LAST_LINE          = 0
    IMPORTING
      BUFFER             = x_content
    TABLES
      BINARY_TAB         = lt_content
    EXCEPTIONS
      FAILED             = 1
      OTHERS             = 2
            .
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  content = x_content.

  data: l_mimetype type W3CONTTYPE,
        l_type type string.

  translate ls_object-file_ext to lower case.

  clear l_type.

  CALL FUNCTION 'SDOK_MIMETYPE_GET'
    EXPORTING
      EXTENSION                  = ls_object-file_ext
      X_USE_LOCAL_REGISTRY       = 'X'
    IMPORTING
      MIMETYPE                   = l_mimetype
            .

  l_type = l_mimetype.

  CREATE OBJECT cached_response
         TYPE CL_HTTP_RESPONSE EXPORTING add_c_msg = 1.

  l_xlen = xstrlen( content ).
  cached_response->set_data( data   = content
                      length = l_xlen ).

  cached_response->set_header_field(
        name  = if_http_header_fields=>content_type
        value = l_type ).
  cached_response->set_status( code = 200 reason = 'OK' ).
  cached_response->server_cache_expire_rel( expires_rel = 180 ).

  CALL FUNCTION 'GUID_CREATE'
    IMPORTING
      ev_guid_32 = guid.

  CONCATENATE runtime->application_url '/' guid '.'
              ls_object-file_ext
              INTO me->display_url.

  cl_http_server=>server_cache_upload( url      = me->display_url
                                       response = cached_response ).


________________________________

From: sap-wug-bounces at mit.edu [mailto:sap-wug-bounces at mit.edu] On Behalf
Of Alon Raskin
Sent: Thursday, June 28, 2007 10:07 PM
To: SAP Workflow Users' Group
Subject: Long Shot - SOFM from Workitem to BSP



I know it's a long shot.

 

A SOFM is  created by a user by attaching a PPT file (Powerpoint) to a
work item.

 

What the BSP does is read the SOFM using SO_DOCUMENT_READ_API1 and
return the file to the BSP so that the PPT can be displayed.


The problem is that what the user sees is a whole bunch of junk. My
guess is that the problem is the conversion of the data from the FM
SO_DOCUMENT_READ_API1 to XSTRING. Perhaps someone has done something
like this before and can suggest what I am doing wrong?

 

I have attached the code.

 

Regards,

 

Alon Raskin

e: araskin at 3i-consulting.com <mailto:araskin at 3i-consulting.com> 

_______________________________________________
SAP-WUG mailing list
SAP-WUG at mit.edu
http://mailman.mit.edu/mailman/listinfo/sap-wug

_______________________________________________
SAP-WUG mailing list
SAP-WUG at mit.edu
http://mailman.mit.edu/mailman/listinfo/sap-wug




More information about the SAP-WUG mailing list