Advertisement
Guest User

Untitled

a guest
Apr 15th, 2018
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 1.80 KB | None | 0 0
  1. REPORT zdemo_igs.
  2.  
  3. DATA: lv_path         TYPE string,
  4.       photo_out       TYPE string,
  5.       lv_str          TYPE string,
  6.       lv_handle       TYPE i,
  7.       lv_buff         TYPE xstring,
  8.       lv_len          TYPE i,
  9.       lt_bin          TYPE sdokcntbins,
  10.       image_processor TYPE REF TO cl_fxs_image_processor.
  11.  
  12.  
  13. lv_str = 'C:\temp\photo\photo_big.jpg'.
  14.  
  15. photo_out = 'C:\temp\photo\photo_small.jpg'.
  16.  
  17. CALL METHOD cl_gui_frontend_services=>gui_upload
  18.   EXPORTING
  19.     filename   = lv_str
  20.     filetype   = 'BIN'
  21.   IMPORTING
  22.     filelength = lv_len
  23.   CHANGING
  24.     data_tab   = lt_bin
  25.   EXCEPTIONS
  26.     OTHERS     = 1.
  27. IF sy-subrc <> 0.
  28. ENDIF.
  29.  
  30. CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
  31.   EXPORTING
  32.     input_length = lv_len
  33.   IMPORTING
  34.     buffer       = lv_buff
  35.   TABLES
  36.     binary_tab   = lt_bin
  37.   EXCEPTIONS
  38.     failed       = 1
  39.     OTHERS       = 2.
  40. IF sy-subrc <> 0.
  41.  
  42. ENDIF.
  43.  
  44. CREATE OBJECT image_processor.
  45. TRY.
  46.     lv_handle = image_processor->add_image( lv_buff ).
  47.   CATCH cx_root.
  48.  
  49. ENDTRY.
  50. TRY.
  51.  
  52.     CALL METHOD image_processor->resize
  53.       EXPORTING
  54.         iv_handle = lv_handle
  55.         iv_xres   = 1024
  56.         iv_yres   = 768
  57.       EXCEPTIONS
  58.         OTHERS    = 1.
  59.     IF sy-subrc = 0.
  60.       lv_buff = image_processor->get_image( lv_handle ).
  61.     ELSE.
  62.       "smth
  63.     ENDIF.
  64.  
  65.   CATCH cx_root.
  66.     "smth
  67. ENDTRY.
  68.  
  69. CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
  70.   EXPORTING
  71.     buffer        = lv_buff
  72.   IMPORTING
  73.     output_length = lv_len
  74.   TABLES
  75.     binary_tab    = lt_bin.
  76. lv_str = photo_out.
  77. CONDENSE lv_str.
  78.  
  79. CALL METHOD cl_gui_frontend_services=>gui_download
  80.   EXPORTING
  81.     bin_filesize = lv_len
  82.     filename     = lv_str
  83.     filetype     = 'BIN'
  84.   CHANGING
  85.     data_tab     = lt_bin
  86.   EXCEPTIONS
  87.     OTHERS       = 1.
  88. IF sy-subrc <> 0.
  89. ENDIF.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement