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: 

On uploading a photo identity

Former Member
0 Kudos

hey guys!

firstly thanks for replying to my previous thread. Now i have another scenario where i need to upload employee photo identity in my module pool programming!. Can anyone help me out with the code and step by step by procedure.

Thank You,

Abhishek

1 ACCEPTED SOLUTION

valter_oliveira
Active Contributor
0 Kudos

First of all, create a custom control (container, named PHOTO in my example) in your screen.

Then in your PBO, GET and SHOW the photo of your emplyee:


DATA: handle TYPE i.
DATA: pernr TYPE pernr_d.

CLEAR handle.
pernr = '1234'. "your emplyee number

CALL FUNCTION 'HR_IMAGE_INIT'
  EXPORTING
    p_pernr        = pernr
    p_tclas        = 'A'
    container      = 'PHOTO'
  IMPORTING
    handle         = handle
  EXCEPTIONS
    no_document    = 1
    internal_error = 2
    OTHERS         = 3.

CALL FUNCTION 'HR_IMAGE_SHOW'
  EXPORTING
    p_pernr        = pernr
    p_tclas        = 'A'
    handle         = handle
  EXCEPTIONS
    invalid_handle = 1
    no_document    = 2
    internal_error = 3
  OTHERS         = 4.

If your quey is solved, please close the thread.

Regards,

Valter Oliveira.

11 REPLIES 11

Former Member
0 Kudos

Hi,

u use this FM to geeting photo.

HRXSS_WIW_GET_DETAILS

SSF_FUNCTION_MODULE_NAME

Regards:

Prabu

valter_oliveira
Active Contributor
0 Kudos

First of all, create a custom control (container, named PHOTO in my example) in your screen.

Then in your PBO, GET and SHOW the photo of your emplyee:


DATA: handle TYPE i.
DATA: pernr TYPE pernr_d.

CLEAR handle.
pernr = '1234'. "your emplyee number

CALL FUNCTION 'HR_IMAGE_INIT'
  EXPORTING
    p_pernr        = pernr
    p_tclas        = 'A'
    container      = 'PHOTO'
  IMPORTING
    handle         = handle
  EXCEPTIONS
    no_document    = 1
    internal_error = 2
    OTHERS         = 3.

CALL FUNCTION 'HR_IMAGE_SHOW'
  EXPORTING
    p_pernr        = pernr
    p_tclas        = 'A'
    handle         = handle
  EXCEPTIONS
    invalid_handle = 1
    no_document    = 2
    internal_error = 3
  OTHERS         = 4.

If your quey is solved, please close the thread.

Regards,

Valter Oliveira.

0 Kudos

Hello Valter Oliveira,

Thanks for your reply. But here i need to display the photo of a employee based on pernr. As per your coding, it displays the photo of a particular employee. My requirement is, there are number of employees and when a particular employee logs in, his photo id should be displayed.

Thanks,

Abhishek.

Edited by: abhishek sunkari on Oct 3, 2008 6:16 AM

Edited by: abhishek sunkari on Oct 3, 2008 6:17 AM

0 Kudos

hi.

Yes, the code I've posted before was just an example. I didn't know your requirement! The only thing you have to do is to replace pernr = '1234' by the employee number that is associated to the user that logged in the system.

For that, have a look at FM CATSXT_GET_USER_ID_OF_PERNR or just check table PA0105 (pernr and usrid are in this table).

Regards,

Valter Oliveira.

0 Kudos

Hi Valter Oliveira,

I have got another doubt. I have around 100 employees in my requirement, then in that case, how do i call a particular photo for each employee when that employee logs in?

Is that possible. Please help me out.

Thanks,

Abhishek.

0 Kudos

Hi again.

Doesn't matter how much employees you have in your system. What counts is, when you call your screen, find what is the pernr that is associated with the user that logged in,

So, you can first get pernr like this:


DATA: pernr TYPE persno.
SELECT pernr FROM pa0105 UP TO 1 ROWS
  INTO (pernr)
 WHERE usrty = '0001' "to use secondary index 1
   AND usrid = sy-uname.
  EXIT.
ENDSELECT.

and then call get the image ...


CALL FUNCTION 'HR_IMAGE_INIT'
  EXPORTING
    p_pernr        = pernr
    p_tclas        = 'A'
    container      = 'PHOTO'
  IMPORTING
    handle         = handle
  EXCEPTIONS
    no_document    = 1
    internal_error = 2
    OTHERS         = 3.
 
CALL FUNCTION 'HR_IMAGE_SHOW'
  EXPORTING
    p_pernr        = pernr
    p_tclas        = 'A'
    handle         = handle
  EXCEPTIONS
    invalid_handle = 1
    no_document    = 2
    internal_error = 3
  OTHERS         = 4.

Regards,

Valter Oliveira.

0 Kudos

Hi!

Thanks for the post, my query is solved. Thanks again.

I just wanted to know that, if the my records are not stored in pernr, i have just created dummy entries in my database table that i have created. Then in that case is it possible to upload a photo id for every dummy entry that i have created? Please help me out with the code for better understanding.

Thanks & Regards,

Abhishek.

0 Kudos

I'm not sure If I understood you right. You have a ztable with some dummy employee numbers that you created (not the ones in HR tables), and want to use those in your program, which means, insert it's pictures in your module pool program?

If so, you can do that using tcode SE78 to upload the photos in SAP and then insert it in your program. If it's this, tell me because I can help you in that case too

Regards,

Valter Oliveira.

0 Kudos

hey Valter Oliveira,

Ya you have understood me right. I have created a ztable, where i have created around 20 employees in that, and am using this in my Module pool programming. Now how do i upload their pics into their respective id's, and how's the validation part done?.If it is similar uploading logo in module pool programming. Then in that case how will the particular employee pic will be displayed, because same logo will be displayed for every employee in my transaction.

Thanks,

Abhishek.

0 Kudos

Hello Abhishek

If you want to do that you can follow this steps:

1 - upload those 20 employee photos in MIME repository (nothing to do with HR), giving a proper name like PHOTO_"number of employee".

2 - Since it's not an HR functionallity, you cannot use those HR FM's that I proposed before. Now you have to do like this:

Create a custom container in screen painter (called container)

Data declaration:


DATA: container TYPE REF TO cl_gui_custom_container,
      logo      TYPE REF TO cl_gui_picture.
DATA: url(255) TYPE c.
DATA: query_table LIKE w3query OCCURS 1 WITH HEADER LINE,
      html_table LIKE w3html OCCURS 1,
      return_code LIKE  w3param-ret_code,
      content_type LIKE  w3param-cont_type,
      content_length LIKE  w3param-cont_len,
      pic_data LIKE w3mime OCCURS 0,
      pic_size TYPE i.

Befor calling screen,


CLEAR: container, logo, url.

In PBO of the screen


* Do only once
CHECK url IS INITIAL.

* Inicialize container object
IF container IS INITIAL.
  CREATE OBJECT container
    EXPORTING
      container_name = 'CONTAINER'
    EXCEPTIONS
      OTHERS         = 1.
  IF sy-subrc NE 0.
    EXIT.
  ENDIF.
ENDIF.

* Inicialize logo object, referencing to container object
IF logo IS INITIAL.
  CREATE OBJECT logo
    EXPORTING
      parent = container
    EXCEPTIONS
      OTHERS = 1.
  IF sy-subrc NE 0.
    EXIT.
  ENDIF.
ENDIF.

REFRESH query_table.
query_table-name  = '_OBJECT_ID'.
query_table-value = 'PHOTO_00000012'. "Name of the uploaded image
APPEND query_table.

* GET MIME
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.

* DISPLAY data
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.

CALL METHOD logo->load_picture_from_url
  EXPORTING
    url    = url
  EXCEPTIONS
    OTHERS = 1.

And that's it !!!

Regards,

Valter Oliveira.

Former Member
0 Kudos

Hi Abhishek,

Check out this link.

[http://saptechnical.com/Tutorials/ABAP/image/screen.htm]

Regards,

Amit.