"-Begin-----------------------------------------------------------------
Program ZPIC2MIME.
"-TypePools---------------------------------------------------------
Type-Pools OLE2.
"-Variables---------------------------------------------------------
Data TempDir Type String.
Data AutoItX Type OLE2_Object.
Data Result Type i.
Data FileName Type String.
Data Cmd Type String.
Data tabPicture Type Table Of TLINE.
Data linePicture Like Line Of tabPicture.
Data Picture Type XString.
Data rif_MR_API Type Ref To if_mr_api.
Data Url Type String Value '/sap/public/components/Test.jpg'.
Field-Symbols <Picture> Type x.
"-Main--------------------------------------------------------------
"-Get temporary directory-----------------------------------------
Call Method cl_gui_frontend_services=>get_temp_directory
Changing TEMP_DIR = TempDir Exceptions Others = 1.
Create Object AutoItX 'AutoItX3.Control'.
If sy-subrc = 0 And AutoItX-Handle > 0 And AutoItX-Type = 'OLE2'.
"-Set AutoItX option--------------------------------------------
Call Method Of AutoItX 'Opt'
Exporting
#1 = 'SendKeyDelay'
#2 = 50.
"-Start MSPAINT-------------------------------------------------
Call Method Of AutoItX 'Run' = Result
Exporting
#1 = 'mspaint.exe'
#2 = TempDir
#3 = 3. "SW_MAXIMIZE
Call Method Of AutoItX 'WinWait' = Result
Exporting
#1 = 'Unbenannt - Paint'.
"-Set the size of the picture-----------------------------------
Cmd = '^w{RIGHT}{TAB}{TAB}{TAB}{SPACE}+{TAB}+{TAB}' &&
'640{TAB}480{ENTER}'.
Call Method Of AutoItX 'Send'
Exporting
#1 = Cmd.
"-Painting------------------------------------------------------
Call Method Of AutoItX 'MouseMove' Exporting #1 = 40 #2 = 180.
Call Method Of AutoItX 'MouseDown' Exporting #1 = 'left'.
Call Method Of AutoItX 'MouseMove' Exporting #1 = 140 #2 = 180.
Call Method Of AutoItX 'MouseMove' Exporting #1 = 140 #2 = 280.
Call Method Of AutoItX 'MouseMove' Exporting #1 = 40 #2 = 280.
Call Method Of AutoItX 'MouseMove' Exporting #1 = 40 #2 = 180.
Call Method Of AutoItX 'MouseUp' Exporting #1 = 'left'.
Call Method Of AutoItX 'MouseMove' Exporting #1 = 60 #2 = 200.
Call Method Of AutoItX 'MouseDown' Exporting #1 = 'left'.
Call Method Of AutoItX 'MouseMove' Exporting #1 = 160 #2 = 200.
Call Method Of AutoItX 'MouseMove' Exporting #1 = 160 #2 = 300.
Call Method Of AutoItX 'MouseMove' Exporting #1 = 60 #2 = 300.
Call Method Of AutoItX 'MouseMove' Exporting #1 = 60 #2 = 200.
Call Method Of AutoItX 'MouseUp' Exporting #1 = 'left'.
"-Save the picture----------------------------------------------
FileName = TempDir && '\Test.jpg'.
Call Method cl_gui_frontend_services=>file_delete
Exporting FILENAME = FileName Changing RC = Result
Exceptions Others = 1.
Call Method Of AutoItX 'Send'
Exporting
#1 = '^s'.
Call Method Of AutoItX 'WinWait' = Result
Exporting
#1 = 'Speichern unter'.
Cmd = '{TAB}j+{TAB}' && TempDir && '\Test.jpg{ENTER}'.
Call Method Of AutoItX 'Send'
Exporting
#1 = Cmd.
"-Quit MSPAINT--------------------------------------------------
Call Method Of AutoItX 'WinWait' = Result
Exporting
#1 = 'Test - Paint'.
Call Method Of AutoItX 'WinKill' = Result
Exporting
#1 = 'Test - Paint'.
Free Object AutoItX.
"-Upload the picture--------------------------------------------
Call Function 'GUI_UPLOAD'
Exporting
FILENAME = FileName
FILETYPE = 'BIN'
Tables
DATA_TAB = tabPicture
Exceptions
Others = 1.
Loop At tabPicture Into linePicture.
Assign linePicture To <Picture> Casting.
Concatenate Picture <Picture> Into Picture In Byte Mode.
EndLoop.
"-Picture to web repository-------------------------------------
If Picture <> ''.
If rif_MR_API Is Initial.
rif_MR_API = cl_mime_repository_api=>if_mr_api~get_api( ).
EndIf.
Call Method rif_MR_API->put
Exporting
i_url = Url
i_content = Picture
i_language = sy-langu
i_suppress_package_dialog = 'X'
i_description = 'Dies ist ein Test'
Exceptions
Others = 1.
EndIf.
EndIf.
"-End-------------------------------------------------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
3 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |