cancel
Showing results for 
Search instead for 
Did you mean: 

Creation of activity

Former Member
0 Kudos
82

Hello Guys,

Am using the following code to create an activity,but am not successful in creating an activity.

Though sy-subrc is resulting in zero and activity is not getting created. Please suggest:

CALL FUNCTION 'CRM_GUID_CREATE'
       IMPORTING
         EV_GUID       =  lv_object_guid  .

ls_activity_h-ref_guid = lv_object_guid.
ls_activity_h-name = 'Create Activity'.
append ls_activity_h to lt_activity_h.

ls_subject-listcode = 'A1Y0000001A001'.
append ls_subject to lt_subject.
ls_osset-subject = lt_subject.
append ls_osset to lt_osset.
ls_service-osset = lt_osset.
append ls_service to lt_service.

ls_input_field_names-fieldname = 'NAME'.
INSERT ls_input_field_names INTO TABLE lt_input_field_names.

ls_input_field_names-fieldname = 'LISTCODE'.
INSERT ls_input_field_names INTO TABLE lt_input_field_names.

  ls_input_fields-ref_kind = 'A'.
  ls_input_fields-objectname = 'ACTIVITY_H'.
  ls_input_fields-field_names = lt_input_field_names.
  INSERT ls_input_fields INTO TABLE lt_input_fields.

CALL FUNCTION 'CRM_ORDER_MAINTAIN'
 EXPORTING
   IT_ACTIVITY_H                 = lt_activity_h
   IT_SERVICE_OS                 = lt_service
 IMPORTING
   ET_EXCEPTION                  = lt_exception
 CHANGING
   CT_ORDERADM_H                 = lt_order_out
   CT_INPUT_FIELDS               = lt_input_fields
 EXCEPTIONS
   ERROR_OCCURRED                = 1
   DOCUMENT_LOCKED               = 2
   NO_CHANGE_ALLOWED             = 3
   NO_AUTHORITY                  = 4
   OTHERS                        = 5
          .
IF SY-SUBRC eq 0.

insert lv_object_guid into table lt_guid.

 CALL FUNCTION 'CRM_ORDER_SAVE'
   EXPORTING
     IT_OBJECTS_TO_SAVE         = lt_guid
  IMPORTING
    ET_SAVED_OBJECTS           = lt_save

 ENDIF.

regards

najm

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

By the way, you must create an order first and set their process type , then you will be able to append an activity.

ls_orderadm_h-handle = 1.

ls_orderadm_h-description = 'My order'.

ls_orderadm_h-process_type = 'Z000'.

INSERT ls_orderadm_h INTO TABLE lt_orderadm_h.

CLEAR: ls_input_fields, ls_input_fields-field_names[].

ls_input_fields-ref_handle = 1.

ls_input_fields-ref_kind = 'A'.

ls_input_fields-objectname = gc_object_name-orderadm_h.

ls_field_names-fieldname = 'PROCESS_TYPE'.

INSERT ls_field_names INTO TABLE ls_input_fields-field_names.

ls_field_names-fieldname = 'DESCRIPTION'.

INSERT ls_field_names INTO TABLE ls_input_fields-field_names.

INSERT ls_input_fields INTO TABLE lt_input_fields.

then your code ...

CALL FUNCTION 'CRM_ORDER_MAINTAIN'

EXPORTING

IT_ACTIVITY_H = lt_activity_h

IT_SERVICE_OS = lt_service

IMPORTING

et_exception = lt_exception

CHANGING

ct_orderadm_h = lt_orderadm_h

ct_input_fields = lt_input_fields

EXCEPTIONS

error_occurred = 1

document_locked = 2

no_change_allowed = 3

no_authority = 4

OTHERS = 5.

then CRM_ORDER_SAVE

then BAPI_TRANSACTION_COMMIT.

Former Member
0 Kudos

I dint understand the purpose of creating an order here, i want to create an activity directly .

Can you please let me know why should i populate order table?

Former Member
0 Kudos

Try with BAPI_TRANSACTION_COMMIT after CRM_ORDER_SAVE.