Skip to Content
0
Former Member
Jul 07, 2011 at 10:05 AM

Creating Service Request from FM CRM_ORDER_MAINTAIN

184 Views

Hello,

I am trying to create service request of type ZCRG through function module using below mentioned code. I am able to create service request but problem is that Sold To Party is not getting maintained

Any Help will be appreciated...

Sample Code :

&----


*& Report ZC_CASES_CONV

*&

&----


*&

*&

&----


REPORT zc_cases_conv.

  • Remove header lines

DATA:

t_object_to_save TYPE crmt_object_guid_tab ,

t_exceptions TYPE crmt_exception_t ,

t_saved_objects TYPE crmt_return_objects ,

t_objects_not_saved TYPE crmt_object_guid_tab ,

t_new_orders TYPE crmt_orderadm_h_comt,

s_new_order TYPE LINE OF crmt_orderadm_h_comt,

t_input_field TYPE crmt_input_field_tab,

s_input_field TYPE crmt_input_field ,

s_fieldname TYPE crmt_input_field_names.

DATA : l_object_to_save TYPE LINE OF crmt_object_guid_tab.

DATA : lt_partner TYPE crmt_partner_comt,

ls_partner LIKE LINE OF lt_partner.

data lv_guid_16 type GUID_16.

CALL FUNCTION 'GUID_CREATE'

IMPORTING

ev_guid_16 = lv_guid_16 .

s_new_order-handle = 0.

s_new_order-guid = lv_guid_16.

s_new_order-mode = 'A'.

s_new_order-process_type = 'ZCRG'.

INSERT s_new_order INTO TABLE t_new_orders.

s_input_field-ref_handle = 0.

s_input_field-ref_guid = lv_guid_16.

s_input_field-ref_kind = 'A'.

s_input_field-objectname = 'ORDERADM_H'.

s_input_field-logical_key = space.

CLEAR s_fieldname.

s_fieldname-fieldname = 'MODE'.

APPEND s_fieldname TO s_input_field-field_names.

s_fieldname-fieldname = 'PROCESS_TYPE'.

APPEND s_fieldname TO s_input_field-field_names.

INSERT s_input_field INTO TABLE t_input_field.

  • Partner

CLEAR s_input_field.

*CALL FUNCTION 'GUID_CREATE'

*IMPORTING

*ev_guid_16 = s_input_field-ref_guid.

s_input_field-ref_handle = 0.

s_input_field-ref_guid = lv_guid_16.

s_input_field-ref_kind = 'A'.

s_input_field-objectname = 'PARTNER'.

s_input_field-logical_key = space.

CLEAR s_fieldname.

s_fieldname-fieldname = 'DISPLAY_TYPE'.

INSERT s_fieldname INTO TABLE s_input_field-field_names.

s_fieldname-fieldname = 'PARTNER_FCT'.

INSERT s_fieldname INTO TABLE s_input_field-field_names.

s_fieldname-fieldname = 'PARTNER_NO'.

INSERT s_fieldname INTO TABLE s_input_field-field_names.

s_fieldname-fieldname = 'NO_TYPE'.

INSERT s_fieldname INTO TABLE s_input_field-field_names.

s_fieldname-fieldname = 'KIND_OF_ENTRY'.

INSERT s_fieldname INTO TABLE s_input_field-field_names.

s_fieldname-fieldname = 'REF_KIND'.

INSERT s_fieldname INTO TABLE s_input_field-field_names.

INSERT s_input_field INTO TABLE t_input_field.

*ls_partner-ref_guid = s_input_field-ref_guid.

ls_partner-ref_guid = lv_guid_16.

MOVE :

0 to ls_partner-ref_handle,

'A' TO ls_partner-ref_kind,

0 TO ls_partner-ref_partner_handle,

'C' to ls_partner-kind_of_entry,

*'00000001' TO ls_partner-ref_partner_fct,

*'7500541' TO ls_partner-ref_partner_no,

*'BP' TO ls_partner-ref_no_type,

*'BP' TO ls_partner-ref_display_type,

'00000001' TO ls_partner-partner_fct,

'7500541' TO ls_partner-partner_no,

'BP' TO ls_partner-no_type,

'BP' TO ls_partner-display_type.

*'X' TO ls_partner-mainpartner.

APPEND ls_partner TO lt_partner.

CALL FUNCTION 'CRM_ORDER_MAINTAIN'

EXPORTING

it_partner = lt_partner

CHANGING

ct_orderadm_h = t_new_orders

ct_input_fields = t_input_field

EXCEPTIONS

error_occurred = 1

document_locked = 2

no_change_allowed = 3

no_authority = 4

OTHERS = 5.

CALL FUNCTION 'CRM_ORDER_MAINTAIN'

EXPORTING

it_partner = lt_partner

CHANGING

ct_orderadm_h = t_new_orders

ct_input_fields = t_input_field

EXCEPTIONS

error_occurred = 1

document_locked = 2

no_change_allowed = 3

no_authority = 4

OTHERS = 5.

break hsingh.

IF sy-subrc = 0.

CLEAR s_new_order.

READ TABLE t_new_orders

INTO s_new_order

INDEX 1.

IF sy-subrc = 0.

l_object_to_save = s_new_order-guid.

INSERT l_object_to_save INTO TABLE t_object_to_save.

CALL FUNCTION 'CRM_ORDER_SAVE'

EXPORTING

it_objects_to_save = t_object_to_save

IMPORTING

et_saved_objects = t_saved_objects

et_exception = t_exceptions

et_objects_not_saved = t_objects_not_saved

EXCEPTIONS

document_not_saved = 1

OTHERS = 2.

ENDIF.

ENDIF.

IF sy-subrc = 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

ENDIF.