Skip to Content
0
5 days ago

IMAGE NOT GETTING OVERWRITTEN IN CL_GUI_PICTURE

56 Views

Hi friends,
please check this issue. extremely urgent. when i click on button, it is showing the image, but when i click on button the 2nd time, the image is not getting overwritten. please check the code and the screenshots.
Beginning of changes by Saurav Lahiry on 13-JAN-2022
DATA: LV_MASK1(40),
LV_MASK2(120).

*Only BMP and TIF are allowed
LV_MASK2 =
',Tagged Image File Format (*.tif; *.tiff),*.tif;*.tiff'.
LV_MASK1 = ',Windows Bitmap (*.bmp),*.bmp'.
CONCATENATE LV_MASK1 LV_MASK2 '.' INTO LV_MASK2.

*Popup to select file
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = ' '
DEF_PATH = ' '
MASK = LV_MASK2
MODE = 'O' "Open
TITLE = ' '
IMPORTING
FILENAME = RLGRAP-FILENAME
* RC =
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
CLEAR RLGRAP-FILENAME.
ENDIF.

DATA : LV_PIC_NAME TYPE STXBITMAPS-TDNAME.
DATA : LV_BDS_DESCRIPTION LIKE BAPISIGNAT-PROP_VALUE,
PV_PICNUM TYPE CHAR1,
PV_NOTIF_NO TYPE ZINSP_HYDRO-NOTIF_NO.
* CONCATENATE '_' PV_PICNUM INTO LV_PIC_NAME.
CONCATENATE lv_qmnum '1'
INTO LV_PIC_NAME.
CONCATENATE 'Notif:' PV_NOTIF_NO 'Pic' '1' INTO LV_BDS_DESCRIPTION
SEPARATED BY SPACE.
STXBITMAPS-TDNAME = LV_PIC_NAME.
STXBITMAPS-TDOBJECT = 'GRAPHICS'.
STXBITMAPS-TDID = 'BMAP'.
STXBITMAPS-TDBTYPE = 'BCOL'.
* bds_description = lv_pic_name. .
*STXBITMAPS-RESIDENT
STXBITMAPS-AUTOHEIGHT = 'X'.
STXBITMAPS-BMCOMP = 'X'.


*Using BMP Import module from SE78
PERFORM GRAPHIC_IMPORT_BDS(SAPLSTXBITMAPS)
USING RLGRAP-FILENAME
STXBITMAPS-TDNAME
STXBITMAPS-TDOBJECT
STXBITMAPS-TDID
STXBITMAPS-TDBTYPE
LV_BDS_DESCRIPTION
STXBITMAPS-RESIDENT
STXBITMAPS-AUTOHEIGHT
STXBITMAPS-BMCOMP
CHANGING STXBITMAPS-RESOLUTION.


DATA: W_LINES TYPE I.
TYPES PICT_LINE(256) TYPE C.
DATA : CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
PICTURE TYPE REF TO CL_GUI_PICTURE,
PICT_TAB TYPE TABLE OF PICT_LINE,
URL(255) TYPE C.

DATA: GRAPHIC_URL(255).
DATA: BEGIN OF GRAPHIC_TABLE OCCURS 0,
LINE(255) TYPE X,
END OF GRAPHIC_TABLE.
DATA: L_GRAPHIC_CONV TYPE I.
DATA: L_GRAPHIC_OFFS TYPE I.
DATA: GRAPHIC_SIZE TYPE I.
DATA: L_GRAPHIC_XSTR TYPE XSTRING.

CALL METHOD CL_GUI_CFW=>FLUSH
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
CNTL_ERROR = 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.
* Getting image



CREATE OBJECT: CONTAINER EXPORTING CONTAINER_NAME = 'CONT'.

CREATE OBJECT PICTURE
EXPORTING
** LIFETIME =
** SHELLSTYLE =
PARENT = CONTAINER
** NAME =
** EXCEPTIONS
** ERROR = 1
** OTHERS = 2
.
* PICTURE EXPORTING PARENT = CONTAINER.
CALL METHOD PICTURE->CLEAR_PICTURE.

CALL METHOD CL_SSF_XSF_UTILITIES=>GET_BDS_GRAPHIC_AS_BMP
EXPORTING
P_OBJECT = 'GRAPHICS'
P_NAME = LV_PIC_NAME
P_ID = 'BMAP'
P_BTYPE = 'BCOL'
RECEIVING
P_BMP = L_GRAPHIC_XSTR
* EXCEPTIONS
* NOT_FOUND = 1
* INTERNAL_ERROR = 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.
GRAPHIC_SIZE = XSTRLEN( L_GRAPHIC_XSTR ).
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.
* Showing image
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
TYPE = 'IMAGE'
SUBTYPE = 'X-UNKNOWN'
SIZE = GRAPHIC_SIZE
LIFETIME = 'T'
TABLES
DATA = GRAPHIC_TABLE
CHANGING
URL = URL.
CALL METHOD PICTURE->LOAD_PICTURE_FROM_URL
EXPORTING
URL = URL.
CALL METHOD PICTURE->SET_DISPLAY_MODE
EXPORTING
DISPLAY_MODE = PICTURE->DISPLAY_MODE_FIT_CENTER.

CALL METHOD PICTURE->SET_3D_BORDER( BORDER = 1 ).
image.png



image.png

image.png
image.png

image.png



image.png