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: 

image from DMS System

Former Member
0 Kudos

hi experts,

I have material image in my DMS system and i want to show images in my z report .Is there any functional module for that or what should i do ...

i have attached to a particular material i dont how to dispaly in a report

Help me Plz

regards,

karthik

Message was edited by:

karthikeyan sukumar

1 REPLY 1

Former Member
0 Kudos

Hey this is the solution.....

REPORT zind_mat_disp_img.

----


  • Tables

----


TABLES : mara, makt, drad.

----


  • internal table

----


DATA : BEGIN OF w_material,

matnr TYPE mara-matnr,

prdha TYPE mara-prdha,

maktx TYPE makt-maktx,

img(18) TYPE c,

END OF w_material.

DATA : i_material LIKE STANDARD TABLE OF w_material WITH HEADER LINE.

DATA : tabix TYPE i.

----


  • TYPE-POOLS AND FIELD CATALOG DECLARATION

----


TYPE-POOLS: slis.

  • To pass name of the report in function module for ALV

DATA: v_repid LIKE sy-repid .

  • Internal table to display top of page and build eventcat

DATA : logoevent TYPE slis_t_event, "FOR LOGO

t_event TYPE slis_alv_event,

i_listheader TYPE slis_t_listheader,

test TYPE slis_listheader.

  • Table for catalog of the fields to be displayed

DATA: i_fieldcat TYPE slis_t_fieldcat_alv.

DATA : x_fieldcat TYPE slis_fieldcat_alv.

&----


*& Document declaration for DMS

&----


  • Document key

DATA: lf_doctype LIKE bapi_doc_draw-documenttype,

lf_docnumber LIKE bapi_doc_draw-documentnumber,

lf_docpart LIKE bapi_doc_draw-documenttype,

lf_docversion LIKE bapi_doc_draw-documentversion.

  • Bapi-Return structure

DATA : ls_return LIKE bapiret2.

  • Originals Document hierarchy

DATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE,

ls_document LIKE bapi_doc_draw2.

&----


*& SELECTION-SCREEN

&----


SELECTION-SCREEN : BEGIN OF BLOCK 001.

SELECT-OPTIONS : c_matnr FOR mara-matnr.

SELECTION-SCREEN : END OF BLOCK 001.

&----


*& INITIALIZATION

&----


INITIALIZATION.

v_repid = sy-repid.

&----


*& START-OF-SELECTION

&----


START-OF-SELECTION.

PERFORM 100_fetch_from_table.

IF NOT i_material IS INITIAL.

PERFORM 200_build_event USING logoevent.

PERFORM 300_build_fieldcatalog.

PERFORM 400_alv_grid_display.

ENDIF.

&----


*& Form 100_fetch_from_table

&----


  • Fetch datas from table into internal table

----


FORM 100_fetch_from_table .

SELECT amatnr aprdha b~maktx FROM mara AS a

INNER JOIN makt AS b

ON amatnr = bmatnr INTO CORRESPONDING FIELDS OF TABLE i_material

WHERE a~matnr IN c_matnr.

IF sy-subrc = 0.

SORT i_material BY matnr.

LOOP AT i_material.

i_material-img = 'Display_Image'.

MODIFY i_material TRANSPORTING img.

ENDLOOP.

ENDIF.

ENDFORM. " 100_fetch_from_table

&----


*& Form 200_build_event

&----


  • Build Event

----


FORM 200_build_event USING p_logoevent TYPE slis_t_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

IMPORTING

et_events = p_logoevent

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

READ TABLE p_logoevent WITH KEY name = slis_ev_top_of_page INTO t_event.

IF sy-subrc = 0.

MOVE 'TOP_OF_PAGE' TO t_event-form.

MODIFY p_logoevent FROM t_event INDEX sy-tabix TRANSPORTING form.

ENDIF.

ENDFORM. " 150_build_event

&----


*& Form 300_build_fieldcatalog

&----


  • Building field catalog for ALV display

----


FORM 300_build_fieldcatalog .

x_fieldcat-col_pos = 1.

x_fieldcat-outputlen = '18'.

x_fieldcat-fieldname = 'MATNR'.

x_fieldcat-tabname = 'I_MATERIAL'.

x_fieldcat-seltext_m = 'Material'.

x_fieldcat-key = 'X'.

x_fieldcat-key_sel = 'X'.

x_fieldcat-hotspot = space.

x_fieldcat-fix_column = 'X'.

APPEND x_fieldcat TO i_fieldcat.

CLEAR x_fieldcat.

x_fieldcat-col_pos = 2.

x_fieldcat-outputlen = '40'.

x_fieldcat-fieldname = 'MAKTX'.

x_fieldcat-tabname = 'I_MATERIAL'.

x_fieldcat-seltext_m = 'Material_Description'.

x_fieldcat-hotspot = space.

APPEND x_fieldcat TO i_fieldcat.

CLEAR x_fieldcat.

x_fieldcat-col_pos = 3.

x_fieldcat-outputlen = '18'.

x_fieldcat-fieldname = 'PRDHA'.

x_fieldcat-tabname = 'I_MATERIAL'.

x_fieldcat-seltext_m = 'Product Hierarchy'.

x_fieldcat-hotspot = space.

APPEND x_fieldcat TO i_fieldcat.

CLEAR x_fieldcat.

x_fieldcat-col_pos = 4.

x_fieldcat-outputlen = '18'.

x_fieldcat-fieldname = 'IMG'.

x_fieldcat-tabname = 'I_MATERIAL'.

x_fieldcat-seltext_m = 'Link to Disp Image'.

x_fieldcat-hotspot = 'X'.

x_fieldcat-key = 'X'.

APPEND x_fieldcat TO i_fieldcat.

CLEAR x_fieldcat.

ENDFORM. " 200_build_fieldcatalog

&----


*& Form 400_alv_list_display

&----


  • ALV List Display

----


FORM 400_alv_grid_display .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = v_repid

i_callback_pf_status_set = 'SET_PF_STATUS'

i_callback_user_command = 'USER_COMMAND'

i_callback_top_of_page = 'TOP_OF_PAGE'

i_structure_name = 'I_MATERIAL'

  • IS_LAYOUT = struct_layout

it_fieldcat = i_fieldcat

it_events = logoevent

TABLES

t_outtab = i_material

EXCEPTIONS

program_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.

ENDFORM. " 300_alv_grid_display

----


  • FORM TOP_OF_PAGE *

----


  • *

----


FORM top_of_page.

REFRESH i_listheader.

DATA: t_header TYPE slis_listheader.

DATA: v_text(50).

WRITE sy-datum TO v_text.

CLEAR t_header.

t_header-typ = 'S'.

t_header-key = 'Date'.

t_header-info = v_text.

APPEND t_header TO i_listheader.

WRITE sy-repid TO v_text.

CLEAR t_header.

t_header-typ = 'S'.

t_header-key = 'Program_Name'.

t_header-info = v_text.

APPEND t_header TO i_listheader.

WRITE sy-uname TO v_text.

CLEAR t_header.

t_header-typ = 'S'.

t_header-key = 'User'.

t_header-info = v_text.

APPEND t_header TO i_listheader.

WRITE 'Materials_Display' TO v_text.

CLEAR t_header.

t_header-typ = 'S'.

t_header-key = 'Details'.

t_header-info = v_text.

APPEND t_header TO i_listheader.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = i_listheader

i_logo = 'ENJOYSAP_LOGO'.

ENDFORM. "TOP_OF_PAGE

&----


*& Form set_pf_status

&----


  • Form used to set the Custom pf-status of the List Display

----


FORM set_pf_status USING i_rt_extab TYPE slis_t_extab.

DATA : x_extab TYPE slis_extab.

x_extab-fcode = '&LFO'.

APPEND x_extab TO i_rt_extab.

SET PF-STATUS 'ZSTANDARD' EXCLUDING i_rt_extab .

ENDFORM. "set_pf_status

&----


*& Form user_command

&----


  • Form used to handle USER_COMMAND events

----


FORM user_command USING rf_ucomm LIKE sy-ucomm

rs TYPE slis_selfield.

tabix = rs-tabindex.

CASE rf_ucomm.

  • Ok code for double click is &IC1 for ALV report

WHEN '&IC1'.

PERFORM sub_disp_img.

ENDCASE.

ENDFORM. "user_command

&----


*& Form sub_disp_img

&----


*

----


FORM sub_disp_img .

PERFORM get_document.

IF sy-subrc = 0.

PERFORM wa_exeute.

ENDIF.

ENDFORM. " sub_disp_img

&----


*& Form get_document

&----


  • text

----


FORM get_document.

IF tabix NE space.

READ TABLE i_material INDEX tabix.

IF sy-subrc = 0.

SELECT SINGLE * INTO drad FROM drad

WHERE objky = i_material-matnr.

IF sy-subrc = 0.

  • * Allocate document data

lf_doctype = drad-dokar.

lf_docnumber = drad-doknr.

lf_docversion = drad-dokvr.

lf_docpart = drad-doktl.

REFRESH lt_files.

CLEAR lt_files.

  • Set detail information for the document

CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'

EXPORTING: documenttype = lf_doctype

documentnumber = lf_docnumber

documentpart = lf_docpart

documentversion = lf_docversion

getobjectlinks = 'X'

getstatuslog = 'X'

getlongtexts = 'X'

getactivefiles = 'X'

IMPORTING:

documentdata = ls_document

return = ls_return

TABLES: documentfiles = lt_files.

IF ls_return-type CA 'EA'.

MESSAGE ID '26' TYPE 'I' NUMBER '000'

WITH ls_return-message.

ENDIF.

ELSE.

MESSAGE 'No Image Found' TYPE 'I'.

ENDIF.

ENDIF.

ENDIF.

ENDFORM. " get_document

&----


*& Form wa_exeute

&----


  • To display image from the path.

----


FORM wa_exeute .

CALL FUNCTION 'WS_EXECUTE'

EXPORTING

inform = 'X'

program = lt_files-docfile

EXCEPTIONS

frontend_error = 1

no_batch = 2

prog_not_found = 3

illegal_option = 4

gui_refuse_execute = 5

OTHERS = 6

.

IF sy-subrc <> 0.

MESSAGE 'Image Path Invalid' TYPE 'W'.

ENDIF.

ENDFORM. " wa_exeute