Difference between revisions of "SAP ABAP ARCHIVE LINK"
From SapWiki
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | == | + | ==Tablas== |
− | TOA01 | + | ===TOA01=== |
+ | ejemplo | ||
SAP_OBJECT BUS1309 | SAP_OBJECT BUS1309 | ||
OBJECT_ID 2000000172RBJ | OBJECT_ID 2000000172RBJ | ||
Line 9: | Line 10: | ||
DEL_DATE | DEL_DATE | ||
RESERVE PDF | RESERVE PDF | ||
+ | ===TOADD - Tipos de documento=== | ||
+ | ejemplo | ||
+ | DOC TYPE JPG | ||
+ | MIMETYPE image/jpeg | ||
+ | APPL TYPE | ||
+ | OBJECTTEXT Formato JPEG (extensión JPG) | ||
==Verificar conexión== | ==Verificar conexión== | ||
reporte RSCMSTBT - Verificar acceso con offset y longitud | reporte RSCMSTBT - Verificar acceso con offset y longitud | ||
==Subir archivo== | ==Subir archivo== | ||
+ | ===Con dialogo=== | ||
<nowiki> | <nowiki> | ||
FORM f_cargar_documento USING p_data TYPE ty_data | FORM f_cargar_documento USING p_data TYPE ty_data | ||
Line 67: | Line 75: | ||
ENDFORM. " F_VER_DOCUMENTO | ENDFORM. " F_VER_DOCUMENTO | ||
</nowiki> | </nowiki> | ||
+ | |||
+ | ===Sin dialogo=== | ||
+ | ====FM ARCHIV_CREATE_TABLE==== | ||
+ | ====Programa Ejemplo==== | ||
+ | <nowiki> | ||
+ | DATA: gt_file_table TYPE filetable, "Uploaded file information | ||
+ | gt_content TYPE soli_tab, "Uploaded files content | ||
+ | g_len TYPE i. "File length | ||
+ | |||
+ | DATA: g_ext TYPE sood1-file_ext, "File extension | ||
+ | g_fname TYPE sood1-objdes. "File name | ||
+ | |||
+ | data: g_archiv_id TYPE saearchivi, "Archive connection ID | ||
+ | g_xstring TYPE xstring, "File in Xstring | ||
+ | g_out TYPE i, | ||
+ | g_arc_doc_id TYPE saeardoid. "Archive document ID | ||
+ | |||
+ | DATA gt_content1024 TYPE TABLE OF tbl1024. "RAW 1024 format | ||
+ | |||
+ | data : g_obj TYPE toav0-sap_object value 'BUS1309', "Business object type | ||
+ | g_obj_ty TYPE toaom-ar_object value 'ZBPCR057', "Archive document type | ||
+ | g_OBJECT_ID type TOA01-OBJECT_ID. | ||
+ | |||
+ | g_ext = 'PDF'. | ||
+ | |||
+ | CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' | ||
+ | EXPORTING | ||
+ | buffer = g_xstring | ||
+ | IMPORTING | ||
+ | output_length = g_len | ||
+ | TABLES | ||
+ | binary_tab = gt_content1024. | ||
+ | |||
+ | |||
+ | DATA: lv_doc_typ TYPE toadv-doc_type, | ||
+ | lv_arc_length TYPE sapb-length. | ||
+ | |||
+ | |||
+ | CALL FUNCTION 'ARCHIV_CONNECTDEFINITION_GET' | ||
+ | EXPORTING | ||
+ | objecttype = g_obj | ||
+ | documenttype = g_obj_ty | ||
+ | client = sy-mandt | ||
+ | IMPORTING | ||
+ | archivid = g_archiv_id | ||
+ | EXCEPTIONS | ||
+ | nothing_found = 1 | ||
+ | OTHERS = 2. | ||
+ | |||
+ | lv_doc_typ = g_ext. "File extension | ||
+ | lv_arc_length = g_len. "File length | ||
+ | |||
+ | CALL FUNCTION 'ARCHIVOBJECT_CREATE_TABLE' | ||
+ | EXPORTING | ||
+ | archiv_id = g_archiv_id | ||
+ | document_type = lv_doc_typ | ||
+ | length = lv_arc_length | ||
+ | IMPORTING | ||
+ | archiv_doc_id = g_arc_doc_id | ||
+ | TABLES | ||
+ | binarchivobject = gt_content1024 | ||
+ | EXCEPTIONS | ||
+ | error_archiv = 1 | ||
+ | error_communicationtable = 2 | ||
+ | error_kernel = 3 | ||
+ | OTHERS = 4. | ||
+ | |||
+ | DATA: lv_doc_type TYPE toadv-doc_type, | ||
+ | lv_file_name TYPE toaat-filename, | ||
+ | lv_object_no TYPE sapb-sapobjid. | ||
+ | |||
+ | lv_doc_type = g_ext. "File type PDF | ||
+ | lv_file_name = g_fname. "File Name | ||
+ | lv_object_no = g_OBJECT_ID. | ||
+ | |||
+ | CALL FUNCTION 'ARCHIV_CONNECTION_INSERT' | ||
+ | EXPORTING | ||
+ | archiv_id = g_archiv_id | ||
+ | arc_doc_id = g_arc_doc_id | ||
+ | ar_object = g_obj_ty | ||
+ | object_id = lv_object_no | ||
+ | sap_object = g_obj | ||
+ | doc_type = lv_doc_type | ||
+ | filename = lv_file_name | ||
+ | descr = space | ||
+ | creator = sy-uname | ||
+ | EXCEPTIONS | ||
+ | error_connectiontable = 1 | ||
+ | OTHERS = 2. </nowiki> | ||
==Bajar archivo== | ==Bajar archivo== | ||
+ | ===ARCHIV_GET_TABLE=== | ||
<nowiki> | <nowiki> | ||
DATA: l_sapobj LIKE toa01-sap_object VALUE 'BUS1309', | DATA: l_sapobj LIKE toa01-sap_object VALUE 'BUS1309', | ||
Line 143: | Line 241: | ||
ENDIF. | ENDIF. | ||
+ | </nowiki> | ||
+ | ===ARCHIVOBJECT_GET_TABLE=== | ||
+ | <nowiki> | ||
+ | DATA it_binarchivobject TYPE TABLE OF tbl1024 WITH HEADER LINE. | ||
+ | DATA lv_document_type LIKE toadd-doc_type. | ||
+ | DATA lv_string TYPE string. | ||
+ | DATA lv_da2048 TYPE text2048. | ||
+ | DATA lv_length TYPE sapb-length. | ||
+ | |||
+ | lv_document_type = ls_toa01-ar_object. | ||
+ | |||
+ | CALL FUNCTION 'ARCHIVOBJECT_GET_TABLE' | ||
+ | EXPORTING | ||
+ | archiv_id = ls_toa01-archiv_id | ||
+ | document_type = lv_document_type | ||
+ | archiv_doc_id = ls_toa01-arc_doc_id | ||
+ | IMPORTING | ||
+ | binlength = lv_length | ||
+ | TABLES | ||
+ | binarchivobject = it_binarchivobject | ||
+ | EXCEPTIONS | ||
+ | error_archiv = 1 | ||
+ | error_communicationtable = 2 | ||
+ | error_kernel = 3 | ||
+ | OTHERS = 4. | ||
</nowiki> | </nowiki> | ||
Line 199: | Line 322: | ||
OTHERS = 7. | OTHERS = 7. | ||
</nowiki> | </nowiki> | ||
+ | ==[[SAP_BDS|SAP Business Document Service]]== | ||
+ | |||
+ | ==Notas== | ||
+ | Para análisis, poner un break-point en la función HTTP2_GET (todas las funciones pasan por ahí!!!) |
Latest revision as of 22:37, 3 September 2024
Contents
Tablas
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
TOADD - Tipos de documento
ejemplo
DOC TYPE JPG MIMETYPE image/jpeg APPL TYPE OBJECTTEXT Formato JPEG (extensión JPG)
Verificar conexión
reporte RSCMSTBT - Verificar acceso con offset y longitud
Subir archivo
Con dialogo
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
Sin dialogo
FM ARCHIV_CREATE_TABLE
Programa Ejemplo
DATA: gt_file_table TYPE filetable, "Uploaded file information gt_content TYPE soli_tab, "Uploaded files content g_len TYPE i. "File length DATA: g_ext TYPE sood1-file_ext, "File extension g_fname TYPE sood1-objdes. "File name data: g_archiv_id TYPE saearchivi, "Archive connection ID g_xstring TYPE xstring, "File in Xstring g_out TYPE i, g_arc_doc_id TYPE saeardoid. "Archive document ID DATA gt_content1024 TYPE TABLE OF tbl1024. "RAW 1024 format data : g_obj TYPE toav0-sap_object value 'BUS1309', "Business object type g_obj_ty TYPE toaom-ar_object value 'ZBPCR057', "Archive document type g_OBJECT_ID type TOA01-OBJECT_ID. g_ext = 'PDF'. CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING buffer = g_xstring IMPORTING output_length = g_len TABLES binary_tab = gt_content1024. DATA: lv_doc_typ TYPE toadv-doc_type, lv_arc_length TYPE sapb-length. CALL FUNCTION 'ARCHIV_CONNECTDEFINITION_GET' EXPORTING objecttype = g_obj documenttype = g_obj_ty client = sy-mandt IMPORTING archivid = g_archiv_id EXCEPTIONS nothing_found = 1 OTHERS = 2. lv_doc_typ = g_ext. "File extension lv_arc_length = g_len. "File length CALL FUNCTION 'ARCHIVOBJECT_CREATE_TABLE' EXPORTING archiv_id = g_archiv_id document_type = lv_doc_typ length = lv_arc_length IMPORTING archiv_doc_id = g_arc_doc_id TABLES binarchivobject = gt_content1024 EXCEPTIONS error_archiv = 1 error_communicationtable = 2 error_kernel = 3 OTHERS = 4. DATA: lv_doc_type TYPE toadv-doc_type, lv_file_name TYPE toaat-filename, lv_object_no TYPE sapb-sapobjid. lv_doc_type = g_ext. "File type PDF lv_file_name = g_fname. "File Name lv_object_no = g_OBJECT_ID. CALL FUNCTION 'ARCHIV_CONNECTION_INSERT' EXPORTING archiv_id = g_archiv_id arc_doc_id = g_arc_doc_id ar_object = g_obj_ty object_id = lv_object_no sap_object = g_obj doc_type = lv_doc_type filename = lv_file_name descr = space creator = sy-uname EXCEPTIONS error_connectiontable = 1 OTHERS = 2.
Bajar archivo
ARCHIV_GET_TABLE
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.
ARCHIVOBJECT_GET_TABLE
DATA it_binarchivobject TYPE TABLE OF tbl1024 WITH HEADER LINE. DATA lv_document_type LIKE toadd-doc_type. DATA lv_string TYPE string. DATA lv_da2048 TYPE text2048. DATA lv_length TYPE sapb-length. lv_document_type = ls_toa01-ar_object. CALL FUNCTION 'ARCHIVOBJECT_GET_TABLE' EXPORTING archiv_id = ls_toa01-archiv_id document_type = lv_document_type archiv_doc_id = ls_toa01-arc_doc_id IMPORTING binlength = lv_length TABLES binarchivobject = it_binarchivobject EXCEPTIONS error_archiv = 1 error_communicationtable = 2 error_kernel = 3 OTHERS = 4.
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.
SAP Business Document Service
Notas
Para análisis, poner un break-point en la función HTTP2_GET (todas las funciones pasan por ahí!!!)