on 04-13-2006 6:37 AM
Hi Friends,
In Module pool program how to include picture?
Thanks,
Jinna
Hi,
This is very simple to do, first create a dialog program with one screen (any number i.e. 0100) and create a custom control called 'CUST_CONTROL'. Now use the below sections of code to create a top include and a PBO module/process. And then finally create a transaction code for it.
CONSTANTS: CNTL_TRUE TYPE I VALUE 1,
CNTL_FALSE type i value 0.
data:
h_picture type ref to cl_gui_picture,
h_pic_container type ref to cl_gui_custom_container.
h_tree type ref to cl_gui_list_tree,
h_docking type ref to cl_gui_docking_container,
h_application type ref to lcl_application.
data: graphic_url(255),
graphic_refresh(1),
g_result like cntl_true.
data: begin of graphic_table occurs 0,
line(255) type x,
end of graphic_table.
data: graphic_size type i.
----
***INCLUDE ZDISPLAYIMAGEPBO .
----
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
module STATUS_0100 output.
data: l_graphic_xstr type xstring,
l_graphic_conv type i,
l_graphic_offs type i.
CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
EXPORTING
p_object = 'GRAPHICS'
p_name = 'ENJOY' "IMAGE NAME - Image name from SE78
p_id = 'BMAP'
p_btype = 'BMON' "(BMON = black&white, BCOL = colour)
RECEIVING
p_bmp = l_graphic_xstr
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc = 1.
MESSAGE e287 WITH g_stxbitmaps-tdname.
ELSEIF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
graphic_size = XSTRLEN( l_graphic_xstr ).
CHECK graphic_size > 0.
l_graphic_conv = graphic_size.
l_graphic_offs = 0.
WHILE l_graphic_conv > 255.
graphic_table-line = l_graphic_xstr+l_graphic_offs(255).
APPEND graphic_table.
l_graphic_offs = l_graphic_offs + 255.
l_graphic_conv = l_graphic_conv - 255.
ENDWHILE.
graphic_table-line = l_graphic_xstr+l_graphic_offs(L_GRAPHIC_CONV).
APPEND graphic_table.
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'image' "#EC NOTEXT
subtype = cndp_sap_tab_unknown " 'X-UNKNOWN'
size = graphic_size
lifetime = cndp_lifetime_transaction "'T'
TABLES
data = graphic_table
CHANGING
url = graphic_url
EXCEPTIONS
dp_invalid_parameter = 1
dp_error_put_table = 2
dp_error_general = 3
OTHERS = 4 .
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
create object h_pic_container
exporting container_name = 'CUST_CONTROL'.
create object h_picture exporting parent = h_pic_container.
call method h_picture->load_picture_from_url
exporting url = graphic_url
importing result = g_result.
endmodule. " STATUS_0100 OUTPUT
Hope this helps.
Reward if helpful.
Regards,
Sipra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is sample code for you to place picture in your picture control
DATA container TYPE REF TO cl_gui_custom_container.
picture Control.
DATA picture TYPE REF TO cl_gui_picture.
Definition of Control Framework
CLASS cl_gui_cfw DEFINITION LOAD.
DATA url(132).
create the custom container
CREATE OBJECT container
EXPORTING container_name = 'CUST1'.
create the picture control
CREATE OBJECT picture
EXPORTING parent = container.
Request an URL from the data provider by exporting the pic_data.
CLEAR URL.
PERFORM LOAD_PIC_FROM_DB CHANGING URL.
load picture
CALL METHOD picture->load_picture_from_url
EXPORTING url = url.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS cntl_system_error = 1
cntl_error = 2.
IF sy-subrc <> 0.
error handling
ENDIF.
form LOAD_PIC_FROM_DB changing p_url.
DATA QUERY_TABLE LIKE W3QUERY OCCURS 1 WITH HEADER LINE.
DATA HTML_TABLE LIKE W3HTML OCCURS 1.
DATA RETURN_CODE LIKE W3PARAM-RET_CODE.
DATA CONTENT_TYPE LIKE W3PARAM-CONT_TYPE.
DATA CONTENT_LENGTH LIKE W3PARAM-CONT_LEN.
DATA PIC_DATA LIKE W3MIME OCCURS 0.
DATA PIC_SIZE TYPE I.
REFRESH QUERY_TABLE.
QUERY_TABLE-NAME = '_OBJECT_ID'.
QUERY_TABLE-VALUE = 'image.BMP'.
For this image you first upload your image into SAP *using se78 and then here use this image as in table
flag1 = 1.
APPEND QUERY_TABLE.
CALL FUNCTION 'WWW_GET_MIME_OBJECT'
TABLES
QUERY_STRING = QUERY_TABLE
HTML = HTML_TABLE
MIME = PIC_DATA
CHANGING
RETURN_CODE = RETURN_CODE
CONTENT_TYPE = CONTENT_TYPE
CONTENT_LENGTH = CONTENT_LENGTH
EXCEPTIONS
OBJECT_NOT_FOUND = 1
PARAMETER_NOT_FOUND = 2
OTHERS = 3.
if sy-subrc = 0.
PIC_SIZE = CONTENT_LENGTH.
endif.
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
TYPE = 'image'
SUBTYPE = cndp_sap_tab_unknown
SIZE = PIC_SIZE
lifetime = cndp_lifetime_transaction
TABLES
DATA = PIC_DATA
CHANGING
URL = URL
EXCEPTIONS
others = 1.
endform. " LOAD_PIC_FROM_DB
Info: If its help to solve your problem then rewards Points.
Regards
Priyank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jinna,
In the previous post, I missed out one step.
Here are the set of steps needed:
These are the steps.
1) In the screen Painter, create a custom control. Give a name to it .(say PICTURE)
2) In the main program, create two reference variables
data: container type ref to cl_gui_custom_container,
pic type ref to cl_gui_picture.
3) In PBO, create objects for the container and the control
CREATE OBJECT CONTAINER
exporting
container_name = 'PICTURE'.
CREATE OBJECT pic
exportin
parent = container.
4)<b>You need to call a method set_display_mode to fit the picture within the control
CALL METHOD obj_picture->set_display_mode
EXPORTING
display_mode = cl_gui_picture=>DISPLAY_MODE_FIT
EXCEPTIONS
ERROR = 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.
</b>
5) call the method to load picture from URL.
CALL METHOD pic->load_picture_from_url
EXPORTING
url = 'file://D:\SP\pic.jpg'.
I hope your query is solved.
Regards,
SP.
Hi Jinna,
You can make use of the class CL_GUI_PICTURE to display the picture in the output.
These are the steps.
1) In the screen Painter, create a custom control. Give a name to it .(say PICTURE)
2) In the main program, create two reference variables
data: container type ref to cl_gui_custom_container,
pic type ref to cl_gui_picture.
3) In PBO, create objects for the container and the control
CREATE OBJECT CONTAINER
exporting
container_name = 'PICTURE'.
CREATE OBJECT pic
exportin
parent = container.
4) call the method to load picture from URL.
CALL METHOD pic->load_picture_from_url
EXPORTING
url = 'file://D:\SP\pic.jpg'.
That is it...
This will work..
Regards,
SP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi !
you need to place a "Picture Control" on your Dynpro.
You can check the program "SAP_PICTURE_DEMO" so see how it works and the SE83 for more advice...
Some forum-points would be fine if this helped you a bit.
Regards
Rainer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check the Controls examples..
DWDM is transaction to find programs....
also try the FM's
FM UPC_FW_SET_DEFAULT_SCR_PICTURE
RSSM_MAINTAIN_PICTURES
check this link..
http://www.guidancetech.com/people/holland/sap/abap/yole.htm
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.