Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SAPGUI crash while printing employee photo on smartform

former_member859396
Discoverer

Custom program is developed which prints employee photo using smartform.

Employee photo is uploaded in OAAD transaction, to print that photo on smartform image is converted to bitmap and uploaded in SE78 tcode.

When this converted photo is printed on smartform SAP GUI gets crash.

error.jpg

Below Code:

CONCATENATE 'C:\TEMP\' pernr '.jpg' INTO zfilename.

"0. Check image on SE78 if exist delete
SELECT SINGLE * FROM stxbitmaps INTO wa_stxbitmaps
WHERE tdobject = 'GRAPHICS'
AND tdname = pernr
AND tdid = 'BMAP'
AND tdbtype = 'BCOL'.
IF sy-subrc EQ 0.
DELETE stxbitmaps FROM wa_stxbitmaps.
ENDIF.

"1. Check Photo
CALL FUNCTION 'HR_IMAGE_EXISTS'
EXPORTING
p_pernr = pernr
p_tclas = 'A'
p_begda = sy-datum
p_endda = sy-datum
IMPORTING
p_exists = p_exists
p_connect_info = p_connect_info
EXCEPTIONS
error_connectiontable = 1
OTHERS = 2.
IF sy-subrc <> 0.
"Create photo not avaiableSELECT SINGLE * FROM stxbitmaps INTO wa_stxbitmaps
SELECT SINGLE * FROM stxbitmaps INTO wa_stxbitmaps
WHERE tdobject = 'GRAPHICS'
AND tdname = 'NOPHOTO'
AND tdid = 'BMAP'
AND tdbtype = 'BCOL'.
IF sy-subrc EQ 0.
wa_stxbitmaps-tdname = pernr.
INSERT INTO stxbitmaps VALUES wa_stxbitmaps.
ELSE.
SELECT SINGLE * FROM stxbitmaps INTO wa_stxbitmaps
WHERE tdobject = 'GRAPHICS'
AND tdname = 'ENJOY'
AND tdid = 'BMAP'
AND tdbtype = 'BCOL'.
wa_stxbitmaps-tdname = pernr.
INSERT INTO stxbitmaps VALUES wa_stxbitmaps.
ENDIF.
ENDIF.
"Check photo exist
CHECK p_exists EQ 1.

"2. Now Read the image in JPG format by using below function module.
CALL FUNCTION 'ALINK_RFC_TABLE_GET'
EXPORTING
im_docid = p_connect_info-arc_doc_id
im_crepid = p_connect_info-archiv_id
IMPORTING
ex_length = length
TABLES
ex_document = it_doc.

"3. Convert the image from JPG Format to Binary Format by using the below function module.
crep_id = p_connect_info-archiv_id.
doc_id = p_connect_info-arc_doc_id.
phio_id = p_connect_info-object_id.

CALL FUNCTION 'SCMS_R3DB_IMPORT'
EXPORTING
mandt = sy-mandt
crep_id = crep_id
doc_id = doc_id
phio_id = phio_id
TABLES
content_bin = it_bin
EXCEPTIONS
error_import = 1
error_config = 2
OTHERS = 3.
* IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* ENDIF.

"4. create a folder in the presentation layer in one of the directory. By using below function module.
CALL FUNCTION 'TMP_GUI_CREATE_DIRECTORY'
EXPORTING
dirname = 'C:\TEMP'
no_flush = ' '
EXCEPTIONS
failed = 1
OTHERS = 2.
* IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* ENDIF.

"5. download the image of the pernr into this folder by using below function module.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = zfilename
filetype = 'BIN'
TABLES
data_tab = it_bin
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
* IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* ENDIF.

* BREAK-POINT.

"6. Now upload the file which you have downloaded by using the function module.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = zfilename
filetype = 'BIN'
IMPORTING
filelength = l_content_length
TABLES
data_tab = mime
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
* IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* ENDIF.

* BREAK-POINT.

"7. convert the binary to bitmap using the below code.
CREATE OBJECT i_igs_image_converter .
i_igs_image_converter->input = 'image/jpeg'.
i_igs_image_converter->output = 'image/x-ms-bmp'.
i_igs_image_converter->width = '100'.
i_igs_image_converter->height = '100'.

CALL METHOD i_igs_image_converter->set_image
EXPORTING
blob = mime
blob_size = l_content_length.

CALL METHOD i_igs_image_converter->execute
EXCEPTIONS
communication_error = 1
internal_error = 2
external_error = 3
OTHERS = 4.

IF sy-subrc = 0.
dpi = '100'.
CALL METHOD i_igs_image_converter->get_image
IMPORTING
blob = blob
blob_size = blob_size
blob_type = blob_type.
ENDIF.

"8. Convert Bitmap to BDS by using the function module.
CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP_BDS'
EXPORTING
color = 'X'
format = 'BMP'
bitmap_bytecount = length
IMPORTING
width_tw = l_width_tw
height_tw = l_height_tw
width_pix = l_width_pix
height_pix = l_height_pix
dpi = dpi
TABLES
bitmap_file = blob
bitmap_file_bds = l_bds_content
EXCEPTIONS
format_not_supported = 1
no_bmp_file = 2
bmperr_invalid_format = 3
bmperr_no_colortable = 4
bmperr_unsup_compression = 5
bmperr_corrupt_rle_data = 6
tifferr_invalid_format = 7
tifferr_no_colortable = 8
tifferr_unsup_compression = 9
bmperr_eof = 10
OTHERS = 11.
* IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* ENDIF.

* BREAK-POINT.

"9. upload the Picture in SE78 by using the below code:
CREATE OBJECT l_bds_object.
wa_bds_components-doc_count = '1'.
wa_bds_components-comp_count = '1'.
wa_bds_components-mimetype = c_bds_mimetype.
wa_bds_components-comp_size = blob_size. "l_bds_bytecount.
APPEND wa_bds_components TO l_bds_components.
wa_bds_signature-doc_count = '1'.
APPEND wa_bds_signature TO l_bds_signature.

CALL METHOD l_bds_object->create_with_table
EXPORTING
classname = c_bds_classname
classtype = c_bds_classtype
components = l_bds_components
content = l_bds_content
CHANGING
signature = l_bds_signature
object_key = l_object_key
EXCEPTIONS
OTHERS = 1.
READ TABLE l_bds_signature INDEX 1 INTO wa_bds_signature
TRANSPORTING doc_id.
p_docid = wa_bds_signature-doc_id.
CALL METHOD l_bds_object->update_with_table
EXPORTING
classname = c_bds_classname
classtype = c_bds_classtype
object_key = l_object_key
doc_id = p_docid
doc_ver_no = '1'
doc_var_id = '1'
CHANGING
components = l_bds_components
content = l_bds_content
EXCEPTIONS
nothing_found = 1
OTHERS = 2.

wa_stxbitmaps-tdname = pernr.
wa_stxbitmaps-tdobject = 'GRAPHICS'.
wa_stxbitmaps-tdid = 'BMAP'.
wa_stxbitmaps-tdbtype = 'BCOL'.
wa_stxbitmaps-docid = p_docid.
wa_stxbitmaps-widthpix = l_width_pix. "'450'. "'540'.”'640' .”l_width_pix.
wa_stxbitmaps-heightpix = l_height_pix. "'400'. "'480'. "l_height_pix.
wa_stxbitmaps-widthtw = l_width_tw. "'11200'. "'12288'.”l_width_tw.
wa_stxbitmaps-heighttw = l_height_tw. "'8000'. "'9216'.”l_height_tw.
wa_stxbitmaps-resolution = '100'.
INSERT INTO stxbitmaps VALUES wa_stxbitmaps.

"10. delete the file which is present on presentation layer by using below FM.
CALL METHOD cl_gui_frontend_services=>file_delete
EXPORTING
filename = zfilename
CHANGING
rc = rc
EXCEPTIONS
file_delete_failed = 1
cntl_error = 2
error_no_gui = 3
file_not_found = 4
access_denied = 5
unknown_error = 6
not_supported_by_gui = 7
wrong_parameter = 8
OTHERS = 9.
* IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* ENDIF.

"11. After all the employees delete the floder in the presentation layer which you have created.
"Note: Give the name of the Picture when your are uploading into SE78 as Employee Number so that for every employee we will get pictures individually in SE78 as name as Employee Number.
"Now in order to print Employee Photo dynamically in smart forms. Generally we use graphic window for displaying Logos, Photos etc.
"But here we have to print Employee Photo for particular employee. So in order to do this code as shown below .This code we have to create program lines then we need to write below code before graphic node.

"DATA: wa_stxbitmaps TYPE stxbitmaps.
CLEAR:wa_stxbitmaps.
wa_stxbitmaps-tdname = pernr.
wa_stxbitmaps-tdobject = 'GRAPHICS'.
wa_stxbitmaps-tdid = 'BMAP'.
wa_stxbitmaps-tdbtype = 'BCOL'.

CALL FUNCTION 'SSFCOMP_PRINT_GRAPHIC'
EXPORTING
bm_name = wa_stxbitmaps-tdname
bm_object = wa_stxbitmaps-tdobject
bm_id = wa_stxbitmaps-tdid
bm_type = wa_stxbitmaps-tdbtype
bm_dpi = '0100'
EXCEPTIONS
error = 1
non_main_overflow = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

CLEAR: length,crep_id,doc_id,phio_id,l_content_length,
l_bds_signature,l_object_key,wa_bds_signature,
wa_bds_components,wa_stxbitmaps.
REFRESH: it_doc,it_bin,mime,blob,l_bds_content.
FREE i_igs_image_converter.
FREE l_bds_object.

10 REPLIES 10

DominikTylczyn
Active Contributor

Use the "CODE" button to format the source code in the question!!!

raymond_giuseppi
Active Contributor
0 Kudos

Did you get a dump (ST22) or information in System Log (SM21)

Sriram2009
Active Contributor
0 Kudos

Could you share the version details of SAPGUI? if possible update the latest patch and then try again.

moshenaveh
Community Manager
Community Manager
0 Kudos

Welcome to the SAP Community. Thank you for visiting us to get answers to your questions.

Since you're asking a question here for the first time, I'd like to offer some friendly advice on how to get the most out of your community membership and experience.

First, please see https://community.sap.com/resources/questions-and-answers, as this resource page provides tips for preparing questions that draw responses from our members. Second, feel free to take our Q&A tutorial at https://developers.sap.com/tutorials/community-qa.html, as that will help you when submitting questions to the community.

I also recommend that you include a profile picture. By personalizing your profile, you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html.

Now for some specific suggestions on how you might improve your question:

* Outline what steps you took to find answers (and why they weren't helpful) -- so members don't make suggestions that you've already tried.

* Share screenshots of what you've seen/done (if possible), as images always helps our members better understand your problem.

* Make sure you've applied the appropriate tags -- because if you don't apply the correct tags, the right experts won't see your question to answer it.

* Use the "insert code" feature when sharing your code, so members have an easier time reading.

Should you wish, you can revise your question by selecting Actions, then Edit.

The more details you provide (in questions tagged correctly), the more likely it is that members will be able to respond.

I hope you find this advice useful, and we're happy to have you as part of SAP Community!

former_member859396
Discoverer
0 Kudos

@S Sriram version which I am working is 740, also tried on 770 & 730 same issue

@raymond.giuseppi no dump is generated in ST22

FredericGirod
Active Contributor
0 Kudos

it crashs in every computer for every users ?

Sriram2009
Active Contributor
0 Kudos

Hi

Thanks for your information,

1. Using the SAP Note 2291168 create the trace file and check the error message. if possible share the log as text file attachement.

2. Try to use the latest version of SAPGUI 7.70 or 8.00, other versions( below Gui 7.60) are outdated from SAP support.

Regards

SS

0 Kudos

S Sriram ji,

Thank your for your response.

Using the SAP note 2291168 we have created trace files . Kindly guide us in which log trace files we will be able to check the error messages.

Attaching the sapgui_????.log and sapgui*.trc log files.

sapguidll-01-0001.txt

sapgui-0001.txt

Regards,

MSETCL_ABAP

0 Kudos

abapmsetcl The client you are working for can give you access to SAP Support in order to read the instructions given in the SAP note.

former_member859396
Discoverer
0 Kudos

@ Frederic Girod yes it crashes in every computer for every user