cancel
Showing results for 
Search instead for 
Did you mean: 

Get URL for a file in Application server in AL11

Former Member
0 Kudos

I have a requirement to store the attachments in CRM one order transaction from a local file path on the SAP application server in AL11. So, all the files will be initially placed in a specific directory of the app server. Now, I want to attach this file via the "Create URL" option on the CRMD_ORDER transaction. For this, I need the URL of the file present in the application server. How do we get the URL of any file in the app server?

Anyone has experience on working in a similar scenario?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi ,

can you please clarify your question.

you want you file/Attachment which is available on AL11 to
be placed in Document Tab, the file will be available on AL11
but it is linked up in Document tab of the Order.
Is this your question?

Thanks,

Anitha

Former Member
0 Kudos

Yes, that is my question. The file is available in the app server ( AL11). I want to attach this file through the documents tab on the order.

Former Member
0 Kudos

Hi ,

use

CALL METHOD cl_crm_documents=>create_with_table

           EXPORTING

             business_object     = li_bor

             properties          = li_prop

             file_access_info    = li_file_access_info

             file_content_binary = i_text[]

             raw_mode            = 'X'

           IMPORTING

             loio                = lv_loio

             phio                = lv_phio

             error               = lv_error.

where u can fill the li_file_access_info

lwa_file_access_info-file_size  = lv_size.

         lwa_file_access_info-binary_flg = 'X'.

         lwa_file_access_info-first_line = 1.

         lwa_file_access_info-file_name  = file path on AL11.

         lwa_file_access_info-mimetype   = lv_mimetype.

         lwa_file_access_info-property   = lv_extn.

         APPEND lwa_file_access_info TO li_file_access_info.

and you can use this FM to fill the properties above

CALL FUNCTION 'CRM_KW_SPLIT_FILENAME'

           EXPORTING

             iv_path      = file path on AL11.

           IMPORTING

             ev_filename  = lv_fname

             ev_extension = lv_extn

             ev_mimetype  = lv_mimetype.

Thanks,

Anitha

Former Member
former_member182606
Participant
0 Kudos

The same solution as above post's but I have give the complete coding to save time.

  DATA :

  lv_fname TYPE  string,

  lv_filename TYPE  string,

  lin TYPE i,

  lv_extn TYPE  string,

  lv_mimetype TYPE  w3conttype,

  lt_properties TYPE sdokproptys,

  ls_properties LIKE LINE OF lt_properties,

  lt_file_access_info    TYPE sdokfilacis,

  ls_file_access_info LIKE LINE OF lt_file_access_info,

  lt_file_content_binary TYPE sdokcntbins,

  ls_file_content_binary LIKE LINE OF lt_file_content_binary.

  DATA: ls_bor TYPE sibflporb,

  lv_loio TYPE skwf_io,

  lv_phio TYPE skwf_io,

  lv_error TYPE skwf_error.

  DATA : v_file TYPE string,

       lv_msg TYPE string.

  DATA: result_tab TYPE STANDARD TABLE OF string.

  v_file = '/tmp/sapinst/dbclient.lst'.

  SPLIT v_file AT '/' INTO TABLE result_tab.

  DESCRIBE TABLE result_tab LINES lin.

  READ TABLE result_tab INDEX lin INTO lv_filename.

*------------------------------------------------------------------------------*

*      read the file from the application server

*------------------------------------------------------------------------------*

  OPEN DATASET v_file FOR INPUT MESSAGE lv_msg IN LEGACY BINARY MODE.

  IF sy-subrc NE 0.

    RETURN.

  ELSE.

    WHILE ( sy-subrc EQ 0 ).

      READ DATASET v_file INTO ls_file_content_binary.

      IF NOT ls_file_content_binary IS INITIAL.

        APPEND ls_file_content_binary TO lt_file_content_binary.

      ENDIF.

      CLEAR ls_file_content_binary.

    ENDWHILE.

  ENDIF.

  CLOSE DATASET v_file.

  MOVE: 'BUS2000115' TO ls_bor-typeid,

        'BO' TO ls_bor-catid,

        '0026B98B6AD11ED4B6AC5E61242D9CFE' TO ls_bor-instid.

  CALL FUNCTION 'CRM_KW_SPLIT_FILENAME'

    EXPORTING

      iv_path      = v_file

    IMPORTING

      ev_filename  = lv_fname

      ev_extension = lv_extn

      ev_mimetype  = lv_mimetype.

  DESCRIBE TABLE lt_file_content_binary.

  ls_file_access_info-file_size  = sy-tfill * sy-tleng.

  ls_file_access_info-binary_flg = 'X'.

  ls_file_access_info-first_line = 1.

  ls_file_access_info-file_name  = v_file. "FILE path ON al11.

  ls_file_access_info-mimetype   = lv_mimetype.

  ls_file_access_info-property   = lv_extn.

  APPEND ls_file_access_info TO lt_file_access_info.

  ls_properties-name = 'KW_RELATIVE_URL'.

  ls_properties-value = lv_filename. " E.g.: EXCEL.xlsx

  APPEND ls_properties TO lt_properties.

  ls_properties-name = 'DESCRIPTION'.

  ls_properties-value = lv_filename. "E.g.: Excel file

  APPEND ls_properties TO lt_properties.

  ls_properties-name = 'LANGUAGE'.

  ls_properties-value = 'EN'. " E.g.: ‘EN’.

  APPEND ls_properties TO lt_properties.

  CALL METHOD cl_crm_documents=>create_with_table

    EXPORTING

      business_object     = ls_bor    " Local Persistent Object Reference - BOR-Compatible

      properties          = lt_properties    " SDOK: Object Attribute, Name and Feature

      file_access_info    = lt_file_access_info    " SDOK: Entries for Document Contents in Internal Tables

      file_content_binary = lt_file_content_binary    " SDOK: Line of Binary Document Content for WWW Server

      raw_mode            = 'X'    " KW Framework: Boolean Flag ('X' Active, ' ' Deleted)

    IMPORTING

      loio                = lv_loio

      phio                = lv_phio

      error               = lv_error.