ABAP Program to Display SE78 pictures on Screen

0
657

There has been requirement to upload the image and show that on the screen in Module Pool programming. The following program displays a color  Picture in a custom container on screen that has been uploaded using SE78 pictures.    

 

SE78 Graphics (on-screen)
SE78 Graphics (on-screen)

 

Steps to follow:

Step 1: Upload the image (say, WATERMARK_DEMO) using SE78.

Step 2: Create a Module Pool program/Executable Program with a Screen (using SE38) and place a custom container(name it PICTURE_CONTAINER) on the screen(say, dynpro 9000).

step 3: Place the following code in the program.

Report ZTEST.

*&———————————————————————*

*& Program which prints a SE78 uploaded picture *

*into screen with custom area name ‘PICTURE_CONTAINER’

*&———————————————————————*

 call screen 9000.

*&———————————————————————*

*& Module STATUS_9000 OUTPUT

*&———————————————————————*

* Picture is to be uploaded during PBO module of screen.

*———————————————————————-*

 MODULE STATUS_9000 OUTPUT.

DATA: W_LINES TYPE I.
TYPES PICT_LINE(256) TYPE C.

DATA :CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
EDITOR TYPE REF TO CL_GUI_TEXTEDIT,
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.

CREATE OBJECT:

CONTAINER EXPORTING CONTAINER_NAME = ‘PICTURE_CONTAINER’,

PICTURE EXPORTING PARENT = CONTAINER.

*Method which takes the object “WATERMARK_DEMO” – uploaded through *SE78 into the ABAP memory. Change name to object to be displayed in
*screen.

CALL METHOD CL_SSF_XSF_UTILITIES=>GET_BDS_GRAPHIC_AS_BMP

EXPORTING
P_OBJECT = ‘GRAPHICS’
P_NAME = ‘WATERMARK_DEMO’
P_ID = ‘BMAP’
P_BTYPE = ‘BCOL’

RECEIVING
P_BMP = L_GRAPHIC_XSTR

.

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.

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.

ENDMODULE. ” STATUS_9000 OUTPUT

 

 

Thats it…!! Just declare the data in the appropriate section and place the code, in the PBO module of the screen.

Note: Pl check the authority you have or not, as it may lead to dump. The Form to check for the authority during runtime is AUTHORITY_DOCUMENT_SET.


LEAVE A REPLY