Chinaunix首页 | 论坛 | 博客
  • 博客访问: 402413
  • 博文数量: 120
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 1266
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-16 16:04
文章分类

全部博文(120)

文章存档

2011年(4)

2010年(10)

2009年(38)

2008年(68)

我的朋友

分类:

2008-09-26 11:12:14

文档相关表:
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.
阅读(1031) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~