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

Turns the Header and Item of a CRM contract to live status



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



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Oct 27, 2007 2:29 pm    Post subject: Turns the Header and Item of a CRM contract to live status Reply with quote

Here I am setting the header and item status of a business transaction to live.

Code:
*&---------------------------------------------------------------------*
*& Report  ZRCRM_MAKE_CONTRACT_LIVE                                    *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*
 
REPORT  zrcrm_make_contract_live                .
 
*----------------------------------------------------------------------*
*   PROGRAM DESCRIPTION                                                *
*----------------------------------------------------------------------*
*   This progeam turns the Header and Item of a contract to live status*
*----------------------------------------------------------------------*
*   RESPONSIBILITY - ORIGINAL BUILD                                    *
*----------------------------------------------------------------------*
* Author............: Amit Mishra                                      *
* Creation date.....: 05.10.2006                                       *
* Project...........: Beacon Release 1                                 *
* Version...........:                                                  *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* CHANGE HISTORY - Should be completed in reverse date order           *
* Revised by........:                                                  *
* Change date.......:                                                  *
* Request No ........                                                  *
* Change no.........:                                                  *
* Description.......:                                                  *
*----------------------------------------------------------------------*
 
TABLES: crmd_orderadm_h.
 
TYPES:  BEGIN OF ty_guid,
          guid TYPE crmt_object_guid,
        END OF ty_guid.
 
DATA:   git_contract_nos      TYPE RANGE OF crmd_orderadm_h-object_id,
        git_header_guid       TYPE TABLE OF ty_guid,
        git_item_guid         TYPE TABLE OF ty_guid,
        git_modify_status     TYPE crmt_status_comt,
        git_input_fields      TYPE crmt_input_field_tab,
        git_field_names       TYPE crmt_input_field_names_tab,
        git_head_to_save      TYPE crmt_object_guid_tab.
 
DATA:   wa_modify_status      LIKE LINE OF git_modify_status,
        wa_header_guid        LIKE LINE OF git_header_guid,
        wa_item_guid          LIKE LINE OF git_item_guid,
        wa_input_fields       LIKE LINE OF git_input_fields,
        wa_field_names        LIKE LINE OF git_field_names.
 
CONSTANTS: gc_status_e0012 TYPE  crm_j_status      VALUE 'E0012',
           gc_cont_i       TYPE  j_stsma           VALUE 'ZCONTR_I',
           gc_cont_h       TYPE  j_stsma           VALUE 'ZCONTR_H'.
 
SELECT-OPTIONS: s_contno  FOR  crmd_orderadm_h-object_id OBLIGATORY.
 
AT SELECTION-SCREEN.
 
  APPEND LINES OF s_contno TO git_contract_nos.
 
START-OF-SELECTION.
 
* Select the Header Guids for the contracts
  SELECT guid
    INTO TABLE git_header_guid
    FROM crmd_orderadm_h
   WHERE object_id IN git_contract_nos.
 
  CHECK sy-subrc EQ 0.
 
* Select the Item GUIDs for the contracts
  SELECT guid
    INTO TABLE git_item_guid
    FROM crmd_orderadm_i
     FOR ALL ENTRIES IN git_header_guid
   WHERE header EQ git_header_guid-guid.
 
  CHECK sy-subrc EQ 0.
 
  wa_field_names-fieldname  = 'ACTIVATE'.
  wa_field_names-changeable = space.
  APPEND wa_field_names TO git_field_names.
 
* Fill the status for the Header GUIDs
  LOOP AT git_header_guid INTO wa_header_guid.
 
*   Fill the status as 'LIVE'
    wa_modify_status-ref_guid       = wa_header_guid-guid.
    wa_modify_status-ref_kind       = 'A'.
    wa_modify_status-status         = gc_status_e0012.
    wa_modify_status-user_stat_proc = gc_cont_h.
    wa_modify_status-activate       = 'X'.
    INSERT wa_modify_status INTO TABLE git_modify_status.
 
*   Fill the input fields for the status
    wa_input_fields-ref_guid    = wa_header_guid-guid.
    wa_input_fields-ref_kind    = 'A'.
    wa_input_fields-objectname  = 'STATUS'.
    wa_input_fields-field_names = git_field_names.
    INSERT wa_input_fields INTO TABLE git_input_fields.
 
    INSERT wa_header_guid-guid INTO TABLE git_head_to_save.
 
    CLEAR: wa_modify_status,
           wa_input_fields.
 
  ENDLOOP.
 
* Fill the status for the Item GUIDs
  LOOP AT git_item_guid INTO wa_item_guid.
 
*   Fill the status as 'LIVE'
    wa_modify_status-ref_guid       = wa_item_guid-guid.
    wa_modify_status-ref_kind       = 'B'.
    wa_modify_status-status         = gc_status_e0012.
    wa_modify_status-user_stat_proc = gc_cont_i.
    wa_modify_status-activate       = 'X'.
    INSERT wa_modify_status INTO TABLE git_modify_status.
 
*   Fill the input fields for the status
    wa_input_fields-ref_guid    = wa_item_guid-guid.
    wa_input_fields-ref_kind    = 'B'.
    wa_input_fields-objectname  = 'STATUS'.
    wa_input_fields-field_names = git_field_names.
    INSERT wa_input_fields INTO TABLE git_input_fields.
 
    CLEAR: wa_modify_status,
           wa_input_fields.
 
  ENDLOOP.
 
* Modify the status to live
  CALL FUNCTION 'CRM_ORDER_MAINTAIN'
    EXPORTING
      it_status         = git_modify_status
    CHANGING
      ct_input_fields   = git_input_fields
    EXCEPTIONS
      error_occurred    = 1
      document_locked   = 2
      no_change_allowed = 3
      no_authority      = 4
      OTHERS            = 5.
 
  CHECK sy-subrc EQ 0.
 
* Call CRM_ORDER_SAVE to save the contracts
  CALL FUNCTION 'CRM_ORDER_SAVE'
    EXPORTING
      it_objects_to_save = git_head_to_save
    EXCEPTIONS
      document_not_saved = 1
      OTHERS             = 2.
 
* Commit the data in the buffer
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      wait = 'X'.
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 -> SAP Other 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.