
*&---------------------------------------------------------------------*
*& Report ZCRM_SO_QTY_210
*&---------------------------------------------------------------------*
*& Name : Premanand Shelke
*& Emp ID : 129210
*& Description : Sales Order Report by adding necessary header level
*& data .
*&---------------------------------------------------------------------*
*************************************************************** Main Report Page*********************************************************
REPORT zcrm_so_210 NO STANDARD PAGE HEADING.
*----------------------------------------------------------------------*
* INCLUDES *
*----------------------------------------------------------------------*
INCLUDE: zcrm_so_210_top,
zcrm_so_210_cls.
*----------------------------------------------------------------------*
* INITIALISATION *
*----------------------------------------------------------------------*
INITIALIZATION .
CREATE OBJECT obj.
obj->clear( ).
*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
obj->create_guid( ).
obj->get_data( ).
obj->process_data( ).
*----------------------------------------------------------------------*
* END-OF-SELECTION
*----------------------------------------------------------------------*
END-OF-SELECTION.
obj->display( ).
*************************************************TOP OF INCLUDE************************************************
*&---------------------------------------------------------------------*
*& Include ZCRM_SO_210_TOP
*&---------------------------------------------------------------------*
******************************************DATA DECLARATION*********************************************************************
DATA: i_orderadm_h TYPE crmt_orderadm_h_comt, "for header data
wa_orderadm_h TYPE crmt_orderadm_h_com,
wa_input_fields TYPE crmt_input_field, "for input field type
i_input_fields TYPE crmt_input_field_tab,
i_object_save1 TYPE crmt_object_guid_tab, "for generate GUID
wa_object_save1 TYPE crmt_object_guid,
i_saved_objects1 TYPE crmt_return_objects, "for saved objects
wa_saved_objects1 TYPE crmt_return_objects_struc,
it_bapiret TYPE TABLE OF bapiret2. "for return table which shows all errors
DATA: gv_guid TYPE guid_16. "for global GUID
CLASS ZCRM_SO_210 DEFINITION DEFERRED. "class defination declaration
DATA :obj TYPE REF TO ZCRM_SO_210. "object declaration for corresponding class
*************************************************INCLUDE FOR CLASS*****************************************************************************
**********************************************CLASS DEFINATION AND IMPLEMENTATION*****************************************************
*&---------------------------------------------------------------------*
*& Include ZCRM_SO_210_CLS
*&---------------------------------------------------------------------*
CLASS ZCRM_SO_210 DEFINITION.
PUBLIC SECTION.
"method declaration
METHODS : clear, "for clear all internal tables
create_guid, "for creating GUID
get_data, "for get data
process_data, "for process data
display. "for display final transaction number
ENDCLASS.
*----------------------------------------------------------------------*
* CLASS zsales_order IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS ZCRM_SO_210 IMPLEMENTATION.
METHOD clear. "clear starts here
CLEAR : i_orderadm_h ,
i_input_fields ,
i_object_save1 ,
i_saved_objects1.
ENDMETHOD. "clear ends here
METHOD create_guid. "create_guid starts here
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_16 = gv_guid.
ENDMETHOD. "create_guid ends here
METHOD get_data. "get_data starts here
"ASSIGN HARD CODED VALUES
wa_orderadm_h-handle = '0000000001'.
wa_orderadm_h-guid = gv_guid.
wa_orderadm_h-process_type = 'ZSTA'.
wa_orderadm_h-mode = 'A'.
*Inserting values from work area to internal table.
INSERT wa_orderadm_h INTO TABLE i_orderadm_h.
CLEAR wa_orderadm_h.
*Passing values in the work area of INPUT_FIELDS1.
wa_input_fields-ref_guid = gv_guid.
wa_input_fields-ref_kind = 'A' .
*Inserting values from work area to internal table.
INSERT wa_input_fields INTO TABLE i_input_fields.
CLEAR wa_input_fields.
ENDMETHOD. "get_data ends here
METHOD process_data. "process_data starts here
CALL FUNCTION 'CRM_ORDER_MAINTAIN' "FM for creating sales order
CHANGING
ct_orderadm_h = i_orderadm_h
ct_input_fields = i_input_fields
EXCEPTIONS
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*Passing value of GUID to work area of internal table I_OBJECT_SAVE.
wa_object_save1 = gv_guid.
* Inserting value from work area to internal table.
INSERT wa_object_save1 INTO TABLE i_object_save1.
CLEAR wa_object_save1.
CALL FUNCTION 'CRM_ORDER_SAVE' "FM to save sales order
EXPORTING
it_objects_to_save = i_object_save1
IMPORTING
et_saved_objects = i_saved_objects1
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.
ENDMETHOD. "process_data ends here
METHOD display . "display starts here
IF NOT i_saved_objects1[] IS INITIAL.
LOOP AT i_saved_objects1 INTO wa_saved_objects1.
WRITE: /1 'Transaction number',
20 wa_saved_objects1-object_id,
30 'Is Saved'.
ENDLOOP.
ENDIF.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'. "FM to commit transaction
ENDMETHOD. "display ends here
ENDCLASS . "class ends here
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.