文档相关表:
DRAW 文档主记录
DRAT 文档描述
TDWS 文档状态
TDWST 文档状态文本
TDWA 文档类型
TDWAT 文档类型描述
1.修改文档状态
DATA: LS_DOC LIKE BAPI_DOC_DRAW2,
LS_DOCX LIKE BAPI_DOC_DRAWX2,
LS_RETURN LIKE BAPIRET2.
CLEAR:LS_DOC,LS_DOCX,LS_RETURN.
LS_DOC-DOCUMENTTYPE = IT_TAB-DOKAR.
LS_DOC-DOCUMENTNUMBER = IT_TAB-DOKNR.
LS_DOC-DOCUMENTVERSION = IT_TAB-DOKVR.
LS_DOC-DOCUMENTPART = IT_TAB-DOKTL.
LS_DOC-STATUSEXTERN = 'XX'."要修改的文档状态
LS_DOCX-STATUSEXTERN = 'X'.
CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'
EXPORTING
DOCUMENTTYPE = LS_DOC-DOCUMENTTYPE
DOCUMENTNUMBER = LS_DOC-DOCUMENTNUMBER
DOCUMENTPART = LS_DOC-DOCUMENTPART
DOCUMENTVERSION = LS_DOC-DOCUMENTVERSION
DOCUMENTDATA = LS_DOC
DOCUMENTDATAX = LS_DOCX
IMPORTING
RETURN = LS_RETURN.
IF LS_RETURN-TYPE CA 'EA'.
ROLLBACK WORK.
ELSE.
COMMIT WORK.
ENDIF.
2.修改文档描述
***文档在初始状态下才能修改相关属性,如何修改,方法前面已经讲了
DATA: LS_DOC LIKE BAPI_DOC_DRAW2,
LS_DOCX LIKE BAPI_DOC_DRAWX2,
LS_RETURN LIKE BAPIRET2.
CLEAR:LS_DOC,LS_DOCX,LS_RETURN.
LS_DOC-DOCUMENTTYPE = IT_TAB-DOKAR.
LS_DOC-DOCUMENTNUMBER = IT_TAB-DOKNR.
LS_DOC-DOCUMENTVERSION = IT_TAB-DOKVR.
LS_DOC-DOCUMENTPART = IT_TAB-DOKTL.
LS_DOC-DESCRIPTION = IT_TAB-DKTXT.
LS_DOCX-DESCRIPTION = 'X'.
CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'
EXPORTING
DOCUMENTTYPE = LS_DOC-DOCUMENTTYPE
DOCUMENTNUMBER = LS_DOC-DOCUMENTNUMBER
DOCUMENTPART = LS_DOC-DOCUMENTPART
DOCUMENTVERSION = LS_DOC-DOCUMENTVERSION
DOCUMENTDATA = LS_DOC
DOCUMENTDATAX = LS_DOCX
IMPORTING
RETURN = LS_RETURN.
IF LS_RETURN-TYPE CA 'EA'.
ROLLBACK WORK.
ELSE.
COMMIT WORK.
ENDIF.
3.删除文档下挂的所有附加文件
DATA: LS_DOC LIKE BAPI_DOC_DRAW2,
LS_DOCX LIKE BAPI_DOC_DRAWX2,
LS_RETURN LIKE BAPIRET2.
DATA: LS_FILES LIKE BAPI_DOC_FILES2 OCCURS 0 WITH HEADER LINE.
REFRESH LS_FILES.
CLEAR LS_FILES.
LS_DOC-DOCUMENTTYPE = IT_TAB1-DOKAR.
LS_DOC-DOCUMENTNUMBER = IT_TAB1-DOKNR.
LS_DOC-DOCUMENTVERSION = IT_TAB1-DOKVR.
LS_DOC-DOCUMENTPART = IT_TAB1-DOKTL.
CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'
EXPORTING
DOCUMENTTYPE = LS_DOC-DOCUMENTTYPE
DOCUMENTNUMBER = LS_DOC-DOCUMENTNUMBER
DOCUMENTPART = LS_DOC-DOCUMENTPART
DOCUMENTVERSION = LS_DOC-DOCUMENTVERSION
IMPORTING
RETURN = LS_RETURN
TABLES
DOCUMENTFILES = LS_FILES.
LOOP AT LS_FILES.
LS_FILES-DELETEVALUE = 'X'.
MODIFY LS_FILES.
ENDLOOP.
CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'
EXPORTING
DOCUMENTTYPE = LS_DOC-DOCUMENTTYPE
DOCUMENTNUMBER = LS_DOC-DOCUMENTNUMBER
DOCUMENTPART = LS_DOC-DOCUMENTPART
DOCUMENTVERSION = LS_DOC-DOCUMENTVERSION
DOCUMENTDATA = LS_DOC
DOCUMENTDATAX = LS_DOCX
IMPORTING
RETURN = LS_RETURN
TABLES
DOCUMENTFILES = LS_FILES.
IF LS_RETURN-TYPE CA 'EA'.
ROLLBACK WORK.
ELSE.
COMMIT WORK.
ENDIF.
4.为文档增加附加文件
DATA: LS_DOC LIKE BAPI_DOC_DRAW2,
LS_DOCX LIKE BAPI_DOC_DRAWX2,
LS_RETURN LIKE BAPIRET2.
DATA: LS_FILES LIKE BAPI_DOC_FILES2 OCCURS 0 WITH HEADER LINE.
REFRESH LS_FILES.
CLEAR LS_FILES.
LS_FILES-STORAGECATEGORY = 'ZTC_CONT'.
LS_FILES-DOCFILE = DOCPATH .
LS_FILES-DESCRIPTION = IT_TAB2-DKTXT.
LS_FILES-WSAPPLICATION = 'WRD' .
APPEND LS_FILES.
CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN2'
EXPORTING
DOCUMENTTYPE = LS_DOC-DOCUMENTTYPE
DOCUMENTNUMBER = LS_DOC-DOCUMENTNUMBER
DOCUMENTPART = LS_DOC-DOCUMENTPART
DOCUMENTVERSION = LS_DOC-DOCUMENTVERSION
IMPORTING
RETURN = LS_RETURN
TABLES
DOCUMENTFILES = LS_FILES.
IF LS_RETURN-TYPE CA 'EA'.
ROLLBACK WORK.
ELSE.
COMMIT WORK.
ENDIF.
阅读(1054) | 评论(0) | 转发(0) |