This report shows , downloading a file from EDMS through ABAP Program ,
REPORT ZEDMS .
TABLES : DRAW ,MKPF , BKPF , DMS_DOC2LOIO , DMS_PH_CD1.
TYPES : BEGIN OF TY_DATA .
INCLUDE STRUCTURE DRAD.
TYPES : END OF TY_DATA.
TYPES : BEGIN OF TY_URL ,
DOCNO TYPE CHAR25,
DOCTYP TYPE CHAR3,
DOCPT TYPE CHAR3 ,
DOCVER TYPE CHAR2,
FILE TYPE CHAR35,
URL TYPE DMS_URL ,
fin TYPE BKPF-BELNR,
com TYPE BKPF-BUKRS,
year1 TYPE BKPF-GJAHR,
mat TYPE MKPF-MBLNR ,
year TYPE MKPF-MJAHR ,
stat(2) ,
stat1(16) ,
END OF TY_URL .
TYPES : BEGIN OF orgin .
INCLUDE STRUCTURE CVAPI_DOC_FILE .
TYPES : END OF orgin .
DATA : LV_URL TYPE DMS_URL,
LS_DOC TYPE BAPI_DOC_KEYS,
IT_DATA TYPE TABLE OF TY_DATA,
WA_DATA TYPE TY_DATA,
IT_URL TYPE TABLE OF TY_URL ,
WA_URL TYPE TY_URL ,
LT_ORIGINALS TYPE CVAPI_DOC_FILE OCCURS 0 ,
LS_DRAW TYPE DRAW,
FIN TYPE BKPF-BELNR,
COM TYPE BKPF-BUKRS,
YEAR3 TYPE BKPF-GJAHR,
MAT TYPE MKPF-MBLNR ,
YEAR2 TYPE MKPF-MJAHR ,
IT_ORG TYPE TABLE OF ORGIN ,
WA_ORG TYPE ORGIN ,
STATUS(2) ,
STAT1(16) ,
FILE TYPE CHAR35,
F(10),
OFF TYPE I,
LIN TYPE I,
VAL(150),
LEN TYPE I,
LINK TYPE STRING.
DATA :BEGIN OF TEXT1 OCCURS 0 ,
sign(1) TYPE c,
option(2) TYPE c,
low(50) TYPE C ,
high(50) TYPE C,
END OF TEXT1 .
SELECTION-SCREEN BEGIN OF BLOCK RK100 WITH FRAME TITLE TEXT-001.
PARAMETERS : R1 RADIOBUTTON GROUP G1 USER-COMMAND AAA DEFAULT 'X',
R2 RADIOBUTTON GROUP G1 .
SELECTION-SCREEN END OF BLOCK RK100.
"""""""""""""""""""""""Select Option for Material Document"""""""
SELECTION-SCREEN BEGIN OF BLOCK RK101 WITH FRAME TITLE TEXT-002.
SELECT-OPTIONS : MATERIAL FOR MKPF-MBLNR MODIF ID QQQ.
PARAMETERS : YEAR TYPE MKPF-MJAHR MODIF ID QQQ.
SELECTION-SCREEN END OF BLOCK RK101.
"""""""""""""""""""""Select Option for Financial Document""""""""
SELECTION-SCREEN BEGIN OF BLOCK RK102 WITH FRAME TITLE TEXT-003.
SELECT-OPTIONS : FINANCE FOR BKPF-BELNR MODIF ID KKK.
PARAMETERS : COMP TYPE BKPF-BUKRS MODIF ID KKK.
PARAMETERS : YEAR1 TYPE BKPF-GJAHR MODIF ID KKK.
SELECTION-SCREEN END OF BLOCK RK102.
AT SELECTION-SCREEN OUTPUT .
LOOP AT SCREEN .
IF SCREEN-GROUP1 = 'QQQ' AND R2 = 'X' .
SCREEN-ACTIVE = '0'.
MODIFY SCREEN.
CONTINUE.
ENDIF .
IF R1 = 'X' AND SCREEN-GROUP1 = 'KKK' .
SCREEN-ACTIVE = '0'.
MODIFY SCREEN.
CONTINUE.
ELSE.
ENDIF.
ENDLOOP .
START-OF-SELECTION .
IF R1 = 'X' .
"* FOR MATERIAL DOCUMENT *"
"* TEXT1 CONTAINS THE COMBINATION OF MATERIAL DOCUMENT NUMBER AND MATERIAL YEAR .*"
CONCATENATE MATERIAL-LOW YEAR INTO TEXT1-LOW .
IF MATERIAL-HIGH IS NOT INITIAL .
CONCATENATE MATERIAL-HIGH YEAR INTO TEXT1-HIGH .
TEXT1-OPTION = 'BT'.
ELSE.
TEXT1-OPTION = 'EQ'.
ENDIF.
TEXT1-SIGN = 'I'.
APPEND TEXT1 .
ELSEIF R2 = 'X' .
"* FOR FINANCIAL DOCUMENT *"
"* TEXT1 CONTAINS THE COMBINATION OF COMPANY CODE ,FINANCIAL DOCUMENT NUMBER *"
"* AND FINANCIAL YEAR *"
CONCATENATE COMP FINANCE-LOW YEAR1 INTO TEXT1-LOW .
IF FINANCE-HIGH IS NOT INITIAL .
CONCATENATE COMP FINANCE-HIGH YEAR1 INTO TEXT1-HIGH .
TEXT1-OPTION = 'BT'.
ELSE.
TEXT1-OPTION = 'EQ'.
ENDIF.
TEXT1-SIGN = 'I'.
APPEND TEXT1 .
ENDIF .
"* TO FIND THE LIST OF DOCUMENTS WHICH SAVED IN CV01N CONTAINS THE FINANCIAL AND *"
"* MATERIAL DOCUMENT . *"
SELECT * FROM DRAD INTO TABLE IT_DATA WHERE OBJKY IN TEXT1 .
LOOP AT IT_DATA INTO WA_DATA .
ls_doc-documenttype = WA_DATA-dokar.
ls_doc-documentnumber = WA_DATA-doknr.
ls_doc-documentpart = WA_DATA-doktl.
ls_doc-documentversion = WA_DATA-dokvr.
"* TO GET THE DOCUMENT INFO RECORDS *"
SELECT SINGLE * FROM draw INTO ls_draw WHERE DOKAR = WA_DATA-dokar
AND DOKNR = WA_DATA-doknr
AND DOKVR = WA_DATA-dokvr
AND DOKTL = WA_DATA-doktl .
"* TO FIND THE FILE NAME OF THE DOCUMENT *"
SELECT SINGLE FILENAME INTO FILE FROM DMS_DOC_FILES WHERE DOKAR = WA_DATA-dokar
AND DOKNR = WA_DATA-doknr
AND DOKVR = WA_DATA-dokvr
AND DOKTL = WA_DATA-doktl .
"* TO FIND THE URL FOR THE DOCUMENT WHICH IS ATTACHED FROM CV01N OR CV02N *"
CALL FUNCTION 'CVAPI_DOC_GETDETAIL'
DESTINATION 'NONE'
EXPORTING
pf_batchmode = 'X'
pf_dokar = ls_doc-documenttype
pf_doknr = ls_doc-documentnumber
pf_dokvr = ls_doc-documentversion
pf_doktl = ls_doc-documentpart
pf_active_files = 'X'
pf_read_comp = 'X'
pf_read_kpro = 'X'
IMPORTING
psx_draw = ls_draw
TABLES
pt_files = It_orG
EXCEPTIONS
not_found = 1
no_auth = 2
error = 3
OTHERS = 4.
IF R1 = 'X' .
MAT = WA_DATA-OBJKY+0(10) .
YEAR2 = WA_DATA-OBJKY+10(4) .
ELSEIF R2 = 'X' .
COM = WA_DATA-OBJKY+0(4) .
FIN = WA_DATA-OBJKY+4(10) .
YEAR3 = WA_DATA-OBJKY+14(4) .
ENDIF.
"* FINAL INTERNAL TABLE *"
LOOP AT IT_ORG INTO WA_ORG.
if WA_ORG-FILENAME = ' '.
ELSE .
WA_URL-DOCVER = WA_DATA-dokvr .
WA_URL-DOCPT = WA_DATA-doktl .
WA_URL-DOCTYP = WA_DATA-dokar .
WA_URL-DOCNO = WA_DATA-doknr .
WA_URL-FILE = FILE .
WA_URL-URL = WA_ORG-FILENAME.
WA_URL-MAT = MAT.
WA_URL-YEAR = YEAR2 .
WA_URL-FIN = FIN .
WA_URL-COM = COM .
WA_URL-YEAR1 = YEAR3.
WA_URL-STAT = ls_draw-DOKST .
APPEND WA_URL TO IT_URL .
CLEAR WA_URL .
endif.
ENDLOOP.
REFRESH IT_ORG .
CLEAR LV_URL.
ENDLOOP.
IF R1 = 'X' .
DELETE IT_URL WHERE YEAR NE YEAR .
ELSEIF R2 = 'X' .
DELETE IT_URL WHERE YEAR1 NE YEAR1 .
ENDIF .
IF R1 = 'X' .
"* R1 --> REPORTS WILL DISPLAYS MATERIAL DOCUMENT NO *"
"* TEXT TO BE DISPLAY IN HEADER FIELD *"
WRITE : /1(265) SY-ULINE.
FORMAT COLOR 1 INTENSIFIED on .
WRITE : /1 sy-vline , 2(15) 'Material-Doc No' CENTERED ,
17 sy-vline , 18(4) 'Year' CENTERED ,
22 SY-VLINE , 23(25) 'Doc Number' CENTERED ,
48 sy-vline , 49(8) 'Doc Type ' CENTERED ,
57 SY-VLINE , 58(4) 'Part' CENTERED ,
62 SY-VLINE , 63(8) 'Version' CENTERED ,
71 SY-VLINE , 72(16) 'Status' CENTERED ,
88 SY-VLINE , 89(25) 'File Name' CENTERED ,
114 SY-VLINE , 115(150) 'URL' CENTERED ,
265 sy-vline .
FORMAT RESET .
LOOP AT IT_URL INTO WA_URL .
"* FOR STATUS FIELD WHICH DISPLAYED IN THE REPORT *"
IF WA_URL-STAT = 'ZA' .
STAT1 = 'Approved (Final)'.
ELSEIF WA_URL-STAT = 'ZD' .
STAT1 = 'Draft' .
ELSEIF WA_URL-STAT = 'ZE' .
STAT1 = 'Rejected Level 2' .
ELSEIF WA_URL-STAT = 'ZF' .
STAT1 = 'Approve 2 Final' .
ELSEIF WA_URL-STAT = 'ZI' .
STAT1 = 'Reviewer Level 1' .
ELSEIF WA_URL-STAT = 'ZL' .
STAT1 = 'Approved Level 1' .
ELSEIF WA_URL-STAT = 'ZR' .
STAT1 = 'Rejected' .
ELSEIF WA_URL-STAT = 'ZT' .
STAT1 = 'Draft' .
ELSEIF WA_URL-STAT = 'ZU' .
STAT1 = 'Draft' .
ELSEIF WA_URL-STAT = 'ZV' .
STAT1 = 'Review' .
ELSEIF WA_URL-STAT = ' ' .
STAT1 = 'Draft' .
ELSEIF WA_URL-STAT = 'ZW' .
STAT1 = 'Deleted' .
ENDIF .
AT NEW MAT.
WRITE : /1(265) SY-ULINE.
ENDAT .
WRITE : /1 sy-vline , 2(15) WA_URL-MAT,
17 sy-vline , 18(4) WA_URL-YEAR,
22 SY-VLINE , 23(25) WA_URL-DOCNO ,
48 sy-vline , 49(8) WA_URL-DOCTYP,
57 SY-VLINE , 58(4) WA_URL-DOCPT ,
62 SY-VLINE , 63(8) WA_URL-DOCVER ,
71 SY-VLINE , 72(16) STAT1,
88 SY-VLINE , 89(25) WA_URL-FILE ,
114 SY-VLINE , 115(150) WA_URL-URL HOTSPOT ON ,
265 sy-vline .
ENDLOOP .
WRITE : /1(265) SY-ULINE.
ELSEIF R2 = 'X' .
"* R2 --> REPORTS WILL DISPLAYS THE FINANCIAL DOCUMENT NOS *"
WRITE : /1(276) SY-ULINE.
FORMAT COLOR 1 INTENSIFIED on .
WRITE : /1 sy-vline , 2(15) 'Finance-Doc No' CENTERED ,
17 sy-vline , 18(10) 'Comp Code' CENTERED ,
28 sy-vline , 29(4) 'Year' CENTERED ,
33 SY-VLINE , 34(25) 'Doc Number' CENTERED ,
59 sy-vline , 60(8) 'Doc Type ' CENTERED ,
68 SY-VLINE , 69(4) 'Part' CENTERED ,
73 SY-VLINE , 74(8) 'Version' CENTERED ,
82 SY-VLINE , 83(16) 'Status' CENTERED ,
99 SY-VLINE , 100(25) 'File Name' CENTERED ,
125 SY-VLINE , 126(150) 'URL' CENTERED ,
276 sy-vline .
FORMAT RESET .
LOOP AT IT_URL INTO WA_URL .
IF WA_URL-STAT = 'ZA' .
STAT1 = 'Approved (Final)'.
ELSEIF WA_URL-STAT = 'ZD' .
STAT1 = 'Draft' .
ELSEIF WA_URL-STAT = 'ZE' .
STAT1 = 'Rejected Level 2' .
ELSEIF WA_URL-STAT = 'ZF' .
STAT1 = 'Approve 2 Final' .
ELSEIF WA_URL-STAT = 'ZI' .
STAT1 = 'Reviewer Level 1' .
ELSEIF WA_URL-STAT = 'ZL' .
STAT1 = 'Approved Level 1' .
ELSEIF WA_URL-STAT = 'ZR' .
STAT1 = 'Rejected' .
ELSEIF WA_URL-STAT = 'ZT' .
STAT1 = 'Draft' .
ELSEIF WA_URL-STAT = 'ZU' .
STAT1 = 'Draft' .
ELSEIF WA_URL-STAT = 'ZV' .
STAT1 = 'Review' .
ELSEIF WA_URL-STAT = ' ' .
STAT1 = 'Draft' .
ELSEIF WA_URL-STAT = 'ZW' .
STAT1 = 'Deleted' .
ENDIF .
WRITE : /1(276) SY-ULINE.
WRITE : /1 sy-vline , 2(15) WA_URL-FIN,
17 sy-vline , 18(10) WA_URL-COM,
28 sy-vline , 29(4) WA_URL-YEAR1,
33 SY-VLINE , 34(25) WA_URL-DOCNO ,
59 sy-vline , 60(8) WA_URL-DOCTYP,
68 SY-VLINE , 69(4) WA_URL-DOCPT ,
73 SY-VLINE , 74(8) WA_URL-DOCVER ,
82 SY-VLINE , 83(16) STAT1 ,
99 SY-VLINE , 100(25) WA_URL-FILE ,
125 SY-VLINE , 126(150) WA_URL-URL HOTSPOT ON ,
276 sy-vline.
ENDLOOP .
WRITE : /1(276) SY-ULINE.
ENDIF.
AT LINE-SELECTION .
"* TO GET THE CURSOR FIELD WHERE IT IS DOUBLE CLICKED IN THE REPORT *"
GET CURSOR FIELD F OFFSET OFF
LINE LIN VALUE VAL LENGTH LEN.
LINK = VAL .
LOOP AT IT_URL INTO WA_URL .
IF WA_URL-url = VAL .
SELECT SINGLE * FROM draw WHERE DOKAR = WA_URL-DOCTYP
AND DOKNR = WA_URL-DOCNO
AND DOKVR = WA_URL-DOCVER
AND DOKTL = WA_URL-DOCPT .
STATUS = DRAW-DOKST .
ENDIF .
ENDLOOP .
IF STATUS = ' ' .
"* TO EXECUTE THE DOCUMENT WHICH IS PRESENT IN THE PRESENTATION SERVER *"
CALL METHOD cl_gui_frontend_services=>execute
EXPORTING
document = LINK
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
bad_parameter = 3
file_not_found = 4
path_not_found = 5
file_extension_unknown = 6
error_execute_failed = 7
synchronous_failed = 8
not_supported_by_gui = 9
others = 10.
IF sy-subrc <> 0.
ENDIF.
ELSE.
"* TO EXCEUTE THE DOCUMENT PRESENT IN THE APPLICATION SERVER *"
PERFORM file_display .
ENDIF .
*&---------------------------------------------------------------------*
*& Form FILE_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FILE_DISPLAY .
DATA: lf_exit1 TYPE REF TO if_ex_document_storage01,
lf_exit2 TYPE REF TO if_ex_document_files01,
ls_doc_file LIKE dms_doc_file,
ls_cout_def LIKE dms_checkout_def,
lf_appl_name LIKE tdwx-appfd,
lf_func_type LIKE tdwx-apptp,
lf_appl_type(2) TYPE c,
lf_error(1) TYPE c,
lf_check_file(1) TYPE c,
lf_use_url(1) TYPE c,
lf_use_last(1) TYPE c,
lf_file_type(2) TYPE c,
lf_ph_index TYPE i,
lf_lo_index TYPE i,
lf_suppress_dlg(1) TYPE c,
lf_use_control(1) TYPE c,
lf_no_checkout(1) TYPE c,
lf_dummy(1) TYPE c,
gs_draw LIKE draw,
ls_phio LIKE dms_phio,
ls_main_file TYPE dms_rec_file,
ls_phio_file TYPE dms_rec_phio,
ls_phio_x TYPE dms_rec_phio,
lt_components TYPE dms_rec_comp OCCURS 0 WITH HEADER LINE,
lt_draz LIKE draz OCCURS 0 WITH HEADER LINE,
lf_act_imp_existing(1) TYPE c,
tmp_node_key TYPE tv_nodekey,
gf_transaction LIKE syst-tcode,
pf_node_key TYPE tv_nodekey,
gs_frontend LIKE dms_frontend_data,
FILENAME(100) ,
FILE(100) ,
A1(50) ,
A2(3) .
SPLIT VAL AT '.' INTO A1 A2 .
TRANSLATE A2 TO UPPER CASE .
ls_cout_def-KPRO_USE = 'X' .
ls_cout_def-COMP_GET = 'X' .
gf_transaction = 'CV03' .
LOOP AT IT_URL INTO WA_URL where url = val .
SELECT SINGLE * FROM draw INTO gs_draw WHERE DOKAR = WA_URL-DOCTYP
AND DOKNR = WA_URL-DOCNO
AND DOKVR = WA_URL-DOCVER
AND DOKTL = WA_URL-DOCPT .
SELECT SINGLE * FROM DMS_DOC2LOIO WHERE DOKAR = WA_URL-DOCTYP
AND DOKNR = WA_URL-DOCNO
AND DOKVR = WA_URL-DOCVER
AND DOKTL = WA_URL-DOCPT .
SELECT SINGLE * from DMS_PH_CD1 WHERE LOIO_ID = DMS_DOC2LOIO-LO_OBJID .
FILE = WA_URL-DOCNO .
ENDLOOP.
"* FILENAME --> TEMPORARY STORAGE FILE PATH IN THE PRESENTATION SYSTEM *"
"* FILE PATH IS C:\DOCUME~1\(USER ID)\LOCALS~1\Temp\(FILENAME.FILETYPE) *"
FILENAME = 'C:\DOCUME~1\' .
CONCATENATE FILENAME SY-UNAME INTO FILENAME.
CONCATENATE FILENAME '\LOCALS~1\Temp\' INTO FILENAME .
CONCATENATE FILE A2 INTO FILE SEPARATED BY '.' .
CONCATENATE FILENAME FILE INTO FILENAME .
LS_DOC_FILE-FILENO = '1'.
LS_DOC_FILE-LANGU = 'E' .
LS_DOC_FILE-FILENAME = FILENAME .
LS_DOC_FILE-DAPPL = A2 .
LS_PHIO-LO_INDEX = DMS_DOC2LOIO-LO_INDEX .
LS_PHIO-LO_OBJID = DMS_DOC2LOIO-LO_OBJID .
LS_PHIO-PH_OBJID = DMS_PH_CD1-PHIO_ID .
LS_PHIO-LANGU = DMS_PH_CD1-LANGU .
LS_PHIO-STATUS = DMS_PH_CD1-PROP04 .
LS_PHIO-STATUS_NR = DMS_PH_CD1-PROP05 .
LS_PHIO-FILENAME = VAL .
LS_PHIO-ACTIVE_VERSION = DMS_PH_CD1-PROP01 .
LS_PHIO-DELETE_FLAG = DMS_PH_CD1-PROP02 .
LS_PHIO-PROTECTED = DMS_PH_CD1-PROP03 .
LS_PHIO-DEFAULT_LANGU = DMS_PH_CD1-PROP06 .
LS_PHIO-FILE_ID = DMS_PH_CD1-PROP08 .
LS_PHIO-CREATE_AUDIT = 'X'.
LS_PHIO-CREATE_NEW_VERSION = 'X'.
LS_PHIO-STORAGE_CAT = DMS_PH_CD1-STOR_CAT .
LS_PHIO-CREATED_BY = DMS_PH_CD1-CREA_USER .
LS_PHIO-CREATED_AT = DMS_PH_CD1-CREA_TIME .
LS_PHIO-CHANGED_BY = DMS_PH_CD1-CHNG_USER .
LS_PHIO-CHANGED_AT = DMS_PH_CD1-CHNG_TIME .
GS_FRONTEND-FRONTEND_TYPE = 'PC' .
GS_FRONTEND-HOSTNAME = 'DEFAULT' .
GS_FRONTEND-WINSYS = 'WN32' .
"* CREATES THE FILE IN THE TEMPORARY LOCATION *"
CALL FUNCTION 'CV120_DOC_CHECKOUT_VIEW'
EXPORTING: ps_cout_def = ls_cout_def
pf_tcode = gf_transaction
ps_doc_file = ls_doc_file
ps_draw = gs_draw
ps_phio = ls_phio
ps_frontend = gs_frontend
IMPORTING: pfx_file = ls_doc_file-filename
pfx_url = ls_doc_file-url
pfx_use_last = lf_use_last
TABLES: pt_components = lt_components
EXCEPTIONS: error = 1
OTHERS = 2.
lf_func_type = 1 .
lf_check_file = 'X'.
"* EXECUTES THE FILE FROM THE TEMPORORY LOCATION *"
CALL FUNCTION 'CV120_START_APPLICATION'
EXPORTING: pf_dappl = ls_doc_file-dappl
ps_frontend = gs_frontend
pf_apptp = lf_func_type
pf_file = ls_doc_file-filename
pf_check_file = lf_check_file
ps_draw = gs_draw
pf_url = ls_doc_file-url
pf_appnr = ls_doc_file-fileno"Note 1454086
TABLES: pt_draz = lt_draz
pt_components = lt_components
EXCEPTIONS: error = 1
file_not_found = 2.
ENDFORM. " FILE_DISPLAY