SAPABAPDMS文档管理开发.doc

上传人:小飞机 文档编号:4220107 上传时间:2023-04-10 格式:DOC 页数:11 大小:164.50KB
返回 下载 相关 举报
SAPABAPDMS文档管理开发.doc_第1页
第1页 / 共11页
SAPABAPDMS文档管理开发.doc_第2页
第2页 / 共11页
SAPABAPDMS文档管理开发.doc_第3页
第3页 / 共11页
SAPABAPDMS文档管理开发.doc_第4页
第4页 / 共11页
SAPABAPDMS文档管理开发.doc_第5页
第5页 / 共11页
点击查看更多>>
资源描述

《SAPABAPDMS文档管理开发.doc》由会员分享,可在线阅读,更多相关《SAPABAPDMS文档管理开发.doc(11页珍藏版)》请在三一办公上搜索。

1、SAP ABAP DMS文档开发1. 用到的BAPI:BAPI_DOCUMENT_CREATE2 ,ZBAPI_DOCUMENT_CHECKOUTVIEW2,BAPI_DOCUMENT_DELETE_DIRECT2. 其中ZBAPI_DOCUMENT_CHECKOUTVIEW2是从标准的BAPI_DOCUMENT_CHECKOUTVIEW2改写(标准的在导出文档时,会自定义一个文档名称);改动代码如下:a) 新增函数组ZMM_CVBAPIb) 将LCVBAPITOP的定义对象拷贝到LZMM_CVBAPITOPc) 在LZMM_CVBAPITOP最后添加如下:INCLUDElcvbapif01.

2、INCLUDElcvbapif02.INCLUDElcvbapif03.INCLUDElcvbapif04.INCLUDElcvbapif05.INCLUDElcvbapif06.INCLUDElcvbapif07.d) 拷贝函数BAPI_DOCUMENT_CHECKOUTVIEW2到新ZBAPI_DOCUMENT_CHECKOUTVIEW2,添加IMPORT参ORFILENAME,并修改代码。3. 以下为参考代码:*文档类型CONSTANTS:con_dokar(3)VALUEZQX.*存储类别CONSTANTS:con_storage_cat(10)VALUEDMS_C1_ST.FORMf

3、rm_creat_file.DATA:lv_rcTYPEi,lt_filetableTYPEfiletableWITHHEADERLINE.DATA:lv_filenameTYPEfilep,lv_pathTYPEfilep.DATA:lv_docnumberTYPEbapi_doc_aux-docnumber.DATA:ls_documentdataTYPEbapi_doc_draw2,ls_documentdataxTYPEbapi_doc_drawx2,bapi_doc_draw2x,lt_objectlinksTYPETABLEOFbapi_doc_dradWITHHEADERLINE

4、,lt_documentfilesTYPETABLEOFbapi_doc_files2WITHHEADERLINE,ls_returnTYPEbapiret2.DATA:t_tdwpTYPETABLEOFtdwpWITHHEADERLINE.DATA:nameTYPEdraw-filep,ext(64)TYPEc.CALLMETHODcl_gui_frontend_services=file_open_dialogEXPORTINGwindow_title=选择文件default_extension=*CHANGINGfile_table=lt_filetablerc=lv_rcEXCEPTI

5、ONSfile_open_dialog_failed=1tl_error=2error_no_gui=3not_supported_by_gui=4OTHERS=9.IFlt_filetableISINITIAL.EXIT.ENDIF.READTABLElt_filetableINDEX1.*解析路径文件PERFORMfrm_split_path_fileUSINGlt_filetable-filenameCHANGINGlv_filenamelv_path.name=lv_filename.WHILEnameCA.SPLITnameAT.INTOextname.ENDWHILE.CONCAT

6、ENATE.nameINTOname.TRANSLATEnameTOLOWERCASE.CALLFUNCTIONCV120_DOC_GET_APPLEXPORTINGpf_file=nameTABLESptx_tdwp=t_tdwp.IFt_tdwpISINITIAL.MESSAGEs001WITH不支持此类型文件.ENDIF.READTABLEt_tdwpINDEX1.ls_documentdata-documenttype=con_dokar.ls_documentdata-documentversion=00.ls_documentdata-documentpart=000.ls_doc

7、umentdata-description=凭证描述.ls_documentdata-username=sy-uname.*ls_documentdata-ecnumber=123.READTABLEt_tdwpINDEX1.lt_documentfiles-documenttype=ZQX.lt_documentfiles-storagecategory=con_storage_cat.lt_documentfiles-wsapplication=t_tdwp-dappl.lt_documentfiles-docpath=lv_path.lt_documentfiles-docfile=lv

8、_filename.lt_documentfiles-checkedin=X.APPENDlt_documentfiles.CALLFUNCTIONBAPI_DOCUMENT_CREATE2EXPORTINGdocumentdata=ls_documentdataIMPORTINGdocumentnumber=lv_docnumberreturn=ls_returnTABLESobjectlinks=lt_objectlinksdocumentfiles=lt_documentfiles.IFls_return-type=EORlv_docnumberISINITIAL.*MESSAGEe00

9、1WITH上传文件出错,请联系管理员.MESSAGEIDls_return-idTYPEls_return-typeNUMBERls_return-numberWITHls_return-message_v1ls_return-message_v2ls_return-message_v3ls_return-message_v4.ELSE.CALLFUNCTIONBAPI_TRANSACTION_COMMIT.MESSAGEs001WITH上传成功.ENDIF.wa_file-doc_id=lv_docnumber.wa_file-dname=lv_filename.wa_file-yk_pla

10、nno=wa_xqjh_h-yk_planno.wa_file-dtype=name.wa_file-credat=sy-datum.wa_file-ctime=sy-uzeit.wa_file-cname=sy-uname.APPENDwa_fileTOit_file.IFwa_xqjh_h-yk_plannoISNOTINITIAL.MODIFYztmm_xqjh_fileFROMwa_file.COMMITWORKANDWAIT.ENDIF.ENDFORM.FRM_UPLOAD_FILE*&-*&Formfrm_split_path_file*&-*text拆分路径和文档名*-*-p1t

11、ext*p1text*directory_exist(directory=lv_file).IFlv_resultX.CALLMETHODcl_gui_frontend_services=directory_createEXPORTINGdirectory=lv_fileCHANGINGrc=lv_rcEXCEPTIONSdirectory_create_failed=1tl_error=2error_no_gui=3directory_access_denied=4directory_already_exists=5path_not_found=6unknown_error=7not_sup

12、ported_by_gui=8wrong_parameter=9OTHERS=10.IFlv_rc0ORsy-subrc0.MESSAGEe001WITH文件路径拒绝访问.ENDIF.ENDIF.GETCURSORLINElv_line.READTABLEit_fileINTOwa_fileINDEXlv_line.CONCATENATElv_fileINTOlv_originalpath.lv_orfilename=wa_file-dname.CALLFUNCTIONZBAPI_DOCUMENT_CHECKOUTVIEW2EXPORTINGdocumenttype=con_dokardocu

13、mentnumber=wa_file-doc_iddocumentpart=000documentversion=00documentfile=ls_documentfileoriginalpath=lv_originalpathorfilename=lv_orfilenameIMPORTINGreturn=ls_return.IFls_returnISNOTINITIAL.MESSAGEIDls_return-idTYPEls_return-typeNUMBERls_return-numberWITHls_return-message_v1ls_return-message_v2ls_ret

14、urn-message_v3ls_return-message_v4.ENDIF.CONCATENATElv_originalpathlv_orfilenameINTOlv_path.CALLMETHODcl_gui_frontend_services=executeEXPORTINGdocument=lv_pathsynchronous=XEXCEPTIONStl_error=1error_no_gui=2bad_parameter=3file_not_found=4path_not_found=5file_extension_unknown=6error_execute_failed=7s

15、ynchronous_failed=8not_supported_by_gui=9OTHERS=10.IFsy-subrc0.*ImplementsuitableerrorhandlinghereMESSAGEs001WITH打开文档失败DISPLAYLIKEE.ENDIF.ENDFORM.FRM_READ_FILE*&-*&FormFRM_DOWN_FILE*&-*text*-*-p1text*file_save_dialogEXPORTINGwindow_title=选择位置*default_extension=default_file_name=lv_filename*with_enco

16、ding=*file_filter=*initial_directory=*prompt_on_overwrite=XCHANGINGfilename=lv_filenamepath=lv_pathfullpath=lv_fullpathEXCEPTIONStl_error=1error_no_gui=2not_supported_by_gui=3invalid_default_file_name=4OTHERS=5.IFsy-subrc0.EXIT.ENDIF.lv_result=cl_gui_frontend_services=directory_exist(directory=lv_pa

17、th).IFlv_resultX.MESSAGEe001WITH文件路径不存在.ENDIF.lv_originalpath=lv_path.lv_orfilename=lv_filename.CALLFUNCTIONZBAPI_DOCUMENT_CHECKOUTVIEW2EXPORTINGdocumenttype=con_dokardocumentnumber=wa_file-doc_iddocumentpart=000documentversion=00documentfile=ls_documentfileoriginalpath=lv_originalpathorfilename=lv_

18、orfilenameIMPORTINGreturn=ls_return.IFls_returnISNOTINITIAL.MESSAGEIDls_return-idTYPEls_return-typeNUMBERls_return-numberWITHls_return-message_v1ls_return-message_v2ls_return-message_v3ls_return-message_v4.ELSE.MESSAGEs001WITH下载成功.ENDIF.ENDFORM.FRM_DOWN_FILE*&-*&FormFRM_DELETE_FILE*&-*text*-*-p1text

19、*-p2text*-*FORMfrm_delete_file.DATA:lv_lineTYPEi,ls_returnTYPEbapiret2.CALLFUNCTIONPOPUP_TO_CONFIRMEXPORTINGtitlebar=消息提示text_question=是否删除文档text_button_1=是text_button_2=否default_button=1display_cancel_button=start_column=25start_row=6*popup_type=ICON_MESSAGE_ERRORIMPORTINGanswer=lv_answerEXCEPTIONS

20、text_not_found=1OTHERS=2.IFlv_answer1.MESSAGEs001WITH用户取消操作DISPLAYLIKEE.EXIT.ENDIF.GETCURSORLINElv_line.READTABLEit_fileINTOwa_fileINDEXlv_line.CALLFUNCTIONBAPI_DOCUMENT_ENQUEUEEXPORTINGdocumenttype=con_dokardocumentnumber=wa_file-doc_iddocumentpart=000documentversion=00IMPORTINGreturn=ls_return.IFl

21、s_returnISNOTINITIAL.MESSAGEIDls_return-idTYPEls_return-typeNUMBERls_return-numberWITHls_return-message_v1ls_return-message_v2ls_return-message_v3ls_return-message_v4.ENDIF.CALLFUNCTIONBAPI_DOCUMENT_DELETE_DIRECTEXPORTINGdocumenttype=con_dokardocumentnumber=wa_file-doc_iddocumentpart=000documentvers

22、ion=00IMPORTINGreturn=ls_return.CALLFUNCTIONBAPI_DOCUMENT_DEQUEUEEXPORTINGdocumenttype=con_dokardocumentnumber=wa_file-doc_iddocumentpart=000documentversion=00.IFls_return-typeE.CALLFUNCTIONBAPI_TRANSACTION_COMMIT.DELETEit_fileINDEXlv_line.DELETEFROMztmm_xqjh_fileWHEREdoc_id=wa_file-doc_id.MESSAGEs0

23、01WITH删除成功.ELSE.MESSAGEIDls_return-idTYPEls_return-typeNUMBERls_return-numberWITHls_return-message_v1ls_return-message_v2ls_return-message_v3ls_return-message_v4.ENDIF.ENDFORM.FRM_DELETE_FILE*&-*&FormFRM_DOUBLE_CLICK*&-*text*-*-p1text*-p2text*-*FORMfrm_double_click.DATA:filedTYPEchar20.GETCURSORFIELDfiled.IFfiled=IT_FILE-DOC_ID.GETCURSORLINEline.READTABLEit_fileINDEXline.SETPARAMETERIDCV1FIELDit_file-doc_id.SETPARAMETERIDCV2FIELDcon_dokar.SETPARAMETERIDCV3FIELD00.SETPARAMETERIDCV4FIELD000.CALLTRANSACTIONCV03NANDSKIPFIRSTSCREEN.ENDIF.ENDFORM.FRM_DOUBLE_CLICK

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号