cancel
Showing results for 
Search instead for 
Did you mean: 

Drag and drop in CRM7?

0 Kudos

Dear Experts,

We are exploring the drag and drop functionnality for our client in SAP CRM7 standalone.

I have found this solution in the scn http://scn.sap.com/community/developer-center/netweaver-gateway/blog/2014/11/12/file-uploaddownload-... .

However, I am new to SAP CRM and would like to know if this is a potential solution?  Has already implemented it before?

Thanks a lot for your feedback,

Regards,

Emilie

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Emilie,

I am not able to visit the link that you have provided as the link is blocked by our company.

Could you please paste some screen shots and elaborate on the requirement?

Rgds

Hari

0 Kudos

Hi Hari,

Thanks for your concern !

Regarding the requirement:  I am refering to the assignement block 'Attachment' in Service Request.

We are looking for a functionnality Drag and Drop to upload multiple files from a desktop to the CRM_UI in one shot.

Concerning the link, it is a post in the scn: http://http://scn.sap.com/community/developer-center/netweaver-gateway/blog/2014/11/12/file-uploaddo...  , below is an extract:

Thanks a lot for your help.

Create the project in SEGW Transaction Code and the Entity Type:

In the Entity Type Properties select the check box: Media

And the properties of Entity Type are:

And then map the RFC function module for the Create Operation in the Entity Set.

And do the mapping for Get Entity (Read) Operation in the Entity Set.

Then Redefine the DEFINE method in the *MPC_EXT class and add the below logic:

  METHOD define.
super
->define( ).
DATA: lo_entity   TYPE REF TO /iwbep/if_mgw_odata_entity_typ,
       lo_property
TYPE REF TO /iwbep/if_mgw_odata_property.


lo_entity
= model->get_entity_type ( iv_entity_name = 'TerritoryFileAttachment' ).

 
IF lo_entity IS BOUND.
   lo_property
= lo_entity->get_property( iv_property_name = 'MIME_TYPE' ).
  
IF lo_property IS BOUND.
     lo_property
->set_as_content_type( ).
  
ENDIF.
ENDIF.

ENDMETHOD.


Then Redefine the CREATE_STREAM Method (/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_STREAM) in the *DPC_EXT class and implement the below logic to upload the file attachment into the CRM WebUI for a given Territory Plan.

All input parameters/values we have to get into the SLUG parameter from the UI Side (If we have multiple input parameter values then with concatenation of multiple parameter values with delimiter we have to get the values in SLUG parameter).

  METHOD /iwbep/if_mgw_appl_srv_runtime~create_stream.

DATAls_file_attach               TYPE        ztp_s_file_attachment,
       lv_tp_guid                  
TYPE        crm_mktpl_ib_mpl_guid,
       ls_key                      
TYPE        /iwbep/s_mgw_tech_pair,
       lt_keys                     
TYPE        /iwbep/t_mgw_tech_pairs,
       lv_entityset_name           
TYPE        string,
       lv_entity_name              
TYPE        string,
       lo_tech_read_request_context
TYPE REF TO /iwbep/cl_sb_gen_read_aftr_crt,
       ls_entity                   
TYPE REF TO data,
       ls_string                   
TYPE        string.

DATAls_bo                  TYPE        sibflporb,
       lt_properties         
TYPE        sdokproptys,
       ls_properties         
TYPE        sdokpropty,
       lt_file_access        
TYPE        sdokfilacis,
       ls_file_access        
TYPE        sdokfilaci,
       lt_file_content_binary
TYPE        sdokcntbins,
       ls_loio               
TYPE        skwf_io,
       ls_phio               
TYPE        skwf_io,
       ls_error              
TYPE        skwf_error,
       lv_file_size          
TYPE        i,
       lt_messages           
TYPE        zif_zdmtp_service=>bapiret2_t,
       ls_messages           
TYPE        bapiret2,
       lo_dp_facade          
TYPE REF TO /iwbep/if_mgw_dp_facade,
       lv_destination        
TYPE        rfcdest,
       lr_dmtp_service       
TYPE REF TO zcl_dmtp_service,
       lv_tp_id              
TYPE        crm_mktpl_campaignid.


FIELD-SYMBOLS: <ls_data> TYPE any.

CLEAR: ls_file_attach, lv_tp_guid, ls_bo, lt_properties, ls_properties,
        lt_file_access
, ls_file_access, lt_file_content_binary,ls_loio,
        ls_phio
, ls_error, lv_file_size.

***IV_SLUG parameter will be passed from the front-end side
SPLIT iv_slug AT '/' INTO ls_file_attach-tp_id
                       ls_file_attach
-filename
                       ls_file_attach
-name
                       ls_file_attach
-description.

****File Type(MIME TYPE)****
ls_file_attach
-mime_type  = is_media_resource-mime_type.


****File Content in XSTRING.*****
ls_file_attach
-file_value = is_media_resource-value.

****Convert the Territory Plan ID into GUID****
CALL FUNCTION 'CONVERSION_EXIT_CGPLP_INPUT'
EXPORTING
   
input  = ls_file_attach-tp_id
IMPORTING
   
output = lv_tp_guid.

****Build Attachment Business Object****
ls_bo
-catid  = 'BO'.
ls_bo
-typeid = 'BUS2010010' .
ls_bo
-instid = lv_tp_guid.

****Build Attachment Properties****
ls_properties
-name  = 'KW_RELATIVE_URL'. "NAME
ls_properties
-value = ls_file_attach-name.
APPEND ls_properties TO lt_properties.
CLEAR ls_properties.

ls_properties
-name  = 'DESCRIPTION'. "DESCRIPTION
ls_properties
-value = ls_file_attach-description.
APPEND ls_properties TO lt_properties.
CLEAR ls_properties.

ls_properties
-name  = 'MIMETYPE'. "MIME TYPE
ls_properties
-value = ls_file_attach-mime_type.
APPEND ls_properties TO lt_properties.
CLEAR ls_properties.

****Convert the Attachment File Data from XSTRING to BINARY****
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
  
buffer                    = ls_file_attach-file_value
IMPORTING
   output_length
= lv_file_size
TABLES
   binary_tab   
= lt_file_content_binary.

****Build File Access Information****
ls_file_access
-file_size  = lv_file_size.
ls_file_access
-binary_flg = abap_true.
ls_file_access
-file_name  = ls_file_attach-filename.
ls_file_access
-mimetype   = ls_file_attach-mime_type.
APPEND ls_file_access TO lt_file_access.
CLEAR ls_file_access.

****Upload the Attachment for Territory Plan in CRM WEBUI****
CALL METHOD cl_crm_documents=>create_with_table
EXPORTING
   business_object    
= ls_bo
   properties         
= lt_properties
   file_access_info   
= lt_file_access
   file_content_binary
= lt_file_content_binary
IMPORTING
   loio               
= ls_loio
   phio               
= ls_phio
   error              
= ls_error.


IF ls_error IS INITIAL.
  ls_file_attach
-file_loio_guid = ls_loio-objid.
ELSE.
  ls_messages
-id                   = ls_error-id.
  ls_messages
-number           = ls_error-no.
  ls_messages
-type                = ls_error-type .
  ls_messages
-message_v1 = ls_error-v1 .
  ls_messages
-message_v2 = ls_error-v2 .
  ls_messages
-message_v3 = ls_error-v3 .
  ls_messages
-message_v4 = ls_error-v4 .
 
APPEND ls_messages TO lt_messages.

me
->/iwbep/if_sb_dpc_comm_services~rfc_save_log(
EXPORTING
   iv_entity_type
= iv_entity_name
   it_return     
= lt_messages
   it_key_tab    
= it_key_tab ).

****Call RFC commit work****
me
->/iwbep/if_sb_dpc_comm_services~commit_work(
EXPORTING
iv_rfc_dest
= lv_destination) .


RETURN.
ENDIF.


*-------------------------------------------------------------------------*
*             -****Read After Create -******
*-------------------------------------------------------------------------*
CREATE OBJECT lo_tech_read_request_context.
* Create key table for the read operation
ls_key
-name  = 'TP_ID'.
ls_key
-value    = ls_file_attach-tp_id.
APPEND ls_key TO lt_keys.

ls_key
-name  = 'FILENAME'.
ls_key
-value    = ls_file_attach-filename.
APPEND ls_key TO lt_keys.

ls_key
-name  = 'IV_OBJECT'.
ls_key
-value    = 'FILEATTACH'.
APPEND ls_key TO lt_keys.

ls_key
-name  = 'FILE_LOIO_GUID'.
ls_key
-value    = ls_file_attach-file_loio_guid.
APPEND ls_key TO lt_keys.

****Set into request context object the key table and the entity set name****
lo_tech_read_request_context
->set_keys( IMPORTING et_keys = lt_keys ).

lv_entityset_name
= io_tech_request_context->get_entity_set_name( ).

lo_tech_read_request_context
->set_entityset_name( IMPORTING ev_entityset_name = lv_entityset_name ).


****Call read after create****
/iwbep/if_mgw_appl_srv_runtime
~get_entity(
EXPORTING
   iv_entity_name         
= iv_entity_name
   iv_entity_set_name     
= iv_entity_set_name
   iv_source_name         
= iv_source_name
   it_key_tab             
= it_key_tab
   io_tech_request_context
= lo_tech_read_request_context
   it_navigation_path     
= it_navigation_path
IMPORTING
   er_entity              
= ls_entity ).

****Send the read response to the caller interface****
ASSIGN ls_entity->* TO <ls_data>.

IF <ls_data> IS ASSIGNED.
   copy_data_to_ref
(

        EXPORTING

            is_data = <ls_data>
   
CHANGING 

            cr_data = er_entity ).
ENDIF.
ENDIF.
ENDMETHOD.


Once the CREATE_STREAM method redefines is done then we can test the service using the REST Client to upload the file attachment into CRM WebUI for Territory Plan.

Please Note: Maximum file size 30 MB will allow to upload the file from CRM WebUI standard functionality.

Test the service using the Rest-client.

First get the CSRF-Token value while calling below service.

Then in the response we will get the CSRF Token Value.

Then give the CSRF Token value and SLUG parameter in the Headers and choose the file to upload it via OData Service. Once we click on send then file will be uploaded in CRM WebUI for a given Territory Plan.