1、lv_filename TYPEfilep ,lv_pathTYPE filep .lv docnumberTYPE bapi doc aux - docnumber.ls documentdataTYPE bapi doc draw2 ,ls documentdatax TYPE bapi doc drawx2 , bapi doc draw2x,lt_objectlinksTYPE TABLE OF bapi_doc_drad WITH HEADER LINE,lt_documentfiles TYPE TABLE OF bapi_doc_files2 WIT H HEADER LINE,
2、ls_return TYPE bapiret2 . t_tdwp TYPE TABLE OF tdwp WITH HEADER LINE. nameTYPE draw- filepext (64) TYPE c.IF lt filetableIS INITIAL .EXIT.ENDIF.READ TABLE lt_filetableCALL METHOD cl gui frontend services =file open dialogEXPORTINGwindow title= 选择文件 default extensionCHANGINGfile table= lt filetablerc
3、= lv_rcEXCEPTIONSfile open dialog failed= 1cntl error=2error no gui= 3not supported by gui= 4OTHERS = 9.*解析路径文件PERFORM frm split path file USING lt filetable- filenameCHANGING lv_filename lv_path .INDEX 1.name = lv_filename .WHILE name CA .SPLIT name AT INTO ext name. ENDWHIL.ECONCATENATE. name INTO
4、 name. TRANSLATE name TO LOWER CASE.CALL FUNCTION CV120_DOC_GET_APPLpf file= nameTABLESptx_tdwp= t_tdwp .IF t tdwp ISINITIAL .MESSAGE s001WITH 不支持此类型文件 READ TABLE t_tdwp INDEX 1.- documenttype= con dokar .- documentversion00- documentpart000- description 凭证描述 - username= sy- uname.ls_documentdata-ec
5、number = 123lt documentfiles- storagecategory= con storage cat .- wsapplication= t tdwp - dappl .- docpath= lv path .- docfile= lv filename .- checkedinXAPPEND lt documentfiles .BAPI DOCUMENT CREATE2EXPORTINGdocumentdata= ls documentdataIMPORTINdocumentnumber =return = ls returnTABLES objectlinks =
6、lt_objectlinks documentfiles = lt_documentfiles .IF ls_return -type = E OR lv_docnumber IS INITIAL . * MESSAGEe 001 WITH 上传文件出错 , 请联系管理员 MESSAGE ID ls_return -id TYPE ls_return -type NUMBER ls_ret urn - numberWITH ls_return - message_v1 ls_return - message_v2 ls_return - message_v3 ls_return - messa
7、ge_v4.ELSE.BAPI_TRANSACTION_COMMI.T MESSAGE s001 WITH 上传成功 wa file- doc id =lv_docnumber .- dname =lv filename .- yk planno= wa xqjh h - yk planno .- dtype =name.wa_file - credat = sy- datum.wafile- ctime =sy-uzeit .- cname =uname.APPEND wa_file TO it_fileIF wa xqjh h - yk planno ISNOT INITIAL .MODI
8、FY ztmm xqjh fileFROM wa file .COMMIT WORK AND WAIT.ENDFOR. M FRM_UPLOAD_FILE*& * Form frm_split_path_file* text 拆分路径和文档名FORM frm_split_path_file USING uv_fullname CHANGING cv_filename cv pathname . lt_match TYPE match_result_tab , ls_match LIKE LINE OF lt_match .FIND ALL OCCURRENCESO F IN uv_fullna
9、me IN CHARACTERM ODE RESULTS lt matchIF NOT lt matchISLOOP AT lt_matchINTO ls_match .ENDLOO.PADD 1 TOls match - offset .cv_pathname= uv_fullname ( ls_match - offset ).cv filename= uvfullname+ls match- offset .ENDFOR.M Form FRM_READ_FILE* text* -p1textdirectory_exist ( directory = lv_file ).IF lv res
10、ult CALL METHOD cl gui frontend services=directory createdirectory= lv filerc = lv rcdirectory create failedcntl_error= 2directory_access_denied =4directory already exists= 5path not found= 6unknown_error= 7not_supported_by_gui = 8wrong_parameter = 9OTHERS = 10. IF lv_rc 0 OR sy - subrc executedocum
11、entlv pathsynchronousbad parameterfile_not_found5file extension unknownerror execute failedsynchronous failed= 8not_supported_by_gui= 9OTHERS10.IF sy - subrc p1 text* file_save_dialog EXPORTINGwindow title = 选择位置default extension =default file namelv filenamewith_encodingfile filterinitial directory
12、 =prompt on overwrite =filename= lv_filenamepath= lv pathfullpathlv_fullpath3invalid default file name= 5.IF sy- subrc directory_exist ( directory = lv path ).IF lv_result . MESSAGE e001 WITH 文件路径不存在 lv orfilename= ls_documentfile= lv originalpathreturn = ls_returnIF ls_return IS NOT INITIAL . 下载成功
13、ENDFOR. M FRM DOWN FILEFormFRM DELETE FILEFORM frm_delete_file . lv_line TYPE i ,titlebar 消息提示 text question 是否删除文档 POPUP_TO_CONFIRMtext button 1 是 text button 2 否 default button1display cancel buttonstart column= 25start row =6popup_typeICON_MESSAGE_ERRORanswerlv_answertext_not_foundIF lv answer 用户取消操作 DISPLAY LIKE = condokar= wa file- doc id=
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1