删除订单BOM的链接的文档(linked document)[BAPI_DOCUMENT_SAVEOBJECTLINKS]

ぐ巨炮叔叔 提交于 2019-11-29 00:32:25

1, 前台操作

Tcode:CSKB 输入销售订单号和行项目,点击start order browser展开订单BOM(order BOM).

找到对应的物料,右键display

可以看到链接的文档信息,

2, 例子程序

可以通过函数BAPI_DOCUMENT_SAVEOBJECTLINKS删除order BOM中链接的文档。

逻辑如下:

删除order bom 行项目中链接的文档

1,STPO中读取objectkey,如果要删除订单BOM 头中的链接文档需要从STKO中读取

2,调用BAPI_DOCUMENT_GETOBJECTDOCS取得链接的文档信息

3,调用BAPI_DOCUMENT_SAVEOBJECTLINKS删除文档和订单BOM的链接关系

REPORT ztest_del_link.  DATA:g_guidx         TYPE stpo-guidx,       g_objectkey     TYPE bapi_doc_drad-objectkey,       git_list        TYPE STANDARD TABLE OF bapi_doc_keys,       gwa_list        TYPE bapi_doc_keys,       git_objectlinks TYPE TABLE OF bapi_doc_drad,       gwa_objectlinks TYPE bapi_doc_drad,       gwa_return      TYPE bapiret2.  * 测试,所以只取了1条,实际会有多条的情况  SELECT SINGLE stpo~guidx    INTO g_guidx    FROM stpo   INNER JOIN kdst ON stpo~stlnr = kdst~stlnr   WHERE stpo~stlty = 'K'     AND stpo~idnrk = 'B1-10'      "Material Number     AND kdst~vbeln = '0690000318' "Sales Order Number     AND kdst~vbpos = '200'        "Sales order Item     AND kdst~werks = '8800'       "Plant         .  g_objectkey = g_guidx.  refresh:git_list.  CALL FUNCTION 'BAPI_DOCUMENT_GETOBJECTDOCS'    EXPORTING      objecttype   = 'STPO_DOC'  "order bom 头用STKO_DOC      objectkey    = g_objectkey  *   CURRENTVERSIONSONLY       =      date         = sy-datum  *  IMPORTING  *   RETURN       =    TABLES      documentlist = git_list[].    LOOP AT git_list INTO gwa_list.    CLEAR   gwa_objectlinks.    REFRESH:git_objectlinks.    gwa_objectlinks-deletevalue = 'X'.    gwa_objectlinks-objecttype  = 'STPO_DOC'. "Order BOM头用STKO_DOC    gwa_objectlinks-objectkey   = g_guidx.    APPEND gwa_objectlinks TO git_objectlinks.    CALL FUNCTION 'BAPI_DOCUMENT_SAVEOBJECTLINKS'      EXPORTING        documenttype    = gwa_list-documenttype        documentnumber  = gwa_list-documentnumber        documentpart    = gwa_list-documentpart        documentversion = gwa_list-documentversion      IMPORTING        return          = gwa_return      TABLES        objectlinks     = git_objectlinks.    * Commit or Rollback    IF gwa_return-type NA 'AE'.      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'        EXPORTING          wait = 'X'.    ELSE.      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.    ENDIF.    ENDLOOP.

运行结果,订单BOM行项目上的链接的文档已删除,也就是文档与订单BOM没有链接关系了。

以上。

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!