Application Development and Automation 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: 
Read only

Dynamic logo in smartforms based on internal table values.

Jay_Kamdar
Participant
0 Likes
9,136

Hello experts,

I am new to smartforms.

I have a requirement where i have to print smartforms equal to the no. of records in the internal table which will be passed from a driver program;

and the logo which will be displayed in the form will change according to the data in the internal table.

For example :

if there are 4 records in the internal table it_final :

Vinnr
modeldealer
WV12345abcabc
WA12345abcabc
TM12345abcabc
WV12345abcabc

The logo will be different for first 3 records and the same for 4th and 1st one .

there will be a condition like :

LOOP AT it_final INTO wa_final.

if wa_final-vinnr cp 'WV*'.

  logo = 'V_W'.

  ELSEIF wa_final-vinnr cp 'TM*'.

  logo = 'VW_SK_LOGO'.

  ELSEIF wa_final-vinnr cp 'WA*'.

  logo = 'VW_A_LOGO'.

  endif.

ENDLOOP.

is it possible ?

if yes then how ?

Where to put this condition ?

1 ACCEPTED SOLUTION
Read only

rosenberg_eitan
Active Contributor
0 Likes
5,612

Hi ,

May I suggest that you do your business logic in your print program .

call the form in a loop and pass individual records and the logo name to be used.

Regards.

Eitan.

Some "code" (Every thing in your print program) .

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

CALL FUNCTION 'SSF_OPEN'

LOOP AT it_final INTO wa_final.

* find out what logo to use for given record .

if wa_final-vinnr cp 'WV*'.

  logo = 'V_W'.

  ELSEIF wa_final-vinnr cp 'TM*'.

  logo = 'VW_SK_LOGO'.

  ELSEIF wa_final-vinnr cp 'WA*'.

  logo = 'VW_A_LOGO'.

  endif.

 

CALL FUNCTION fm_name

    EXPORTING

      control_parameters   = st_control_parameters

      output_options       = st_output_options

      user_settings        = abap_false

      wa_final = wa_final

      logo     = logo .

           

ENDLOOP.

CALL FUNCTION 'SSF_CLOSE'

15 REPLIES 15
Read only

former_member209120
Active Contributor
0 Likes
5,612

Hi Jay,

Create Variable name as  logo  in global definition like this

AND DO LIKE THIS

WRITE CODE LIKE THIS

Before that you should upload logos with this name in sap

V_W

VW_SK_LOGO

VW_A_LOGO

Read only

0 Likes
5,612

Thanks .

it has been solved to some extent.

But if there are multiple records in the internal table then variable logo takes the latest value .

The requirement states that after printing the first record of it_final the logo should change for the second record to be printed depending on the condition.

Read only

bastinvinoth
Contributor
0 Likes
5,612

Hi Jay Kamdar

See the below youtube video for STEP by STEP approach

http://www.youtube.com/watch?v=-GQ9daLVmbw

Read only

soumik_de2
Participant
0 Likes
5,612

HI jay ,

               Please follow the attached smartforms and ........... in program logic do your desired logic.

       like ...................

LOOP AT it_final INTO wa_final.

if wa_final-vinnr cp 'WV*'.

  logo = 'V_W'.

  ELSEIF wa_final-vinnr cp 'TM*'.

  logo = 'VW_SK_LOGO'.

  ELSEIF wa_final-vinnr cp 'WA*'.

  logo = 'VW_A_LOGO'.

  endif.

ENDLOOP.

and please don't forget to upload all logos into sap system (SE78).......

Enjoy.....................

Read only

0 Likes
5,611

unable to view it .

Read only

0 Likes
5,611

just  download the xml file from here and create one demo from       then follow the path

UTILITIES-> upload  ..............

it will ask for file name browse the directory and give the xml file path ............... 

Read only

Former Member
0 Likes
5,611

The condition must be given in the smartform.

In the logo window, add all the logos as graphic nodes and put a condition for each logo.

Only the logo corresponding to the value will be displayed in the form.

Give the field name wa_final-vinnr

For the comparison operator you can give the wild card pattern *

And value 'WV', 'TV' etc.

Read only

0 Likes
5,611

Thanks i tried your approach ,

but 2 logo's are being printed on the same form even if the condition is not met.

and if there are 3 different records in the internal table then 3 logo's are being printed.

Read only

0 Likes
5,611

You need the logo for each row in the table within the same form right?

So you will be having the logo as a column in the table right?

Did you give all the logo as graphic nodes under this column with the condition?

Let me know if I have understood it correctly.

Read only

rosenberg_eitan
Active Contributor
0 Likes
5,613

Hi ,

May I suggest that you do your business logic in your print program .

call the form in a loop and pass individual records and the logo name to be used.

Regards.

Eitan.

Some "code" (Every thing in your print program) .

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

CALL FUNCTION 'SSF_OPEN'

LOOP AT it_final INTO wa_final.

* find out what logo to use for given record .

if wa_final-vinnr cp 'WV*'.

  logo = 'V_W'.

  ELSEIF wa_final-vinnr cp 'TM*'.

  logo = 'VW_SK_LOGO'.

  ELSEIF wa_final-vinnr cp 'WA*'.

  logo = 'VW_A_LOGO'.

  endif.

 

CALL FUNCTION fm_name

    EXPORTING

      control_parameters   = st_control_parameters

      output_options       = st_output_options

      user_settings        = abap_false

      wa_final = wa_final

      logo     = logo .

           

ENDLOOP.

CALL FUNCTION 'SSF_CLOSE'

Read only

0 Likes
5,611

Thanks .

Solved

but i used the logic without ssf_open and ssf_close

will it harm ?

Read only

0 Likes
5,611

Hi ,

In such situation I always use ssf_open and ssf_close this way I have more control over the process .

Do some testing and if you are happy with that I guess it is ok.

Regards.

Did you move the logic to your print program ?

I am using ssf_open and ssf_close when I call the form within a loop .

See program SF_EXAMPLE_03

Regards.

Read only

0 Likes
5,611

hello,

Yes i moved it to the driver program .

thanks .

Read only

0 Likes
5,611

Hi,  Very good.  Try always to move the business logic to your print program .
So no debugging is required in the form.
  If you need to create structures use public type in class.


Sample:

See attachment .

class Y_CL_R_EITAN_TEST_02 definition
  public
  final
  create public .

*"* public components of class Y_CL_R_EITAN_TEST_02
*"* do not include other source files here!!!
public section.

  types:
    BEGIN OF tp_airport_x  .
    TYPES: name        TYPE sairport-name ,
           time_zone   TYPE sairport-time_zone .
    TYPES: END OF tp_airport_x .
  types:
    BEGIN OF tp_flat_1 .
            INCLUDE TYPE scarr   AS scarr   RENAMING WITH SUFFIX _scarr .
            INCLUDE TYPE spfli   AS spfli   RENAMING WITH SUFFIX _spfli .
            INCLUDE TYPE sflight AS sflight RENAMING WITH SUFFIX _sflight .
            INCLUDE TYPE sticket AS sticket RENAMING WITH SUFFIX _sticket .
    TYPES: END OF tp_flat_1 .
  types:
    tp_flat_1_tab TYPE STANDARD TABLE OF tp_flat_1 .
  types:
    BEGIN OF tp_sbook_1 .
            INCLUDE TYPE sbook AS sbook RENAMING WITH SUFFIX _sbook .
    TYPES: END OF tp_sbook_1 .
  types:
    tp_sbook_1_tab TYPE STANDARD TABLE OF tp_sbook_1 WITH NON-UNIQUE DEFAULT KEY .
  types:
    BEGIN OF tp_sflight_1 .
            INCLUDE TYPE sflight AS sflight RENAMING WITH SUFFIX _sflight .
    TYPES: it_sbook_1 TYPE tp_sbook_1_tab .
    TYPES: END OF tp_sflight_1 .
  types:
    tp_sflight_1_tab TYPE STANDARD TABLE OF tp_sflight_1 WITH NON-UNIQUE DEFAULT KEY .
  types:
    BEGIN OF tp_spfli_1 .
            INCLUDE TYPE spfli AS spfli RENAMING WITH SUFFIX _spfli .
            INCLUDE TYPE tp_airport_x AS fr_airport RENAMING WITH SUFFIX _fr .
            INCLUDE TYPE tp_airport_x AS to_airport RENAMING WITH SUFFIX _to .
    TYPES: it_sflight_1 TYPE tp_sflight_1_tab .
    TYPES: END OF tp_spfli_1 .
  types:
    tp_spfli_1_tab TYPE STANDARD TABLE OF tp_spfli_1 WITH NON-UNIQUE DEFAULT KEY .
  types:
    BEGIN OF tp_scarr_1.
            INCLUDE TYPE scarr AS scarr RENAMING WITH SUFFIX _scarr .
    TYPES: it_spfli_1 TYPE tp_spfli_1_tab .
    TYPES: END OF tp_scarr_1 .
  types:
    tp_scarr_1_tab TYPE STANDARD TABLE OF tp_scarr_1 WITH NON-UNIQUE DEFAULT KEY .

Read only

0 Likes
5,611

Thanks

Forever Learning