*&---------------------------------------------------------------------*
*& Report ZBAPI_DMS_CV01N
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zbapi_dms_cv01n.
TYPES: BEGIN OF t_record,
gv_descripcion(40), " Description
documentversion(2), " Documet version
documentpart(3), " Document part
created_by(12), " Creator
wsapplication(3), " Document type
docfile(255), " File path
charname(30), " Characteristic Name
charvalue(30) , " Plant maintenance Document
doctyp(3), " Document Type
END OF t_record.
DATA: record TYPE STANDARD TABLE OF t_record WITH HEADER LINE.
DATA: gv_documento LIKE draw-doknr,
* gv_clase LIKE draw-dokar VALUE 'PMD',
gv_version LIKE draw-dokvr VALUE '00',
gv_part LIKE draw-doktl VALUE '000',
gv_descripcion LIKE drat-dktxt,
gv_return LIKE bapiret2,
gv_ruta LIKE bapi_doc_files2-docfile.
DATA: gs_documentdata LIKE bapi_doc_draw2,
gt_characteristicvalues LIKE bapi_characteristic_values OCCURS 0 WITH HEADER LINE,
gt_classallocations LIKE bapi_class_allocation OCCURS 0 WITH HEADER LINE,
gt_documentfiles LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE.
DATA : l_path TYPE string,
length TYPE i.
*--->>> selection Screen
SELECTION-SCREEN BEGIN OF BLOCK rad1 WITH FRAME TITLE text-002.
PARAMETERS: pa_fname LIKE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK rad1.
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_fname.
*&---------------------------------------------------------------------*
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
mask = ',*.TXT,*.TXT.'
mode = 'O'
IMPORTING
filename = pa_fname
EXCEPTIONS
inv_winsys = 01
no_batch = 02
selection_cancel = 03
selection_error = 04.
START-OF-SELECTION.
l_path = pa_fname.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_path
* FILETYPE = 'ASC'
has_field_separator = 'X'
IMPORTING
filelength = length
TABLES
data_tab = record
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE i016(pg) WITH 'Invalid file. Please check again'.
STOP.
ENDIF.
LOOP AT record.
CLEAR: gs_documentdata.
gs_documentdata-documenttype = record-doctyp.
gs_documentdata-documentnumber = gv_documento.
gs_documentdata-documentversion = record-documentversion.
gs_documentdata-documentpart = record-documentpart.
gs_documentdata-description = record-gv_descripcion.
CLEAR: gt_characteristicvalues, gt_characteristicvalues[].
gt_characteristicvalues-classtype = '017'.
gt_characteristicvalues-classname = 'PM_DOCUMENT'.
gt_characteristicvalues-charname = record-charname.
gt_characteristicvalues-charvalue = record-charvalue.
APPEND gt_characteristicvalues.
CLEAR: gt_classallocations, gt_classallocations[].
gt_classallocations-classtype = '017'.
gt_classallocations-classname = 'PM_DOCUMENT'.
APPEND gt_classallocations.
CLEAR: gt_documentfiles, gt_documentfiles[].
gt_documentfiles-wsapplication = record-wsapplication."'XLS'.
*--->>>
* CONCATENATE record-docfile '.' record-wsapplication INTO record-docfile.
* CONDENSE record-docfile.
*--->>>
gt_documentfiles-docfile = record-docfile. " file path
gt_documentfiles-created_by = gt_documentfiles-created_by.
gt_documentfiles-storagecategory = 'Z5'.
gt_documentfiles-checkedin = 'X'.
APPEND gt_documentfiles.
*--->>>
CLEAR: gv_return.
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
documentdata = gs_documentdata
IMPORTING
return = gv_return
TABLES
characteristicvalues = gt_characteristicvalues
classallocations = gt_classallocations
documentfiles = gt_documentfiles.
IF gv_return-type CA 'AE'.
* WRITE gv_return-message.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
CLEAR: gs_documentdata, gv_return, gt_characteristicvalues[], gt_classallocations[], gt_documentfiles[].
ENDLOOP.
************************************************************************************
Data Uploading Format
Description | Documet version | Document part | Creator | Document type | File path | Characteristic Name | Plant maintenance Document | Document Type |
Description test | 00 | 000 | developer1 | PPT | \\172.17.9.151\DMS-Upload\Mobile Safety | MACHINEDRAWINGS | PLANNING & RELIABILITY | PMD |
Permitted document types
Doc Type | Text |
DOC | Microsoft Word file |
DOX | MS word 2007 |
DRW | Autocad files |
HTM | HTML Files |
IMG | Scanned Files (Image) |
JPG | Scanned Files |
MPP | MS Project |
Acrobat Reader | |
PPT | Microsoft Powerpoint |
PPX | Microsoft Powerpoint |
SIM | SAP Tutor Application |
TXT | Text Files |
VSD | Microsoft Visio files |
WWI | Winword 6.0 |
XLS | Microsoft EXCEL |
XLX | MS excel 2007 |
ZTF | TIFF formatt - Scanned Files |
No comments:
Post a Comment