cancel
Showing results for 
Search instead for 
Did you mean: 

Smartform FM in Loop.. endloop

Former Member
0 Kudos

Hello All,

I have a smartform, and in the print program i have included the SF FM in loop ...end loop.

Now the problm is that if the loop passes for 5 times i am getting the print preview dialog box for 5 times.. but i want that print preview dialog box only once.. how can we acheive that.

i know it is not a good idea to put hte SF FM in loop,... but i have no option for my req... so i had gone with that loop .. endlop..

please help me with a quick solution

Thanks in Advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi

why is not good idea? it's not true

All u need to do is just to open/close the spool once and show the dialog at the beginning.

That means after the first calling u need to transfer the same print data to the following calls:

DESCRIBE TABLE ITAB LINES TOT_LINES.

LOOP AT ITAB.
   IF SY-TABIX = 1.
* Dialog at first loop only
      CONTROL_PARAMETERS-NO_DIALOG = SPACE.
* Open the spool at the first loop only:
      CONTROL_PARAMETERS-NO_OPEN     = SPACE
* Close spool at the last loop only
      CONTROL_PARAMETERS-NO_CLOSE   = 'X'.
   ELSE.
* Dialog at first loop only
      CONTROL_PARAMETERS-NO_DIALOG = 'X'.
* Open the spool at the first loop only:
      CONTROL_PARAMETERS-NO_OPEN     = 'X'.
   ENDIF.

   IF SY-TABIX = TOT_LINES.
* Close spool
      CONTROL_PARAMETERS-NO_CLOSE   = SPACE.
   ENDIF.

    CALL FUNCTION <SMARTFORM
      EXPORTING
        CONTROL_PARAMETERS = CONTROL_PARAMETERS 
        OUTPUT_OPTIONS            = OUTPUT_OPTIONS
        ........................
      IMPORTING
         JOB_OUTPUT_OPTIONS   = JOB_OUTPUT_OPTIONS
        ........................

*  the same output options for all:
  MOVE-CORRESPONDING JOB_OUTPUT_OPTIONS TO  OUTPUT_OPTIONS.
ENDLOOP.

Max

Former Member
0 Kudos

Excelent Max, it works perfect. Thank you.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

When you are calling the smartform FM,

there is one parameter

CONTROL_PARAMETERS.

Inside that there is one field NO_DIALOG

Just make this as 'X',

when you call the FM 2nd time and onwards.

regards,

amit m.

guilherme_frisoni
Contributor
0 Kudos

Hi,

using no dialog, you can achieve this, but it will generate 5 spools.

You can also use NO_OPEN and NO_CLOSE from CONTROL_PARAMETERS.

like this:


LOOP...
MOVE 'X' TO CONTROL_PARAMETERS-NO_OPEN.
MOVE 'X' TO CONTROL_PARAMETERS-NO_CLOSE.
AT FIRST.
CLEAR CONTROL_PARAMETERS-NO_OPEN.
ENDAT.

Call Smartform...

AT LAST.
CLEAR CONTROL_PARAMETERS-NO_CLOSE.
ENDAT.
ENDLOOP.

Regards,

Frisoni