专栏首页Jerry的SAP技术分享Use BAdI to link appointment to a given opportunity during creation

Use BAdI to link appointment to a given opportunity during creation

版权声明:本文为博主汪子熙原创文章,未经博主允许不得转载。 https://jerry.blog.csdn.net/article/details/90053805

Requirement

This requirement is raised by customer. They have extended a new field “Opportunity id” in My Appointment creation page. During appointment creation, customer choose an opportunity from this extension field via value help, and they would like to automatically generate a document history which links the created appointment with this manually chosen opportunity.

Implementation

create one BAdI implementation on spot CRM_APPT_ODATA_ENH with following source code:

  METHOD if_ex_crm_appt_odata~update_appointment_details.
    INCLUDE: crm_object_names_con,
             crm_object_types_con,
             crm_object_kinds_con,
             crm_mode_con.
    DATA: ls_doc_flow     TYPE crmt_doc_flow_com,
          lt_doc_flow     LIKE ct_doc_flow,
          ls_doc_link     TYPE crmt_doc_flow_extd,
          ls_appointment  LIKE LINE OF ct_appointment,
          lt_exception    TYPE crmt_exception_t,
          lt_input_fields TYPE crmt_input_field_tab,
          ls_input        LIKE LINE OF ct_input_fields,
          ls_field        LIKE LINE OF ls_input-field_names.
    IF sy-uname = 'WANGJER'.
      READ TABLE ct_appointment INTO ls_appointment INDEX 1.
      ASSERT sy-subrc = 0.
      ls_doc_flow-ref_handle = ls_appointment-ref_handle.
      ls_doc_flow-ref_kind   = 'A'.
      ls_doc_link-objkey_a   = '0050569F4AEA1ED4BFF22CF79358C400'.
      ls_doc_link-handle_b   = ls_appointment-ref_handle.
      ls_doc_link-brel_kind  = 'A'.
      ls_doc_link-brel_mode  = 'A'.
      ls_doc_link-reltype    = 'VONA'.
      APPEND ls_doc_link TO ls_doc_flow-doc_link.
      INSERT ls_doc_flow INTO TABLE lt_doc_flow.
      CLEAR: ls_input-field_names.
      ls_field = 'OBJKEY_A'.
      INSERT ls_field INTO TABLE ls_input-field_names.
      ls_field-fieldname = 'OBJTYPE_A'.
      INSERT ls_field INTO TABLE ls_input-field_names.
      ls_field-fieldname = 'OBJKEY_B'.
      INSERT ls_field INTO TABLE ls_input-field_names.
      ls_field-fieldname = 'OBJTYPE_B'.
      INSERT ls_field INTO TABLE ls_input-field_names.
      ls_field-fieldname = 'BREL_KIND'.
      INSERT ls_field INTO TABLE ls_input-field_names.
      ls_field-fieldname = 'RELTYPE'.
      INSERT ls_field INTO TABLE ls_input-field_names.
      ls_input-ref_handle = ls_appointment-ref_handle.
      ls_input-ref_kind    = 'A'.
      ls_input-objectname  = gc_object_name-doc_flow.
      INSERT ls_input INTO TABLE lt_input_fields.
      CALL FUNCTION 'CRM_ORDER_MAINTAIN'
        IMPORTING
          et_exception      = lt_exception
        CHANGING
          ct_input_fields   = lt_input_fields
          ct_doc_flow       = lt_doc_flow
          ct_orderadm_h     = ct_orderadm_h
        EXCEPTIONS
          error_occurred    = 1
          document_locked   = 2
          no_change_allowed = 3
          no_authority      = 4.
    ENDIF.
  ENDMETHOD.

Archievement


Appointment 成功创建之后,代码里hard code的opportunity guid对应的opportunity就会出现在Appointment的Transaction History area里:

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • 利用ABAP代码动态生成ABAP类

    Jerry Wang
  • SAP S/4HANA销售订单创建时,会自动触发生产订单的创建

    版权声明:本文为博主汪子熙原创文章,未经博主允许不得转载。 https://jerry.blog....

    Jerry Wang
  • 使用ABAP代码创建SAP S/4HANA Sales Order

    Jerry Wang
  • 【leetcode刷题】T46-丑数 II

    Write a program to find the n-th ugly number.

    木又AI帮
  • 【Python入门】Python列表的11个方法全解

    列表是Python里面非常重要的数据类型,其中的方法总共有11个,数量掌握这些方法,对数据的处理效率会大大提高,现在分享给大家。

    黄博的机器学习圈子
  • ls 命令还能这么玩?看一下这 20 个实用范例

    小小科
  • Linux常用命令04 - ls

    ls 命令是任何 Linux 用户都应该知道的基本命令之一。 它用于列出有关文件系统中的文件和目录的信息。 ls 实用程序是安装在所有 Linux 发行版上的 ...

    叉叉敌
  • Linux之ls命令——查看目录

    ls命令是linux下最常用的命令。ls命令就是list的缩写,缺省下ls用来打印出当前目录的清单,如果ls指定其他目录,那么就会显示指定目录里的文件及文件夹清...

    浩Coding
  • 挖洞经验 | 命令注入突破长度限制

    0x01 背景 很多时候,在我们历经千辛万苦挖掘出一个漏洞或者找到一个利用点的时候,却因为一些egg hurt的限制,导致get shell或者send pay...

    FB客服
  • Linux系统中ls命令的使用方法

    1. ls -a 列出文件下所有的文件,包括以“.“开头的隐藏文件(linux下文件隐藏文件是以.开头的,如果存在..代表存在着父目录)。

    用户2141593

扫码关注云+社区

领取腾讯云代金券