Sunteți pe pagina 1din 26

BUKU TEBALKU

ABAP : Display Photo in Smartforms


March 29, 2016 at 9:43 am (ABAP, ABAP HR, HR, SAP)

Menampilkan photo employee pada Personnel Profile dengan menggunakan Smartforms.

Sisipkan prosedure loadpicture dibawah ini.

PERFORM load_picture.

CALL FUNCTION ‘SSF_FUNCTION_MODULE_NAME’


EXPORTING
formname = c_formname
IMPORTING
fm_name = g_fm_name.

CALL FUNCTION g_fm_name


EXPORTING
control_parameters = st_control_parameters
output_options = st_output_options
IMPORTING
document_output_info = st_document_output_info
job_output_info = st_job_output_info
job_output_options = st_job_output_options
TABLES
…..
…..

Load _picture lengkapnya dibawah ini.


*&---------------------------------------------------------------------*
*& Form load_picture
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM load_picture.
DATA: p_connect_info LIKE toav0, p_exists(1) TYPE c.
DATA: length TYPE i, it_doc LIKE tbl1024 OCCURS 0.
DATA: it_bin LIKE sdokcntbin OCCURS 0,
crep_id LIKE p_connect_info-archiv_id,
doc_id LIKE p_connect_info-arc_doc_id,
phio_id TYPE sdok_phid.
DATA: l_content_length TYPE i,
mime TYPE w3mimetabtype.
DATA: i_igs_image_converter TYPE REF TO cl_igs_image_converter,
dpi LIKE stxbitmaps-resolution,
blob TYPE w3mimetabtype,
blob_size TYPE w3param-cont_len,
blob_type TYPE w3param-cont_type,
l_width_tw LIKE stxbitmaps-widthtw,
l_height_tw LIKE stxbitmaps-heighttw,
l_width_pix LIKE stxbitmaps-heightpix,
l_height_pix LIKE stxbitmaps-heightpix,
l_bds_content TYPE sbdst_content.
DATA: l_bds_object TYPE REF TO cl_bds_document_set,
wa_bds_components TYPE LINE OF sbdst_components,
* c_bds_mimetype LIKE wa_bds_components-mimetype,
c_bds_mimetype TYPE bds_mimetp VALUE 'application/octet-stream',
l_bds_components TYPE sbdst_components,
wa_bds_signature TYPE LINE OF sbdst_signature,
l_bds_signature TYPE sbdst_signature,
* c_bds_classname LIKE bds_locl-classname,
* c_bds_classtype LIKE bds_locl-classtype,
c_bds_classname TYPE sbdst_classname VALUE 'DEVC_STXD_BITMAP',
c_bds_classtype TYPE sbdst_classtype VALUE 'OT', " others
l_object_key TYPE sbdst_object_key,
p_docid TYPE sbdst_doc_id, "wa_bds_signature-doc_id,
wa_stxbitmaps TYPE stxbitmaps.
DATA: rc TYPE i.
DATA: zfilename TYPE string.

LOOP AT iprofile.

CONCATENATE ‘C:\TEMP\’ iprofile-pernr ‘.jpg’ INTO zfilename.

“0. Check image on SE78 if exist delete


SELECT SINGLE * FROM stxbitmaps INTO wa_stxbitmaps
WHERE tdobject = ‘GRAPHICS’
AND tdname = iprofile-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 = iprofile-pernr
p_tclas = ‘A’
p_begda = pn-begda
p_endda = pn-endda
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 = iprofile-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 = iprofile-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 = iprofile-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.
* wa_stxbitmaps-tdname = itprofile-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.

ENDLOOP.

Kemudian Create Graphic di Smartforms sbb:


Advertisements
REPORT THIS AD
REPORT THIS AD

Like this:

Related

SAP - Send external email from within ABAP program

Send external email from within ABAP program The code below demonstrates how to send
an email to an external email address(test@sapdev.co.uk) *&---------------------------------------
------------------------------* *& Report ZSENDEMAIL *
*& * *&---------------------------------------------------
------------------* *& Example of sending external email via SAPCONNECT *
*& * *&---------------------------------------------------
------------------* REPORT zsendemail . PARAMETERS: psubject(40) type c
default 'Hello',…

SAP - Upload Tab delimited file from PC into internal table

Upload Tab delimited file from PC into internal table


http://www.sapdevelopment.co.uk/file/file_uptabpc.htm ABAP code for uploading a TAB
delimited file into an internal table. See code below for structures. The code is base on
uploading a simple txt file. *&---------------------------------------------------------------------* *&
Report ZUPLOADTAB *
*& * *&---------------------------------------------------
------------------* *& Example of Uploading tab…

SAP - Convert Spool request to PDF and send as e-mail

Convert Spool request to PDF and send as e-mail The code below demonstrates how to
retrieve a spool request and email it as a PDF document. Please note for the below program to
process a spool request the program must be executed in background otherwise no spool
request will be…

Leave a Reply
727c11bcd9 /2016/03/29/abap-d guest

Enter your comment here...

Fill in your details below or click an icon to log in:


(required)(Address never made public)(required)WordPress.com( Log Out / Change )
1550060378
( Log Out / Change ) ( Log Out / Change ) ( Log Out / Change )
1550060374600


Search

 Category
o ABAP HR (14)
o HR (3)
o php (2)
o Saham (3)
o SAP (81)
 ABAP (79)
 Coding (56)
 File Processing (15)
 OLE (5)
 SCREEN (15)
 Search Help / Listbox (3)
o Tips & Tricks (4)
o Vb.net (5)
 Archives
o March 2016 (3)
o July 2015 (1)
o June 2015 (44)
o April 2007 (8)
o February 2007 (39)
 Recent Comment
zdiodic on ABAP – BPJS Kesehatan Pr…
Dewi on ABAP – BPJS Kesehatan Pr…
Eslam on SAP – Send external emai…
Piroz Eslam on SAP – Sending mail with…
cio on SAP – Send external emai…

 Blog Stats
o 83,560 hits

 http://feedjit.com

Blog at WordPress.com.

Post to
Reblog Post 728370 https://diocio.wordp BUKU TEBALKU
Cancel
bae333c954 /2016/03/29/abap-d

Close and accept


Privacy & Cookies: This site uses cookies. By continuing to use this website,
you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
 Follow

o BUKU TEBALKU

o Customize
o Follow
o Sign up
o Log in
o Copy shortlink
o Report this content
o Manage subscriptions
o Collapse this bar
%d bloggers like this:
<img src="https://pixel.wp.com/b.gif?v=noscript"
style="height:0px;width:0px;overflow:hidden" alt="" />
REPORT THIS AD

How to create a QR code and show it in a


Smartform
Last Updated: November 14th 2015 by Admin

A+ A-
Before running the code given below what should we do?

1. Create a smartform. Follow the steps given below.


2. Goto Form Interface and add a new variable under the import tab which holds the
name
of the qrcode that we are passing from the driver program[W_NAME type char20]
3. Create a new graphics and as shown below give the name as &W_NAME&.
[Dynamic
variable]

4. Done.

5. Copy the code below.

6. Enjoy the emerging technology of qrcode in SAP.

Note : In the program given below I have used a screen 9000. Please do create it
before running and also create acustom control in the screen layout and give the
name ‘PICTURECONTROL’ to it.

SOURCE CODE
*&------------------------------------------------------------
---------*
*& Report Z03_QRCODE_IMAGE
*&
*&------------------------------------------------------------
---------*
*&
*&
*&------------------------------------------------------------
---------*

REPORT z03_qrcode_image.

*types: ty_boolean(1) type c.


*
*constants:
* c_true type ty_boolean value 'X',
* c_false type ty_boolean value space.

DATA : bds_description like bapisignat-prop_value.

* BDS handling
constants:
c_bds_classname type sbdst_classname value
'DEVC_STXD_BITMAP',
c_bds_classtype type sbdst_classtype value 'OT', "
others
c_bds_mimetype type bds_mimetp value
'application/octet-stream',
c_bds_original type sbdst_doc_var_tg value 'OR'.

* Graphic handling
constants:
c_stdtext like thead-tdobject value 'TEXT',
c_graphics like thead-tdobject value 'GRAPHICS',
c_bmon like thead-tdid value 'BMON',
c_bcol like thead-tdid value 'BCOL'.

DATA: gi_filename type rlgrap-filename,


gi_name type stxbitmaps-tdname,
gi_object type stxbitmaps-tdobject,
gi_id type stxbitmaps-tdid,
gi_btype type stxbitmaps-tdbtype,
gi_resident type stxbitmaps-resident,
gi_autoheight type stxbitmaps-autoheight,
gi_bmcomp type stxbitmaps-bmcomp,
gi_resolution type stxbitmaps-resolution,

l_extension type rlgrap-filename,


l_docid type stxbitmaps-docid.

"Picture Control
DATA: picture_container TYPE REF TO cl_gui_custom_container,
picture_control TYPE REF TO cl_gui_picture.

DATA: l_img_url TYPE w3url.


DATA :l_img_subtype TYPE w3param-cont_type.
DATA : l_str_length TYPE i.
DATA : url TYPE string.
DATA : l_content_length TYPE i.

DATA : mime TYPE w3mimetabtype.


DATA: blob TYPE w3mimetabtype,
blob_size TYPE w3param-cont_len,
blob_type TYPE w3param-cont_type.

DATA : i_igs_image_converter TYPE REF TO


cl_igs_image_converter.
DATA: content TYPE xstring.
DATA : http_client TYPE REF TO if_http_client.

TYPES : BEGIN OF ty_binary,


binary_field(1000) TYPE c,
END OF ty_binary.

DATA : hex_tab1 TYPE TABLE OF ty_binary WITH HEADER LINE.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.


PARAMETERS : qr_text TYPE char100 OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.


PARAMETERS : width TYPE int3,
height TYPE int3.
SELECTION-SCREEN END OF BLOCK b2.

PARAMETERS : p_rad1 RADIOBUTTON GROUP rd1 DEFAULT 'X',


p_rad2 RADIOBUTTON GROUP rd1.

START-OF-SELECTION.

PERFORM download_qrcode.
PERFORM convert_image.

*&------------------------------------------------------------
---------*
*& Form DOWNLOAD_QRCODE
*&------------------------------------------------------------
---------*
* text
*-------------------------------------------------------------
---------*
* --> p1 text
* <-- p2 text
*-------------------------------------------------------------
---------*

FORM download_qrcode .

CONCATENATE
'http://chart.apis.google.com/chart?chs=200x200&cht=qr&chld=|1
&chl=' qr_text '/chart.png' INTO url.

CALL METHOD cl_http_client=>create_by_url


EXPORTING
url = url
IMPORTING
client = http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4.

IF sy-subrc = 0.

http_client->send( ).

http_client->receive( ).

content = http_client->response->get_data( ).
http_client->close( ).

l_str_length = xstrlen( content ).

CALL FUNCTION 'RSFO_XSTRING_TO_MIME'


EXPORTING
c_xstring = content
i_length = l_str_length
TABLES
c_t_mime = mime.

ENDIF.

ENDFORM. " DOWNLOAD_QRCODE

*&------------------------------------------------------------
---------*
*& Form CONVERT_IMAGE

*&------------------------------------------------------------
---------*
* text
*-------------------------------------------------------------
---------*
* --> p1 text
* <-- p2 text
*-------------------------------------------------------------
---------*

FORM convert_image .

CREATE OBJECT i_igs_image_converter .

i_igs_image_converter->input = 'image/png'.
i_igs_image_converter->output = 'image/bmp'.
i_igs_image_converter->width = width.
i_igs_image_converter->height = height.

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.

CALL METHOD i_igs_image_converter->get_image


IMPORTING
blob = blob
blob_size = blob_size
blob_type = blob_type.

ENDIF.

IF sy-subrc = 0.

IF p_rad1 = 'X'.

CALL SCREEN '9000'. "Calling the screen for qrcode


display

ELSE.

PERFORM show_smart_form. "calling the smartform for


qrcode display

ENDIF.

ENDIF.

ENDFORM. " CONVERT_IMAGE

*&------------------------------------------------------------
---------*
*& Module STATUS_9000 OUTPUT
*&------------------------------------------------------------
---------*
* text
*-------------------------------------------------------------
---------*

MODULE status_9000 OUTPUT.

SET PF-STATUS 'PF'.

"Creating the object for the container

CREATE OBJECT picture_container


EXPORTING
container_name = 'PICTURECONTROL'.
CREATE OBJECT picture_control
EXPORTING
parent = picture_container.

"Calling the screen

PERFORM call_screen.

ENDMODULE. " STATUS_9000 OUTPUT

*&------------------------------------------------------------
---------*
*& Form CALL_SCREEN
*&------------------------------------------------------------
---------*
* text
*-------------------------------------------------------------
---------*
* --> p1 text
* <-- p2 text
*-------------------------------------------------------------
---------*

FORM call_screen .

"Creating the url of the image for the display in the


container in the screen
SPLIT blob_type AT '/' INTO blob_type l_img_subtype.

CALL FUNCTION 'DP_CREATE_URL'


EXPORTING
type = blob_type
subtype = l_img_subtype
size = blob_size
lifetime = cndp_lifetime_transaction
TABLES
data = blob
CHANGING
url = l_img_url
EXCEPTIONS
OTHERS = 1.

IF sy-subrc IS INITIAL.
CALL METHOD picture_control->load_picture_from_url
EXPORTING
url = l_img_url.
ENDIF.

ENDFORM. " CALL_SCREEN

*&------------------------------------------------------------
---------*
*& Module USER_COMMAND_9000 INPUT
*&------------------------------------------------------------
---------*
* text
*-------------------------------------------------------------
---------*
MODULE user_command_9000 INPUT.

IF sy-ucomm = 'BACK'.

LEAVE TO SCREEN 0.

ENDIF.

ENDMODULE. " USER_COMMAND_9000 INPUT

*&------------------------------------------------------------
---------*
*& Form SHOW_SMART_FORM
*&------------------------------------------------------------
---------*
* text
*-------------------------------------------------------------
---------*
* --> p1 text
* <-- p2 text
*-------------------------------------------------------------
---------*

FORM show_smart_form .

gi_name = 'QRCODE10'. "name of the qrcode will be in


se78 after one time running this program
gi_object = 'GRAPHICS'.
gi_id = 'BMAP'.
gi_btype = 'BCOL'. "If u want black and white pass BMON
gi_resident = ' '.
gi_autoheight = 'X'.
gi_bmcomp = 'X'.
l_extension = 'BMP'.

"importing the image into se78 before displaying it in the


smartform.

perform import_bitmap_bds using blob


gi_name
gi_object
gi_id
gi_btype
l_extension
' '
gi_resident
gi_autoheight
gi_bmcomp
changing l_docid
gi_resolution.

IF sy-subrc = 0.

DATA:fname TYPE rs38l_fnam.

"gettingt the name FM of the smartform


CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZQR_TEST'
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
fm_name = fname
* EXCEPTIONS
* NO_FORM = 1
* NO_FUNCTION_MODULE = 2
* OTHERS = 3 .

"Calling the FM of the smartform for display


CALL FUNCTION fname
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
* CONTROL_PARAMETERS =
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
* OUTPUT_OPTIONS =
* USER_SETTINGS = 'X'
w_name = 'QRCODE10'
* IMPORTING
* DOCUMENT_OUTPUT_INFO =
* JOB_OUTPUT_INFO =
* JOB_OUTPUT_OPTIONS =
* EXCEPTIONS
* FORMATTING_ERROR = 1
* INTERNAL_ERROR = 2
* SEND_ERROR = 3
* USER_CANCELED = 4
* OTHERS = 5 .

IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

ENDIF.

ENDFORM. " SHOW_SMART_FORM

*&------------------------------------------------------------
---------*
*& Form IMPORT_BITMAP_BDS (Copied from standard program
and modified it as per the requirement)
*&------------------------------------------------------------
---------*
form import_bitmap_bds
using p_blob type w3mimetabtype
p_name type stxbitmaps-tdname
p_object type stxbitmaps-tdobject
p_id type stxbitmaps-tdid
p_btype type stxbitmaps-tdbtype
p_format type c
p_title like bds_description
p_resident type stxbitmaps-resident
p_autoheight type stxbitmaps-autoheight
p_bmcomp type stxbitmaps-bmcomp
changing p_docid type stxbitmaps-docid
p_resolution type stxbitmaps-resolution.

data: l_object_key type sbdst_object_key.


data: l_tab type ddobjname.

data: begin of l_bitmap occurs 0,


l(64) type x,
end of l_bitmap.

data: l_filename type string,


l_bytecount type i,
l_bds_bytecount type i.
data: l_color(1) type c,

l_width_tw type stxbitmaps-widthtw,


l_height_tw type stxbitmaps-heighttw,
l_width_pix type stxbitmaps-widthpix,
l_height_pix type stxbitmaps-heightpix.
data: l_bds_object type ref to cl_bds_document_set,
l_bds_content type sbdst_content,
l_bds_components type sbdst_components,
wa_bds_components type line of sbdst_components,
l_bds_signature type sbdst_signature,
wa_bds_signature type line of sbdst_signature,
l_bds_properties type sbdst_properties,
wa_bds_properties type line of sbdst_properties.

data wa_stxbitmaps type stxbitmaps.

* Enqueue
perform enqueue_graphic using p_object
p_name
p_id
p_btype.

* Bitmap conversion
call function 'SAPSCRIPT_CONVERT_BITMAP_BDS'
exporting
color = 'X'
format = p_format
resident = p_resident
bitmap_bytecount = l_bytecount
compress_bitmap = p_bmcomp
importing
width_tw = l_width_tw
height_tw = l_height_tw
width_pix = l_width_pix
height_pix = l_height_pix
dpi = p_resolution
bds_bytecount = l_bds_bytecount
tables
bitmap_file = p_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
others = 7.

if sy-subrc <> 0.

perform dequeue_graphic using p_object


p_name
p_id
p_btype.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
raising conversion_failed.
endif.

* Save bitmap in BDS


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 = l_bds_bytecount.
append wa_bds_components to l_bds_components.

if p_docid is initial. " graphic is new

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.

if sy-subrc <> 0.

perform dequeue_graphic using p_object


p_name
p_id
p_btype.
* message e285 with p_name 'BDS'.

endif.

read table l_bds_signature index 1 into wa_bds_signature


transporting doc_id.

if sy-subrc = 0.

p_docid = wa_bds_signature-doc_id.

else.
perform dequeue_graphic using p_object
p_name
p_id
p_btype.
* message e285 with p_name 'BDS'.

endif.

else. " graphic already exists

********* read object_key for faster access *****


clear l_object_key.
select single * from stxbitmaps into wa_stxbitmaps
where tdobject = p_object
and tdid = p_id
and tdname = p_name
and tdbtype = p_btype.

select single tabname from bds_locl into l_tab


where classname = c_bds_classname
and classtype = c_bds_classtype.

if sy-subrc = 0.

select single object_key from (l_tab) into l_object_key


where loio_id = wa_stxbitmaps-docid+10(32)
and classname = c_bds_classname
and classtype = c_bds_classtype.

endif.

******** read object_key end ********************

call method l_bds_object->update_with_table


exporting
classname = c_bds_classname
classtype = c_bds_classtype
object_key =

S-ar putea să vă placă și