Hi Npl,
Below is the code for warranty fetching.
CONSTANTS: l_c_obj_ref TYPE crmt_il_wty_reference VALUE '04'. " Object reference as 04
* This function module reads the object with warranty. The importing parameter et_interlinkage will have the details on warranty end date.
CALL FUNCTION 'CRM_IBCWTY_IL_API_READ'
EXPORTING
iv_object_guid = <fs_refobj>-guid_object
iv_object_reference = l_c_obj_ref
iv_raise_exception = abap_true
IMPORTING
et_interlinkage = l_i_interlinkage
EXCEPTIONS
input_parameter_missing = 1
error_occurred = 2
OTHERS = 3.
IF sy-subrc <> 0.
RAISE no_data_found. "If no data found, raise the exception.
ENDIF.
* We need the highest of warranty end date. So sort descending first and then read with index 1.
SORT l_i_interlinkage BY end_date DESCENDING.
READ TABLE l_i_interlinkage ASSIGNING <fs_interlinkage> INDEX 1.
IF sy-subrc = 0.
TRY.
l_v_end_date = <fs_interlinkage>-end_date. " Assign to the char type to use concatenate
CATCH cx_sy_move_cast_error.
RETURN.
ENDTRY.
* The date has to be shown in dd.mm.yyyy format. So change the end date.
CONCATENATE l_v_end_date+6(2) l_v_end_date+4(2) l_v_end_date+0(4) INTO ex_end_date SEPARATED BY l_c_separator.
ENDIF.
ENDIF.