Skip to Content
Technical Articles
Author's profile photo Jeevitha Palanisamy

Dynamic logo in smart form using variables


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.
  PARAMETERS p_ebeln TYPE ebeln.

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'.
  ls_data-logo = 'DEMO LOGO 2'.

    formname           = 'ZDEMO_SFM_DYM_LOGO'
    fm_name            = lv_fmname
    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'
    control_parameters = ls_cntl_parm
    output_options     = ls_op_options
    user_settings      = 'X'
    e_structure        = ls_data
    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.



  • Demo output 1 Document date is lesser than 30.01.2021.

  • Demo output 2 Document date is greater than 30.01.2021.



  • Hope you all know how to achieve a dynamic logo in the smart form now. It will be a pleasure to receive comments from you.
  • Preparing more new topics to connect with you all.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Sandra Rossi
      Sandra Rossi

      Thanks. I guess the goal of this blog post is:

      1. to explain how to print an image in a Smart Form,
      2. to explain how to make the image name come from a variable in order to avoid defining one Condition Node and two Graphic nodes (or more),

      assuming that people are familiar with defining parameters and copying parameters to Smart Form variables (you didn't say how you go from E_STRUCTURE parameter to GS_DATA variable).

      You missed the important information that the user must click first the below button to switch from constant name to variable name:


      smart form from constant name to variable name

      Author's profile photo Jeevitha Palanisamy
      Jeevitha Palanisamy
      Blog Post Author

      Hello Sandra.

      Thanks for your response. Here the goal of this blog is:

      1. Print image in Smart Form.

      2.Print dynamic logo in Smart Form.

      The points you were suggest are noted. I'll add that to this blog soon.



      Author's profile photo Rob Ariaans
      Rob Ariaans

      Why not just simply make use of the "Conditions" tab in the smartform graphics window? What is the added value / benefit of coding this in the print program?

      Author's profile photo Jeevitha Palanisamy
      Jeevitha Palanisamy
      Blog Post Author

      Hi Rob.

      Thanks for your response.

      Obviously, we can go for the "Condition" tab in Smart form. There's nothing gone wrong. It's another method where we can set the logo name inside the structure. If you are familiar with Smartform "Condition" tab is the best thing.




      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      In Conditions, you have to specify, well, conditions. 🙂 You'd have to put a condition like "if X, then print Logo1, else print Logo2". When you have 99 logos this approach is obviously not sustainable.

      When name is in the variable, then you have full power of ABAP (within form limitations, of course) to set the variable value however you like.

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Thanks for sharing! Sandra Rossi already commented on that, so just to add more information. I was confused by "create a dynamic logo... through program" part, was almost expecting a program that calls up DALL-E or some AI to generate the image. 🙂 The logo images here are static though and we just determine which one to use by storing the name in a variable.

      And "SE38 program" is "ABAP report". SE38 is just one of the transactions where such reports can be managed from. Most developers will probably understand what you mean but some might be confused. We can create an ABAP report in Eclipse ADT these days, SE38 doesn't have a monopoly here. 🙂

      I would adjust the title to make it more clear. Maybe something like "How to use variables in Smart Forms to determine graphics name dynamically"? Something to reflect better what this post is about. Just a suggestion.

      Thank you.

      Author's profile photo Sandra Rossi
      Sandra Rossi

      "How to use variables in Smart Forms to determine graphics name dynamically"

      Very good title indeed!

      Author's profile photo Jeevitha Palanisamy
      Jeevitha Palanisamy
      Blog Post Author

      Hi Jalena.

      Thanks for your response. The title you gave is a suitable one. But I consider users will not try to search "Determine graphics name using variables" or ''Smart form graphics dynamically changed by variables" at all. That's why I gave this title. But I will change the 'SE38 Program' to 'ABAP Report'. Once again Thanks for your valuable response.