cancel
Showing results for 
Search instead for 
Did you mean: 

SMARTFORM: How to print on document per row in an internal table

Former Member
0 Kudos

Hi.

I have created a SmatForm that is a one-page document to be printed once for every row in an itab I'm sending it via the Table Interface.

I hope I didn't waste my time designing this form but I created several Windows for each section (header, recipient address, summary of coverage, detail coverage information, disclaimer, etc.). I arbitrarily chose the header window as the "main" window (mainly because I couldn't find out what the difference between the different choices was). I've got the form laid out exactly how I want it.

If I test the SmartForm and pass in 2+ records via the test screen only the first one prints.

I thought about trying a LOOP but since you have to place the text within the loop that means all the Windows I have defined won't "get" any of the data.

I thought about looping in the driver ABAP program and just calling the SmartForm once per row but that seems horribly inefficient.

PLEASE HELP! Can I salvage what I've done already?

Accepted Solutions (1)

Accepted Solutions (1)

naimesh_patel
Active Contributor
0 Kudos

As all your windows has different content for each and every page than the simplest solution is: you have to call your smartform in LOOP inside your driver program.

Regards,

Naimesh Patel

Former Member
0 Kudos

I only have one page. The document that is printed is a certificate of coverage (life insurance). That page has multiple windows (header, logo, coverage summary, etc.). Some windows have static text but others have data from that needs to come from the interface (itab, structure,etc.).

Would you still recommend I loop in the driver program? is this a potential performance problem?

Former Member
0 Kudos

I guess the question I should really ask is how should I have designed it to print one document per row in my itab?

naimesh_patel
Active Contributor
0 Kudos

Yes, There might be some impact on performance but you can avoid the complexity. As suggested, you can use the "COMMAND" in the MAIN window to call the same page again. But, to achieve that you need to take a temporary table and every time you need to pass only one record to that so, than MAIN window can call the next page and you can provide the next row to the temporary table.

Regards,

Naimesh Patel

valter_oliveira
Active Contributor
0 Kudos

Hello again.

Since you prefer the loop inside the smartform, you can do it this way. You have only one page, with several fixed windows on it right? So, try this.

Create a window, that should be the MAIN window. Inside that window make a loop to your table. Inside that loop insert a control comand "go to new page". But you must have a counter, to do it n times (n is the number of lines). This will print 1 page per line. Since your windows are fixed, this should work.

Hope it helps.

p.s. i would make the loop in the print program too ....

Best regards.

Valter Oliveira.

Edited by: Valter Oliveira on May 14, 2008 5:41 PM

Former Member
0 Kudos

Valter:

OK. I'm trying this and running into a snag.

In the Form Interface section I have a table interface parameter defined as this:

P_CERTIFICATES_IN TYPE ZBNTT_LIFECERTIFICATE

next I declared a variable named "IT_CERTIFICATES LIKE LINE OF P_CERTIFICATES_IN" in the "Global Definitions" section and on my LOOP element (under my new MAIN window) I have "[X] Internal Table" checked and

"P_CERTIFICATES_IN" "INTO" "IT_CERTIFICATES"

but the compiler says "Global Definitions Field "P_CERTIFICATES_IN" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement . . . . . .".

Why can't the Smartform "see" P_CERTIFICATES_IN?

valter_oliveira
Active Contributor
0 Kudos

Hi.

ZBNTT_LIFECERTIFICATE must be a table type not a structure. If not, create a table type ZTYPE with the type = ZBNTT_LIFECERTIFICATE (in SE11). Then use P_CERTIFICATES_IN TYPE ZTYPE.

IF it is already a table type, in global definitions, use TYPE instead of like line and then in the type, use the structure type of the table type (type of each line)

Best regards.

Valter Oliveira.

Edited by: Valter Oliveira on May 14, 2008 6:02 PM

Former Member
0 Kudos

It's working!!! Thanks for all the help, guys. Points duly awarded

Former Member
0 Kudos

What did you mean by using a counter?

This is working although I have an extra page at the end - the last record prints twice.

valter_oliveira
Active Contributor
0 Kudos

Good morning.

Since I'm not there (seing the smartform would be the best) I was wondering that you would need a counter. Probably an integer variable with the number of lines (number of pages to print).

In your loop you should subtract 1 from that counter until it goes to zero.

In your command next page, you create a condition like IF counter GT 0.

Now, since you need n-1 comands, contrary to what I said, n should be number of lines - 1.

And that's it (I think).

Best regards.

Valter Oliveira.

Former Member
0 Kudos

Where can I put the logic to decrement the counter in the LOOP element?

valter_oliveira
Active Contributor
0 Kudos

Hello again!

To insert the logic, go to the MAIN window, and inside the loop, before the NEXT page COMMAND, do:

CREATE->FLOW LOGIC->PROGRAM LINE.

The counter should be a in and out parameter.

Best regards.

Valter Oliveira.

Former Member
0 Kudos

Valter:

Thanks! Now may I ask why the counter also has to be an OUTPUT parameter?

valter_oliveira
Active Contributor
0 Kudos

Since the counter was defined in global definitions, probably it's not necessary.

However, since program lines work like FM's I would say yes. Put it both in input and output parameters.

Valter.

Answers (1)

Answers (1)

valter_oliveira
Active Contributor
0 Kudos

Hello Steve.

When you pass a table with 2 or more rows only the first creates a page in the spool, right? This happens because you are only printing one page. Your MAIN window is not making a page break!

You must have a table or a loop in the main window, and in each line, insert a control comand to make a page break. That way you will have one page by each line of that table. The problem is that you must, in that MAIN window, to have all the layout (not one window per part).

A loop in the driver program is the easiest solution.

Best regards.

Valter Oliveira.

Former Member
0 Kudos

The SmartForm only has one page and when I test it and click "Print Preview" it shows page 1 of 1 even though my test data itab I put 3 rows in it.