ZSDTXT

Embed Size (px)

DESCRIPTION

ggg

Citation preview

report zsd_so_item_texts.tables: sscrfields,stxh,rssce.include icons.*types: begin of lty_cus_text,* customer type kunnr,* shipto type kunnr,* plant type werks_d,* textid type tdid,* family type char30,* type type char30,* spras type spras,* textname type tdobname,* text type tdline,* edit type iconname,* delete type iconname,* end of lty_cus_text.**data: lt_cust_text type standard table of lty_cus_text,* ls_cust_text type lty_cus_text.data: lt_texttable type soli_tab.data: ls_text type soli.data: lt_tline type standard table of tline, ls_tline type tline.data: ls_head type thead.data: lv_tdname type tdobname.data: lv_status type flag.*data: lt_so_text type standard table of zsd_nor_custtext,* ls_so_text type zsd_nor_custtext.data: lt_cust_text type standard table of zsd_nor_custtext, ls_cust_text type zsd_nor_custtext.data: lv_edit type abap_bool.field-symbols: type standard table, type any.field-symbols: type zsd_nor_custtext.field-symbols: type any, type any, type any, type any, type any, type any, type any, type any, type any.constants: lc_commentctrl type scrfname value 'CC_COMMENT'.lv_edit = abap_false.class lcl_view_nor definition inheriting from zcl_nor_report_template. public section. methods: handle_link_click_salv for event link_click of cl_salv_events_table importing row column.endclass.data: lo_sdtx type ref to lcl_view_nor.class lcl_view_nor implementation. method handle_link_click_salv. data: ls_data_table type ref to data. assign lo_sdtx->ct_data->* to . create data ls_data_table like line of . assign ls_data_table->* to .* Read the Line selected. read table assigning index row. if sy-subrc eq 0. case column. when 'EDIT'.* Set the Edit Flag as True. lv_edit = abap_true.* Call screen 2000 to enter comment. call screen '2000'. when 'DEL'. assign component 'TEXTID' of structure to . assign component 'SPRAS' of structure to . assign component 'TEXTNAME' of structure to . assign component 'CUSTOMER' of structure to . assign component 'SHIPTO' of structure to . assign component 'PLANT' of structure to . assign component 'FAMILY' of structure to . assign component 'TYPE' of structure to . if is assigned and is assigned and is assigned. call function 'DELETE_TEXT' exporting client = sy-mandt id = language = name = object = 'TEXT' savemode_direct = 'X' exceptions not_found = 1 others = 2. endif. if is not initial. delete zsd_nor_custtext from . endif. if is not initial. delete index row. endif. set_alv( changing ct_data_table = ). display_alv( ). when others. endcase. endif. endmethod. "handle_data_changedendclass.selection-screen begin of block b1 with frame title text-001.parameter: p_kunnr type kunnr, "Customer p_shipto type kunnr, "Ship to Party p_textid type tdid, "Text ID p_werk type werks_d, "Plant p_family type char30, "Family p_type type char30, "Type of material p_spras type spras. "Languageselection-screen skip.selection-screen pushbutton /10(12) comm1 user-command sel.selection-screen pushbutton 30(20) comm2 user-command txt.selection-screen end of block b1.initialization. concatenate icon_execute_object 'Select' into comm1 separated by space. concatenate icon_create_text 'Create Text' into comm2 separated by space. create object lo_sdtx exporting iv_custom_control = lc_commentctrl. " Name of a Screen Elementat selection-screen. case sscrfields-ucomm. when 'SEL'. if p_textid is not initial. perform fetch_data. if lt_cust_text is not initial. perform show_alv. else. message 'No Information found' type 'I'. " Put in the Message Class endif. else. message 'Please enter the mandatory fields Text ID' type 'E'. "Put in the Message Class endif. when 'TXT'.* On clicking Create Text , Check for the Mandatory Fields. if p_kunnr is not initial and p_textid is not initial and p_spras is not initial. select count(*) from zsd_nor_custtext where customer = p_kunnr and textid = p_textid and shipto = p_shipto and plant = p_werk and family = p_family and type = p_type and spras = p_spras. if sy-subrc ne 0.* When Create Text is clicked , call screen 2000. lv_edit = abap_false. call screen 2000. else. message 'Entry with the Name already exists' type 'E'. endif. else. message 'Please enter the mandatory fields , Customer and Text ID and Language' type 'E'. endif. endcase.*&---------------------------------------------------------------------**& Module STATUS_9000 OUTPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*module status_2000 output. set pf-status 'ZSDTX_GUI_STAT'. set titlebar 'ZSDTX_2000_TITLE'.endmodule.*&---------------------------------------------------------------------**& Module USER_COMMAND_9000 INPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*module user_command_2000 input. case sy-ucomm. when 'SAVE'. "Save Item Text perform save_text. when 'CANC'. " No Save Item Text leave to screen 0. when 'BACK'. perform show_popup. "Show Text ID popup clear lv_status. leave to screen 0. when 'EXIT'. leave program. endcase.endmodule.*&---------------------------------------------------------------------**& Module CREATE_CONT OUTPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*module create_cont output.* Create container. call method lo_sdtx->create_comment_container( ).* if the Edit button is clicked, first read the Created text and display. if lv_edit = abap_true. perform read_text. endif.endmodule.*&---------------------------------------------------------------------**& Form FETCH_DATA*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* p1 text* create_docking_container. call method lo_sdtx->set_alv changing ct_data_table = lt_cust_text. lo_sdtx->cv_events = lo_sdtx->cv_salv->get_event( ). set handler lo_sdtx->handle_link_click_salv for lo_sdtx->cv_events. call method lo_sdtx->set_column_attributes_salv exporting id_field_name = 'SHIPTO' " ALV control: Field name of internal table field* if_is_hotspot = abap_true id_long_text = 'Ship-to'. " Long Field Label call method lo_sdtx->set_column_attributes_salv exporting id_field_name = 'FAMILY' " ALV control: Field name of internal table field* if_is_hotspot = abap_true id_long_text = 'Family'. " Long Field Label call method lo_sdtx->set_column_attributes_salv exporting id_field_name = 'TYPE' " ALV control: Field name of internal table field* if_is_hotspot = abap_true id_long_text = 'Type'. " Long Field Label* call method lo_sdtx->set_column_attributes_salv* exporting* id_field_name = 'TEXTID' " ALV control: Field name of internal table field* if_is_visible = abap_false. call method lo_sdtx->set_column_attributes_salv exporting id_field_name = 'TEXTNAME' " ALV control: Field name of internal table field id_long_text = 'Text Name'. " Long Field Label call method lo_sdtx->set_column_attributes_salv exporting id_field_name = 'TEXT' " ALV control: Field name of internal table field if_is_visible = abap_false. call method lo_sdtx->set_column_attributes_salv exporting id_field_name = 'EDIT' " ALV control: Field name of internal table field if_is_a_button = abap_true. call method lo_sdtx->set_column_attributes_salv exporting id_field_name = 'DEL' " ALV control: Field name of internal table field if_is_a_button = abap_true. call method lo_sdtx->display_alv.endform.*&---------------------------------------------------------------------**& Form SAVE_TEXT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* get_comment importing ct_text = lt_texttable. if lv_edit = abap_true. assign component 'TEXTID' of structure to . assign component 'SPRAS' of structure to . assign component 'TEXTNAME' of structure to . if is assigned. ls_head-tdid = . endif. if is assigned. ls_head-tdspras = . endif. if is assigned. ls_head-tdname = . endif. ls_head-tdobject = 'TEXT'. ls_head-tdfuser = sy-uname. clear lt_tline. loop at lt_texttable into ls_text. ls_tline-tdformat = '*'. ls_tline-tdline = ls_text. append ls_tline to lt_tline. endloop. perform save. else. concatenate 'Z000' p_kunnr p_shipto '0001' into lv_tdname. "Need to Check and Change... ls_head-tdobject = 'TEXT'. ls_head-tdid = 'ST'. "p_textid. "" Need to Chage ls_head-tdspras = p_spras. ls_head-tdname = lv_tdname. ls_head-tdfuser = sy-uname. loop at lt_texttable into ls_text. ls_tline-tdformat = '*'. ls_tline-tdline = ls_text. append ls_tline to lt_tline. endloop. try. perform save. if sy-subrc eq 0. message 'Text has been Saved' type 'S'. "Needs to be put in the message class lv_status = abap_true. read table lt_tline into ls_tline index 1. if sy-subrc eq 0. ls_cust_text-text = ls_tline-tdline. endif. ls_cust_text-customer = p_kunnr. ls_cust_text-shipto = p_shipto. ls_cust_text-plant = p_werk. ls_cust_text-family = p_family. ls_cust_text-type = p_type. ls_cust_text-spras = p_spras. ls_cust_text-textname = lv_tdname. ls_cust_text-textid = 'ST'. "" Need to Change append ls_cust_text to lt_cust_text. clear ls_cust_text. endif. endtry. endif. if lt_cust_text is not initial.* move-corresponding lt_cust_text to lt_so_text.* modify zsd_nor_custtext from table lt_so_text. modify zsd_nor_custtext from table lt_cust_text. commit work. endif.endform.*&---------------------------------------------------------------------**& Form SHOW_POPUP*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* flush exceptions cntl_system_error = 1 cntl_error = 2 others = 3. endif. endif. endtry.endform.*&---------------------------------------------------------------------**& Form SAVE*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text*