on 05-27-2014 12:07 PM
Hi Experts,
In my scenario, I have a User decision step and i want to attach the existing smart form as PDF attachment
to the work item of user decision step itself.
for achiving this i have used the Program Exit Tab of the User decision step; i have created one class which has implemented the standard
SAP interface IF_SWF_IFS_WORKITEM_EXIT. Within the method EVENT_RAISED, i have written the following logical steps.
below steps will work only after work item creation event, i.e. SWRCO_EVENT_AFTER_CREATION
IST_OTF_DATA[] = GD_JOB_OUTPUT-OTFDATA.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 10
IMPORTING
BIN_FILESIZE = GD_PDF_LENGTH
BIN_FILE = GD_PDF_XSTRING
TABLES
OTF = IST_OTF_DATA
LINES = IST_LINES
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5.
LS_FILE_HEADER-FILE_TYPE = 'B'.
CONCATENATE SY-DATUM SY-UZEIT 'MYFILE' INTO LS_FILE_HEADER-FILE_NAME. "File name
LS_FILE_HEADER-FILE_EXTENSION = 'PDF'.
LS_FILE_HEADER-LANGUAGE = 'EN'.
refresh: LST_SWR_MESSAG,LST_SWR_MSTRUC.
CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'
EXPORTING
WORKITEM_ID = LV_ID "work item ID
ATT_HEADER = LS_FILE_HEADER
ATT_BIN = GD_PDF_XSTRING "Parameter FM CONVERT_OTF
DOCUMENT_OWNER = SY-UNAME
IMPORTING
RETURN_CODE = LS_RETURN_CODE
ATT_ID = LS_ATTCH_ID
TABLES
MESSAGE_LINES = LST_SWR_MESSAG
MESSAGE_STRUCT = LST_SWR_MSTRUC.
Issue is: after executing this FM, LS_RETURN_CODE value is 7; LST_SWR_MESSAG contains message as 'Unable to create attachment'
LST_SWR_MSTRUC contains 1 row as message ID SWR and message no 220.
Work item does not contain any attachment.
please do the needful.
Regards,
Jagesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, the reason I use this way is because it bypasses problems such as your attachment error, it is closer to the regular way PDFs or attachments are displayed in other programs (if it works for the standard display - it will work for you) that is why I started using z-objects.
Any way (SOFM or z-object) I would recommend you do add the attachment in the program exit but as an attribute (or using a task to create the object) since it will be easier to test and to see problems in the log.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.