Vous êtes sur la page 1sur 17

*&---------------------------------------------------------------------* *& Report ZI_CS_DISPO_ORDER *& *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *----------------------------------------------------------------------* * Title: CS Dispo Order *----------------------------------------------------------------------* * Author : DEX00537 *----------------------------------------------------------------------*

* Program description: * *----------------------------------------------------------------------* * Change-History: Change history * Techem Energy Services * DEX00537/18122011/Initial Version *-----------------------------------------------------------------------* REPORT zi_cs_dispo_order. *Table Declarations TABLES:vbak,vbpa. *Types Declaration TYPES:BEGIN OF tf_person, " structure to hold person name pernr TYPE persno, vorna TYPE pad_vorna, nachn TYPE pad_nachn, END OF tf_person. *Internal Table Declarations DATA:lt_vbak TYPE TABLE OF vbak, lt_vbap TYPE TABLE OF vbap, lt_qmel TYPE TABLE OF qmel, lt_vbpa TYPE TABLE OF vbpa, lt_afko TYPE TABLE OF afko, lt_ordna TYPE TABLE OF m_ordna, lt_crhd TYPE TABLE OF crhd, lt_status TYPE TABLE OF jstat, lt_index_rows TYPE lvc_t_row, lt_org_unit TYPE /mrss/t_objec_tab, lt_person TYPE TABLE OF tf_person, lt_afvu TYPE TABLE OF afvu, lt_operations TYPE TABLE OF bapi_alm_order_operation_e, lt_return TYPE TABLE OF bapiret2, lt_afvgd TYPE TABLE OF afvgd, lt_main TYPE TABLE OF zis_cs_main_order_notif, lt_sub TYPE TABLE OF zis_cs_sub_order_details. *Structure Declarations. DATA :ls_vbak TYPE vbak, ls_vbap TYPE vbap, ls_qmel TYPE qmel, ls_vbpa TYPE vbpa, ls_afko TYPE afko, ls_strno TYPE iflos-strno, ls_itob TYPE itob, ls_ordna TYPE m_ordna, ls_crhd TYPE crhd, ls_objec TYPE objec, ls_status TYPE jstat,

ls_tj30t TYPE tj30t, ls_index_rows LIKE LINE OF lt_index_rows, ls_person TYPE tf_person, ls_afvu TYPE afvu, ls_header TYPE bapi_alm_order_header_e, ls_servdata TYPE bapi_alm_order_srvdat_e, ls_operations TYPE bapi_alm_order_operation_e, ls_afvgd TYPE afvgd, ls_main TYPE zis_cs_main_order_notif, ls_sub TYPE zis_cs_sub_order_details. *Variable Declarations DATA:lf_notf_stat TYPE j_txt30, lf_objnr TYPE j_objnr, lf_stsma TYPE j_stsma, lf_maktx TYPE maktx, lf_lines(255) TYPE c, "No. of lines in ALV lf_no_rows TYPE i . "No. of rows selected *Data declaration for container and ALV DATA:lref_custom_container_main TYPE REF TO cl_gui_custom_container, lref_custom_container_sub TYPE REF TO cl_gui_custom_container, lref_alv_grid_main TYPE REF TO cl_gui_alv_grid, lref_alv_grid_sub TYPE REF TO cl_gui_alv_grid, ls_layo TYPE lvc_s_layo, "For layout lt_fcat TYPE lvc_t_fcat, "for fieldcatalog ls_fcat TYPE lvc_s_fcat, "for fieldcatalog lt_fcat_sub TYPE lvc_t_fcat, "for fieldcatalog ls_fcat_sub TYPE lvc_s_fcat, "for fieldcatalog lref_document TYPE REF TO cl_dd_document, "Document lref_split TYPE REF TO cl_gui_easy_splitter_container,"Splitter lref_top_container TYPE REF TO cl_gui_container, "Top Container lref_bottom_container TYPE REF TO cl_gui_container."Bottom Container *---------------------------------------------------------------------* * CLASS event_class DEFINITION *---------------------------------------------------------------------* * *---------------------------------------------------------------------* CLASS event_class DEFINITION. *Handling double click PUBLIC SECTION. METHODS: handle_double_click FOR EVENT double_click OF cl_gui_alv_grid IMPORTING handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid IMPORTING handle_user_command FOR EVENT user_command OF IMPORTING e_ucomm, handle_toolbar1 FOR EVENT toolbar OF cl_gui_alv_grid IMPORTING handle_user_command1 FOR EVENT user_command OF IMPORTING e_ucomm. ENDCLASS. "lcl_event_class DEFINITION

e_row e_column, e_object , cl_gui_alv_grid

e_object , cl_gui_alv_grid

DATA: event_receiver TYPE REF TO event_class. *Selection screen SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME. SELECT-OPTIONS:vkorg FOR vbak-vkorg, vtweg FOR vbak-vtweg, spart FOR vbak-spart, auart FOR vbak-auart, kunnr FOR vbak-kunnr OBLIGATORY, kunnr1 FOR vbpa-kunnr. SELECTION-SCREEN END OF BLOCK b1. START-OF-SELECTION. PERFORM selection. IF lt_main IS NOT INITIAL. CALL SCREEN 9000. ENDIF. *---------------------------------------------------------------------* * CLASS event_class IMPLEMENTATION *---------------------------------------------------------------------* * *---------------------------------------------------------------------* CLASS event_class IMPLEMENTATION. METHOD handle_double_click. *Read the selected data into a variable READ TABLE lt_main INDEX e_row-index INTO ls_main. CASE e_column. *write the logic to go to transaction WHEN 'KUNNR'. IF ls_main-kunnr IS NOT INITIAL. SET PARAMETER ID 'KUN' FIELD ls_main-kunnr. CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN. ENDIF. WHEN 'KUNNR1'. IF ls_main-kunnr1 IS NOT INITIAL. SET PARAMETER ID 'KUN' FIELD ls_main-kunnr1. CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN. ENDIF. WHEN 'VBELN'. IF ls_main-vbeln IS NOT INITIAL. SET PARAMETER ID 'AUN' FIELD ls_main-vbeln. CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN. ENDIF. WHEN 'MATNR'. IF ls_main-matnr IS NOT INITIAL. SET PARAMETER ID 'MAT' FIELD ls_main-matnr. CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN. ENDIF. WHEN 'TPLNR'. IF ls_main-tplnr IS NOT INITIAL. SET PARAMETER ID 'IFL' FIELD ls_main-tplnr. CALL TRANSACTION 'IL03' AND SKIP FIRST SCREEN. ENDIF. WHEN 'QMNUM'.

IF ls_main-qmnum IS NOT INITIAL. SET PARAMETER ID 'IQM' FIELD ls_main-qmnum. CALL TRANSACTION 'IW53' AND SKIP FIRST SCREEN. ENDIF. WHEN 'AUFNR'. IF ls_main-aufnr IS NOT INITIAL. SET PARAMETER ID 'ANR' FIELD ls_main-aufnr. CALL TRANSACTION 'IW33' AND SKIP FIRST SCREEN. ENDIF. ENDCASE. *Read the selected data into a variable READ TABLE lt_sub INDEX e_row-index INTO ls_sub. CASE e_column. WHEN 'ORDER_SUB'. IF ls_sub-order_sub IS NOT INITIAL. SET PARAMETER ID 'ANR' FIELD ls_sub-order_sub. CALL TRANSACTION 'IW33' AND SKIP FIRST SCREEN. ENDIF. ENDCASE. ENDMETHOD. "handle_double_click METHOD handle_toolbar. DATA: ls_toolbar TYPE stb_button. CLEAR ls_toolbar. MOVE 3 TO ls_toolbar-butn_type. APPEND ls_toolbar TO e_object->mt_toolbar. CLEAR ls_toolbar. MOVE 'REFRESH' TO ls_toolbar-function. MOVE icon_refresh TO ls_toolbar-icon. APPEND ls_toolbar TO e_object->mt_toolbar. CLEAR ls_toolbar. MOVE 3 TO ls_toolbar-butn_type. APPEND ls_toolbar TO e_object->mt_toolbar. CLEAR ls_toolbar. MOVE 'DISPLAY' TO ls_toolbar-function. MOVE 'Dispo Order'(001) TO ls_toolbar-text. APPEND ls_toolbar TO e_object->mt_toolbar. ENDMETHOD. "handle_toolbar METHOD handle_toolbar1. DATA:ls_sub_toolbar TYPE stb_button. CLEAR ls_sub_toolbar. MOVE 3 TO ls_sub_toolbar-butn_type. APPEND ls_sub_toolbar TO e_object->mt_toolbar. CLEAR ls_sub_toolbar. MOVE 'Appointment'(002) TO ls_sub_toolbar-function. MOVE 'Appointment schedule'(003) TO ls_sub_toolbar-text. APPEND ls_sub_toolbar TO e_object->mt_toolbar. ENDMETHOD. "handle_toolbar METHOD handle_user_command.

CASE e_ucomm. WHEN 'DISPLAY'. PERFORM selection_sub. WHEN 'REFRESH'. CLEAR:ls_vbak,ls_vbap,ls_vbpa,ls_qmel,ls_main. REFRESH:lt_vbak,lt_vbap,lt_vbpa,lt_main. PERFORM selection. CALL METHOD lref_alv_grid_main->refresh_table_display . ENDCASE. ENDMETHOD. METHOD handle_user_command1. CASE e_ucomm. WHEN 'Appointment'. PERFORM appointment. WHEN 'Ernennung'. PERFORM appointment. ENDCASE. ENDMETHOD. ENDCLASS. "handle_user_command

"handle_user_command "event_class DEFINITION

*&---------------------------------------------------------------------* *& Form SELECTION *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM selection . *Fetch Sales Order data from vbak table according to selection criteria SELECT vbeln kunnr vdatu qmnum FROM vbak INTO CORRESPONDING FIELDS OF TABLE l t_vbak WHERE kunnr IN kunnr AND vkorg IN vkorg AND vtweg IN vtweg AND spart IN spart AND auart IN auart. *Fetch ZL partner data from table VBAP IF lt_vbak IS NOT INITIAL. SELECT vbeln kunnr FROM vbpa INTO CORRESPONDING FIELDS OF TABLE lt_vbpa FOR ALL ENTRIES IN lt_v bak WHERE vbeln = lt_vbak-v beln AND kunnr IN kunnr1 AND parvw = 'ZL'. *Fetch sales order data from vbap table SELECT vbeln posnr matnr kwmeng vrkme FROM vbap INTO CORRESPONDING FIELDS OF TABLE lt_vbap FOR ALL ENTRIES IN lt_vbak WHERE vbeln = lt_vbak-vbeln .

*Fetch notification/mainorder from table QMEL SELECT qmnum strmn ltrmn aufnr objnr crobjty arbpl arbplwerk FROM qmel INTO CORRESPONDING FIELDS OF TABLE lt_qmel FOR ALL ENTRIES IN lt_vbak WHERE qmnum = lt_vbak-qmnum. IF lt_qmel IS NOT INITIAL. *Fetch object id from table CRHD SELECT objty objid arbpl FROM crhd INTO CORRESPONDING FIELDS OF TABLE lt_c rhd FOR ALL ENTRIES IN lt_q mel WHERE objty = lt_qmel-crob jty AND objid = lt_qmel-arb pl. ENDIF. ELSE. MESSAGE s003(zord). ENDIF. LOOP AT lt_vbap INTO ls_vbap. ls_main-vbeln = ls_vbap-vbeln. ls_main-posnr = ls_vbap-posnr. ls_main-matnr = ls_vbap-matnr. ls_main-kwmeng = ls_vbap-kwmeng. ls_main-vrkme = ls_vbap-vrkme. READ TABLE lt_vbak WITH KEY vbeln = ls_vbap-vbeln INTO ls_vbak. IF sy-subrc = 0. ls_main-kunnr = ls_vbak-kunnr. ls_main-vdatu = ls_vbak-vdatu. ls_main-qmnum = ls_vbak-qmnum. ENDIF. READ TABLE lt_vbpa WITH KEY vbeln = ls_vbak-vbeln INTO ls_vbpa. IF sy-subrc = 0. ls_main-kunnr1 = ls_vbpa-kunnr. ENDIF. ls_strno = ls_vbpa-kunnr. *Derive functional location from partner REPLACE FIRST OCCURRENCE OF '1' IN ls_strno WITH '0'. REPLACE FIRST OCCURRENCE OF '0' IN ls_strno WITH space. CONCATENATE ls_strno+0(4) '/' ls_strno+4(5) INTO ls_strno. CALL FUNCTION 'ITOB_FUNCLOC_READ_SINGLE' EXPORTING i_func_location_label = ls_strno i_labeling_system = '0' IMPORTING e_object_rec = ls_itob. EXCEPTIONS

* *

not_successful OTHERS

= 1 = 2.

IF ls_itob-tplnr IS NOT INITIAL. ls_main-tplnr = ls_itob-tplnr. ENDIF. READ TABLE lt_qmel WITH KEY qmnum = ls_vbak-qmnum INTO ls_qmel. IF sy-subrc = 0. ls_main-strmn = ls_qmel-strmn. ls_main-ltrmn = ls_qmel-ltrmn. ls_main-aufnr = ls_qmel-aufnr. ls_main-arbplwerk = ls_qmel-arbplwerk. *Get notifcation status from object number CALL FUNCTION 'STATUS_READ' EXPORTING * CLIENT = SY-MANDT objnr = ls_qmel-objnr only_active = 'X' IMPORTING stsma = lf_stsma TABLES status = lt_status . LOOP AT lt_status INTO ls_status. SELECT SINGLE txt30 FROM tj30t INTO lf_notf_stat WHERE estat = ls_status-stat AND stsma = lf_stsma. IF sy-subrc = 0. ls_main-estat = lf_notf_stat. ENDIF. ENDLOOP. ENDIF. READ TABLE lt_crhd WITH KEY objty = ls_qmel-crobjty objid = ls_qmel-arbpl INTO ls_crhd. IF sy-subrc = 0. ls_main-arbpl = ls_crhd-arbpl. ENDIF. *Append all data from structure to final internal table APPEND ls_main TO lt_main. CLEAR: ls_vbak,ls_vbap,ls_vbpa,ls_qmel,ls_crhd,ls_main. ENDLOOP. ENDFORM. " SELECTION *&---------------------------------------------------------------------* *& Module STATUS_9000 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE status_9000 OUTPUT. SET PF-STATUS 'MENU'. SET TITLEBAR 'TITLE'. DATA:lf_date TYPE sdydo_text_element, lf_uname TYPE sdydo_text_element, lf_time TYPE sdydo_text_element.

IF lref_custom_container_main IS INITIAL. *Create custom container for main order CREATE OBJECT lref_custom_container_main EXPORTING container_name = 'CONTAINER_MAIN'. * Splitting the container CREATE OBJECT lref_split EXPORTING parent = lref_custom_container_main sash_position = 25."Position of Splitter Bar (in Percent) * Placing the containers in the splitter lref_top_container = lref_split->top_left_container . lref_bottom_container = lref_split->bottom_right_container. *Create ALV grid CREATE OBJECT lref_alv_grid_main EXPORTING i_parent = lref_bottom_container. CREATE OBJECT lref_document EXPORTING style = 'ALV_GRID'. *Creating fieldcatalog PERFORM build_fieldcatalog. *Creating Layout PERFORM build_layout_main. * Adding Line CALL METHOD lref_document->new_line. * Adding Text CALL METHOD lref_document->add_text EXPORTING text = 'Username :'(004). * Adding username lf_uname = sy-uname. CALL METHOD lref_document->add_text EXPORTING text = lf_uname. * Adding Line CALL METHOD lref_document->new_line. * Adding Text CALL METHOD lref_document->add_text EXPORTING text = 'Current Date :'(005). * Adding date lf_date = sy-datum. CALL METHOD lref_document->add_text EXPORTING text = lf_date.

* Adding Line CALL METHOD lref_document->new_line. * Adding Text CALL METHOD lref_document->add_text EXPORTING text = 'Time :'(006). * Adding time lf_time = sy-uzeit. CALL METHOD lref_document->add_text EXPORTING text = lf_time. * Adding Line CALL METHOD lref_document->new_line. * Adding Text CALL METHOD lref_document->add_text EXPORTING text = 'No of records generated :'(007). * Adding Text DESCRIBE TABLE lt_main LINES lf_lines. CALL METHOD lref_document->add_text EXPORTING text = lf_lines. * Adding Line CALL METHOD lref_document->new_line. * Display the data CALL METHOD lref_document->display_document EXPORTING parent = lref_top_container. *Call method for display ALV CALL METHOD lref_alv_grid_main->set_table_for_first_display EXPORTING i_structure_name = 'ZIS_CS_MAIN_ORDER_NOTIF' is_layout = ls_layo CHANGING it_outtab = lt_main it_fieldcatalog = lt_fcat. ENDIF. *Set event handler for double click CREATE OBJECT event_receiver. SET HANDLER event_receiver->handle_double_click FOR lref_alv_grid_main. *Set event handler for pushbutton SET HANDLER event_receiver->handle_toolbar FOR lref_alv_grid_main. *Set event handler for user command SET HANDLER event_receiver->handle_user_command FOR lref_alv_grid_main. * Method to raise event toolbar. CALL METHOD lref_alv_grid_main->set_toolbar_interactive. ENDMODULE. " STATUS_9000 OUTPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_9000 INPUT *&---------------------------------------------------------------------*

* text *----------------------------------------------------------------------* MODULE user_command_9000 INPUT. CASE sy-ucomm. WHEN 'BACK'. LEAVE TO SCREEN 0 . WHEN 'EXIT'. LEAVE PROGRAM. WHEN 'CANCEL'. LEAVE PROGRAM. ENDCASE. ENDMODULE. " USER_COMMAND_9000 INPUT *&---------------------------------------------------------------------* *& Form BUILD_LAYOUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM build_layout_main . ls_layo-grid_title = 'CS Notification Display'(008). ls_layo-zebra = 'X'. "Alternating line color (striped) ls_layo-cwidth_opt = 'X'. "Optimize column width ls_layo-sel_mode = 'A'. ENDFORM. " BUILD_LAYOUT_MAIN *&---------------------------------------------------------------------* *& Module STATUS_9001 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE status_9001 OUTPUT. SET PF-STATUS 'MENU'. SET TITLEBAR 'TITLE'. *Create custom container for main order CREATE OBJECT lref_custom_container_sub EXPORTING container_name = 'CONTAINER_SUB'. *Create ALV grid CREATE OBJECT lref_alv_grid_sub EXPORTING i_parent = lref_custom_container_sub. *Creating fieldcatalog PERFORM build_fieldcatalog_sub. *Creating Layout PERFORM build_layout_sub. *Call method for display ALV CALL METHOD lref_alv_grid_sub->set_table_for_first_display EXPORTING i_structure_name = 'ZIS_CS_SUB_ORDER_DETAILS' is_layout = ls_layo CHANGING it_outtab = lt_sub it_fieldcatalog = lt_fcat_sub. *Event handler for double click

CREATE OBJECT event_receiver. SET HANDLER event_receiver->handle_double_click FOR lref_alv_grid_sub. *Set event handler for pushbutton SET HANDLER event_receiver->handle_toolbar1 FOR lref_alv_grid_sub. *Set event handler for user command SET HANDLER event_receiver->handle_user_command1 FOR lref_alv_grid_sub. * method to raise event TOOLBAR. CALL METHOD lref_alv_grid_sub->set_toolbar_interactive. ENDMODULE. " STATUS_9001 OUTPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_9001 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE user_command_9001 INPUT. CASE sy-ucomm. WHEN 'BACK'. CALL METHOD lref_custom_container_sub->free. LEAVE TO SCREEN 0 . WHEN 'EXIT'. LEAVE PROGRAM. WHEN 'CANCEL'. LEAVE PROGRAM. ENDCASE. ENDMODULE. " USER_COMMAND_9001 INPUT *&---------------------------------------------------------------------* *& Form BUILD_LAYOUT_SUB *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM build_layout_sub . ls_layo-grid_title = 'Installation Orders'(009). ls_layo-zebra = 'X'. "Alternating line color (striped) ls_layo-cwidth_opt = 'X'. "Optimize column width ls_layo-sel_mode = 'A'. ENDFORM. " BUILD_LAYOUT_SUB *&---------------------------------------------------------------------* *& Form SELECTION_SUB *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM selection_sub . CLEAR:lt_index_rows. REFRESH :lt_sub,lt_ordna. CALL METHOD lref_alv_grid_main->get_selected_rows IMPORTING et_index_rows = lt_index_rows. DESCRIBE TABLE lt_index_rows LINES lf_no_rows. IF lf_no_rows EQ 0. MESSAGE i002(zord). EXIT. ELSE.

LOOP AT lt_index_rows INTO ls_index_rows. READ TABLE lt_main INTO ls_main INDEX ls_index_rows-index. IF sy-subrc = 0. SELECT aufnr lead_aufnr FROM afko INTO CORRESPONDING FIELDS OF TABLE lt_afko WHERE aufnr = ls_main-aufnr. IF sy-subrc EQ 0. READ TABLE lt_afko INTO ls_afko WITH KEY aufnr = ls_main-aufnr. CALL FUNCTION 'CO_I0_GET_SUBORDER_NUMBERS' EXPORTING lead_aufnr = ls_afko-lead_aufnr aufnr = ls_afko-aufnr transporting_table = 'X' TABLES t_ordna = lt_ordna. LOOP AT lt_ordna INTO ls_ordna. ls_sub-order_sub = ls_ordna-aufnr. *Get objnr from order to get planning status CALL FUNCTION 'ZI_CS_ORD_GET_OPERATION_DATA' EXPORTING iv_aufnr = ls_ordna-aufnr IMPORTING et_afvgd = lt_afvgd. *Call BAPI to get suborder details CALL FUNCTION 'BAPI_ALM_ORDER_GET_DETAIL' EXPORTING number = ls_ordna-aufnr IMPORTING es_header = ls_header es_srvdata = ls_servdata TABLES et_operations = lt_operations return = lt_return. ls_sub-material = ls_servdata-material . *Fetch assembly description from table MAKT SELECT SINGLE maktx FROM makt INTO lf_maktx WHERE matnr = ls_servdata-material. ls_sub-short_text = lf_maktx. *Fetch org.unit from table crhd. SELECT hroid werks arbpl FROM crhd INTO CORRESPONDING FIELDS OF TABLE lt_crhd FOR ALL ENTRIES IN lt_operations WHERE arbpl = lt_operations-work_cntr AND werks = lt_operations-plant. *Fetch Technician name from table PA0002 SELECT pernr vorna nachn FROM pa0002 INTO CORRESPONDING FIELDS OF TABLE lt_person FOR ALL ENTRIES IN lt_operations WHERE pernr = lt_operations-pers_no. *Fetch profile key from table AFVU. SELECT * FROM afvu INTO CORRESPONDING FIELDS OF TABLE lt_afvu FOR ALL ENTRIES IN lt_afvgd WHERE aufpl = lt_afvgd-aufp l

AND aplzl = lt_afvgd-aplzl. LOOP AT lt_operations INTO ls_operations. ls_sub-vornr ls_sub-ltxa1 ls_sub-pernr ls_sub-fsavd ls_sub-fsedd ls_sub-arbpl ls_sub-werks ls_sub-steus ls_sub-dauno ls_sub-daune k_cntr werks = ls_operations-plant. ls_sub-hroid = ls_crhd-hroid. READ TABLE lt_person INTO ls_person WITH KEY pernr = ls_operations-pers_no. CONCATENATE ls_person-vorna ls_person-nachn INTO ls_sub-technicia n SEPARATED BY space. READ TABLE lt_afvgd INTO ls_afvgd WITH KEY vornr = ls_operations-a ctivity. lf_objnr = ls_afvgd-objnr. *Get profile key from table AFVU CLEAR: ls_afvu. READ TABLE lt_afvu INTO ls_afvu WITH KEY aufpl = ls_afvgd-aufpl aplzl = ls_afvgd-aplzl. IF sy-subrc = 0. ls_sub-prof_key = ls_afvu-/mrss/prof_key. ls_sub-mrs_slot_guid = ls_afvu-zzmrs_slot_guid. ls_sub-mrs_res_id = ls_afvu-zzmrs_res_id. ENDIF. CALL FUNCTION 'STATUS_READ' EXPORTING client = sy-mandt objnr = lf_objnr only_active = 'X' IMPORTING stsma = lf_stsma TABLES status = lt_status. *Fetch status description from table TJ30T SELECT txt30 FROM tj30t INTO ls_tj30t-txt30 FOR ALL ENTRIES IN lt_ status WHERE estat = lt_stat us-stat AND stsma = lf_stsma. *Assign icon for planning status. IF ( ls_tj30t-txt30 = 'Assigned' OR ls_tj30t-txt30 = 'Assigned + ' OR ls_tj30t-txt30 = 'Assigned -' ). ls_sub-planning = '@B4@' . = = = = = = = = = = ls_operations-activity . ls_operations-description. ls_operations-pers_no. ls_operations-earl_sched_start_date. ls_operations-earl_sched_fin_date. ls_operations-work_cntr. ls_operations-plant. ls_operations-control_key. ls_operations-duration_normal. ls_operations-duration_normal_unit.

READ TABLE lt_crhd INTO ls_crhd WITH KEY arbpl = ls_operations-wor

EXIT. ELSE. ls_sub-planning = '@B3@'. ENDIF. ENDSELECT. APPEND ls_sub TO lt_sub. CLEAR : ls_sub-planning,ls_sub-technician,ls_operations, ls_person-vorna,ls_person-nachn,ls_crhd-hroid. ENDLOOP. CLEAR:ls_sub-order_sub, ls_ordna-aufnr,ls_header,ls_servdata, ls_servdata-material,ls_sub-material,ls_sub-short_text,lf_makt x. ENDLOOP. CLEAR ls_sub. ENDIF. ENDIF. ENDLOOP. IF lt_sub IS NOT INITIAL. CALL SCREEN 9001. ELSE. MESSAGE i003(zord) . ENDIF. ENDIF. ENDFORM. " SELECTION_SUB *&---------------------------------------------------------------------* *& Form BUILD_FIELDCATALOG *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM build_fieldcatalog . REFRESH lt_fcat. CLEAR ls_fcat. ls_fcat-row_pos = '1'. ls_fcat-col_pos = 1. ls_fcat-fieldname = 'KUNNR'. ls_fcat-coltext = 'Customer'(010). ls_fcat-hotspot = 'X'. APPEND ls_fcat TO lt_fcat. CLEAR ls_fcat. ls_fcat-row_pos ls_fcat-col_pos ls_fcat-fieldname ls_fcat-coltext = ls_fcat-hotspot = APPEND ls_fcat TO CLEAR ls_fcat. ls_fcat-row_pos ls_fcat-col_pos ls_fcat-fieldname ls_fcat-hotspot = APPEND ls_fcat TO CLEAR ls_fcat. = '1'. = 2. = 'KUNNR1'. 'ZL Partner'(011). 'X'. lt_fcat. = '1'. = 3. = 'VBELN'. 'X'. lt_fcat.

ls_fcat-row_pos ls_fcat-col_pos ls_fcat-fieldname ls_fcat-hotspot = APPEND ls_fcat TO CLEAR ls_fcat. ls_fcat-row_pos ls_fcat-col_pos ls_fcat-fieldname ls_fcat-hotspot = ls_fcat-coltext = APPEND ls_fcat TO CLEAR ls_fcat. ls_fcat-row_pos ls_fcat-col_pos ls_fcat-fieldname ls_fcat-hotspot = APPEND ls_fcat TO

= '1'. = 5. = 'MATNR'. 'X'. lt_fcat. = '1'. = 9. = 'TPLNR'. 'X'. 'Property'(012). lt_fcat. = '1'. = 12. = 'QMNUM'. 'X'. lt_fcat.

CLEAR ls_fcat. ls_fcat-row_pos = '1'. ls_fcat-col_pos = 14. ls_fcat-fieldname = 'AUFNR'. ls_fcat-hotspot = 'X'. APPEND ls_fcat TO lt_fcat. ENDFORM. " BUILD_FIELDCATALOG *&---------------------------------------------------------------------* *& Form BUILD_FIELDCATALOG_SUB *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM build_fieldcatalog_sub . REFRESH lt_fcat_sub. CLEAR ls_fcat. ls_fcat_sub-row_pos = '1'. ls_fcat_sub-col_pos = 4. ls_fcat_sub-fieldname = 'MATNR'. ls_fcat_sub-coltext = 'Serv Prod'(016). APPEND ls_fcat_sub TO lt_fcat_sub. REFRESH lt_fcat_sub. CLEAR ls_fcat. ls_fcat_sub-row_pos ls_fcat_sub-col_pos ls_fcat_sub-fieldname ls_fcat_sub-coltext = APPEND ls_fcat_sub TO REFRESH lt_fcat_sub. CLEAR ls_fcat. ls_fcat_sub-row_pos ls_fcat_sub-col_pos ls_fcat_sub-fieldname ls_fcat_sub-coltext = ls_fcat_sub-hotspot =

= '1'. = 11. = 'HROID'. 'Org Unit'(017). lt_fcat_sub.

= '1'. = 1. = 'ORDER_SUB'. 'Dispo Order'(014). 'X'.

APPEND ls_fcat_sub TO lt_fcat_sub. CLEAR ls_fcat. ls_fcat_sub-row_pos = '1'. ls_fcat_sub-col_pos = 17. ls_fcat_sub-fieldname = 'PLANNING'. ls_fcat_sub-coltext = 'Planning Status'(015). ls_fcat_sub-icon = 'X'. APPEND ls_fcat_sub TO lt_fcat_sub. ENDFORM. " BUILD_FIELDCATALOG_SUB *&---------------------------------------------------------------------* *& Form APPOINTMENT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM appointment . CLEAR: lt_index_rows,ls_objec-objid. REFRESH lt_org_unit. CALL METHOD lref_alv_grid_sub->get_selected_rows IMPORTING et_index_rows = lt_index_rows. DESCRIBE TABLE lt_index_rows LINES lf_no_rows. IF lf_no_rows EQ 0. MESSAGE i002(zord). EXIT. ENDIF. IF lf_no_rows > 1 . MESSAGE i001(zord). ENDIF. IF lf_no_rows = 1. READ TABLE lt_index_rows INTO ls_index_rows INDEX 1. READ TABLE lt_sub INTO ls_sub INDEX ls_index_rows-index. ls_objec-objid = ls_sub-hroid. ls_objec-otype = 'O'. ls_objec-plvar = 01. APPEND ls_objec TO lt_org_unit. IF sy-subrc = 0. CALL FUNCTION 'ZI_CS_APPT_SCHEDULE_UI' EXPORTING iv_obtyp = 'ORI' it_org_unit = lt_org_unit iv_orderid = ls_sub-order_sub iv_activity = ls_sub-vornr IV_NOTIFICATION = iv_item_key = iv_work_center = ls_sub-arbpl iv_control_key = ls_sub-steus IV_PRESELECTION = iv_profile_key = ls_sub-prof_key IT_STRUC_QUALIF = IS_DIMENSIONS = IMPORTING

* * * * * *

* ENDIF. ENDIF. ENDFORM.

ET_RETURN .

" APPOINTMENT