2015 Jul 16 8:09 AM
Hi Experts,
I am trying to upload an image in a custom table zfrontend_upload.
The execution halts at a dump after I select the image to be uploaded.
This is my code-
*--------------------------------------------------------------------------------------
* Data Declarations.
*--------------------------------------------------------------------------------------
DATA: lt_file TYPE STANDARD TABLE OF FILE_TABLE,
ls_file TYPE FILE_TABLE,
lv_rc TYPE I,
lv_filename TYPE string,"file_table-filename,
lv_length TYPE I,
lt_data TYPE RSANM_FILE_TABLE,
lv_content TYPE XSTRING,
wa_zfrontend_upload TYPE zfrontend_upload.
*--------------------------------------------------------------------------------------
* Select image from frontend system
*--------------------------------------------------------------------------------------
cl_gui_frontend_services=>file_open_dialog(
CHANGING
file_table = lt_file " Table Holding Selected image
rc = lv_rc ).
READ TABLE lt_file INTO ls_file INDEX 1.
IF sy-subrc = 0.
lv_filename = ls_file-filename.
ENDIF.
*--------------------------------------------------------------------------------------
* Upload selected image into SAP system.
*--------------------------------------------------------------------------------------
cl_gui_frontend_services=>gui_upload(
EXPORTING
filename = lv_filename " Name of file
filetype = 'BIN'
IMPORTING
filelength = lv_length " File length
CHANGING
data_tab = lt_data " Transfer table for file contents
EXCEPTIONS
OTHERS = 19 ).
*--------------------------------------------------------------------------------------
* Convert image into XSTRING format.
*--------------------------------------------------------------------------------------
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = lv_length
IMPORTING
buffer = lv_content " Image data
TABLES
binary_tab = lt_data
EXCEPTIONS
failed = 1
OTHERS = 2.
*--------------------------------------------------------------------------------------
* Save the photo in the ztable
*--------------------------------------------------------------------------------------
wa_zfrontend_upload-SrNo = 1.
wa_zfrontend_upload-photo = lv_content.
MODIFY zfrontend_upload FROM wa_zfrontend_upload .
Where do I go wrong?
Thank You in advance,
-Nimish Kate
2015 Jul 16 8:14 AM
Sorry, but the dump screenshot is missing
How did you declared zfrontend_upload-photo?
2015 Jul 16 8:14 AM
Sorry, but the dump screenshot is missing
How did you declared zfrontend_upload-photo?
2015 Jul 16 8:23 AM
Hi Simone,
I got a dump before the debugger reached the part where zfrontend_upload comes into picture.
As for the declaration, the field photo has been declared of type HRTMC_XSTRING.
Here's the dump-
Thanks,
-NK
2015 Jul 16 8:32 AM
So the dump is in GUI_UPLOAD since it happens in Func. Group SFES and the open dialog seems ok.
Which release are you running?
I cannot find in mine your "RSANM_FILE_TABLE" so i cannot give a try to your code.
2015 Jul 16 8:51 AM
Hi simone,
My version of SAP is 7.4 SP level 0008.
Let me know if you need more details.
Thanks,
-NK
2015 Jul 16 11:07 AM
Hi Simone Milesi,
The type of changing parameter data_tab is given to be Standard Table in the method GUI_UPLOAD. We cannot declare the table to be passed of the type Standard Table, So i used RSANM_FILE_TABLE to declare lt_tab in my code.
If you cannot find RSANM_FILE_TABLE in your SAP release, can you suggest me what type do I use to declare the table lt_tab?
Thanks,
-NK
2015 Jul 16 1:26 PM
2015 Jul 16 1:53 PM
Hi Minish,
You can use /ORS/DATA_STREAM structure to get selected image RAW data.
Regards,
Praveer.