04-23-2008 6:03 AM
Hi Experts!
How to pass seletion screen date in query.
TABLES: crmd_orderadm_h.
**************************************************************************
* Selection screen
**************************************************************************
SELECT-OPTIONS: s_date FOR crmd_orderadm_h-posting_date.
TYPES: ty_date TYPE RANGE OF crmt_posting_date.
FIELD-SYMBOLS:
<fs_tab> TYPE ANY TABLE,
<wa_tab> TYPE ANY,
<fs_field> TYPE crmd_orderadm_h.
*----------------------------------------------------------------------*
* CLASS Transaction_text DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS transaction_text DEFINITION.
PUBLIC SECTION.
CONSTANTS: c_tabname TYPE tabname VALUE 'CRMD_ORDERADM_H'.
DATA: w_data TYPE REF TO data.
METHODS: constructor IMPORTING value(im_date) TYPE ty_date,
process_data.
PRIVATE SECTION.
TYPES: BEGIN OF i_orderadm_h,
guid TYPE crmt_object_guid,
object_id TYPE crmt_object_id_db,
process_type TYPE crmt_process_type_db,
posting_date TYPE crmt_posting_date,
END OF i_orderadm_h.
DATA: lv_header_guid TYPE string,
iv_header_guid TYPE crmt_object_guid,
lt_header_guid TYPE crmt_object_guid_tab.
DATA: im_orderadm_h TYPE crmt_orderadm_h_wrkt,
wa_orderadm_h TYPE crmt_orderadm_h_wrk.
DATA: im_text TYPE crmt_text_wrkt,
wa_text TYPE crmt_text_wrk.
ENDCLASS. "Transaction_text DEFINITION
*----------------------------------------------------------------------*
* CLASS Transaction_text IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS transaction_text IMPLEMENTATION.
METHOD: constructor.
CREATE DATA w_data TYPE STANDARD TABLE OF (c_tabname) WITH NON-UNIQUE DEFAULT KEY.
ASSIGN w_data->* TO <fs_tab>.
*bold* How to pass selection-date here? *bold*
SELECT * FROM (c_tabname)
INTO CORRESPONDING FIELDS OF TABLE <fs_tab> WHERE posting_date = im_date.
"and process_type = .
ENDMETHOD. "constructor
METHOD: process_data.
LOOP AT <fs_tab> ASSIGNING <wa_tab>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <wa_tab> TO <fs_field>.
lv_header_guid = <fs_field>-guid.
iv_header_guid = lv_header_guid.
REFRESH: lt_header_guid.
INSERT iv_header_guid INTO TABLE lt_header_guid.
REFRESH: im_orderadm_h,im_text.
CALL FUNCTION 'CRM_ORDER_READ'
EXPORTING
it_header_guid = lt_header_guid
IMPORTING
et_orderadm_h = im_orderadm_h
et_text = im_text
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.
ENDIF.
ENDDO.
ENDLOOP.
ENDMETHOD. "process_data
ENDCLASS. "Transaction_text IMPLEMENTATION
DATA: oref TYPE REF TO transaction_text.
START-OF-SELECTION.
CREATE OBJECT oref.
CALL METHOD oref=>process_data
EXPORTING
im_date = s_date[].
04-23-2008 7:52 AM
Hello Anee
I still recommend to use the approach described in because you do not have to change the CONSTRUCTOR method of your class if your requirements for reading select-option changes.
You just change the evaluation of the select-options and parameters within your class.
Regards
Uwe
04-23-2008 7:43 AM
Hello Anee,
do you mean you want to pass the select-options fields s_date to the constructor?
Regards,
Gianpietro
04-23-2008 7:46 AM
04-23-2008 7:52 AM
Hello Anee
I still recommend to use the approach described in because you do not have to change the CONSTRUCTOR method of your class if your requirements for reading select-option changes.
You just change the evaluation of the select-options and parameters within your class.
Regards
Uwe
04-23-2008 7:58 AM
Hi again,
sorry you was to fast...;-)
Regards,
Gianpietro
Edited by: Gianpietro Dal Zio on Apr 23, 2008 9:01 AM
Edited by: Gianpietro Dal Zio on Apr 23, 2008 9:02 AM