Advertisement
Aleksoid_1978

Добавить метод get_raw()

May 6th, 2019
924
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 5.48 KB | None | 0 0
  1.  for_abap_711/ZCL_DOCX_CLASS_711.abap | 96 +++++++++++++-----------------------
  2.  1 file changed, 34 insertions(+), 62 deletions(-)
  3.  
  4. diff --git a/for_abap_711/ZCL_DOCX_CLASS_711.abap b/for_abap_711/ZCL_DOCX_CLASS_711.abap
  5. index 8fa5edc..0dd240a 100644
  6. --- a/for_abap_711/ZCL_DOCX_CLASS_711.abap
  7. +++ b/for_abap_711/ZCL_DOCX_CLASS_711.abap
  8. @@ -179,19 +179,20 @@ CLASS lcl_docx DEFINITION.
  9.        IMPORTING
  10.          !iv_path TYPE string
  11.          !iv_data TYPE xstring.
  12. +
  13. +    METHODS get_raw
  14. +      RETURNING
  15. +        value(rv_content) TYPE xstring.
  16. +
  17.      METHODS save
  18.        IMPORTING
  19.          !on_desktop   TYPE xfeld DEFAULT 'X'
  20.          !iv_folder    TYPE string DEFAULT 'report'
  21.          !iv_path      TYPE string DEFAULT ''
  22.          !iv_file_name TYPE string DEFAULT 'report.docx'
  23. -        !no_execute   TYPE xfeld DEFAULT ''
  24. -     RETURNING
  25. -      value(iv_path_out) TYPE string .
  26. -
  27. -
  28. -
  29. -
  30. +        !no_execute   TYPE xfeld DEFAULT ''
  31. +      RETURNING
  32. +        value(rv_path_out) TYPE string.
  33.  
  34.      METHODS map_data
  35.        IMPORTING
  36. @@ -866,19 +867,10 @@ CLASS lcl_docx IMPLEMENTATION.
  37.                 content = iv_data ).
  38.  
  39.    ENDMETHOD.                    "add_file
  40. -  METHOD save.
  41. -
  42. -    DATA
  43. -             : lv_content         TYPE xstring
  44. -             , lv_content2         TYPE xstring
  45. -             .
  46. -
  47. -*    dump_data( node = document
  48. -*                   fname = 'before save' ).
  49. -
  50. -    lv_content = me->create_document( ).
  51. -
  52.  
  53. +  METHOD get_raw.
  54. +    CLEAR rv_content.
  55. +    rv_content = me->create_document( ).
  56.  
  57.      DATA
  58.            : lv_string TYPE string
  59. @@ -887,32 +879,23 @@ CLASS lcl_docx IMPLEMENTATION.
  60.            , lt_string TYPE TABLE OF string
  61.            , lt_data TYPE TABLE OF text255
  62.            .
  63. -
  64. -*    CALL FUNCTION 'Z_CNV_XSTRING_TO_STRING'
  65. -*      EXPORTING
  66. -*        iv_xstring = lv_content
  67. -*      IMPORTING
  68. -*        ev_string  = lv_string.
  69. -
  70. -
  71.      DATA
  72.            : converter TYPE REF TO cl_abap_conv_in_ce
  73.            .
  74.  
  75.      CALL METHOD cl_abap_conv_in_ce=>create
  76.        EXPORTING
  77. -        input       = lv_content
  78. +        input       = rv_content
  79.          encoding    = 'UTF-8'
  80.          replacement = '?'
  81.          ignore_cerr = abap_true
  82.        RECEIVING
  83.          conv        = converter.
  84.  
  85. -
  86.      TRY.
  87. -        CALL METHOD converter->read
  88. -          IMPORTING
  89. -            data = lv_string.
  90. +      CALL METHOD converter->read
  91. +        IMPORTING
  92. +          data = lv_string.
  93.        CATCH cx_sy_conversion_codepage.
  94.  *-- Should ignore errors in code conversions
  95.        CATCH cx_sy_codepage_converter_init.
  96. @@ -921,9 +904,6 @@ CLASS lcl_docx IMPLEMENTATION.
  97.        CATCH cx_parameter_invalid_range.
  98.      ENDTRY.
  99.  
  100. -
  101. -
  102. -
  103.      SPLIT lv_string AT '[SPACE]' INTO TABLE lt_string.
  104.  
  105.      DATA
  106. @@ -936,8 +916,8 @@ CLASS lcl_docx IMPLEMENTATION.
  107.      lv_rem = 255.
  108.  
  109.      FIELD-SYMBOLS
  110. -    : <fs_str> TYPE string
  111. -    .
  112. +                   : <fs_str> TYPE string
  113. +                   .
  114.  
  115.      LOOP AT lt_string ASSIGNING <fs_str>.
  116.  
  117. @@ -957,12 +937,9 @@ CLASS lcl_docx IMPLEMENTATION.
  118.            lv_pos = lv_pos + lv_len.
  119.            lv_rem = lv_rem - lv_len.
  120.            CLEAR <fs_str>.
  121. -
  122.          ENDIF.
  123.          lv_len = strlen( <fs_str> ).
  124.  
  125. -
  126. -
  127.        ENDWHILE.
  128.  
  129.        IF lv_pos < 254.
  130. @@ -978,16 +955,12 @@ CLASS lcl_docx IMPLEMENTATION.
  131.          lv_pos = 1.
  132.          lv_rem = 254.
  133.          CLEAR lv_buf.
  134. -
  135. -
  136.        ENDIF.
  137.  
  138. -
  139.      ENDLOOP.
  140.  
  141.      APPEND lv_buf TO lt_data.
  142.  
  143. -
  144.      FIELD-SYMBOLS
  145.                     : <xstr> TYPE x
  146.                     .
  147. @@ -999,39 +972,38 @@ CLASS lcl_docx IMPLEMENTATION.
  148.            , lv_str TYPE string
  149.            .
  150.  
  151. -    CLEAR lv_content.
  152. -*    loop at lt_data assigning <xstr> casting .
  153. -*      concatenate lv_content <xstr> into lv_content in byte mode.
  154. -*    endloop.
  155. -
  156.      FIELD-SYMBOLS
  157.                     : <fs_data> TYPE text255
  158.                     .
  159.  
  160.      LOOP AT lt_data ASSIGNING <fs_data>.
  161. -
  162.        CONCATENATE lv_str <fs_data> INTO lv_str RESPECTING BLANKS.
  163. -
  164.      ENDLOOP.
  165.  
  166.      DATA
  167. -             : lr_conv_out TYPE REF TO cl_abap_conv_out_ce
  168. -             , lv_echo_xstring TYPE xstring
  169. -             .
  170. +          : lr_conv_out TYPE REF TO cl_abap_conv_out_ce
  171. +          , lv_echo_xstring TYPE xstring
  172. +          .
  173.  
  174.      lr_conv_out = cl_abap_conv_out_ce=>create(
  175. -      encoding    = 'UTF-8'               " Êîäèðîâêà â êîòîðóþ áóäåì ïðåîáðàçîâûâàòü
  176. +      encoding    = 'UTF-8'
  177.      ).
  178.  
  179. -
  180. -    lr_conv_out->convert( EXPORTING data = lv_str IMPORTING buffer = lv_content ).
  181. -
  182. +    lr_conv_out->convert( EXPORTING data = lv_str IMPORTING buffer = rv_content ).
  183.  
  184.      zip->delete( name = me->c_document ).
  185.      zip->add( name    = me->c_document
  186. -               content = lv_content ).
  187. +              content = rv_content ).
  188.  
  189. -    lv_content = zip->save( ).
  190. +    rv_content = zip->save( ).
  191. +  ENDMETHOD.                    "get_raw
  192. +
  193. +  METHOD save.
  194. +
  195. +    DATA
  196. +             : lv_content TYPE xstring.
  197. +
  198. +    lv_content = me->get_raw( ).
  199.  
  200.      DATA
  201.            : lt_file_tab  TYPE solix_tab
  202. @@ -1055,8 +1027,8 @@ CLASS lcl_docx IMPLEMENTATION.
  203.      ENDIF.
  204.  
  205.      CONCATENATE lv_path '\' iv_folder '\'  iv_file_name  INTO lv_path.
  206. -    
  207. -    iv_path_out = lv_path.
  208. +
  209. +    rv_path_out = lv_path.
  210.  
  211.      cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount
  212.                                                         filename     = lv_path
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement