Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
dvkumar17
Explorer
0 Kudos
Dear All,

This is my first blog in this series.

In this blog post you will learn how to make a basic Module Pool program using custom container to display image of employee from PA30.

Module pool programming is a special type of programming which is used to create custom SAP screens.

We will first upload the image for the employee on the SAP Server using the transaction OAAD. The name of the image we upload is APPLE and is in black and white (the supported formats are .jpg and .png).

Transaction code for creating module pool program is SE80.

Below is the required configuration in the SAP system:-

  1. Using SM30 with table T588J click on maintain


       


      2.Add the below highlighted entry if does not exist in your system and save it in your transport

or local object as per your convenience.

      


     3.Upload the image as per the below using transaction OAAD.Click on Store and Assign

 

      


      4.Create as per the provided business object & document type and provide the employee no

and it will pop up to select the photo for the employee

      


 

       


  5. Photo uploaded for the employee No 4180


 

6.Now we are going to get the photo into the module pool custom container.Below are the code

for the same.
*&---------------------------------------------------------------------*
*& Report ZHR_EMPLOYEE_IMAGE_DISPLAY
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zhr_employee_image_display.

"To display employee photo from PA30 to module pool custom container

***Variable Declaration
DATA : handle TYPE i,
p_exists TYPE c,
p_connect_info LIKE toav0,
gv_initialize TYPE flag,
p_pernr TYPE pa0001-pernr.

START-OF-SELECTION.
"Screen with custom Container
CALL SCREEN 100.

*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.

ENDMODULE.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'ENTER' OR ' '.
IF p_pernr IS NOT INITIAL.
"Variable Clear
CLEAR: p_exists, p_connect_info.", handle.
"Below funtion module to check if the photo exists for the employee
CALL FUNCTION 'HR_IMAGE_EXISTS'
EXPORTING
p_pernr = p_pernr
p_tclas = 'A'
p_begda = '19100101'
p_endda = '99991231'
IMPORTING
p_exists = p_exists
p_connect_info = p_connect_info
EXCEPTIONS
error_connectiontable = 1
OTHERS = 2.
IF sy-subrc <> 0.
gv_initialize = abap_false.
"Below function module to display the blank in the screen if no photo exists for the employee
CALL FUNCTION 'HR_IMAGE_SHOW'
EXPORTING
p_pernr = p_pernr
p_tclas = 'A'
handle = handle
EXCEPTIONS
invalid_handle = 1
no_document = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
"Below function module to reset the image in the screen
CALL FUNCTION 'HR_IMAGE_RESET'
EXPORTING
handle = handle
EXCEPTIONS
invalid_handle = 1
OTHERS = 2.
ENDIF.
ELSE.
IF gv_initialize = abap_false.
"Below function module to initialize the custom container to displaye the photo for the employee
CALL FUNCTION 'HR_IMAGE_INIT'
EXPORTING
p_pernr = p_pernr
p_tclas = 'A'
container = 'IMAGE'
IMPORTING
handle = handle
EXCEPTIONS
no_document = 1
internal_error = 2
OTHERS = 3.
IF sy-subrc IS INITIAL.
gv_initialize = abap_true.
"Below function module to display the photo in the screen if photo exists for the employee
CALL FUNCTION 'HR_IMAGE_SHOW'
EXPORTING
p_pernr = p_pernr
p_tclas = 'A'
handle = handle
EXCEPTIONS
invalid_handle = 1
no_document = 2
internal_error = 3
OTHERS = 4.
ENDIF.
ELSE.
CALL FUNCTION 'HR_IMAGE_SHOW'
EXPORTING
p_pernr = p_pernr
p_tclas = 'A'
handle = handle
EXCEPTIONS
invalid_handle = 1
no_document = 2
internal_error = 3
OTHERS = 4.
ENDIF. " SY-SUBRC IS INITIAL.
ENDIF.
ENDIF.
ENDCASE.
ENDMODULE.

PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.

Screen 0100:-

In the screen 100 click on highlighted layout to open screen painter


 

In the screen painter as shown below click on Dictionary/Program fields to get the program fields to copy into the screen


Now we have added the employee no(P_PERNR) from the program to screen


We have added the custom container in the name of IMAGE into the screen and also added Text filed as Employee Photo


Create transaction ZPA30 using transaction SE93 as shown below



Finally executing the report using transaction ZPA30 to display the image into custom container

 



By following the steps you will be able to create basic Module Pool Program to display image of the employee. I hope this blog helps you to achieve your business requirement.

As we continue to learn more in this series about Module Pool Programming I will use this blog post to link all the parts of this series.

Follow my account dvkumar17 to be notified of the next blog post. Please feel free to ask any questions you have in the comments section below.

Join the conversation about the ABAP programming by following the tag ABAP Development

Post questions and answer related to tag by following the tag Questions & Answers

Read other blog post on topic ABAP Development