Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *&---------------------------------------------------------------------*
- *& Include ZWL_GET_DATA_FROM_FM
- *&---------------------------------------------------------------------*
- FORM get_initialization_data.
- ******************************************************
- ** Przykłado config
- ** FILE_BATCH_SIZE 500000
- ** FILE_PATH /usr/sap/trans/data/
- ** FILE_STRING_MASKS *maski*
- ** FILE_STRING_PC *skrotyPodatnikowCzynnych*
- ** FILE_STRING_PZ *skrotyPodatnikowZwolnionych*
- **
- ******************************************************
- TRY.
- go_cfg = NEW zwl_cl_taxpayer_cfg_helper( ).
- p_path = go_cfg->get_file_path( ).
- p_batch = go_cfg->get_file_batch_size( ).
- gv_str_pc = go_cfg->get_cfg_by_name( 'FILE_STRING_PC' ).
- gv_str_pz = go_cfg->get_cfg_by_name( 'FILE_STRING_PZ' ).
- gv_str_masks = go_cfg->get_cfg_by_name( 'FILE_STRING_MASKS' ).
- gv_ok = 'X'.
- CATCH zcx_wl_taxpayer INTO DATA(lo_cx).
- MESSAGE lo_cx->get_custom_text( ) TYPE 'W' DISPLAY LIKE 'E'.
- ENDTRY.
- ENDFORM.
- FORM convert_data.
- DATA: lt_data_pc TYPE TABLE OF zwl_hashed_pc WITH EMPTY KEY,
- lt_data_pz TYPE TABLE OF zwl_hashed_pz WITH EMPTY KEY,
- lt_data_masks TYPE TABLE OF zwl_hashed_masks WITH EMPTY KEY,
- lv_line TYPE string,
- lv_mode TYPE c.
- DATA: lv_ind_pc TYPE i,
- lv_ind_pz TYPE i,
- lv_ind_masks TYPE i.
- DATA(lv_file_path) = |{ p_path }{ p_dats }{ c_file }|.
- OPEN DATASET lv_file_path FOR INPUT IN TEXT MODE ENCODING DEFAULT.
- DO.
- IF sy-subrc = 8.
- EXIT.
- ENDIF.
- READ DATASET lv_file_path INTO lv_line.
- IF lv_line IS NOT INITIAL.
- PERFORM get_mode USING lv_line CHANGING lv_mode.
- CASE lv_mode.
- WHEN 'C'. "Podatnicy czynni
- PERFORM transfer_pc_data USING lv_line CHANGING lv_ind_pc lt_data_pc.
- WHEN 'Z'. "Podatnicy zwolnieni
- PERFORM transfer_pz_data USING lv_line CHANGING lv_ind_pz lt_data_pz.
- WHEN 'M'. "Maski
- PERFORM transfer_masks_data USING lv_line CHANGING lv_ind_masks lt_data_masks.
- ENDCASE.
- ELSE.
- EXIT.
- ENDIF.
- ENDDO.
- CLOSE DATASET lv_file_path.
- PERFORM insert_left_data CHANGING lt_data_pc lt_data_pz lt_data_masks.
- IF lv_ind_pc > 0.
- gv_ok = 'X'.
- WRITE : / 'Zaktualizowano tabelę ZWL_HASHED_PC -' COLOR COL_POSITIVE, lv_ind_pc, 'wpisów.'.
- ELSE.
- WRITE : / 'Brak nowych danych dla tabeli ZWL_HASHED_PC.' COLOR COL_NEGATIVE.
- ENDIF.
- IF lv_ind_pz > 0.
- gv_ok = 'X'.
- WRITE : / 'Zaktualizowano tabelę ZWL_HASHED_PZ -' COLOR COL_POSITIVE, lv_ind_pz, 'wpisów.'.
- ELSE.
- WRITE : / 'Brak nowych danych dla tabeli ZWL_HASHED_PZ.' COLOR COL_NEGATIVE.
- ENDIF.
- IF lv_ind_masks > 0.
- gv_ok = 'X'.
- WRITE : / 'Zaktualizowano tabelę ZWL_HASHED_MASKS -' COLOR COL_POSITIVE, lv_ind_masks, 'wpisów.'.
- ELSE.
- WRITE : / 'Brak nowych danych dla tabeli ZWL_HASHED_MASKS.' COLOR COL_NEGATIVE.
- ENDIF.
- ENDFORM.
- FORM insert_left_data CHANGING ct_data_pc TYPE tt_pc ct_data_pz TYPE tt_pz ct_data_masks TYPE tt_masks.
- INSERT zwl_hashed_pc FROM TABLE ct_data_pc.
- INSERT zwl_hashed_pz FROM TABLE ct_data_pz.
- INSERT zwl_hashed_masks FROM TABLE ct_data_masks.
- CLEAR: ct_data_pc, ct_data_pz, ct_data_masks.
- ENDFORM.
- FORM get_mode USING iv_data TYPE string CHANGING cv_mode TYPE c.
- IF iv_data CP gv_str_pc.
- cv_mode = 'C'.
- EXIT.
- ENDIF.
- IF iv_data CP gv_str_pz.
- cv_mode = 'Z'.
- EXIT.
- ENDIF.
- IF iv_data CP gv_str_masks.
- cv_mode = 'M'.
- EXIT.
- ENDIF.
- ENDFORM.
- FORM transfer_pc_data USING iv_data TYPE string CHANGING cv_ind ct_data_pc TYPE tt_pc.
- DATA: ls_data TYPE zwl_hashed_pc,
- lv_data TYPE string.
- FIND REGEX '\"(.*)\"'
- IN iv_data
- SUBMATCHES lv_data
- RESPECTING CASE.
- CHECK strlen( lv_data ) = 128.
- cv_ind = cv_ind + 1.
- IF cv_ind MOD p_batch = 0.
- INSERT zwl_hashed_pc FROM TABLE ct_data_pc.
- CLEAR ct_data_pc.
- ENDIF.
- ls_data-hashed_key = lv_data.
- ct_data_pc = VALUE #( BASE ct_data_pc ( ls_data ) ).
- ENDFORM.
- FORM transfer_pz_data USING iv_data TYPE string CHANGING cv_ind ct_data_pz TYPE tt_pz.
- DATA: ls_data TYPE zwl_hashed_pz,
- lv_data TYPE string.
- FIND REGEX '\"(.*)\"'
- IN iv_data
- SUBMATCHES lv_data
- RESPECTING CASE.
- CHECK strlen( lv_data ) = 128.
- cv_ind = cv_ind + 1.
- IF cv_ind MOD p_batch = 0.
- INSERT zwl_hashed_pz FROM TABLE ct_data_pz.
- CLEAR ct_data_pz.
- ENDIF.
- ls_data-hashed_key = lv_data.
- ct_data_pz = VALUE #( BASE ct_data_pz ( ls_data ) ).
- ENDFORM.
- FORM transfer_masks_data USING iv_data TYPE string CHANGING cv_ind ct_data_masks TYPE tt_masks.
- DATA: ls_data TYPE zwl_hashed_masks,
- lv_data TYPE string.
- FIND REGEX '\"(.*)\"'
- IN iv_data
- SUBMATCHES lv_data
- RESPECTING CASE.
- CHECK strlen( lv_data ) = 26.
- cv_ind = cv_ind + 1.
- IF cv_ind MOD p_batch = 0.
- INSERT zwl_hashed_masks FROM TABLE ct_data_masks.
- CLEAR ct_data_masks.
- ENDIF.
- ls_data-mask_key = lv_data+2(8).
- ls_data-mask_value = lv_data.
- ct_data_masks = VALUE #( BASE ct_data_masks ( ls_data ) ).
- ENDFORM.
- FORM set_update_date.
- IF gv_ok = 'X'.
- go_cfg->set_last_update_date( p_dats ).
- ENDIF.
- ENDFORM.
- *&---------------------------------------------------------------------*
- *& Form CLEAR_DB_TABLEs
- *&---------------------------------------------------------------------*
- *& text
- *&---------------------------------------------------------------------*
- *& --> p1 text
- *& <-- p2 text
- *&---------------------------------------------------------------------*
- FORM clear_db_tables .
- DELETE FROM zwl_hashed_pc.
- DELETE FROM zwl_hashed_pz.
- DELETE FROM zwl_hashed_masks.
- COMMIT WORK AND WAIT.
- ENDFORM.
- *&---------------------------------------------------------------------*
- *& Form CHECK_FILES_EXISTS
- *&---------------------------------------------------------------------*
- *& text
- *&---------------------------------------------------------------------*
- *& --> p1 text
- *& <-- p2 text
- *&---------------------------------------------------------------------*
- FORM check_files_exists CHANGING ev_ok.
- DATA lv_file_path TYPE string.
- ev_ok = 'X'.
- lv_file_path = |{ p_path }{ p_dats }{ c_file }|.
- OPEN DATASET lv_file_path FOR INPUT IN TEXT MODE ENCODING DEFAULT.
- IF sy-subrc <> 0.
- CLEAR ev_ok.
- WRITE : / 'Brak pliku' COLOR COL_TOTAL, lv_file_path.
- ENDIF.
- CLOSE DATASET lv_file_path.
- *
- * lv_file_path = |{ p_path }{ p_dats }{ c_file_inact }|.
- * OPEN DATASET lv_file_path FOR INPUT IN TEXT MODE ENCODING DEFAULT.
- * IF sy-subrc <> 0.
- * CLEAR ev_ok.
- * WRITE : / 'Brak pliku' COLOR COL_TOTAL, lv_file_path.
- * ENDIF.
- * CLOSE DATASET lv_file_path.
- *
- * lv_file_path = |{ p_path }{ p_dats }{ c_file_masks }|.
- * OPEN DATASET lv_file_path FOR INPUT IN TEXT MODE ENCODING DEFAULT.
- * IF sy-subrc <> 0.
- * CLEAR ev_ok.
- * WRITE : / 'Brak pliku' COLOR COL_TOTAL, lv_file_path.
- * ENDIF.
- * CLOSE DATASET lv_file_path.
- ENDFORM.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement