Tạo attachment URL with GOS

Các bài viết chia sẽ về các đoạn code, chương trình hoạt động và hữu ích trong lạp trình ABAP
Post Reply
Huyhuynhhong
Posts: 2
Joined: Sun Mar 20, 2022 9:51 am

Tạo attachment URL with GOS

Post by Huyhuynhhong »

Attachment files sé được đính kèm lên PO, SO, Vender, Customer, BP... tùy thuộc object type khi chạy.
Các bước thực hiện:

- Tạo folder ID:

Code: Select all

CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
  EXPORTING
    region    = 'B'
  IMPORTING
    folder_id = ls_folder_id
  EXCEPTIONS
    OTHERS    = 1.
    
- Tạo Content URL:

Code: Select all

DATA lt_objcont TYPE STANDARD TABLE OF soli.
DATA lt_objcont TYPE STANDARD TABLE OF soli.
CONCATENATE '&KEY&' 'http://google.com' INTO ls_objcont.
APPEND ls_objcont TO lt_objcont.
- Set name, language, Sensitivity

Code: Select all

ls_obj_data-objsns = 'O'.
ls_obj_data-objla  = sy-langu.
ls_obj_data-objdes = 'google.com'.
- Call save attachment url

Code: Select all

CALL FUNCTION 'SO_OBJECT_INSERT'
  EXPORTING
    folder_id             = ls_folder_id
    object_type           = 'URL'
    object_hd_change      = l_obj_data
  IMPORTING
    object_id             = l_obj_id
  TABLES
    objhead               = lt_objhead
    objcont               = lt_objcont
  EXCEPTIONS
    active_user_not_exist = 35
    folder_not_exist      = 6
    object_type_not_exist = 17
    owner_not_exist       = 22
    parameter_error       = 23
    OTHERS                = 1000.
- Build key for assign to Bussiness object:

Code: Select all

ls_document_id-foltp = ls_folder_id-objtp.
  ls_document_id-folyr = ls_folder_id-objyr.
  ls_document_id-folno = ls_folder_id-objno.
  ls_document_id-doctp = ls_obj_id-objtp.
  ls_document_id-docyr = ls_obj_id-objyr.
  ls_document_id-docno = ls_obj_id-objno.
- Input business object with objkey is Object number and objtype
in example:
objkey is PO number
objtype = BUS2012 is PO type (referent table TOJTB)

Code: Select all

  ls_object-objkey = '4500136568'.
  ls_object-objtype = 'BUS2012'.
- Assign attachment to Bussiness object

Code: Select all

  CLEAR ls_rel_doc.
  ls_rel_doc-objkey  = ls_document_id.
  ls_rel_doc-objtype = 'MESSAGE'.
  CALL FUNCTION 'BINARY_RELATION_CREATE'
    EXPORTING
      obj_rolea    = ls_object
      obj_roleb    = ls_rel_doc
      relationtype = 'URL'
    EXCEPTIONS
      OTHERS       = 1.
We can save any file with build binary data and save with 'SO_OBJECT_INSERT'
Post Reply