常用的模板一般是SMW0和OAOR,根据不同需求来的。
WAD有个不好的地方就是不支持GUI上的OLE和DOI,所以需要做转换,下面是常用的方式:
FUNCTION ZCRM_DOWNLOAD_TEMPLATE *"---------------------------------------------------------------------- *"*"Local Interface: *" IMPORTING *" REFERENCE(IV_OBJID) TYPE W3OBJID *"---------------------------------------------------------------------- DATA: LS_FILEKEY TYPE WWWDATATAB, LT_MIME TYPE TABLE OF W3MIME. DATA: LV_XSTRING TYPE XSTRING, LV_FILENAME TYPE STRING, LV_MIME_TYPE TYPE STRING. LS_FILEKEY-RELID = 'MI'. LS_FILEKEY-OBJID = IV_OBJID. CALL FUNCTION 'WWWDATA_IMPORT' EXPORTING KEY = LS_FILEKEY TABLES MIME = LT_MIME EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0. RETURN. ENDIF. CALL METHOD CL_BCS_CONVERT=>SOLIX_TO_XSTRING EXPORTING IT_SOLIX = LT_MIME * IV_SIZE = RECEIVING EV_XSTRING = LV_XSTRING. SELECT SINGLE VALUE INTO LV_MIME_TYPE FROM WWWPARAMS WHERE RELID = LS_FILEKEY-RELID AND OBJID = LS_FILEKEY-OBJID AND NAME = 'fileextension'. SELECT SINGLE VALUE INTO LV_FILENAME FROM WWWPARAMS WHERE RELID = LS_FILEKEY-RELID AND OBJID = LS_FILEKEY-OBJID AND NAME = 'filename'. CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE( EXPORTING I_FILENAME = LV_FILENAME I_CONTENT = LV_XSTRING I_MIME_TYPE = LV_MIME_TYPE I_IN_NEW_WINDOW = ABAP_FALSE I_INPLACE = ABAP_FALSE ). ENDFUNCTION.
后来做FTP的时候就想到了另一个办法:
文件上传下载类型的模板。。。