Difference between revisions of "SAP ABAP ARCHIVE LINK"

From SapWiki
Line 1: Line 1:
 
==Tabla de documentos==
 
==Tabla de documentos==
 
TOA01, ejemplo
 
TOA01, ejemplo
SAP_OBJECT    BUS1309
+
SAP_OBJECT    BUS1309
OBJECT_ID      2000000172RBJ
+
OBJECT_ID      2000000172RBJ
ARCHIV_ID      ZP
+
ARCHIV_ID      ZP
ARC_DOC_ID    00505682475E1EDBBAD007C24499CD17
+
ARC_DOC_ID    00505682475E1EDBBAD007C24499CD17
AR_OBJECT      EDXISFOPDF
+
AR_OBJECT      EDXISFOPDF
AR_DATE        20210721
+
AR_DATE        20210721
DEL_DATE
+
DEL_DATE
RESERVE        PDF
+
RESERVE        PDF
  
 
==Verificar conexión==
 
==Verificar conexión==

Revision as of 22:02, 21 July 2021

Tabla de documentos

TOA01, ejemplo

SAP_OBJECT     BUS1309
OBJECT_ID      2000000172RBJ
ARCHIV_ID      ZP
ARC_DOC_ID     00505682475E1EDBBAD007C24499CD17
AR_OBJECT      EDXISFOPDF
AR_DATE        20210721
DEL_DATE
RESERVE        PDF

Verificar conexión

reporte RSCMSTBT - Verificar acceso con offset y longitud

Subir archivo

FORM f_cargar_documento USING p_data TYPE ty_data
                     CHANGING p_archiv_doc_id.
  DATA: l_archiv_id     TYPE toaom-archiv_id VALUE 'ZE',
        l_ar_object     TYPE toaom-ar_object,
        l_object_id     TYPE sapb-sapobjid,
        l_sap_object    TYPE toaom-sap_object VALUE 'ZBUS1309',
        l_archiv_doc_id TYPE toav0-arc_doc_id.

  CLEAR p_archiv_doc_id.

  MOVE p_data-clase_docto TO l_ar_object.
  MOVE p_data-arc_doc_id TO l_archiv_doc_id.
  l_object_id = g_object_id.

  CALL FUNCTION 'ARCHIV_CREATE_DIALOG_META'
    EXPORTING
      archiv_id                = l_archiv_id
      ar_object                = l_ar_object
*     DEL_DATE                 = ' '
*     NOTE                     =
      object_id                = l_object_id
      sap_object               = l_sap_object
*     FILE                     = ' '
*     COMMIT_FLAG              = ' '
*     VSCAN_PROFILE            = '/SCMS/KPRO_CREATE'
*     FILE_DESCR_POP_SUP       = ' '
    IMPORTING
*     ARCHIV                   =
      archiv_doc_id            = l_archiv_doc_id
*     DOCUMENTCLASS            =
* TABLES
*     OUTDOCTAB                =
* CHANGING
*     INFILETAB                =
    EXCEPTIONS
      error_archiv             = 1
      error_communicationtable = 2
      error_connectiontable    = 3
      error_kernel             = 4
      error_parameter          = 5
      error_scanqueue          = 6
      canceled_by_user         = 7
      blocked_by_policy        = 8
      OTHERS                   = 9.
  IF sy-subrc <> 0.
* Implement suitable error handling here
    MESSAGE i000(0k) WITH 'Error en Subir Archivo a Archive Link' DISPLAY LIKE 'E'.
  ENDIF.

  MOVE l_archiv_doc_id TO p_archiv_doc_id.

ENDFORM.                    " F_VER_DOCUMENTO

Bajar archivo

DATA: l_sapobj LIKE toa01-sap_object  VALUE 'BUS1309',
      l_objid  LIKE toa01-object_id   VALUE '%6527124%',
      l_archiv LIKE toa01-archiv_id   VALUE 'ZP',
      l_object LIKE toa01-ar_object   VALUE 'ZAFISH46'.

SELECT *  INTO CORRESPONDING FIELDS OF TABLE t_alf
    FROM toa01
    WHERE
          sap_object  =     l_sapobj  AND
          object_id   LIKE  l_objid   AND
          archiv_id   =     l_archiv  AND
  ar_object  =     l_object.
  IF sy-subrc = 0.
    DATA: l_tabix LIKE sy-tabix,
          w_toaat TYPE toaat.

    LOOP AT t_alf INTO w_alf.
      l_tabix = sy-tabix.
      CLEAR w_toaat.
      SELECT SINGLE * INTO w_toaat
        FROM toaat
      WHERE arc_doc_id = w_alf-arc_doc_id.

      w_alf-responsable  = w_toaat-creator.
*    w_alf-bp_emp     = wa_alv-object_id+12(10).
      w_alf-filename  = w_toaat-filename.
      w_alf-descr     = w_toaat-descr.
      MODIFY t_alf FROM w_alf INDEX l_tabix.

      REFRESH :t_arc_obj, t_binarc_obj.

      CALL FUNCTION 'ARCHIV_GET_TABLE'
        EXPORTING
          ar_object                = w_alf-ar_object
          object_id                = w_alf-object_id
          sap_object               = l_sapobj
        IMPORTING
          length                   = ld_len
*         BINLENGTH                =
        TABLES
          archivobject             = t_arc_obj
          binarchivobject          = t_binarc_obj
        EXCEPTIONS
          error_archiv             = 1
          error_communicationtable = 2
          error_connectiontable    = 3
          error_kernel             = 4
          error_parameter          = 5
          not_unique               = 6
          OTHERS                   = 7.
      IF sy-subrc <> 0.
* Implement suitable error handling here
*        error = c_x.
      ENDIF.

move ld_len to slen.

      CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
        EXPORTING
          input_length = slen
*         FIRST_LINE   = 0
*         LAST_LINE    = 0
        IMPORTING
          buffer       = p_xstring
        TABLES
          binary_tab   = t_binarc_obj
        EXCEPTIONS
          failed       = 1
          OTHERS       = 2.
      IF sy-subrc <> 0.
* Implement suitable error handling here
      ENDIF.


Ver documento

FORM f_ver_documento .
  DATA: l_archiv_id     TYPE toaom-archiv_id VALUE 'ZE',
        l_ar_object     TYPE toaom-ar_object,
        l_object_id     TYPE sapb-sapobjid,
        l_sap_object    TYPE toaom-sap_object VALUE 'ZBUS1309',
        l_archiv_doc_id TYPE toav0-arc_doc_id.

  MOVE wa_data-clase_docto TO l_ar_object.
  MOVE wa_data-arc_doc_id TO l_archiv_doc_id.
  l_object_id = g_object_id.

  CALL FUNCTION 'ARCHIVOBJECT_DISPLAY'
    EXPORTING
      archiv_doc_id            = l_archiv_doc_id
      archiv_id                = l_archiv_id
      object_id                = l_object_id
      ar_object                = l_ar_object
    EXCEPTIONS
      error_archiv             = 1
      error_communicationtable = 2
      error_kernel             = 3
      OTHERS                   = 4.

  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.

ENDFORM.                    " F_VER_DOCUMENTO

Borrar archivo

    CALL FUNCTION 'ARCHIV_DELETE_META'
      EXPORTING
        client                   = sy-mandt
        archiv_id                = gs_ds_rebj_do-archiv_id
        arc_doc_id               = gs_ds_rebj_do-arc_doc_id
        ar_object                = gs_ds_rebj_do-ar_object
        object_id                = gs_ds_rebj_do-object_id
        sap_object               = gs_ds_rebj_do-sap_object
        delete_flag              = 1
      IMPORTING
        all_connections_deleted  = lv_all_connections_deleted
      EXCEPTIONS
        error_connectiontable    = 1
        error_parameter          = 2
        error_archiv             = 3
        error_kernel             = 4
        error_communicationtable = 5
        error_authority          = 6
        OTHERS                   = 7.