Introduction
Dealing with logos is always a big deal in Smart form. This blog shows how to generate a Smart form with a dynamic logo in SE38. The objective is by using the parameter values set dynamic logo in the report program.
Requirement: Pass Purchase document number (EBELN) as input parameter and fetch Document date (BEDAT). If the Purchase document date is lower than require date then, print the First logo. Else print the Second logo.
◉ Upload logos in the Graphic library using T-code SE78.
◉ Demo Logo 1
◉ Demo Logo 2
◉ The below structure is a source of this object. Create a Smart form using the below structure and save it in a local object.
◉ Creating a program in Abap editor using T-code SE38. Save it in a local object.
◉ Write below code to call smart form through report. In this code, logo name changed based on the condition.
SELECTION-SCREEN BEGIN OF BLOCK b1.
PARAMETERS p_ebeln TYPE ebeln.
SELECTION-SCREEN END OF BLOCK b1.
DATA: ls_data TYPE zdemo_str_dym_logo,
lv_fmname TYPE rs38l_fnam,
ls_cntl_parm TYPE ssfctrlop,
ls_op_options TYPE ssfcompop,
lv_date TYPE sydatum.
SELECT SINGLE ebeln, bedat
FROM ekko
INTO @ls_data
WHERE ebeln = @p_ebeln.
IF ls_data-doc_date <= '20210131'.
ls_data-logo = 'DEMO LOGO 1'.
ELSE.
ls_data-logo = 'DEMO LOGO 2'.
ENDIF.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZDEMO_SFM_DYM_LOGO'
IMPORTING
fm_name = lv_fmname
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
ls_cntl_parm-langu = 'EN'.
ls_cntl_parm-preview = space.
ls_cntl_parm-no_dialog = abap_true.
ls_op_options-tddest = 'LP01'.
ls_op_options-tdnewid = abap_true.
ls_op_options-tdimmed = abap_true.
ls_op_options-tddelete = space.
CALL FUNCTION lv_fmname "'/1BCDWB/SF00000086'
EXPORTING
control_parameters = ls_cntl_parm
output_options = ls_op_options
user_settings = 'X'
e_structure = ls_data
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
◉ In smart form create a window. Inside the window create a Graphic.
◉ Make sure to change the name field to a dynamic field by clicking the icon. Otherwise, it wouldn’t fetch runtime values.
◉ Inside the graphic window fill the name, object, and Id of images as shown below.
◉ Get the above details in t-code SE78 as shown below.
Output
◉ Demo output 1 Document date is lesser than 30.01.2021.
◉ Demo output 2 Document date is greater than 30.01.2021.
No comments:
Post a Comment