cancel
Showing results for 
Search instead for 
Did you mean: 

Copy Dates from Lead to Task

Former Member
0 Kudos

Hi All,

I am trying to implement BADI CRM_COPY_BADI while creating follow up from LEAD to TASK , where I need to copy LEAD_END date of u2018Leadu2019 to DUE_DATE of u2018Tasku2019.

I am trying to put the code in IF_EX_CRM_COPY_BADIDATES but the debugger does not stop at this method where as for IF_EX_CRM_COPY_BADIORDERADM_H it stops.

Could you please help me in understanding why the DATES method is not called on creating TASK followup from LEAD, whereas DATES method gets called when creating followup for Activity.

Or may be if this does not work then I need to copy the dates using CRMV_EVENT, or is there any other workaround.

Regards,

Dipesh.

Accepted Solutions (0)

Answers (1)

Answers (1)

Maggie
Employee
Employee
0 Kudos

Hi Dipesh,

Could you please check:

- Is the copy routine correctly maintianed in copy control settings?

- Please set a break point at FM CRM_DATES_COPY_EC, it is where the date BADI should be called.

Best regards,

Maggie

Former Member
0 Kudos

Hi Maggy,

Thanks for your reply.

FM CRM_DATES_COPY_EC do get triggered.

But unless the IF_EX_CRM_COPY_BADI~DATES does not get triggered , how can I code the requirement.

As you said the Copy routine is maintained in SPRO.I checked for the Activity follow up it works fine.

Awaiting for reply.

Regards,

Dipesh.

Maggie
Employee
Employee
0 Kudos

Hi Dipesh,

Please debug FM CRM_DATES_COPY_EC. At line 475, it starts to call the BADI. You could check why the BADI implementation is not executed there.

Best regards,

Maggie

Former Member
0 Kudos

Hi Maggie ,

Thanks for the guidance.

After debugging I found that the Date types in LEAD and TASK are different. That is in TASK I want to set the 'ORDERPLANNED' type and this is not there in the LEAD date profile. So the badi DATE method wo't be called.

other workaround's

1. I am trying to create CRMV_EVENT and set the 'ORDERPLANNED' date using FM 'CRM_APPT_MAINTAIN_MULTI_OW' , but this does not set the DUE_DATE for TASK.

2. in the BADI inside IF_EX_CRM_COPY_BADI~ORDERADM_H method , trying to use FM 'CRM_APPT_MAINTAIN_MULTI_OW' but this sets the assignment block planned date's not the header value for Due_date.

data: gt_appointment type crmt_appointment_comt.

data gs_appointment like line of gt_appointment.

data: gt_input_fields type crmt_input_field_tab,

gs_input_fields type crmt_input_field,

gs_field_names type crmt_input_field_names.

data: lt_activity type crmt_activity_h_comt.

data: ls_activity type crmt_activity_h_com.

data: iv_object_guid type CRMT_OBJECT_GUID .

gs_appointment-ref_guid = cs_orderadm_h-guid. "'DFAC8D7F8BBBCFF1BC83001A644955AE'.

gs_appointment-ref_kind = 'A'.

gs_appointment-appt_type = 'ORDERPLANNED'.

  • lv_startdate = ls_ztab-registerdate.

  • convert date sy-datum time sy-uzeit

  • into time stamp gs_appointment-timestamp_from time zone sy-zonlo.

gs_appointment-TIMESTAMP_TO = '20111113183000'.

gs_appointment-mode = 'B'.

insert gs_appointment into table gt_appointment.

gs_input_fields-ref_guid = cs_orderadm_h-guid. "guid of TASK

gs_input_fields-ref_handle = 0.

gs_input_fields-ref_kind = 'A'.

gs_input_fields-objectname = 'APPOINTMENT'.

gs_input_fields-logical_key = 'ORDERPLANNED'.

clear gs_field_names.

  • gs_field_names-fieldname = 'TIMESTAMP_FROM'. "payment term

  • append gs_field_names to gs_input_fields-field_names.

gs_field_names-fieldname = 'TIMESTAMP_TO'. "payment term

append gs_field_names to gs_input_fields-field_names.

insert gs_input_fields into table gt_input_fields.

iv_object_guid = cs_orderadm_h-guid.

CALL FUNCTION 'CRM_APPT_MAINTAIN_MULTI_OW'

EXPORTING

iv_ref_guid = iv_object_guid

iv_ref_kind = 'A'

it_appointment_com = gt_appointment

CHANGING

ct_input_fields = gt_input_fields

EXCEPTIONS

precondition_violation = 1

invariant_violation = 2

OTHERS = 3.

Regards,

Dipesh.

robert_kunstelj
Active Contributor
0 Kudos

Check that you have date profile assigned to task and to lead.

And register also the following event for object BUS 20000108 in trx CRMV_EVENTu2026

Trans. Category : BUS2000108

Execution Time : 1 Immediately

Priority : 50

Object Name : ORDERADM_H

Event : AFTER_CREATE_WITH_REFERENCE

Attribute : <*>

Function : CRM_DATES_COPY_EC

Regards.

Former Member
0 Kudos

Hi Robert,

Thanks for your valuable time and suggestion.

First, I have assigned Date profile to both LEAD and TASK, but in LEAD date profile u2018ORDERPLANNEDu2019 is not there so in the Badi IF_EX_CRM_COPY_BADI~DATES will not be triggered. Also in standard this EVENT is already registered for u2018CRM BUS TRANSACTIONu2019.

Even if we add u2018ORDERPLANNEDu2019 to the date profile of LEAD , inside CRM_DATES_COPY_EC only LEAD_START and LEAD_END is read, due to this the BADI is not called from CRM_DATES_COPY_EC.

Second, in the BADI I coded IF_EX_CRM_COPY_BADI~ORDERADM_H method, calling

CALL FUNCTION 'CRM_APPT_MAINTAIN_MULTI_OW'

EXPORTING

iv_ref_guid = iv_object_guid

iv_ref_kind = 'A'

it_appointment_com = gt_appointment

CHANGING

ct_input_fields = gt_input_fields

EXCEPTIONS

precondition_violation = 1

invariant_violation = 2

OTHERS = 3.

But this only sets the assignment block PLANNED DATE not the header DUE_DATE.

Third, I have registered a new event to task with a new Function module ZSET_FOLLOWUPDATE , calling FM

CALL FUNCTION 'CRM_APPT_MAINTAIN_MULTI_OW'

EXPORTING

iv_ref_guid = iv_object_guid

iv_ref_kind = 'A'

it_appointment_com = gt_appointment

CHANGING

ct_input_fields = gt_input_fields

EXCEPTIONS

precondition_violation = 1

invariant_violation = 2

OTHERS = 3.

Here it does set any date, not the assignment block planned date nor the header due date.

Note: CALL FUNCTION 'CRM_APPT_MAINTAIN_MULTI_OW' called from a program works fine when I try to change the due date for a task already created. It sets the header due date and the assignment block planned date properly.

Last workaround was that I enhanced the component BT125H_TASK/Taskdetails , and set the TIMESTAMP_TO with new value in the get method for DDATE, here it works fine both the assignment block planned date and the header due date is set to required date. I donu2019t think there should be any issue with setting the value this way.

Your suggestions are highly acceptable, so please comment on my suggested workarounds.

Regards,

Dipesh.

Maggie
Employee
Employee
0 Kudos

Hi Dipesh,

Is it possible for you business to copy the same date type from LEAD to TASK first, then determine 'ORDERPLANNED' via a date rule in TASK?

Best regards,

Maggie

Former Member
0 Kudos

Thanks to both of you.

Finally I have used DO_PREPARE_OUTPUT in IMPL CLASS to SET THE PLANNED DATE.

Regards,

Dipesh.