on 05-18-2006 2:06 PM
Friends,
can anybody explains about the concept of attachments in work flow what is sofm object why should I use this.
Hi!
I have tried to attach an uploaded document to a workflow using SOFM.
First I convert the document to a table of strings from xstring. Then I call the following code:
CALL FUNCTION 'SWL_SOFM_CREATE_WITH_TABLE'
EXPORTING
note_title = 'Created with SOFM'
document_type = l_extension
IMPORTING
sofm_key = ls_sofm_key
TABLES
note_text = l_contents.
INCLUDE <swfcntn01>.
DATA: lr_sofm TYPE swf_bor_object.
swf_create_object lr_sofm 'SOFM' ls_sofm_key.
CALL METHOD mr_wf_container->if_swf_ifs_parameter_container~set
EXPORTING
name = 'ATTACHMENT'
value = lr_sofm
IMPORTING
returncode = ls_subrc.
NB! A workflow guy inserted an element called 'ATTACHMENT' in the workflow template I use for the worfklow container.
PS: I have still not found out how to convert a Word file into a format that is excepted of SOFM. So I'm still working on this solution. At least it works for TXT files and I can open the attachment as a link in the workitem in the SAP inbox.
Regards, Tine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Why not create a non-SOFM attachment for the MS Word files? I would think it is possible although I don't know quite how to do it. I think SOFM is just an acronym SAP Office Mail and as such contains no magic. Not that I would recommend anyone to use MS Word proprietary document formats for information the authorities may require in 10 years... PDF or ODT would be better choices if this is non-temporary information.
Since you can attach any file type to a document using Generic Object Services it would be a surprise if attachments to a work item can only be SOFMs.
To display the available types, display a work item, go to menu item "Work item" => "Attachments" => "Create" and use F4 in the document type field.
PS: Tom Michael was hacking GOS for one of the A&C solutions. Perhaps he has more to-the-point information. I think he did some serious debugging, so he knows more than your average developer.
Dear Tine,
Your requirement is exactly what we need.Have you been able to resolve this?
We are using a function module to create the event and trigger the workflow. We have also created a container element in workflow named 'Attachments'.
For the below mail posted by you i have few queries.
1. Shall we write the code you have mention in the function module befor calling swe_event_create.
2. we have implemented your code in to our function module however we are not able to find the type of 'mr_wf_container' defied in your code.
I have also atach the code to create the event which is a mix of your code and our code.
************************************
FUNCTION zib_pt_arq_offer_letter_main .
*"----
""Local Interface:
*" IMPORTING
*" VALUE(I_PERNR) TYPE PERNR_D
*" TABLES
*" INPUT_PARA STRUCTURE ZIB_OFFER_SCREEN
*" SOFM STRUCTURE SOFM
*"----
INCLUDE <cntn01>. " include container macros
DATA: objkey LIKE sweinstcou-objkey,
eventid LIKE swedumevid-evtid.
structure containg the details of the candidate passed to workflow through container
DATA : BEGIN OF wag_screen_data.
INCLUDE STRUCTURE zib_offer_screen.
DATA : END OF wag_screen_data.
DATA : BEGIN OF SOFM_DATA occurs 0.
INCLUDE STRUCTURE SOFM.
DATA: END OF SOFM_DATA.
***********************************************
data : l_extension type SOODK-OBJTP value 'RAW',
ls_sofm_key type SWOTOBJID-OBJKEY.
data : begin of l_contents occurs 0,
SOLISTI1 type SOLISTI1 ,
end of l_contents.
CALL FUNCTION 'SWL_SOFM_CREATE_WITH_TABLE'
EXPORTING
note_title = 'Created with SOFM'
document_type = l_extension
IMPORTING
sofm_key = ls_sofm_key
TABLES
note_text = l_contents.
iNCLUDE <swfcntn01>.
DATA: lr_sofm TYPE swf_bor_object.
swf_create_object lr_sofm 'SOFM' ls_sofm_key.
CALL METHOD<b> t_container</b>->if_swf_ifs_parameter_container~set
EXPORTING
name = 'Attachments'
value = lr_sofm
IMPORTING
returncode = ls_subrc.
***************************************************
swc_set_element t_container 'LastName' input_para-LNAME.
swc_set_element t_container 'FirstName' input_para-FNAME .
swc_set_element t_container 'CompanyCode' input_para-BUKRS.
swc_SET_table t_container 'Attachments' SOFM .
passing the primary key of business object
objkey = i_pernr.
*(function module for triggering workflow)
CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
objtype = 'ZOFFER'
objkey = objkey
event = 'CREATE'
CREATOR = ' '
TAKE_WORKITEM_REQUESTER = ' '
START_WITH_DELAY = ' '
START_RECFB_SYNCHRON = ' '
NO_COMMIT_FOR_QUEUE = ' '
DEBUG_FLAG = ' '
NO_LOGGING = ' '
IDENT =
IMPORTING
EVENT_ID = eventid
TABLES
event_container = t_container
EXCEPTIONS
OBJTYPE_NOT_FOUND = 1
OTHERS = 2
.
IF sy-subrc <> 0.
WRITE : 'NO reciver found '.
ELSE.
WRITE : 'One reciever found'.
COMMIT WORK.
ENDIF.
ENDFUNCTION.
************************************
kindly help.
Hi,
I had the same problem in the last days and finally I got a quite simple solution:
I had a look at the FM SWL_SOFM_CREATE_WITH_TABLE an noticed that it calls another FM (SO_DOCUMENT_INSERT_API1) which has a tables parameter for HEX data and is actually able to create a SOFM object from HEX data.
I simply copied SWL_SOFM_CREATE_WITH_TABLE as a customer FM and applied a few changes to make it accept HEX data:
First I added a new table parameter in the interface which gets the HEX data from the calling application (uploaded data using BIN format):
OBJECT_CONTENT_HEX LIKE SOLIX
Here is the code of the FM (I marked all additional and changed lines with a comment):
function z_test_sofm_create_with_table .
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(NOTE_TITLE) LIKE SODOCCHGI1-OBJ_DESCR OPTIONAL
*" VALUE(DOCUMENT_TYPE) LIKE SOODK-OBJTP DEFAULT SPACE
*" EXPORTING
*" VALUE(SOFM_KEY) LIKE SWOTOBJID-OBJKEY
*" TABLES
*" NOTE_TEXT STRUCTURE SOLISTI1 OPTIONAL
*" OBJECT_CONTENT_HEX STRUCTURE SOLIX OPTIONAL
*" EXCEPTIONS
*" ERROR_SOFM_CREATION
*"----------------------------------------------------------------------
data: region like sofd-folrg.
data: folder_id like soodk.
data: l_folder_id like soobjinfi1-object_id.
data: document_data like sodocchgi1.
data: document_info like sofolenti1.
data: object_content like solisti1 occurs 0 with header line.
data: lines like sy-tabix.
*- set default
if document_type is initial.
document_type = 'RAW'.
endif.
*- create office object
*-- get dark folder
region = 'B'.
call function 'SO_FOLDER_ROOT_ID_GET'
exporting
region = region
importing
folder_id = folder_id
exceptions
communication_failure = 1
owner_not_exist = 2
system_failure = 3
x_error = 4
others = 5.
if sy-subrc ne 0.
message e696(wl) "<== Add message class
raising error_sofm_creation.
endif.
*- get description
if note_title is initial.
read table note_text index 1.
note_title = note_text.
endif.
*-- create office document
document_data-obj_name = 'ATTACHMENT'.
document_data-obj_descr = note_title.
document_data-obj_langu = sy-langu.
object_content[] = note_text[].
describe table object_content lines lines.
document_data-doc_size = ( lines - 1 ) * 255 + strlen( object_content ).
if object_content[] is initial. "<== insert
describe table object_content_hex lines lines. "<== insert
document_data-doc_size = lines * 255. "<== insert
endif. "<== insert
l_folder_id = folder_id.
call function 'SO_DOCUMENT_INSERT_API1'
exporting
folder_id = l_folder_id
document_data = document_data
document_type = document_type
importing
document_info = document_info
tables
object_content = object_content
contents_hex = object_content_hex " <== Insert line
exceptions
folder_not_exist = 1
document_type_not_exist = 2
operation_no_authorization = 3
parameter_error = 4
x_error = 5
enqueue_error = 6
others = 7.
if sy-subrc ne 0.
message e696(wl) "<== Add message class
raising error_sofm_creation.
endif.
*- set export parameter
sofm_key = document_info-doc_id.
endfunction.
The returned SOFM key I added to a container element. The element refers to event parameter of type OBJ_RECORD in my ABAP OO Class. In data binding from event to workflow I mapped the element to the AttachObjects parameter (using mode APPEND) in the workflow container.
Using this function I was able to raise an event by using Method cl_swf_evt_event=>raise
that invoked a workitem containing an Excel-File i had uploaded as binary file and passed to the FM Z_TEST_SOFM_CREATE_WITH_TABLE as document type 'XLS'.
In the woritem preview when clicking on the attachment the file was opened directly in Excel.
Actually the new lines for calculation the file size is not yet quite correct. At first glance it does not seem to cause any trouble, but I will stll check that. In FM SO_OBJECT_INSERT the size is again checked and calculated if initial, so leaving size initial might also be an option.
I hope this helps.
Greetings,
Michael Gulitz
Attachments are included in the container of a work item or a workflow as object references (of object type SOFM). They are shown as such on the tab strip "Available objects" of the work item display and from there can be displayed and created.
The titles of the attachments can be found on the first tab strip "Basic data" of the work item display.
while executing Workitem user can create attacments and forward the attachments to the next level of the workflows. For E.g IF you have APPROVAL and REJECTION decision step in Workflow.
IF the responsible agent APPROVES or REJECT he can include APPROVAL or REJECTION note as attachment and by using binding you can forward that note to the next level. So the next level person can read the note about the reason of REJECT or APPROVAL note.
In the WORKFLOW to you need to bind standard workflow container element &_ATTACH_OBJECTS&
Check this URL also
<a href="http://help.sap.com/saphelp_46c/helpdata/en/41/1b13a81c7111d2a20c00a0c943858e/frameset.htm">http://help.sap.com/saphelp_46c/helpdata/en/41/1b13a81c7111d2a20c00a0c943858e/frameset.htm</a>
Also in Transaction SWO1 you can see all the methods and other info of SOFM.
Hope this will help you.
If you have specif question about SOFM , do let us know
Regards
Aman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Aman ,
I am urgently in need of a help . My req is simple I need to create a work item attachment in a PDF document so that the user reads the attachment when he is going to approve it by executing the workitem ....
I have data a in a internal table .. how to bind this data to a SOFM insatnce ..
Regards
Abhilahs
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.