SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

CRM ORDER change



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> CRM
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Fri Aug 22, 2014 5:46 pm    Post subject: CRM ORDER change Reply with quote

Code:
data: lt_status type CRMT_STATUS_COMT,
      ls_status like line of lt_status.

data: ch_inputfields type CRMT_INPUT_FIELD_TAB,
      lt_sorted type CRMT_INPUT_FIELD_NAMES_TAB,
      ls_sorted like line of lt_sorted,
      ls_inputfields like line of ch_inputfields.



data: lt_header_guid type crmt_object_guid_tab,
      ls_header_guid type crmt_object_guid,

      lt_appointment_wrk type crmt_appointment_wrkt,
      ls_appointment_wrk type crmt_appointment_wrk,
      lt_appointment type crmt_appointment_comt,
      ls_appointment type crmt_appointment_com.


data: ls_input_fields type crmt_input_field,
      lt_input_fields type crmt_input_field_tab,
      ls_input_field_names type crmt_input_field_names,
      lt_input_field_names type crmt_input_field_names_tab.


ls_header_guid = '52678085A0265C9EE1000000AC19665E'.
insert ls_header_guid into table lt_header_guid.


CALL FUNCTION 'CRM_ORDER_READ'
  EXPORTING
    IT_HEADER_GUID       = lt_header_guid
    iv_mode              = 'B' "Change modus
  IMPORTING
    ET_APPOINTMENT       = lt_appointment_wrk
  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.
  write: 'Fehler Order Read'.
  BREAK-POINT.
ENDIF.
BREAK-POINT.
delete lt_appointment_wrk where appt_type <> 'ORDERPLANNED'

    or timestamp_from is initial.

ls_input_field_names-fieldname = 'TIMESTAMP_FROM'.
insert ls_input_field_names into table lt_input_field_names.

ls_input_field_names-fieldname = 'TIMESTAMP_TO'.
insert ls_input_field_names into table lt_input_field_names.

ls_input_fields-ref_handle = '0000000000'.
ls_input_fields-ref_guid = ls_header_guid.
ls_input_fields-ref_kind = 'A'.
ls_input_fields-objectname = 'APPOINTMENT'.
ls_input_fields-logical_key = 'ORDERACTUAL'.
ls_input_fields-field_names = lt_input_field_names.
insert ls_input_fields into table lt_input_fields.

LOOP AT lt_appointment_wrk into ls_appointment_wrk.
  MOVE-CORRESPONDING ls_appointment_wrk to ls_appointment.
  ls_appointment-appt_type = 'ORDERACTUAL'.
  append ls_appointment to lt_appointment.
ENDLOOP.

BREAK-POINT.
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
EXPORTING
   IT_APPOINTMENT                = lt_appointment
CHANGING
   CT_INPUT_FIELDS               = lt_input_fields
EXCEPTIONS
   ERROR_OCCURRED                = 1
   DOCUMENT_LOCKED               = 2
   NO_CHANGE_ALLOWED             = 3
   NO_AUTHORITY                  = 4
   OTHERS                        = 5.
IF SY-SUBRC <> 0.
  BREAK-POINT.
  write:/ 'Fehler Maintain', sy-subrc.
else.
  data: lt_save_guid          type crmt_object_guid_tab,
        ls_save_guid          type crmt_object_guid,
        lt_saved_objects      type crmt_return_objects,
        lt_not_saved_objects  type crmt_object_guid_tab,
        ls_saved_objects      type crmt_return_objects_struc,
        lv_update_task_local  type boolean.
  BREAK-POINT.
  ls_save_guid = ls_header_guid.
  append ls_save_guid to lt_save_guid.

  CALL FUNCTION 'CRM_ORDER_SAVE'
    EXPORTING
      IT_OBJECTS_TO_SAVE           = lt_save_guid
      IV_UPDATE_TASK_LOCAL         = lv_update_task_local
   IMPORTING
     ET_SAVED_OBJECTS             = lt_saved_objects
     ET_OBJECTS_NOT_SAVED         = lt_not_saved_objects
   EXCEPTIONS
     DOCUMENT_NOT_SAVED           = 1
     OTHERS                       = 2.
  IF sy-subrc <> 0.
    BREAK-POINT.
  ENDIF.
  IF SY-SUBRC <> 0.
    write: 'Fehler ORDER SAVE'.
  else.
    data: lt_return type  BAPIRET2.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        WAIT   = 'X'
      IMPORTING
        RETURN = lt_return.
  ENDIF.
ENDIF.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> CRM All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.