Skip to Content
0
Former Member
Nov 30, 2006 at 02:56 PM

calling r/3 function module from crm using rfc

155 Views

Dear SDN Members,

I'm given a task to write a method on CRM side which sets the equipment status to "lost" in ABAON transaction on R/3 side. There is a function module on r/3 side which is RFC enabled and it will set the stuatus to LOST when we call that from CRM. This RFC fm is not available on CRM side, so I cannot used Pattern. I'm very new to abap and when i've gone through abap help I got the syntax which i've write with destination parameter. But I'm really not understanding how to pass Lost status to that fm.

Here-with I put the coding so far i've done on crm side and also the rfc fm coding aswell on r/3 side.

Should any one need for more info please do let me know to my yahoo ID:

sam4u_yvs@yahoo.co.uk. I would be pleased to provide you the same.

The coding on crm side to call the r/3 fm through rfc follows here..

method IF_EX_EXEC_METHODCALL_PPF~EXECUTE.

----


  • 21st November 2006

  • Created by Venkata Sunder

  • Method for

  • Loss Disposal - ERP Equipment Status Update

  • Damage Notifications

  • Called by actions

*----


DATA: lv_guid_ref TYPE crmt_object_guid,

lv_kind_ref TYPE crmt_object_kind. "#EC NEEDED

DATA: lv_preview TYPE char1. "#EC NEEDED

DATA:

lt_header_guid TYPE crmt_object_guid_tab,

lt_orderadm_i_buffer TYPE crmt_orderadm_i_wrkt,

gs_orderadm_i_buffer TYPE crmt_orderadm_i_wrk,

lt_orderadm_i_db TYPE crmt_orderadm_i_wrkt,

gs_orderadm_i_db TYPE crmt_orderadm_i_wrk,

lt_customer_i_buffer TYPE crmt_customer_i_wrkt,

gs_customer_i_buffer TYPE crmt_customer_i_wrk,

lt_log_handle TYPE balloghndl,

return TYPE bapiret2_t,

gs_return TYPE bapiret2,

ev_rfcdest TYPE rfcdest.

  • get guid for referenced object

CALL METHOD cl_hf_helper=>action_helper->get_ref_object

EXPORTING

io_appl_object = io_appl_object

ip_action = ip_action

ii_container = ii_container

IMPORTING

ev_guid_ref = lv_guid_ref

ev_kind_ref = lv_kind_ref

ev_preview = lv_preview.

  • current crm transaction is identified

IF lv_guid_ref IS INITIAL.

RAISE EXCEPTION TYPE cx_socm_condition_violated.

ENDIF.

  • Header GUID

APPEND lv_guid_ref TO lt_header_guid.

  • Read order details from buffer

CALL FUNCTION 'CRM_ORDER_READ'

EXPORTING

it_header_guid = lt_header_guid

IMPORTING

et_orderadm_i = lt_orderadm_i_buffer

et_customer_i = lt_customer_i_buffer

CHANGING

cv_log_handle = lt_log_handle

EXCEPTIONS

document_not_found = 1

error_occurred = 2

document_locked = 3

no_change_authority = 4

no_display_authority = 5

no_change_allowed = 6

OTHERS = 7.

IF sy-subrc <> 0.

ENDIF.

call function destination 'DERCLNT200'.

(I'm not understanding how and wt to pass to this fm.)

The fm 'Z_SET_EQUIPMENT_STATUS_RFC' on r/3 side has the following coding..

DATA:

lv_objnr LIKE equi-objnr,

lv_estat LIKE tj30-estat,

wa_return LIKE bapiret2.

LOOP AT equipment_status.

SELECT SINGLE objnr

FROM equi

INTO lv_objnr

WHERE equnr EQ equipment_status-equnr.

SELECT estat

FROM tj30t

INTO lv_estat

WHERE stsma = equipment_status-stat_profile

AND txt04 = equipment_status-status

AND spras = sy-langu.

ENDSELECT.

CALL FUNCTION 'STATUS_CHANGE_EXTERN'

EXPORTING

  • CHECK_ONLY = ' '

client = sy-mandt

objnr = lv_objnr

user_status = lv_estat

  • SET_INACT = ' '

  • SET_CHGKZ =

  • NO_CHECK = ' '

  • IMPORTING

  • STONR =

EXCEPTIONS

object_not_found = 1

status_inconsistent = 2

status_not_allowed = 3

OTHERS = 4.

IF sy-subrc NE 0.

MOVE:

equipment_status-equnr TO wa_return-message_v1,

'E' TO wa_return-type,

' Equipment Update failed' TO wa_return-message.

APPEND wa_return TO return.

ELSE.

COMMIT WORK.

ENDIF.

CLEAR wa_return.

ENDLOOP.

ENDFUNCTION.

Thanks in advance.

Best Regards!

Sam.