cancel
Showing results for 
Search instead for 
Did you mean: 

Workitem attachment to be done

former_member906594
Participant
0 Kudos

Hi ,

I have a workitem waiting with approver 2 .Now approver 1 calls and tell he forgot to add an attachement before approval .

how can we do this so that approver 1 is given an option( Transaction ) so that he can upload another

attachment and approver 2 also sees it before his approval .

I dont't want approver2 to add the attachment of approver1 .

Regards

Abhilash

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Yes the way mentioned by Arghadip is only way to accomplish this task or otherwise if your business process allows you to make attachment mandatory then you can always force user to attach docs before moving ahead.

Former Member
0 Kudos

One way is to forward the workitem that is sent to approver 2 to Approver 1 and he will attach the document and forward this back again to approver 2. I think this is the only way you can do this as attaching a document will involve dialog step and this step is already completed by Approver 1.

Thanks

Arghadip

former_member906594
Participant
0 Kudos

Hi ,

Thanks for the reply . I think this will work . one more issues can i some how make the create attachement in the my workitem manadtory . I am using a decission step for approval so I want the user to always attach something before approval .

can we achieve this. ?

Former Member
0 Kudos

Hi

Check this comment

Delegate your BOR: SOFM and create a method to force attachment create.

Enter this bit of code to check that the attachment was created:

do.

swc_call_method self 'Create' container.

swc_get_element container '_Result' self.

if sy-subrc = 0.

exit.

else.

message s007(zwf). "raise this exception until attachment saved

endif.

enddo.

This will check the result of the 'Create' method in SOFM. As long as your

attachment was created and saved, the subrc returned will be 0.

Thanks

Arghadip

former_member906594
Participant
0 Kudos

Hi Arghadip ,

Thanks for the great reply . I have worked with Delegation long time back . I have one more doubt.

I delegated the business object to ZSOFM and created a new method CHECKATT and added the code given by you .

Can you tell me how this new method will be called ? do I need to do anything in my builder . I tested one workitem which was in my inbox it is passign through with out any check of attachment .. ?

hope you will reply back soon

Regards

Abhilash

Edited by: Abhilas Stanly on May 10, 2009 6:20 AM

Former Member
0 Kudos

To forec user to attach document you can need to do 2 things.

1> Put the user decision task in the loop.

2> put exit condition say zattach = 'X' for loop that when attachemet is done by user then only exit from loop.

3> To Check whether user has created attachment or not put this piece of code in task(method) after user decision and return the zattach flag from the method to task to workflow through binding.

Select * up to 1 rows
        from SRGBTBREL
        into w_SRGBTBREL
        where INSTID_A = objectid.
 endselect.
if sy-subrc = 0.
"Doc attached" 
zattach = 'X'.
endif

.

4> It will force user to attach document then only it will move to next step.

former_member906594
Participant
0 Kudos

I don think this will work. The table sepecified by you doesnt have all the entries.

bpawanchand
Active Contributor
0 Kudos

You mean to say that already the APR1 approved the workitem and he forgot to add a attachment to the workitem., So you want a mechanism where you can add a attachment to the workitem which is with the APR2 .

If this is the case then get the workitem id of the approved workitem by APR1 (the latest one) and then by using FM SAP_WAPI_ADD_ATTACHMENT you can add a attachement to the workitem. which is in the in the APR2 inbox.

Try Like this i think it works the key thing here is how you will get the workitem ID which is approved by APR1.IF you can do it then by using the FM that i mentioned you can create a attachment to the workitem.

now write the entire logic in a se38 ptogram and create a txn for that.

former_member906594
Participant
0 Kudos

Hi ,

Thanks for the FM it is working and getting attached ..

I have one small isssue . Please find the below code which I have tried .

I want to give the user a transaction so that he can upload the any file ( XL, word, PDF or an email )

and then it can be attached to the workitem . There are 2 parmeters in exporting of the FM lv_xstring and lv_header. lv_header am ok . but lv_xstring can you let me know how can I pass different formats of file to this parameter ? is there any FM once I get the file location during upload.

INCLUDE <CNTN01>.

TYPE-POOLS: SWLC.

include <symbol>.

DATA :

lv_header TYPE swr_att_header,

lv_objsofm TYPE swotobjid-objtype,

lv_objtkey TYPE swotobjid-objkey.

  • ls_fitment TYPE r_fitment_mstr,

data : lv_xstring TYPE xstring,

att_id type SWR_ATT_ID,

lv_return TYPE sy-subrc.

data : bo_sofm TYPE SWC_OBJECT .

lv_xstring = 'test '.

start-of-selection .

  • IF lv_xstring IS NOT INITIAL.

*

  • lv_header-file_type = 'B'.

  • lv_header-file_name = 'Candidate Attachment'.

  • lv_header-file_extension = 'DOC'.

  • lv_header-language = 'EN'.

*

  • CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'

  • EXPORTING

  • workitem_id = '985095'

  • att_header = lv_header

  • att_bin = lv_xstring

  • IMPORTING

  • return_code = lv_return

  • att_id = att_id.

*

  • IF lv_return = 0.

*

  • lv_objtkey = att_id-doc_id.

  • lv_objsofm = 'SOFM'.

  • swc_create_object bo_sofm lv_objsofm lv_objtkey.

*

  • ENDIF. " IF lv_return = 0

*

  • ELSE.

*

  • att_id = 0.

  • lv_objtkey = att_id-doc_id.

*

*

  • swc_create_object bo_sofm lv_objsofm lv_objtkey.

*

  • endif.

Former Member
0 Kudos

Abhilas,

Please follow the steps.

1> Give a provision for user to put in file name on selection screen. A field referring to RLGRAP-FILENAME

2> Use FM GUI_UPLOAD to read the file in binary format (no matter what ever the extension be)

3> Use SCMS_BINARY_TO_XSTRING to convert it to Xstring

4> Use FM SAP_WAPI_ATTACHMENT_ADD, assign the xstring content to import variable ATT_BIN.

I assume this being a one- off activity you can harcode the WI_ID.

You should be aware that you need to change this WI_ID everytime you need to run for different instances and users.

Thanks

AKJ

former_member906594
Participant
0 Kudos

Thanks for the quick reply I will try it out soon .

I have completed the workitem attachment deletion program . it is working fine now . I will try the addtion .

REPORT ZWF_ATTACH_DELETE.

INCLUDE <CNTN01>.

TYPE-POOLS: SWLC.

include <symbol>.

DATA :

lv_header TYPE swr_att_header,

lv_objsofm TYPE swotobjid-objtype,

lv_objtkey TYPE swotobjid-objkey.

  • ls_fitment TYPE r_fitment_mstr,

data : lv_xstring TYPE xstring,

att_id type SWR_ATT_ID,

lv_return TYPE sy-subrc.

data : bo_sofm TYPE SWC_OBJECT .

data : att type SWR_ATT_ID.

data : w_msg type SWR_MSTRUC occurs 0 .

data : wa_msg type SWR_MSTRUC.

selection-screen begin of block b1 with frame.

parameters: WRK_ID like SWR_STRUCT-WORKITEMID obligatory ,

zATT_ID like SWR_ATT_ID-DOC_ID obligatory.

selection-screen end of block b1.

start-of-selection .

att-DOC_CAT ='AT'.

att-DOC_ID = zATT_ID .

CALL FUNCTION 'SAP_WAPI_ATTACHMENT_DELETE'

EXPORTING

WORKITEM_ID = WRK_ID

ATT_ID = att

  • LANGUAGE = SY-LANGU

  • DO_COMMIT = 'X'

IMPORTING

RETURN_CODE = lv_return

TABLES

  • MESSAGE_LINES =

MESSAGE_STRUCT = w_msg

.

write : ' Return code : ' , lv_return.

loop at w_msg into wa_msg.

write : /5 wa_msg-MSGID,

15 wa_msg-MSGTY,

25 wa_msg-MSGNO.

skip 2 .

write :/5 'Message details : '.

write : /5 wa_msg-MSGV1,

30 wa_msg-MSGV2,

50 wa_msg-MSGV3,

60 wa_msg-MSGV4.

endloop.