資源描述:
《demo excl單頁導入模板程序 和 excel 簡單示例demo》由會員上傳分享,免費在線閱讀,更多相關內容在教育資源-天天文庫。
1、模板導入的程序:REPORT?ZEXCELTEMPLATEUPLOAD.TABLES:?ZHROFFICE.SELECTION-SCREEN?BEGIN?OF?BLOCK?B1?WITH?FRAME?TITLE?TEXT-001.PARAMETERS?SRTFD?LIKE?ZHROFFICE-SRTFD?OBLIGATORY.?"關鍵字(報表事務代碼)PARAMETERS?FILENAME?LIKE?ZHROFFICE-FILENAME?OBLIGATORY.?"文件名SELECTION-SCREEN?END?OF?BLOCK?B1.AT?SEL
2、ECTION-SCREEN?ON?VALUE-REQUEST?FOR?SRTFD.??PERFORM?GETF4HELP1?USING?SRTFD.AT?SELECTION-SCREEN?ON?VALUE-REQUEST?FOR?FILENAME.??PERFORM?GET_PC_FILENAME?USING?FILENAME?'O'.START-OF-SELECTION.??DATA?F(128)?OCCURS?0?WITH?HEADER?LINE.??DATA?LC?TYPE?I.??DATA:?L_PGMNA?LIKE?ZHROFFICE-
3、FILEDESC,????????L_TTEXT?LIKE?TSTCT-TTEXT.??SELECT?A~PGMNA?B~TTEXT????FROM?TSTC?AS?A????LEFT?JOIN?TSTCT?AS?B?ON?SPRSL?=?'1'?AND?B~TCODE?=?A~TCODE????INTO?(L_PGMNA,L_TTEXT)????WHERE?A~TCODE?=?SRTFD.??ENDSELECT.??IF?SY-SUBRC?<>?0.????MESSAGE?'事務代碼不存在!'?TYPE?'S'?DISPLAY?LIKE?'E'
4、.????STOP.??ENDIF.??SPLIT?FILENAME?AT?''?INTO?TABLE?F.??DESCRIBE?TABLE?F?LINES??LC.??READ?TABLE?F?INDEX?LC.??ZHROFFICE-FILENAME?=?F.??ZHROFFICE-FILEDESC?=?L_TTEXT.??ZHROFFICE-AEDAT?=?SY-DATUM.??ZHROFFICE-USERA?=?SY-UNAME.??DATA:?DATA_CONTAINER?LIKE?SOLI?OCCURS?0?WITH?HEADER?
5、LINE.??DATA:?LENGTH?TYPE?I.??CLEAR?DATA_CONTAINER.??REFRESH?DATA_CONTAINER.??CALL?FUNCTION?'WS_UPLOAD'????EXPORTING??????FILENAME????????????=?FILENAME??????FILETYPE????????????=?'BIN'????IMPORTING??????FILELENGTH??????????=?LENGTH????TABLES??????DATA_TAB????????????=?DATA_CO
6、NTAINER????EXCEPTIONS??????CONVERSION_ERROR????=?1??????FILE_OPEN_ERROR?????=?2??????FILE_READ_ERROR?????=?3??????INVALID_TABLE_WIDTH?=?4??????INVALID_TYPE????????=?5??????NO_BATCH????????????=?6??????UNKNOWN_ERROR???????=?7??????OTHERS??????????????=?8.??IF?SY-SUBRC?NE?0.???
7、?CALL?FUNCTION?'POPUP_TO_DISPLAY_TEXT'??????EXPORTING????????TITEL?????=?'上載文件'????????TEXTLINE1?=?'上載失??!'??????EXCEPTIONS????????OTHERS????=?1.??ELSE.????MOVE?LENGTH?TO?DATA_CONTAINER-LINE.????APPEND?DATA_CONTAINER.????EXPORT?DATA_CONTAINER?TO?DATABASE?ZHROFFICE(CN)?ID?SRTFD
8、.????IF?SY-SUBRC?NE?0.??????CALL?FUNCTION?'POPUP_TO_DISPLAY_TEXT'???