cancel
Showing results for 
Search instead for 
Did you mean: 

Newbie question: Just printing a few fields on a single page -- approach?

former_member210148
Participant
0 Kudos

Good day, everyone. First of all, I apologize if this has been covered somewhere else. I've done a LOT of searching of this forum and the Internet over the past 24 hours, and I've not found an answer to my question yet (or perhaps I have, but I don't know if it really applies to my situation).

Here's the deal. I'm new to Smart Forms but have been doing ABAP for a few years now. I am passing a table to my Smart Form that contains records of basic employee data. Each record in the table is one employee. The Smart Form is one page and is very simple. I want to print a title, followed by data fields from the record. The data fields are displayed in two columns (see below). So, if I have 8 employee records in my table, I expect 8 pages to print -- one page (form) for each employee.

After that is static blocks of text that will be on every form for every employee. So, I want to process the next record in my table -- print the title, the data, the static text -- etc. until I'm done.

That's all I need to do. I put a LOOP in my main window, but when I run my program and do a print preview, all I see is data for the last record in my table. The specific data part is the only thing under my LOOP command. Everything else is before it (like the title) or after it in a higher node (like the static text). So I'm thinking the LOOP command is looping through my entire table, landing on the last record, and that's why I see only the last record.

But I don't know what the best approach is to this scenario. How can I expand my LOOP to put everything else within it? It needs to be in the MAIN window, yes? Or should I not be using a LOOP at all and use some other construct? Here's how my basic form looks:

LOGO

CENTERED TITLE

PERNR: <value> Name: <value>

Emp. Group: <value> Org. Unit: <value>

Emp. Subgrp: <value> Org. Name: <value>

CUL: <value> Position: <value>

Annual Salary: <value>

STATIC TEXT 1 STATIC TEXT 2

STATIC TEXT 3 STATIC TEXT 4

Thanks in advance. I appreciate any help on direction you can provide.

Accepted Solutions (0)

Answers (1)

Answers (1)

MarcinPciak
Active Contributor
0 Kudos

Hi Dave,

I think the best is call smarftorm function within the loop and pass each time on record with EE data and all static data you have. So the logic would look like


loop at ee_tab into wa_ee.

refresh sm_ee_tab.
append wa_ee to sm_ee_tab.  "append only one record.

   "call your smartform
   CALL FUCNTION ....
        tables 
          EE_TAB = sm_ee_tab "pass one table record with EE data

    ..."here smartform will execute printing static data 
       "with ee data you pass to it, no need to loop
       " inside the smartform
endloop

Regards

Marcin

Moderator message - Please don't put long comments inside code tags.

Edited by: Rob Burbank on Apr 1, 2010 10:31 AM

former_member210148
Participant
0 Kudos

But that won't allow the end user to Print Preview ALL of the forms generated, will it? Wouldn't that approach bring up the Print Preview option (which they want) for every single form generated instead of just one at the end with all of the pages? Would it also generated a separate spool entry for each form?

I fully admit I may not understand the workings of Smart Forms in this scenario, and I need to learn.

former_member628395
Active Participant
0 Kudos

Hi Dave,

In continuation with Marcin's reply, I would like to suggest you a workaround.

I had a similar requirement wherein I had to merge the output of multiple smartforms into one and either display it or print it.

For this, as Mercin has already suggested, you can call the smartform(in loop) with the get_otf and no_dialog paramaters of the

CONTROL_PARAMS structure (which you pass to the smartform function module call) to 'X' and fetch the output in OTF format

from JOB_OUTPUT_INFO paramater of the function module call.

Being in a loop you would get the OTF for every smartform call inside the loop. Keep appending the OTFDATA field of the

JOB_OUTPUT_INFO structure to that of another JOB_OUTPUT_INFO structure(this will hold the otf for all the smartforms togather) .

Once that has been done for all the smartforms , you will have the OTF output of all the smartforms which you will need to either

display as a print preview or print, for which you can use either the function module SSFDISPLAY_OTF or SSFPRINT_OTF.

Hope this helps.

Regards,

Sagar