cancel
Showing results for 
Search instead for 
Did you mean: 

How to get attachments to a material and open it via fm ?

gerd_hotz
Contributor
0 Kudos

Hello experts,

in crm 5.0, in tx commpr01 I have a material where I have attached some documents in tabstrip documents.

Now I want to select the documents for this material per report and and then after clicking on the

selected attachement I want to open it.

Does anybody know how to do this with a fm etc. ?

Thanks and best regards

Gerd

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Gerd,

For opening attachments in CRM 5.0 there are 2 possibilities:

1. SAP GUI ---> FOR this please refer to class CL_CRM_DOCUMENT_EXPLORER. Here EXECUTE_FUNCTION hass all the events that you want. (eg. create doc, open doc, etc.) Just call this with the right parameters.

2. PCUI ---> For this please refer to class CL_CRM_DOCUMENTS. Here the method 'do_handle_event' has all the events one can trigger.

I hope this helps.

Regards,

Saurabh

Answers (3)

Answers (3)

gerd_hotz
Contributor
0 Kudos

Hello again,

I've tested again class cl_crm_documents with method get_with_url

but after executing this method I get error 33: content not found.

When I execue method get_with_file I can download the file, no problems.

Does anybody know why the method get_with_url not works ?

Which service in sicf must be activated ?

Thanks

Gerd

Pankaj13
Explorer
0 Kudos

Hi Gede,

I am also undergoing this problem, did u managed to find the solutin for this. Please let me know.

The method cl_crm_documents=>get_with_url returns back error 33 of class SKWF_SDOKERRS.

Same method works fine in our IDES but nnot in live system

Please help.

Reply awaited.

Regards

Pankaj Khare

gerd_hotz
Contributor
0 Kudos

Hi Pankaj,

first I did call fm:

   function zcom_product_get_documents.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     REFERENCE(IV_PRODUCT_GUID) TYPE  COMT_PRODUCT_GUID
*"  EXPORTING
*"     REFERENCE(LT_IOS) TYPE  SKWF_IO
*"     REFERENCE(LT_PHIOLOIOS) TYPE  SKWF_LPIOS
*"     REFERENCE(LT_IOS_PROPERTIES_RESULT) TYPE  CRM_KW_PROPST
*"     REFERENCE(LTT_LOIOS) TYPE  SKWF_IO
*"     REFERENCE(LTT_PHIOS) TYPE  SKWF_IO
*"----------------------------------------------------------------------

  data :
    ls_cm_business_object   type  sibflporb.
  check not iv_product_guid is initial.
  ls_cm_business_object-typeid = 'BUS1178'.
  ls_cm_business_object-catid  = 'BO'.
  ls_cm_business_object-instid = iv_product_guid.

  data: lt_loios type table of skwf_io.
  data: lt_phios type table of skwf_io.

  call method cl_crm_documents=>get_info
    exporting
      business_object       = ls_cm_business_object
*        PROPERTIES_REQUEST    =
         newest_only           = 'X'
*        PROPERTIES_QUERY      =
      importing
        phioloios             = lt_phioloios
        ios_properties_result = lt_ios_properties_result
        loios                 = lt_loios
        phios                 = lt_phios

then I did:

    loop at lt_lt_ios_properties_result into
wa_lt_ios_properties_result.

    ls_result =
      wa_lt_ios_properties_result-properties.

    if wa_lt_ios_properties_result-objtype = 'P'.
      ls_dokumente-objid = wa_lt_ios_properties_result-objid.

      sort ls_result by name ascending.
      append ls_result to lt_result.

      loop at ls_result into  lss_result.
        if lss_result-name = 'KW_RELATIVE_URL'.
          ls_dokumente-name = lss_result-value.
        elseif  lss_result-name = 'CREATED_BY'.
          ls_dokumente-description = lss_result-value.
        elseif   lss_result-name = 'KW_PARENT_FOLDER_ID'.
          ls_dokumente-kw_parent_folder_id = lss_result-value.
        endif.
        ls_dokumente-kw_parent_folder_class = 'BDS_POC22'.
        ls_dokumente-product_id = lt_comm_product-product_guid.
      endloop.

      if ls_dokumente-name <> ''.
        append ls_dokumente to lt_dokumente.
      endif.

    endif.
    clear ls_dokumente.
  endloop.

  loop at lt_dokumente into lss_dokumente.
******
    do 1 times.
      ls_phio-class = lss_dokumente-kw_parent_folder_class .
      ls_phio-objtype = 'P'.
      ls_phio-objid = lss_dokumente-objid.
      ls_component-alias_name = lss_dokumente-name.

** get URL for doc:
      call method o_cl_crm_documents->get_with_url
        exporting
          phio     = ls_phio
          url_type = '2'
        importing
          url      = ls_urls-url.
    enddo.
    append lss_dokumente to ltt_dokumente.
  endloop.

I get the URL and it works.

But I don't know If  I had to start any service in sicf, thats very long ago.

Former Member
0 Kudos

Hi,

For converting XML to itab please refer to

====

CALL TRANSFORMATION {trans|(name)}

[PARAMETERS {p1 = e1 p2 = e2 ...}|(ptab)]

[OBJECTS {o1 = e1 o2 = e2 ...}|(otab)]

[OPTIONS a1 = e1 a2 = e2 ...]

SOURCE {XML sxml}

| {{bn1 = e1 bn2 = e2 ...}|(stab)}

RESULT {XML rxml}

| {{bn1 = f1 bn2 = f2 ...}|(rtab)}.

====

I hope this helps.

Regards,

Saurabh

BGarcia
Active Contributor
0 Kudos

Hello Gerd.

The first part of your question is easy. Try using static method GET_INFO of class CL_CRM_DOCUMENTS to obtain the attachments of an product.

In this method you have to fill the importing parameter BUSINESS_OBJECT, like this:

INSTID -> your product guid

TYPEID -> BUS1178 "Business Object for Product

CA -> BO "Business Object

Execute it, and take a look into table PHIOS. This table has the information so that you can advance into the second part. It has the physical ID.

But this part I don't know how to show it in SAP GUI. I know that if you open it in COMMPR01 t-code, the standard use class CL_CRM_DOCUMENT_EXPLORER

and method EXECUTE_FUNCTION to open the attachment. But I don't know how to instaciate this class

You have an alternative, this is display the attachment content via Internet explorer. If this is a valid alternativa to you, check out static method GET_WITH_URL of class CL_CRM_DOCUMENTS.

Enter in it your PHIO structure (you can read it from table PHIOS from the method above), and enter in url_type the value '2'. You'll obtain in exporting parameter URL, the url link to acceed the attachment via Internet explorer (you must have the service for contentserver activated in your SICF structure)

Hope that this may help you to go a little further.

Kind regards.

Bruno

Former Member
0 Kudos

HI,

I have a similar requirement, that i need to convert xml files into internal table. are you aware of that ?

Regards

Sidd

Pankaj13
Explorer
0 Kudos

Hi Bruno,

Can you please tell me what service needs to be activated in SICF for method cl_crm_documents=>get_with_url to work properly.

Expecting your help.

Regards

Pankaj khare