Code listing for: CREATE_URL

Description: Create URL (not contents) and attach it to given GOS Object

**************************************************************************
*   Method attributes.                                                   *
**************************************************************************
Instantiation: Public
**************************************************************************

METHOD create_url.

  FIELD-SYMBOLS: <fs> TYPE any.

  DATA:
    ls_business_object TYPE sibflporb,
    ls_properties TYPE sdokpropty,
    lt_properties TYPE sdokproptys,
    lv_dummy_message TYPE string.

  DATA: lt_url TYPE sdokcntascs.

  DATA:
    ls_logical_key TYPE skwf_io,
    ls_physical_key TYPE skwf_io,
    ls_key TYPE skwf_lpio,
    ls_error TYPE skwf_error.

  ls_business_object-instid = object_key.
  ls_business_object-typeid = object_type.
  ls_business_object-catid = category_id.

  ls_properties-name  = 'KW_RELATIVE_URL'.

  IF name IS NOT INITIAL.
    ls_properties-value = name.
  ELSE.
    ls_properties-value = url.
  ENDIF.

  APPEND ls_properties TO lt_properties.

  ls_properties-name  = 'DESCRIPTION'.

  IF description IS INITIAL.
    ls_properties-value = description.
  ELSE.
    ls_properties-value = description.
  ENDIF.

  APPEND ls_properties TO lt_properties.

  ls_properties-name  = 'LANGUAGE'.
  ls_properties-value = sy-langu.
  APPEND ls_properties TO lt_properties.

* Create the url
  APPEND url TO lt_url.

  CALL METHOD cl_crm_documents=>create_url
    EXPORTING
      url             = lt_url
      properties      = lt_properties
      business_object = ls_business_object
    IMPORTING
      loio            = ls_logical_key
      phio            = ls_physical_key
      error           = ls_error.

  IF ls_error IS NOT INITIAL.
    MESSAGE ID ls_error-id TYPE ls_error-type NUMBER ls_error-no
      WITH ls_error-v1 ls_error-v2 ls_error-v3 ls_error-v4
      INTO lv_dummy_message.
    RAISE EXCEPTION TYPE zcx_gos_attachment_exception.
  ENDIF.

  IF ls_error IS INITIAL AND ls_logical_key IS NOT INITIAL.

    ls_key-objtypelo = ls_logical_key-objtype.
    ls_key-classlo = ls_logical_key-class.
    ls_key-objidlo = ls_logical_key-objid.
    ls_key-objtypeph = ls_physical_key-objtype.
    ls_key-classph = ls_physical_key-class.
    ls_key-objidph = ls_physical_key-objid.

    CREATE OBJECT attachment
      EXPORTING
        key = ls_key.

  ENDIF.

ENDMETHOD.