Friday 13 September 2013

Sum in the footer of Smartforms

Skip to end of metadata
Go to start of metadata
This page will be helpful to all those people working with smartforms who haven't yet dealt with sub totals.
STEP1
If the requirement is to get subtotal on each page, we can use calculation tab of smartforms which is present on table line as shown in the figure below.
As shown, three types of operations can be done.
1) To get the sum of all values of all line items.
2) To get average or mean value of all line items
3) To get a count of all line items.
According to your requirement you can choose the operation.

 STEP2
Put the name of the field of the table whose subtotal you want in the column Field Name.
Put a variable in the column Target Field Name. This variable will have the value of subtotal which you got to print. 

 
STEP3
Set the time according to your requirement.
  
As shown in the figure you can set time in four ways.
For the operations Total or Average Value use After Loop. It is not possible to use the event Before Loop to display a total of the table items to come, because the calculation event refers to one loop pass only and not to the entire loop.
 
STEP4
  
Initialize-Activate this setting if you want the target field name to be reset to the initial value before the loop starts.
Reset -The value of the target field name can be reset to the initial value.
For field name-If you set the event for the reset to 'Sort Criterion' you must enter the relevant sort criterion here.
  

Thursday 12 September 2013

SmartForms Q&A

1. You have created a Smartform in DEV environment. Then you migrated the Smartform to PROD environment. Will the name of the function module be same in DEV and PROD?
Once you transport the Smartform from DEV to PROD environment, a new function module name for the Smartform in generated in the PROD environment. For a particular Smartform , generated function module names are different in different systems.One can get the name of the function module for Smartform by passing the Smartform name to FM SSF_FUNCTION_MODULE_NAME.

Hence in the driver program for Smartform, it is common practice to use FM SSF_FUNCTION_MODULE_NAME and then calling the Smartform Function Module.

CALL FUNCTION
 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZZ_SMARTFORMS'
IMPORTING
fm_name = lv_fm_name

CALL FUNCTION lv_fm_name

2. How do you convert a Smartform Output to PDF output?
There is a tricky solution here.But let's keep that for the last. Let us first discuss the conventional way of getting a PDF output for Smartform. For that you need to keep in mind the following two function modules and their importing/exporting parameters:

CONVERT_OTF
CONVERT_OTF_2_PDF

In the Driver program, import the parameter 'job_output_info' from the Smartform FM and utilize that info in 'OTF' parameter of the two aforementioned function modules.

Here is one more and probably the easiest way to see PDF output for a Smartform.
Type PDF! in the command prompt and hit enter :).



To see the Smartform Print Preview output as list output,
Type SLIS in the command prompt and hit enter.



3. How do you achieve Bar Code printing in Smartforms?
Step1: Use SE73 i.e. SAP-Script Font Maintenance and create a Bar code say ZDEMO.
Step 2: For Smartform, create a character format C1 and use the recently created Barcode ZDEMO.




It can be finally used to print Barcode as:
 

4. How do you add a Watermark Or a Background Image for Smartforms ?
If you go to the properties of a page in Smartform, you will find a tab for Background Image.
Specify the source of the image you need here and it can be used as background image / Watermark in Smartforms.

Graphics can be maintained using T.code SE78.
Background Image for Smartforms


5. How will you print on both sided of a Smartform?
At the Page level in Smartforms, you can find something called as Print Mode.
Set the Print mode to duplex to print on both sides of the Smartform.Duplex Print mode in Smartforms


6. What is the difference in a Table and a Template in Smartform?A Template has fixed number of Rows and Columns whereas a Table can have variable rows and columns i.e. you can have a internal table with contents associated to a Table element but not to a Template.

You should use a template when the tabular output is fixed!

How do you achieve Page Protection in Smartform ?While one can use the PROTECT ..... ENDPROTECT command for SAP-Scripts, for Smartforms the Page-Protection checkbox can be used to ensure page protection:
Page Protection in Smartforms
Note:  You have Page-protection property only for Text Elements in the Main Window.

6. Can you move a Smartform from one SAP system to another without using transports ?
Yes, this can be achieved using the Upload/Download feature for Smartforms.
One can download the Smartform from one system and save it as an XML file.
Once that is done, the XML file can be used to upload the Smartform in another system.
  
Upload / Download Smartform


7. Can you have a Smartform without a main window?
Yes, you can create a Smartform without a Main Window. But there is no need to do anything of such sort.
Whenever you create a Smartform, a main window is created by default. I can't think of a situation , where you will have a situation in which it is mandatory for you to remove the Main Window. But still I have seen this question in ABAP interviews. So I have put it here.

8. How do you find the name of the Function Module for a Smartform?
When is this function module created?
The function module for Smartform is created when the Smartform is activated.
You can find the name of the Function Module for a Smartform by going to
Environment --> Function Module Name.

9. How do you pass data to Smartforms from the driver program?
when we are creating Smartform we need to create form interface, these are nothing but the interface of the FM which is created after form activation, so when the form is called in the driver program we can pass the data through FM parameters.

10. How do you Debug Smartforms ?
Basically we can set a break point in the FM related to the Form.
*Inside the FM we can get performs which are nothing but the code for Initialization and program lines.

11. How would you go about printing a logo in a Smartform?
Create a logo window to print Logo, for multiple Logos we can create a variable and pass the logo name to logo window.
How do you print address number in Smartforms ?
can create a address window and write the details.
How do you print Symbols and Icons in Smartforms?

What are Basic Nodes and Auxiliary Nodes ?

What is the use of Folder in Smartforms ?
A folder can be used for two purposes
1. Page protection. like Prtect endprotect in scripts(so all come on one page)
2. Logical grouping
If u want to put a condition on a group of text elemnts u can put them in a floder
and apply the condtion once to the folder

By using a folder node and checking the 'protect' checkbox, everything in that folder will be page protected.