cancel
Showing results for 
Search instead for 
Did you mean: 

New-page for smartform

Former Member
0 Kudos

Hello all,

I am facing a problem using smartforms. I am printing a report where there is a loop running for a list of plants. For printing the information of each plant, I need to use a new page. Information of one plant may take several pages but for every new plant, I need to insert a page break.

I am using a COMMAND with a checked next page option in my EVENT ON SORT BEGIN for the plant code.

This does the trick, but if I use the command at the bottom, it inserts a blank page at the end of the report. If I use the command at the top of the event, it first shows a blank page and then the data from the 2nd page.

Please sugest how can I fix this.

Anmol

Accepted Solutions (1)

Accepted Solutions (1)

former_member196280
Active Contributor
0 Kudos

try to palce a program lines and read number of lines in your internal table and increment a variable and place condition..

For example, total lines in internal table is 10,

if increment < 10

****new page

Endif.

Regards,

Sairam

Former Member
0 Kudos

Well, for every plant there is a lot of data being displayed..which includes some material details and their totals based on some grouping conditions. so I cannot find out the number of lines..

my other question is, how do i code the new-page command within an if-endif in smartforms?

former_member196280
Active Contributor
0 Kudos

You cannot use if in your text you can place your conditions.

Note:For page-break you have to Create a Node Called COMMAND. Here you can Specify a Different PAGE as next page if u want.

Close the thread if your question is answered.

Regards,

Sairam

Answers (4)

Answers (4)

Former Member
0 Kudos

It was a complex scenario so I had to use several check conditions, COMMANDs and alternatives to meet all requirements. Thanks for the suggestions, they were helpful.

Former Member
0 Kudos

Hai anmol,

U can trigger a new page for every new plant, do follow below steps

first u create a local vriable in global definitions for plant .

and in initialization of global data read first record of internal table, and assign the local variable to that record's plant.

then at last , ie with in the loop after all the data display, create one program lines and in that write local variable = present record' plant.

and in the loop starting create a command, and put a condition

if local variable ne workarea-plant, goto new page.

In this the logic is first we are putting first rcords plant in local variable and every time we are updating in the loop with current record's plant, if it is same printing continue, otherwise if it is a new plant it starts a new page.

i hope this solves ur problem.

Former Member
0 Kudos

Hi Friend,

You can use following tips for generating smartforms for every new plant.I have generated sales order report using this steps.You can refer it.Tips are given below:

1.Define the structure,workarea and internal table for sales order header and details and also define

select-options for sales order.

2.Also define the one STRUCTURE which has type as ssfctrlop.

e.g. control type ssfctrlop.

This variable we have to define because we are going to use this in

SSF_OPEN function.This is used to avoid print preview while openning smartform

for every sales order.

3. Select data from vbak for sales header.

4. Call function SSF_FUNCTION_MODULE_NAME.

e.g.*CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = w_formname

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

fm_name = w_functionname

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

5.Now here define the various features or field in control structure.

This is controls for smartform.

e.g. control-no_dialog = 'X'.

control-preview = 'X'.

control-no_open = 'X'.

control-no_close = 'X'.

6. Call function SSF_OPEN.

Here you have to pass the control structure which you have define in declaration.

e.g.

CALL FUNCTION 'SSF_OPEN'

EXPORTING

  • ARCHIVE_PARAMETERS =

  • USER_SETTINGS = 'X'

  • MAIL_SENDER =

  • MAIL_RECIPIENT =

  • MAIL_APPL_OBJ =

  • OUTPUT_OPTIONS =

control_parameters = control

  • IMPORTING

  • JOB_OUTPUT_OPTIONS =

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

7. Take loop at header internal table .

8. Select data from vbak for sales details. Also select data from respective tables

like makt,kna1 here.

9.Then call function module which generated after executing smartform. And also pass the control structure

in import parameter in this function module.

e.g. CALL FUNCTION '/1BCDWB/SF00000397'

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

control_parameters = control

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

  • OUTPUT_OPTIONS =

  • USER_SETTINGS = 'X'

wa_vbak = wa_vbak

  • IMPORTING

  • DOCUMENT_OUTPUT_INFO =

  • JOB_OUTPUT_INFO =

  • JOB_OUTPUT_OPTIONS =

TABLES

it_vbak = it_vbak

it_vbap = it_vbap

  • EXCEPTIONS

  • FORMATTING_ERROR = 1

  • INTERNAL_ERROR = 2

  • SEND_ERROR = 3

  • USER_CANCELED = 4

  • OTHERS = 5

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

10.After endloop call function SSF_CLOSE.

If it will help you reward me points.

Regards,

Santosh.

Former Member
0 Kudos

Hi ,

the first soution given by Sai ram reddy works fine. eventhough if u cannot use it in the same way, use the idea in different way. If u give a clear picture of ur internal table, we can give u a right solution.

the answer to ur next question is:

1. u can use command node in an altenative node. if the condition in alternative is met 'true' node will get executed otherwise 'false' node will be executed. place command node in either of the nodes according to ur requirement.

2. no need to use alternative node. in the command node itself there is a conditions tab. In that u cn define ur condition like increment < rows .

regards,

Ravi.