You can do most of this using the document management system which is already available in SAP so you're basically re-inventing something that exists.
You can view all sorts of files from within SAP.
For example, this routine displays auto cad drawings:
Code:
*&---------------------------------------------------------------------*
*& Include Z_CV03N_ACD_FORMS *
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form Load_Acd
*&---------------------------------------------------------------------*
* text Loads and displays an Autocad Drawing DWG.
* Sets up the handler for this object
*----------------------------------------------------------------------*
* --> Global data from table DRAW
* --> Container to user
* --> ECL 2D Viewer Control to use.
* <-- Control Loaded Ok/Not
*----------------------------------------------------------------------*
Form Load_Acd Changing pc_Main_Container
Type Ref to Cl_Gui_Custom_Container
pc_Acd_Viewer Type Ref to Cl_Gui_Ecl_2dviewer
pc_Ok Type Boolean.
Data: w_FileName type Char255,
w_Del_File type String,
w_Subrc type sysubrc,
w_Error_Code type sysubrc.
*
Move ' ' to pc_Ok.
Perform CheckOut_File Changing w_FileName w_Subrc.
If w_subrc = 0.
Create Object Pc_Main_Container
Exporting
container_name = 'G_MAIN_CONTAINER'
Exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
If sy-subrc <> 0.
Message E000 with 'Could not create ECL Container'.
Else.
Create Object pc_Acd_Viewer
Exporting
Parent = pc_Main_Container
Exceptions
Cntl_Error = 1
Cntl_System_Error = 2
Create_Error = 3
Lifetime_Error = 4
Others = 5.
If sy-subrc <> 0.
Message E000 with 'Could not create ECL Container'.
Else.
Call Method Pc_Acd_Viewer->Open_Document
Exporting
File = W_Filename
Markup_Forbidden = 'X'
Importing
Error_Code = W_Error_Code
Exceptions
Cntl_Error = 1
Cntl_System_Error = 2
Invalid_File_Format = 3
Permission_Denied = 4
File_Not_Found = 5
Bad_File_Name = 6
Invalid_Data = 7
Others = 8.
If Sy-Subrc = 0 And W_Error_Code = 0.
Call Method Pc_Acd_Viewer->Create_Toolbar
Exporting
Options = ' '
Viewer_OpenFile = ' '
Viewer_CloseFile = ' '
Viewer_SaveFile = ' '
Remove_Document = ' '
Exceptions
Cntl_System_Error = 1
Cntl_Error = 2
Cntb_Btype_Error = 3
Dp_Error = 4
Wrong_Fcode_Error = 5
Others = 6.
Call Method Pc_Acd_Viewer->Set_Visible
Exporting
Visible = 'X'
Exceptions
Cntl_Error = 1
Cntl_System_Error = 2
Others = 3.
*
* Create the handler events.
*
Create Object g_Acd_Handler.
set handler g_Acd_Handler->on_file_dropped
for Pc_Acd_Viewer.
Move 'X' to pc_Ok.
Else.
Message E000 with 'Could not open document' w_FileName.
Endif.
EndIf.
EndIf.
Else.
Message E000 with 'Could not check out file.'.
EndIf.
EndForm.
*
Form Process_User_Command_1070.
Case sy-ucomm.
When 'BACK'.
Perform Free_Controls_1070.
When '%EX'.
Perform Free_Controls_1070.
When '%RW'.
Perform Free_Controls_1070.
EndCase.
EndForm.
*
Form Free_Controls_1070.
Call method g_Acd_Viewer->Free.
Call method g_Main_Container->Free.
Perform Delete_CheckedOut_File.
EndForm.
and this code,
Code:
*&---------------------------------------------------------------------*
*& Include Z_CV03N_WRD_FORMS *
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form Load_Wrd
*&---------------------------------------------------------------------*
* text Loads and displays a Word document
*----------------------------------------------------------------------*
* --> Global data from table DRAW
* --> Container to user
* --> Word Container to use
* --> Document proxy
* <-- Control Loaded Ok/Not
*----------------------------------------------------------------------*
Form Load_Wrd Changing pc_Main_Container
Type Ref to Cl_Gui_Custom_Container
pc_Wrd_Container
Type Ref to i_Oi_Container_Control
pc_Wrd_Viewer
Type Ref to i_Oi_Document_Proxy
pc_Ok Type Boolean.
Data: w_FileName type Char255,
w_Del_File type String,
w_co_Subrc type sySubrc,
w_Subrc type Ref To I_OI_Error,
w_Error_Code type SoI_Ret_String,
w_IS_Closed type sysubrc.
*
Move ' ' to pc_Ok.
Perform CheckOut_File Changing w_FileName w_co_Subrc.
If w_co_subrc = 0.
Call Method C_Oi_Container_Control_Creator=>Get_Container_Control
Importing Control = Pc_Wrd_Container.
Call Method C_Oi_Errors=>Show_Message Exporting Type = 'E'.
Create Object Pc_Main_Container
Exporting Container_Name = 'G_WRD_MAIN_CONTAINER'.
Call Method Pc_Main_Container->Set_Visible Exporting Visible = 'X'.
Call Method Pc_Wrd_Container->Init_Control
Exporting R3_Application_Name =
'R/3 Basis' "#EC NOTEXT
Inplace_Enabled = 'X'
Inplace_Scroll_Documents = 'X'
Parent = Pc_Main_Container
Register_On_Close_Event = 'X'
Register_On_Custom_Event = 'X'
No_Flush = ' '.
Call Method C_Oi_Errors=>Show_Message Exporting Type = 'E'.
Call Method Pc_Wrd_Container->Get_Document_Proxy
Exporting Document_Type = 'Word.Document.8'
No_Flush = ' '
Importing Document_Proxy = Pc_Wrd_Viewer.
Call Method C_Oi_Errors=>Show_Message Exporting Type = 'E'.
Call Method Pc_Wrd_Viewer->Is_Destroyed
Importing Ret_Value = w_Is_Closed.
Check Not w_Is_Closed Is Initial.
*
* Need to stick the word 'file://' on the front of the file name
*
Concatenate 'FILE://' w_FileName into w_FileName.
Call Method Pc_Wrd_Viewer->Open_Document
Exporting
Document_Url = w_FileName
No_Flush = ''
Open_Inplace = 'X'
Open_Readonly = 'X'
Protect_Document = 'X'
Onsave_Macro = ''
Startup_Macro = ''
Importing
Error = w_subrc
Retcode = w_Error_Code.
Move 'X' to pc_Ok.
Call Method C_Oi_Errors=>Show_Message Exporting Type = 'E'.
Else.
Message E000 with 'Could not check out file.'.
EndIf.
EndForm.
*
Form Process_User_Command_1080.
Case sy-ucomm.
When 'BACK'.
Perform Free_Controls_1080.
When '%EX'.
Perform Free_Controls_1080.
When '%RW'.
Perform Free_Controls_1080.
EndCase.
EndForm.
*
Form Free_Controls_1080.
Call method g_Wrd_Viewer->Close_Document.
Call method g_Wrd_Container->Destroy_Control.
Call method g_Wrd_Main_Container->Free.
Perform Delete_CheckedOut_File.
endForm.
views a word document. You can view emails, jpgs, bit maps, html pages all sorts.
I would consider having a look at the DMS before you carry on down the route of writing custom uploads etc for documents.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.