Employee Photos
Employee Photos
Employee Photos
************************************************************************ * Include Programs ************************************************************************ *INCLUDE . ************************************************************************ * Database Tables ************************************************************************ TABLES: kna1. "Customer Master ************************************************************************ * Types ************************************************************************ TYPE-POOLS: kkblo. ************************************************************************ * Structures
************************************************************************ * Structure to hold the Color Information DATA: BEGIN OF st_color, color(3) TYPE c, END OF st_color. * Structure to hold the Icon Information DATA: BEGIN OF st_icon, icon(4) TYPE c, END OF st_icon. * ALV Field Catalog Structure DATA: st_fieldcat TYPE slis_fieldcat_alv. * ALV Layout Structure DATA: st_layout TYPE slis_layout_alv. ************************************************************************ * Internal Tables ************************************************************************ * Output Table DATA: BEGIN OF tbl_kna1 OCCURS 0. INCLUDE STRUCTURE st_icon. "Icon Structure INCLUDE STRUCTURE kna1. "Customer Master Structure INCLUDE STRUCTURE st_color. "Color Structure DATA: END OF tbl_kna1. * ALV Field Catalog Table DATA: tbl_fieldcat TYPE slis_t_fieldcat_alv. ************************************************************************
* Variables ************************************************************************ DATA: fieldname(30) TYPE c, g_repid LIKE sy-repid. ************************************************************************ * Start of Selection ************************************************************************ START-OF-SELECTION. g_repid = sy-repid. PERFORM get_data. ************************************************************************ * End of Selection ************************************************************************ END-OF-SELECTION. PERFORM do_fancy_stuff. PERFORM get_layout. PERFORM get_fieldcat. PERFORM create_report. *&---------------------------------------------------------------------* *& Form CREATE_REPORT *&---------------------------------------------------------------------* * Learn to read the subroutine name! *----------------------------------------------------------------------* FORM create_report. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING i_interface_check = ' ' i_callback_program = g_repid i_callback_user_command = 'PROCESS_USER_COMMANDS' it_fieldcat = tbl_fieldcat i_default = 'X' i_save = ' ' is_layout = st_layout TABLES t_outtab = tbl_kna1 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. " CREATE_REPORT *&---------------------------------------------------------------------* *& Form GET_FIELDCAT *&---------------------------------------------------------------------* * Build the Field Catalog *----------------------------------------------------------------------* FORM get_fieldcat. * Here the field catalog is created. To display more fields simply
* 'uncomment' the additional lines and add the field name. Also note * that the field catalog is much more powerful than this. You can * intensify fields, change the colour, assign reference fields, etc. * Look at type slis_fieldcat_alv for more options. PERFORM write_fieldcat USING 'ICON' 'TBL_KNA1' ' ' 'X' 1 '2' 'X' ' '. PERFORM write_fieldcat USING 'KUNNR' 'TBL_KNA1' 'KNA1' 'X' 2 ' ' ' ' ' '. PERFORM write_fieldcat USING 'NAME1' 'TBL_KNA1' 'KNA1' ' ' 3 '10' ' ' 'X'. PERFORM write_fieldcat USING 'STRAS' 'TBL_KNA1' 'KNA1' ' ' 4 ' ' ' ' ' '. PERFORM write_fieldcat USING 'TELF1' 'TBL_KNA1' 'KNA1' ' ' 5 ' ' ' ' ' '. PERFORM write_fieldcat USING 'ORT01' 'TBL_KNA1' 'KNA1' ' ' 6 ' ' ' ' ' '. PERFORM write_fieldcat USING 'PSTLZ' 'TBL_KNA1' 'KNA1' ' ' 7 ' ' ' ' ' '. PERFORM write_fieldcat USING 'SORTL' 'TBL_KNA1' 'KNA1' ' ' 8 ' ' ' ' ' '. PERFORM write_fieldcat USING 'ERNAM' 'TBL_KNA1' 'KNA1' ' ' 9 ' ' ' ' ' '. PERFORM write_fieldcat USING 'SPRAS' 'TBL_KNA1' 'KNA1' ' ' 10 ' ' ' ' ' '. * perform write_fieldcat using ' ' 'TBL_KNA1' 'KNA1' ' ' 10 ' '.
* perform write_fieldcat using ' ' 'TBL_KNA1' 'KNA1' ' ' 11 ' '. * perform write_fieldcat using ' ' 'TBL_KNA1' 'KNA1' ' ' 12 ' '. ENDFORM. " GET_FIELDCAT *&---------------------------------------------------------------------* *& Form WRITE_FIELDCAT *&---------------------------------------------------------------------* * Write the Field Catalog data to the Field Catalog Table *----------------------------------------------------------------------* * -->name Field name * -->tab Table name * -->st Structure Name * -->key Is this field a Key? * -->pos Position Number * -->length Field Length * -->icon Display as Icon * -->hot Hotspot *----------------------------------------------------------------------* FORM write_fieldcat USING name tab st key pos length icon hot. st_fieldcat-fieldname = name. st_fieldcat-tabname = tab. st_fieldcat-ref_tabname = st. st_fieldcat-key = key. st_fieldcat-col_pos = pos. st_fieldcat-outputlen = length. st_fieldcat-icon = icon.
st_fieldcat-hotspot = hot. APPEND st_fieldcat TO tbl_fieldcat. CLEAR st_fieldcat. ENDFORM. " WRITE_FIELDCAT *&---------------------------------------------------------------------* *& Form PROCESS_USER_COMMANDS *&---------------------------------------------------------------------* * Interactive Reporting Commands *----------------------------------------------------------------------* FORM process_user_commands USING syst-ucomm LIKE syst-ucomm selfield TYPE slis_selfield. * This subroutine is called when there is user interaction in the output * In this case if the user double clicks the Customer Number then the * program will call transaction XD03 and display the Customer Master * Data CASE syst-ucomm. WHEN '&IC1'. * get cursor field fieldname. READ TABLE tbl_kna1 INDEX selfield-tabindex. SET PARAMETER ID 'KUN' FIELD tbl_kna1-kunnr. CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN. ENDCASE. ENDFORM. " PROCESS_USER_COMMANDS *&---------------------------------------------------------------------* *& Form GET_LAYOUT
*&---------------------------------------------------------------------* * set the layout of the ALV. * add color to the row? *----------------------------------------------------------------------* FORM get_layout. st_layout-info_fieldname = 'COLOR'. st_layout-colwidth_optimize = 'X'. st_layout-get_selinfos = 'X'. ENDFORM. " GET_LAYOUT *&---------------------------------------------------------------------* *& Form get_data *&---------------------------------------------------------------------* * Get some data to play with *----------------------------------------------------------------------* FORM get_data. SELECT * FROM kna1 INTO CORRESPONDING FIELDS OF TABLE tbl_kna1 UP TO 30 ROWS. ENDFORM. " get_data *&---------------------------------------------------------------------* *& Form do_fancy_stuff *&---------------------------------------------------------------------* * Do some fancy pants stuff for example changing the color of * lines and adding icons *----------------------------------------------------------------------* FORM do_fancy_stuff.
* Here we will demonstrate changing the color of ALV Record lines as * well as displaying Icons LOOP AT tbl_kna1. * All records where NAME1 begins with 'M', will be displayed in Bluish * Green IF tbl_kna1-name1(1) EQ 'M'. tbl_kna1-color = 'C41'. "Bluish Green MODIFY tbl_kna1 TRANSPORTING color. ENDIF. * All records with no TELF1 will be displayed in White and have a * Warning Icon IF tbl_kna1-telf1 IS INITIAL. tbl_kna1-color = 'C00'. "White tbl_kna1-icon = '@AH@'. "Warning Icon MODIFY tbl_kna1 TRANSPORTING icon color. ENDIF. ENDLOOP. ENDFORM. " do_fancy_stuff
Logo should be uploaded into application server using transaction 'OAER'. 1. Go to Transaction OAER,
2. Give Class Name as PICTURES 3. Class type as OT 4. Object Key is the name you want to search or you want to upload. 5. Then select the Document from below after double click on it .Choose in screen for logos. 6. Upon execution you would be prompted to give the file path details. Just upload which ever logo u want to display 7. Now you can use the same name in your ALV FM. In your ALV program, you need to have event for TOP_OF_PAGE, and also this works only in case of Grid not in ALV LIST.
**********************
call function 'REUSE_ALV_GRID_DISPLAY' exporting i_callback_program = i_repid it_fieldcat = header is_layout = gt_layout i_callback_top_of_page = 'TOP-OF-PAGE1' i_grid_title = xyz it_sort = gt_sort[] i_default = 'X' i_save = 'U' is_variant = gt_variant
*****************
*-------------------------------------------------------------------*
* Form TOP-OF-PAGE1
*-------------------------------------------------------------------*
form top-of-page1.
* TITLE AREA
wa-typ = 'S'. concatenate text-h02 sy-uname into wa-info separated by space. append wa to header.
wa-typ = 'S'. concatenate text-h01 sy-repid into wa-info separated by space. append wa to header.
********" LOGO
exporting
it_list_commentary = header
i_logo = 'ENJOYSAP_LOGO'.
*********" LOGO
endform.
Here in TOP-OF-PAGE form it will show you the Prog name,Date, User Name
o
Have you solved your issue regarding the employee picture? I'm having exactly the same problem.
As far as I found out during my Internet and SDN research is, that the picture of TCODE OAAD cannot be printed in SmartForm directly. SmartForm can only read graphics from the 'Graphics store' using SE78.
As we also store our employee picture using OAAD, we will run the following steps to include the picture into the SmartForm (The following steps are done during printing): 1. Get image document id with function 'HR_IMAGE_EXISTS' 2. Read the image in JPG format using function 'ALINK_RFC_TABLE_GET' 3. Convert the image from JPG to BMP (this is done by calling a VisualBasic.NET command line function returning the image in BMP format (l_bitmap(255) type x)) 4. Convert the BMP into BDS with 'SAPSCRIPT_CONVERT_BITMAP_BDS' 5. Store the BDS with method 'l_bds_object->create_with_table' and the employee number is being used as ID Note: step 4 and 5 are copied out of 'IMPORT_BITMAP_BDS' of main program 'SAPLSTXBITMAPS' 6. Use 'dynamic' bitmap in SmartForm as described in Adding images dynamically to SAPScript
We have tested the steps individually and it seems to work. However, the program hasn't been completed yet. Nevertheless, we expect this to work, even if it is not efficient from a performance point of view. Hence, my question: is it possible to print a BMP (stored in a ABAP table) directly in the SmartForm without having to store it in the 'Graphics storage' SE78?
Report Abuse
Like (0)
Report Abuse
Re: Employee Picture Upload in SmartForm
Like (0)
Report Abuse
Like (0)
Jens Guntenhner Aug 21, 2008 2:28 PM (in response to Herbert Stckl)
Did you found a solution for the problem?
Report Abuse
Like (0)
Report Abuse
Like (0)
balakumar ganesan Sep 11, 2007 11:40 AM (in response to Adrian Buenter)
Hi Adrian ,
The steps u Provided to Display Employee Picture in Smartforms seems to be helpful.I need a Clarification explain me about the Visual Basic.Net Command Line conversion.What is that ?Is that requires some sort of software need to be installed,if so Could u Pls explain the step involved in CONVERSION... waiting for ur reply.
Thank You,
G.Balakumar.
Report Abuse
Like (0)
Jen Barber Jan 23, 2008 12:15 PM (in response to Adrian Buenter)
Did anyone solve this problem? I can't read the image using ALINK_RFC_TABLE_GET, is there any other module function? Thank you very much.
Jen
Report Abuse
Like (0)
Bhaskar Pani Kakanur Jan 4, 2006 2:17 PM (in response to Sachin Shirke)
Hi Sachin,
Can you please help Jennie regarding Archiveline with Smartform. He asked a similar question like this. Please go thru the link: Formatting an excel
Thanks, Bhaskar.
Report Abuse
o
Re: Employee Picture Upload in SmartForm
Like (0)
Elena Millan Sep 28, 2007 2:50 PM (in response to Sachin Shirke)
Hello, Did anyone find a solution? I have the same problem. My program follows similar steps as described by Adrian Buenter, but I don't know how to perform step 3
"Convert the image from JPG to BMP (this is done by calling a VisualBasic.NET command line function returning the image in BMP format (l_bitmap(255) type x))"
Elena.
Report Abuse
o
Re: Employee Picture Upload in SmartForm
Like (0)
Lai Min Sam Dec 11, 2007 9:08 AM (in response to Sachin Shirke)
Hi...anyone has the solution of this?
Report Abuse
o
Re: Employee Picture Upload in SmartForm
Like (0)
Nitesh Jain Dec 26, 2007 10:22 AM (in response to Sachin Shirke)
Dear all,
In ECC 5.0 onwards there is a new form builder which can be accessed using transaction SFP.
Does anyone know whether we can directly use the SAP link of Employee photo in forms developed using this new tool??
Cheers Nitesh
Step 2)Modify the file extension of the picture from ".jpg" etc. to ".html"(any of the allowed MIME types from the previous step).
Step 3)Upload a picture through transaction SMW0 by creating a new "Z" object (you can save it in a transport if you want):
Step 4) Create a program as shown below with a Screen 0100, PF-STATUS "S0100" and Custom Container "CONT" . This program can be used to display any of the pictures uploaded through SMW0.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
*&---------------------------------------------------------------------* *& Report ZTEST_PICTURE *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT ztest_picture. TYPE-POOLS: cndp. DATA: ok_code TYPE syucomm, container TYPE REF TO cl_gui_custom_container, picture TYPE REF TO cl_gui_picture, url TYPE cndp_url. PARAMETERS: p_objid TYPE w3objid OBLIGATORY. AT SELECTION-SCREEN. SELECT COUNT(*) FROM wwwparams WHERE objid = p_objid. IF sy-subrc <> 0. MESSAGE e001(00) WITH 'MIME Object not found'. ENDIF. START-OF-SELECTION. IF container IS INITIAL.
31 CREATE OBJECT container 32 EXPORTING 33 container_name = 'CONT' 34 repid = 'ZTEST_PICTURE' 35 dynnr = '0100' 36 EXCEPTIONS 37 cntl_error = 1 38 cntl_system_error = 2 39 create_error = 3 40 lifetime_error = 4 41 lifetime_dynpro_dynpro_link = 5 42 OTHERS = 6. 43 IF sy-subrc <> 0. 44 MESSAGE i001(00) WITH 'Error while creating container'. 45 LEAVE LIST-PROCESSING. 46 ENDIF. 47 ENDIF. 48 IF picture IS INITIAL. 49 CREATE OBJECT picture 50 EXPORTING 51 parent = container 52 EXCEPTIONS 53 error = 1 54 OTHERS = 2. 55 IF sy-subrc <> 0. 56 MESSAGE i001(00) WITH 'Error while displaying picture'. 57 LEAVE LIST-PROCESSING. 58 ENDIF. 59 ENDIF. 60 IF picture IS NOT INITIAL. 61 62 CALL FUNCTION 'DP_PUBLISH_WWW_URL' 63 EXPORTING 64 objid = p_objid 65 lifetime = cndp_lifetime_transaction 66 IMPORTING 67 url = url 68 EXCEPTIONS 69 OTHERS = 1. 70 71 IF sy-subrc = 0. 72 CALL METHOD picture->load_picture_from_url_async 73 EXPORTING 74 url = url. 75 76 CALL METHOD picture->set_display_mode 77 EXPORTING 78 display_mode = cl_gui_picture=>display_mode_fit. 79 ELSE. 80 MESSAGE i001(00) WITH 'Error while load picture'. 81 LEAVE LIST-PROCESSING. 82 ENDIF. 83 ENDIF. 84 85 CALL SCREEN 0100. 86 *&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE status_0100 OUTPUT. SET PF-STATUS 'S0100'. * SET TITLEBAR 'xxx'. ENDMODULE. " STATUS_0100 OUTPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE user_command_0100 INPUT. CASE ok_code. WHEN 'BACK'. SET SCREEN 00. LEAVE SCREEN. ENDCASE. ENDMODULE. " USER_COMMAND_0100 INPUT
Test it :
I would like to explain about a simple report program to display graphics. The SAP Graphics can be used for various business purposes. In this article I am explaining about a simple Sales analysis on a yearly basis. *&---------------------------------------------------------------------* *& Report ZGRAPH_TEST *& *&---------------------------------------------------------------------* REPORT ZGRAPH_TEST. DATA: BEGIN OF TAB OCCURS 5, CLASS(5) TYPE C, VAL1(2) TYPE I, VAL2(2) TYPE I, VAL3(2) TYPE I, END OF TAB. DATA: BEGIN OF OPTTAB OCCURS 1, C(20), END OF OPTTAB. MOVE: 'fan' TO TAB-CLASS, 12 TO TAB-VAL1, 8 TO TAB-VAL2, 15 TO TAB-VAL3. APPEND TAB. CLEAR TAB. MOVE: 'cool' TO TAB-CLASS, 15 TO TAB-VAL1, 10 TO TAB-VAL2, 18 TO TAB-VAL3. APPEND TAB.
CLEAR TAB. MOVE: 'DA' TO TAB-CLASS, 17 TO TAB-VAL1, 11 TO TAB-VAL2, 20 TO TAB-VAL3. APPEND TAB. CLEAR TAB. OPTTAB = 'FIFRST = 3D'. APPEND OPTTAB. "// Grafik-Typ OPTTAB = 'P3TYPE = TO'. APPEND OPTTAB. "// Objektart OPTTAB = 'P3CTYP = RO'. APPEND OPTTAB. "// Farben der Objekte OPTTAB = 'TISIZE = 2'. APPEND OPTTAB. "// Haupttitelgre OPTTAB = 'CLBACK = X'. APPEND OPTTAB. "// Background Color CALL FUNCTION 'GRAPH_MATRIX_3D' EXPORTING COL1 = '1997' COL2 = '1998' COL3 = '1999' DIM2 = 'Products' DIM1 = 'Years' TITL = 'Sales In Rs. Crores' TABLES DATA = TAB OPTS = OPTTAB EXCEPTIONS OTHERS = 1. LEAVE PROGRAM. Results : Execute the report program for an output shown below.