Code for using CRM_ORDER_READ
* Get Order details...
lv_guid = iv_guid.
* insert values into importing tables for one order read .
INSERT lv_guid INTO TABLE lt_header_guid.
MOVE gc_object_name-ordera dm_h TO lv_req_obj. INSERT lv _req_obj INTO TABLE lt_req_ obj ." header
MOVE gc_object_name-partne r TO lv_req_obj. INSERT lv _req_obj INTO TABLE lt_req_ obj ." Partners
MOVE gc_object_name-doc_ flow TO lv_req_obj. INSERT lv_req_obj INTO TABLE lt_req_ obj ." Documents
* MOVE gc_object_name- orderadm_i TO lv_req_obj. INSERT lv_req_obj INTO TABLE lt_req_obj ." Item details .
* Get the details of the appointment .
CALL FUNCTION 'CRM_ORDER_ READ'
EXPORTING
it_header_guid = lt_header_guid
it_requested_objects = lt_req_obj
IMPORTING
et_orderadm_h = lt_orderadm_h
* et_orderadm_i = et_orderadm_i
et_partner = lt_partner
et_doc_flow = lt_doc_flow
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.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy -msgv4.
RETURN.
ENDIF.
READ TABLE lt_orderadm_h A SSIGNING <fs_ord> INDEX 1.
CHECK sy-subrc EQ 0.
*** Proceed only for Process type 'ZAPP'..........
CHECK <fs_ord>-process_ type EQ 'ZAPP' AND
* lt_doc_flow[] IS NOT INITIAL AND
lt_partner[] IS NOT INITIAL .
********* Code for adding the Employee responsible when the appointment is created as a followon document ******
**Read employee responsible from lt_partner..
READ TABLE lt_partner ASSI GNING <fs_part> WITH KEY ref_ partner_fct = lc_partner_ese_ fct.
* if sy-subrc eq 0.
CHECK sy-subrc EQ 0.
MOVE <fs_part>-partner_no TO lv_partner_no.
**Read main partner..........
CALL FUNCTION 'CRM_ PARTNER_READ_OW'
EXPORTING
iv_ref_guid = lv_guid
iv_ref_kind = 'A'
iv_partner_fct = '00000009'
iv_mainpartner_only = 'X'
IMPORTING
et_partner_wrk = lt_mpart
es_partner_wrk = ls_mpart
EXCEPTIONS
error_occurred = 1
parameter_error = 2
entry_does_not_exist = 3
OTHERS = 4.
MOVE ls_mpart-partner_no T O lv_mpart.
CALL FUNCTION 'BUPA_ RELATIONSHIPS_GET'
EXPORTING
iv_partner = lv_mpart
iv_relationship_ category = 'BUR011'
TABLES
et_relationships = lt_relations.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY- MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*********Read employee responsible from lt_partner..
******* read table lt_ partner assigning <fs_part> with key REF_PARTNER_FCT = lc_partner_ese_fct.
******** if sy-subrc eq 0.
******* check sy-subrc eq 0.
******* MOVE <fs_part>- partner_no TO lv_partner_no.
* endif. " if sy-subrc eq 0.
DESCRIBE TABLE lt_ relations LINES lv_nr.
IF lv_nr NE 0 .
* READ TABLE lt_relations WITH KEY partner2 = lv_ partner_no ASSIGNING <fs_rel> .
READ TABLE lt_relations INTO ls_relations WITH KEY pa rtner2 = lv_partner_no. " ASSIGNING <fs_rel> .
IF sy-subrc NE 0 .
CLEAR ls_relations.
READ TABLE lt_ relations INTO ls_relations WI TH KEY defaultrelationship = ' X'.
IF sy-subrc EQ 0. " In case Default Key is checked........
CALL FUNCTION 'BAPI_ BUPR_RELATIONSHIP_CREATE'
EXPORTING
businesspartner1 = lv_ mpart
businesspartner2 = lv_ partner_no
relationshipcategory = ' BUR011'.
* TABLES
* return = lt_return.
ELSE. " In Case Default Key is unchecked.........
CALL FUNCTION 'BAPI_ BUPR_RELATIONSHIP_CREATE'
EXPORTING
businesspartner1 = lv_ mpart
businesspartner2 = lv_ partner_no
relationshipcategory = ' BUR011'
xdfrel = 'X'.
* TABLES
* return = lt_return.
ENDIF.
ENDIF. " if sy- subrc ne 0.
ELSE.
CALL FUNCTION 'BAPI_ BUPR_RELATIONSHIP_CREATE'
EXPORTING
businesspartner1 = lv_mpart
businesspartner2 = lv_partner_no
relationshipcategory = ' BUR011'
xdfrel = 'X'.
* TABLES
* return = lt_return.
ENDIF. " if lv_nr GT 1.
CALL FUNCTION 'BUPA_BSP_ EMPLOYEE_SAVE'
EXCEPTIONS
not_saved = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY- MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY- MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Get the lead for which appointment is created as a follow-on document from document flow table .
READ TABLE lt_doc_flow INT O ls_doc_flow WITH KEY objtype _a = lc_lead_obj
objtype_b = 'BUS2000126'
objkey_ b = <fs_ord>-guid .
IF sy-subrc EQ 0.
lv_guid_ = ls_doc_flow-o bjkey_a.
IF lv_partner_no IS NOT INITIAL.
MOVE <fs_part>-partner _no TO lv_partner_no.
* prepare the fields to be changed.
CLEAR:ls_input_field.
REFRESH: lt_input_ field.
ls_input_field-fieldna me = lc_fieldname2.
ls_input_field-inactiv e = space.
INSERT ls_input_field INTO TABLE lt_input_field.
CLEAR ls_input_field.
ls_input_field-fieldna me = lc_fieldname3.
ls_input_field-inactiv e = space.
INSERT ls_input_field INTO TABLE lt_input_field.
CLEAR ls_input_field.
ls_input_field-fieldna me = lc_fieldname4.
ls_input_field-inactiv e = space.
INSERT ls_input_field INTO TABLE lt_input_field.
CLEAR ls_input_field.
ls_input_field-fieldna me = lc_fieldname5.
ls_input_field-inactiv e = space.
INSERT ls_input_field INTO TABLE lt_input_field.
CLEAR ls_input_field.
ls_input_field-fieldna me = lc_fieldname6.
* ls_input_field- changeable = 'X'.
ls_input_field-inactiv e = space.
INSERT ls_input_field INTO TABLE lt_input_field.
CLEAR ls_input_field.
* maintain employee responsible
CLEAR ls_partner.
* ls_partner-ref_handle = lc_ref_handle .
ls_partner-ref_guid = lv_guid_.
************Get Partner Details............
* CALL FUNCTION 'CRM_ PARTNER_READ_OW'
* EXPORTING
* iv_ref_guid = lv_guid
* iv_ref_kind = 'A'
* IMPORTING
* et_partner_wrk = lt_part
* EXCEPTIONS
* error_occurred = 1
* parameter_error = 2
* entry_does_not_exist = 3
* OTHERS = 4.
* IF sy-subrc <> 0.
* EXIT.
* ENDIF.
* describe table lt_part lines lv_nr.
*
******************
ls_partner-ref_kind = 'A' .
ls_partner-ref_ partner_handle = '0001'.
* ls_partner-kind_of_ entry = 'C'.
ls_partner-partner_ fct = lc_partner_ese_fct.
ls_partner-partner_no = lv_partner_no.
ls_partner-display_ type = lc_display_type.
ls_partner-no_type = lc_no_type.
CALL FUNCTION 'CRM_ PARTNER_MAINTAIN_SINGLE_OW'
EXPORTING
iv_ref_guid = lv_guid_
iv_ref_kind = 'A'
is_partner_com = ls_partner
CHANGING
ct_input_field_ names = lt_input_field
EXCEPTIONS
error_occurred = 1
OTHERS = 2.
CLEAR: ls_partner.
REFRESH: lt_input_ field.
REFRESH lt_header_ guid.
INSERT lv_guid_ INTO T ABLE lt_header_guid.
CALL FUNCTION 'CRM_ ORDER_SAVE'
EXPORTING
it_objects_to_ save = lt_header_guid
EXCEPTIONS
document_not_ saved = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY- MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY- MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF. " if sy-subrc eq 0 for lt_partner.
ENDIF. " if sy-subrc EQ 0 for lt_doc_flow
lv_guid = iv_guid.
* insert values into
INSERT lv_guid INTO TABLE
MOVE gc_object_name-ordera
MOVE gc_object_name-partne
MOVE gc_object_name-doc_
* MOVE gc_object_name-
* Get the details of the
CALL FUNCTION 'CRM_ORDER_
EXPORTING
it_header_guid =
it_requested_objects =
IMPORTING
et_orderadm_h =
* et_orderadm_i
et_partner =
et_doc_flow =
EXCEPTIONS
document_not_found =
error_occurred =
document_locked =
no_change_authority =
no_display_authority =
no_change_allowed =
OTHERS =
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE
RETURN.
ENDIF.
READ TABLE lt_orderadm_h A
CHECK sy-subrc EQ 0.
*** Proceed only for Process
CHECK <fs_ord>-process_
* lt_doc_flow[] IS NOT
lt_partner[] IS NOT
********* Code for adding the
**Read employee responsible
READ TABLE lt_partner ASSI
* if sy-subrc eq 0.
CHECK sy-subrc EQ 0.
MOVE <fs_part>-partner_no
**Read main partner..........
CALL FUNCTION 'CRM_
EXPORTING
iv_ref_guid =
iv_ref_kind =
iv_partner_fct =
iv_mainpartner_only =
IMPORTING
et_partner_wrk =
es_partner_wrk =
EXCEPTIONS
error_occurred =
parameter_error =
entry_does_not_exist =
OTHERS =
MOVE ls_mpart-partner_no T
CALL FUNCTION 'BUPA_
EXPORTING
iv_partner
iv_relationship_
TABLES
et_relationships
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE
* WITH SY-MSGV1 SY-
ENDIF.
*********Read employee
******* read table lt_
******** if sy-subrc eq 0.
******* check sy-subrc eq 0.
******* MOVE <fs_part>-
* endif. " if
DESCRIBE TABLE lt_
IF lv_nr NE 0 .
* READ TABLE lt_relations
READ TABLE lt_relations
IF sy-subrc NE 0 .
CLEAR ls_relations.
READ TABLE lt_
IF sy-subrc EQ 0.
CALL FUNCTION 'BAPI_
EXPORTING
* TABLES
* return
ELSE.
CALL FUNCTION 'BAPI_
EXPORTING
xdfrel
* TABLES
* return
ENDIF.
ENDIF. " if sy-
ELSE.
CALL FUNCTION 'BAPI_
EXPORTING
businesspartner1
businesspartner2
xdfrel
* TABLES
* return
ENDIF. " if lv_nr GT 1.
CALL FUNCTION 'BUPA_BSP_
EXCEPTIONS
not_saved = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-
* WITH SY-MSGV1 SY-
ENDIF.
* Get the lead for which
READ TABLE lt_doc_flow INT
IF sy-subrc EQ 0.
lv_guid_ = ls_doc_flow-o
IF lv_partner_no IS NOT
MOVE <fs_part>-partner
* prepare the fields to be
CLEAR:ls_input_field.
REFRESH: lt_input_
ls_input_field-fieldna
ls_input_field-inactiv
INSERT ls_input_field
CLEAR ls_input_field.
ls_input_field-fieldna
ls_input_field-inactiv
INSERT ls_input_field
CLEAR ls_input_field.
ls_input_field-fieldna
ls_input_field-inactiv
INSERT ls_input_field
CLEAR ls_input_field.
ls_input_field-fieldna
ls_input_field-inactiv
INSERT ls_input_field
CLEAR ls_input_field.
ls_input_field-fieldna
* ls_input_field-
ls_input_field-inactiv
INSERT ls_input_field
CLEAR ls_input_field.
* maintain employee
CLEAR ls_partner.
* ls_partner-ref_handle
ls_partner-ref_guid
************Get Partner
* CALL FUNCTION 'CRM_
* EXPORTING
* iv_ref_guid =
* iv_ref_kind =
* IMPORTING
* et_partner_wrk =
* EXCEPTIONS
* error_occurred =
* parameter_error =
* entry_does_not_exist =
* OTHERS =
* IF sy-subrc <> 0.
* EXIT.
* ENDIF.
* describe table lt_part
*
******************
ls_partner-ref_kind
ls_partner-ref_
* ls_partner-kind_of_
ls_partner-partner_
ls_partner-partner_no
ls_partner-display_
ls_partner-no_type
CALL FUNCTION 'CRM_
EXPORTING
iv_ref_guid
iv_ref_kind
is_partner_com
CHANGING
ct_input_field_
EXCEPTIONS
error_occurred
OTHERS
CLEAR: ls_partner.
REFRESH: lt_input_
REFRESH lt_header_
INSERT lv_guid_ INTO T
CALL FUNCTION 'CRM_
EXPORTING
it_objects_to_
EXCEPTIONS
document_not_
OTHERS
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-
* WITH SY-MSGV1 SY-
ENDIF.
ENDIF.
ENDIF.
Post a Comment