1 2 3 4 |
DATA v_bldat TYPE c LENGTH 10. WRITE bsad-bldat TO v_bldat DD/MM/YYYY. REPLACE ALL OCCURRENCES OF '.' IN v_bldat WITH '/'. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace split { class Program { static void Main(string[] args) { if (args.Length == 2) { string arquivo = args[0]; string destino = args[1]; int qtd = 0; StreamWriter writer = null; try { using (StreamReader inputfile = new System.IO.StreamReader(arquivo)) { int count = 0; string line; while ((line = inputfile.ReadLine()) != null) { //800.000 linhas if (writer == null || count >= 800000) { count = 0; if (writer != null) { writer.Close(); writer = null; } writer = new System.IO.StreamWriter(Path.GetDirectoryName(arquivo) + "\\" + Path.GetFileNameWithoutExtension(arquivo) + "_" + qtd.ToString() + ".txt", true); qtd++; } writer.WriteLine(line.ToLower()); ++count; } } } finally { if (writer != null) writer.Close(); Console.WriteLine("Split concluido."); } } else { Console.WriteLine("Split diretorio_e_arquivo diretorio_destino"); } Console.WriteLine("Pressione uma tecla para continuar . . ."); Console.ReadKey(); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
REPORT zmatch. TYPES: BEGIN OF ty_t001w, werks TYPE t001w-werks, sep TYPE c LENGTH 3, name1 TYPE t001w-name1, END OF ty_t001w. DATA: t_t001w TYPE TABLE OF ty_t001w, "#EC NEEDED w_t001w TYPE ty_t001w, l_index TYPE sy-tabix. "#EC NEEDED SELECTION-SCREEN BEGIN OF BLOCK b1. PARAMETERS: p1 TYPE c LENGTH 4. SELECT-OPTIONS: p2 FOR w_t001w-werks NO INTERVALS NO-EXTENSION. SELECTION-SCREEN END OF BLOCK b1. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p1. SELECT werks name1 INTO CORRESPONDING FIELDS OF TABLE t_t001w FROM t001w WHERE vtweg = '10'. w_t001w-sep = ' - '. MODIFY t_t001w FROM w_t001w TRANSPORTING sep WHERE sep IS INITIAL. CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY' EXPORTING endpos_col = 70 endpos_row = 20 startpos_col = 43 startpos_row = 1 titletext = 'SELECIONAR O CENTRO' IMPORTING choise = l_index TABLES valuetab = t_t001w EXCEPTIONS break_off = 1 OTHERS = 2. IF sy-subrc IS NOT INITIAL. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. IF l_index IS NOT INITIAL. READ TABLE t_t001w INTO w_t001w INDEX l_index. * MESSAGE w_t001w-name1 TYPE 'I'. p1 = w_t001w-werks. ENDIF. START-OF-SELECTION. * CLEAR: t_t001w, t_t001w[], w_t001w. * SELECT werks name1 * INTO CORRESPONDING FIELDS OF TABLE t_t001w * FROM t001w * WHERE werks = p1. * READ TABLE t_t001w INTO w_t001w INDEX 1. WRITE: / w_t001w-name1. END-OF-SELECTION. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
*&---------------------------------------------------------------------* *& Report ZREPORT *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT ZREPORT. TABLES: ztabela. CONSTANTS: c_view TYPE char30 VALUE 'ZTABELA', c_u TYPE char1 VALUE 'U', c_and TYPE char3 VALUE 'AND'. DATA: gt_seltab TYPE STANDARD TABLE OF vimsellist. DATA: g_fieldname TYPE vimsellist-viewfield. DATA: gt_exclude TYPE TABLE OF vimexclfun, gwa_exclude TYPE vimexclfun. SELECT-OPTIONS: s_campo FOR ztabela-campo. *Add ID column to selection criteria of Table maintenanace view g_fieldname = 'CAMPO'. CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST' EXPORTING fieldname = g_fieldname append_conjunction = c_and TABLES sellist = gt_seltab rangetab = s_campo. * **Add Name column to selection criteria of Table maintenanace view *g_fieldname = 'NAME'. * *CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST' * EXPORTING * fieldname = g_fieldname * append_conjunction = c_and * TABLES * sellist = gt_seltab * rangetab = s_name. * **Add Place column to selection criteria of Table maintenanace view *g_fieldname = 'PLACE'. * *CALL FUNCTION 'VIEW_RANGETAB_TO_SELLIST' * EXPORTING * fieldname = g_fieldname * append_conjunction = c_and * TABLES * sellist = gt_seltab * rangetab = s_place. *Deactivate New Entries gwa_exclude-function = 'NEWL'. " Function Code for New Entries APPEND gwa_exclude TO gt_exclude. *Deactivate Copy gwa_exclude-function = 'KOPE'. " Function Code for Copy APPEND gwa_exclude TO gt_exclude. *Deactivate Delete gwa_exclude-function = 'DELE'. " Function Code for Delete APPEND gwa_exclude TO gt_exclude. * Call to the 'VIEW_MAINTENANCE_CALL' function module CALL FUNCTION 'VIEW_MAINTENANCE_CALL' EXPORTING action = c_u view_name = c_view TABLES dba_sellist = gt_seltab excl_cua_funct = gt_exclude. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
DATA: BEGIN OF gt_file OCCURS 0, line TYPE c LENGTH 400, END OF gt_file. PARAMETERS: p_file TYPE rlgrap-filename OBLIGATORY DEFAULT 'C:\'. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file. PERFORM z_upload_file. START-OF-SELECTION. PERFORM z_load_file. FORM z_load_file. DATA: lv_arq TYPE string, vl_extab TYPE slis_t_extab. * Abre arquivo de entrada. CALL FUNCTION 'GUI_UPLOAD' EXPORTING filename = p_file filetype = 'ASC' TABLES data_tab = gt_arquivo. IF sy-subrc <> 0. MESSAGE 'Error upload file' TYPE 'I'. EXIT. ENDIF. ENDFORM. " z_load_file FORM z_upload_file. DATA: ret TYPE int4, act TYPE int4. DATA: t_file TYPE TABLE OF file_table, s_file TYPE file_table. CLEAR: t_file[]. CALL METHOD cl_gui_frontend_services=>file_open_dialog EXPORTING window_title = 'Abrir...' default_extension = '*.txt|*.csv|*.*' file_filter = ' TXT (*.txt)|*.txt| CSV(*.csv)|*.csv| Todas(*.*)|*.* ' multiselection = space CHANGING file_table = t_file[] rc = ret user_action = act EXCEPTIONS file_open_dialog_failed = 1 cntl_error = 2 error_no_gui = 3 not_supported_by_gui = 4 OTHERS = 5. IF sy-subrc EQ 0. READ TABLE t_file INTO s_file INDEX 1. MOVE s_file TO p_file. ENDIF. ENDFORM. "z_upload_file |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
DATA: itab TYPE TABLE OF mara WITH HEADER LINE, a(1) TYPE c. BREAK-POINT. MOVE: 1 TO itab-matnr, '1' TO itab-ernam, 'X' TO a. APPEND itab TO itab. ******************************************************************************** * -= CLEAR =- * * Se for tabela sem header line limpa o conteudo mas o espaço fica em memória * * Se for tabela com header line limpa o header mas o espaço fica em memória * ******************************************************************************** CLEAR: itab, a. MOVE: 2 TO itab-matnr, '2' TO itab-aenam. APPEND itab TO itab. ******************************************************************************** * -= REFRESH =- * * Limpa o conteudo mas o espaço fica em memória * ******************************************************************************** REFRESH: itab. MOVE: 3 TO itab-matnr, '3' TO itab-vpsta. APPEND itab TO itab. ******************************************************************************** * -= FREE =- * * Limpa o conteudo e libera o espaço em memória * ******************************************************************************** FREE: itab, a. MOVE: 4 TO itab-matnr. APPEND itab TO itab. BREAK-POINT. CLEAR: itab. FREE: itab. MOVE: 1 TO itab-matnr, '1' TO itab-ernam. APPEND itab TO itab. CLEAR: itab[], a. MOVE: 2 TO itab-matnr, '2' TO itab-aenam. APPEND itab TO itab. REFRESH: itab[]. MOVE: 3 TO itab-matnr, '3' TO itab-vpsta. APPEND itab TO itab. FREE: itab[]. MOVE: 4 TO itab-matnr. APPEND itab TO itab. BREAK-POINT. |