Difference between revisions of "SAP ABAP ARCHIVE LINK"

From SapWiki
Line 1: Line 1:
 
==Subir archivo==
 
==Subir archivo==
 
  <nowiki>
 
  <nowiki>
      CALL FUNCTION 'ARCHIV_CREATE_DIALOG_META'
+
CALL FUNCTION 'ARCHIV_CREATE_DIALOG_META'
        EXPORTING
+
  EXPORTING
          ar_object                = gs_arch_info-ar_object
+
    ar_object                = gs_arch_info-ar_object
          object_id                = gs_arch_info-object_id
+
    object_id                = gs_arch_info-object_id
          sap_object              = gs_arch_info-sap_object
+
    sap_object              = gs_arch_info-sap_object
        IMPORTING
+
  IMPORTING
          archiv                  = gs_arch_info-archiv_id
+
    archiv                  = gs_arch_info-archiv_id
          archiv_doc_id            = gs_arch_info-arc_doc_id
+
    archiv_doc_id            = gs_arch_info-arc_doc_id
          documentclass            = gs_arch_info-doc_type
+
    documentclass            = gs_arch_info-doc_type
        CHANGING
+
  CHANGING
          infiletab                = lt_infiletab  "salida
+
    infiletab                = lt_infiletab  "salida
        EXCEPTIONS
+
  EXCEPTIONS
          error_archiv            = 1
+
    error_archiv            = 1
          error_communicationtable = 2
+
    error_communicationtable = 2
          error_connectiontable    = 3
+
    error_connectiontable    = 3
          error_kernel            = 4
+
    error_kernel            = 4
          error_parameter          = 5
+
    error_parameter          = 5
          error_scanqueue          = 6
+
    error_scanqueue          = 6
          canceled_by_user        = 7
+
    canceled_by_user        = 7
          blocked_by_policy        = 8
+
    blocked_by_policy        = 8
          OTHERS                  = 9.
+
    OTHERS                  = 9.
 
</nowiki>
 
</nowiki>
  

Revision as of 15:00, 8 March 2021

Subir archivo

CALL FUNCTION 'ARCHIV_CREATE_DIALOG_META'
  EXPORTING
    ar_object                = gs_arch_info-ar_object
    object_id                = gs_arch_info-object_id
    sap_object               = gs_arch_info-sap_object
  IMPORTING
    archiv                   = gs_arch_info-archiv_id
    archiv_doc_id            = gs_arch_info-arc_doc_id
    documentclass            = gs_arch_info-doc_type
  CHANGING
    infiletab                = lt_infiletab  "salida
  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.

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