cancel
Showing results for 
Search instead for 
Did you mean: 

Logic in Smartform: Please help

Former Member
0 Kudos

Hi All,

I have a requirement to print a form and Ive chosen to use smartforms but I dont know how to implement it.

I'll be passing a table to the smartforms but the requirement is to print one form for each line item in the table. So if there are 4 line items in the table, there will be 4 identical forms generated with different values.

How do I go about this?

Please help.

Thanks.

Tyken

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can call the smartform in a loop for Total Number of items times. So now u can pass only single line to the smartform each time.

awrd points if useful

Bhupal

Former Member
0 Kudos

thanks for the reply guys.

if i call the smartform within a loop at itab, will all the forms display once. say if i have 10 line items, will it display 10 pages of identical forms? or will it display one form at a time?

thanks.

Former Member
0 Kudos

Hi,

Following are some poin ts to be copnsidered when you print miltiple forms at a time.

1) when you give for printing theys should be in one spool because when you give for direct printing they may appear in different spools

2) when you see the print preview they should appear one below the other

In print preview you cant see all at a time . like If you give it for print priview first it will display first form and when you go on pressing back button it will display one by one . To avoid this write the following code.

DESCRIBE TABLE it_mdocm LINES v_lines.

LOOP AT it_mdocm INTO wa_mdocm.

IF sy-tabix EQ 1.

wa_ssfctrl-no_open = space.

wa_ssfctrl-no_close = c_x.

ELSEIF sy-tabix EQ v_lines.

wa_ssfctrl-no_open = c_x.

wa_ssfctrl-no_close = space.

ELSE.

wa_ssfctrl-no_open = c_x.

wa_ssfctrl-no_close = c_x.

ENDIF.

IF p_pv = c_x.

wa_ssfctrl-preview = c_x. " printpreview required ( I think this you dont need)

ENDIF.

wa_ssfctrl-device = 'PRINTER'. " Device

wa_ssfctrl-no_dialog = c_x. " Dialog

wa_ssfctrl-langu = sy-langu. " langauage

CALL FUNCTION v_func_mod_name

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

control_parameters = wa_ssfctrl

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

output_options = x_output_options

user_settings = space

mdocm = wa_mdocm-mdocm

point = wa_mdocm-point

  • IMPORTING

  • DOCUMENT_OUTPUT_INFO =

  • JOB_OUTPUT_INFO =

  • 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.

endloop.

Reward points if useful.

Regards,

Nageswar

Former Member
0 Kudos

Hi,

Yes if u select Print preview option the 10 forms will be displayed 10 time one at a time.

If u want them diretcly printed wiothout a print preview then the 10 can be printed at a time. This can be done by setting the print parameters before the loop.

awrd points if helpful

Bhupal

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Firsty... what data are you displaying? is it Sales order data?

Will your line items be unique or will you have mulitple data for same line item?

Firstly take all items in an internal table say it_itab.

Now in your printer program

Loop at it_itab into st_itab.

CAll your smartform here.

Endloop.

Scenario 1 : Unique line item..

In your smartform, in the main window, display this header string by creating a template in your main window

I wuld use a template since your data is fixed.

Scenario 2 :

But in the scenario where you have multiple lines for a single item..then go for a table in your smartform.

Manipulate your data in the printer program to send a table with similar line item number to the smartform and use a table in main window to display this data.

Please let me know if you need more help.

Regards,

Soumya

Former Member
0 Kudos

Hi,

Simply you can put your smartform funciton module with in LOOP AT ITAB...... ENDLOOP. Then you requirement will fulfill.

Thanks,

shyla