将业务对象添加到联系人

时间:2019-08-28 16:33:27

标签: sap abap

我已经使用以下功能在SAP IS-U(第618版)系统中成功创建了联系人:BCONTACT_CREATE

  

编辑:
  由于此问题因“过于广泛”而被评选为“接近”-这是一些非常具体的代码:

  DATA:
      ls_contact            TYPE bpc01_bcontact_auto,
      ls_contact_properties TYPE bcont,
      lv_contact_text       TYPE string,
      lv_bp                 TYPE bu_partner,
      lv_bpcontact_id       TYPE ct_contact,
      lv_no_dialog          TYPE flag VALUE abap_true,
      lv_repid              TYPE syst-repid.

*    Main logic
    lv_contact_text = 'Test'.
    lv_bp           = '0010000062'.

    ls_contact_properties-cclass = '0003'.
    ls_contact_properties-activity = '0001'.
    ls_contact_properties-f_coming = '3'.


*  Mapping
*--------------------------------------------------------------------*
    ls_contact-notice-line    = lv_contact_text.
    ls_contact-bcontd         = ls_contact_properties.

* set flag to use auto data
    ls_contact-bcontd_use     = abap_true.
    lv_repid                  = sy-repid.

    CALL FUNCTION 'BCONTACT_CREATE'
      EXPORTING
        x_no_dialog     = lv_no_dialog
        x_auto          = ls_contact
        x_prgcontext    = lv_repid
        x_partner       = lv_bp
      IMPORTING
        y_new_bpcontact = lv_bpcontact_id
      EXCEPTIONS
        existing        = 1
        foreign_lock    = 2
        number_error    = 3
        general_fault   = 4
        input_error     = 5
        not_authorized  = 6
        OTHERS          = 7.

BCT2事务中打开创建的联系人时,在Business-Objects下看不到任何内容: Default Contact - No Business-Objects
如何以编程方式向联系人添加业务对象,以便在此处显示该对象? Contact with Business-Objects

1 个答案:

答案 0 :(得分:0)

我找到了解决方案!

首先为要添加的业务对象创建变量(表和用于填充表的结构)(我看到一些代码的限制为5,所以我也将其设置为安全起见):

lt_business_objs      TYPE TABLE OF bpc_obj INITIAL SIZE 5,
ls_business_obj       TYPE bpc_obj,

接下来添加您的对象,在本示例中,我仅添加一个对象:

* Append business objects
*--------------------------------------------------------------------*
ls_business_obj-objkey  = 'The value here may be your business object input value'.
ls_business_obj-objrole = 'DEFAULT'. "Don't know what this is for...
ls_business_obj-objtype = 'OBJECT_NAME'. "Name of your business object - seen in table TOJTB
APPEND ls_business_obj TO lt_business_objs.

最后将对象列表放入联系人结构中:

ls_contact-iobjects       = lt_business_objs.