SAP ABAP Smart Forms: How to Implement and Configure Part 1

0
389
sap abap smart forms sap abap smartform smart forms sap abap sap smart forms sap abap smartforms interview questions smart form in sap smart form in sap abap smart form sap
SAP ABAP Smart Forms

SAP SMARTFORMS

SMART FORMS SAP ABAP are used to design the business documents such as purchase orders,sales orders,invoice. SAP smart forms are introduced from 4.6C Version onwords

Process of flow of Smart form in SAP

Based on the client requirement,we design the smartform layout through smartforms transaction and provide the nessary symbols and save,check,activate the smartform(layout).
When ever we activate the smartform layout,then it genarates one function module. Based on the function module we develop the print program.
The function module transfers the data from print program to smartform layout

Components of Smart Form in SAP Abap

Components of  SAP ABAP smartforms

1.SMARTFORM LAYOUT
2.Function Module
3.Print program

Components of smartform layout

1.Global settings
2.Pages and windows
Global settings is the collection of :-

1.Form attributes
2.Form interface
3.Global definition

Components of SAP ABAP Smartform layout:

1. Global settings
2. Pages and windows
Global settings are the collection of form attribute, form interface, global definitions.

Form attributes: –

These are used to maintain the administrative information that is form name, language, page format, default style.
Pageformat is the collection of page width and height.
Note : In real time page formats are created by basis people through SPAD transaction code.

Form Interface: –

This is used to declare the variables, work areas and internal tables which are needed to transfers the data from print program to layout

Global definition: –

These are used to declare the variables, work area, internal tables which are needed to implement the logic in the form or layout.

Pages and windows: –

These are used to design the smart form layout.

Below are the some general points which are asked in sap abap smartforms interview questions.

Components : –

1. Pages
2. Windows
3. Page windows
4. Paragraph formats
5. Character formats

Pages: –

Page is the physical area where we can place the windows. We can’t print the data directly on the page.

Windows: –

We can place the same window in any number of pages. We can’t print the data directly on the window.

Page window: –

Page window is nothing but placing the window on the page with co-ordinates (left margin, upper margin, width, height) we can print the data only on page window.

Paragraph format: –

This is used to print the entire paragraph with the required font & style.

Character format: –

This is used to display the perticular text with the required font & style.
We can print the data on the page window is always through symbols. Each symbol start with ‘&’ ends with ‘&’.

There are 3 types of symbols.
1. Program symbols.
2. System symbols
3. Standard symbols

Program symbols: –

Program symbols are variables in the SAP smart forms layout
Ex: –
&WA_T001-BUKRS&
&WA_KNA1-KUNNR&

System symbols: –

System symbols are system variables.
EX: – &sfsy-date&
Note : ‘SFSY’ is the structure which contains all the SAP smart forms system.

Standard symbols: –

Standard symbols are coming from TTDTG standard data base table.
Ex: – &Mr& &Dear&

Note: -‘SMARTFORMS’ is the transaction code to design.

Object: Based on the given vendor number, to display the vendor no, vendor name & city by using smart forms. the smart form layout.

Steps to design smart form in sap ABAP:-

Execute ‘SMARTFORMS’.
-> Select the radio button form.
-> Provide the form name.
-> Click on create.
-> Provide short description.
-> Double click on form interface in the left panel.
-> The import tab (I_Lifnr type Lfa1-lifnr).
-> Double click on global definitions in the left panel.
-> Click on types tab. Declare the types.
Types: begin of ty_LFA1,
Lifnr type lfa1-lifnr,
Name1 type lfa1-name1,
Ort01 type lfa1-ort01,
End of ty_lfa1.
-> Click on global data tab.
-> Provide work area. (WA_LFA1 TYPE TY_LFA1).
-> Click on initialization tab & implement the logic.
-> Provide input output parameters.

INPUT PARAMETER                              OUTPUT PARAMETER
     I_LIFNR                                                              WA_LFA1

select single lifnr name1 ort01 from lfa1 into wa_lfa1 where lifnr = i_lifnr.
-> Expand the page in the left panel. Select the main window. Right click -> create -> text.
-> Double click on text.
-> Click on editor under general attributes tab.
-> Provide symbols.
&wa_lfa1-lifnr&
&wa_lfa1-name1&
&wa_lfa1-ort01&
Click on back. Save, check, activate.
In the menu bar click on environment -> function module name.
based on this function module we develop the print program.

Print program(In SE38)
Report ZBBST_E_SP1
Parameter p_lifnr type lfa1-lifnr.
Call function ‘/1BCDWB/SF00000341’
Exporting
I_lifnr = P_lifnr.
Note: – In the SAP summarized data is available in t001, kna1, lfa1 & their detailed information is available in ‘ADRC’ table. The link is ‘ADRNR’.

Working with address window: –

Address window is used to print the address in the format of target country.
In the real time if you want to print the address, then you must use address window. The input for the address window is address number (ADRNR)
Object: Based on the given Vendor number, display the vendor address by using address window in the smart form.

Steps to design the smart form: –
SMART FORM NAME: ZBBST_O_SF2
Form interface:
Import:
I_LIFNR TYPE LFA1-LIFNR
Global definition
Types:
types: begin of ty_lfa1,
lifnr type lfa1-lifnr,
adrnr type lfa1-adrnr,
end of ty_lfa1.
Global data:
Wa_lfa1 type ty_lfa1

Initialization:
I_lifnr WA_LFA1
select single lifnr adrnr from lfa1 into wa_lfa1 where lifnr = i_lifnr.

Select the page in the left panel. Right click -> create ->address.
Double click on address.
Provide the address number in the general attributes tab. Save, check, activate.
Click on form painter in the application toolbar
Align the windows by drag and drop
Click on form painter once again
In the menu bar click on environment -> function module name.
Based on this function module we develop the print program.

REPORT ZBBST_PRINT.
parameter p_lifnr type lfa1-lifnr.
CALL FUNCTION ‘/1BCDWB/SF00000260’
EXPORTING
I_lifnr = p_lifnr.

Working with graphic: –

By using graphic window we can print the logo in the smart form. The input for the graphic window is graphics image.
We can print the .BMP images in the smart form. Whenever we are working with .BMP image then we must convert .bmp to graphic image by using SE78 transaction.

Steps to convert .BMP image to graphic image:

-> Execute SE78
-> Expand the Graphics
-> Double click on bitmap image
-> Provide graphics name in the right side
-> Click on import icon in the application toolbar
-> Browse the .bmp image, enter.

Steps to place the logo in SAP smartforms: –

-> Execute ‘SMARTFORMS’.
-> Open the smart form in change mode.
-> Select the page in the left panel. Right click -> create -> graphic.
-> Double click on the graphics in the left panel.
-> Provide the name (logo name), object (Graphics), ID (BMAP).
-> Select the radio button color Bitmap image (BCOL).
-> Click on form painter in the application tool bar.
-> Align the windows. Once again click on form painter. Save, check, activate.

Working with SMARTSTYLES:

SMARTSTYLES are used to create the paragraphs as well as character formats in the smart form. The transaction code for smart styles is ‘SMARTSTYLES’.
Left align = left line + 0.2cm.
Right align = Right line – 0.2cm.
Center align = Left line + (column width/2).
1 TAB = ,, 

Steps to create paragraph & character formats: –

-> Execute ‘SMARTSTYLES’.
-> Provide the style name (ZSPRAO_O_S1).
-> Click on create.
-> Provide short description.
-> Select the paragraph formats in the left panel-> Right click–>Create->node.
-> Provide the paragraph format name. Enter.
-> Provide short description.
-> Provide the left margin (0.2 CM),Right margin,space before,space after based on requirement.
-> Click on font tab. Select the font family (Helve), font size (14), font style (bold).
-> Select the checkbox color & select the color. Click on tabs tab.
-> Provide the tab positions. Click on save.
-> Repeat the same steps for all the paragraph formats.
-> Select the character format in the left panel. Right click -> create node.
-> Provide the character format name. Enter. Provide short description.
-> Select the bar code name if it’s required. Click on font tab.
-> Provide the font family, size, style. Click on color check box. Select color. Click on save.
-> Repeat the same steps for all character formats.
-> Double click on header data.
-> Select the standard paragraph as default paragraph. Save, check, activate.

Steps to apply the style in SAP forms:

-> Execute SMARTFORMS transaction
-> Provide the form name
-> Click on change
-> Double click on Form attributes in the left panel
-> Click on output options tab in the right side
-> provide the style name : ZSPRAO_O_S1
->Save, check and activate.

Types of window in smart form:

1. Main window
2. Secondary window
3. Copies window
4. Final window
Main window: Main window is used to print the continues data.
Secondary window: Secondary window is used to print the data based on the window width and window height. if any lines are exceeded window size, those lines are not printed.
Copies window:

If we want to print the same document multiple copies with different headings then we use copies window.

Object : print the same document 3 copies with different headings are

1.Company copy, 2.Customer copy and 3.Govt.copy

Steps to work with copies window: –

Execute ‘SMARTFORMS’. Open the smart form in change mode. Select the page in the left panel. Right click -> create -> window. Double click on window. Select window type as copies window in general attributes tab. Select the copies window in the left panel. Right click -> create -> flow logic -> program lines.
Double click on global definitions in the left pannel
In the data tab
V1 TYPE CHAR20
Double click on code.
IF SFSY-COPYCOUNT = 1.
V1 = ‘DISTRIBUTION CH COPY’.
ELSEIF SFSY-COPYCOUNT = 2.
V1 = ‘SALESORG COPY’.
ELSEIF SFSY-COPYCOUNT = 3.
V1 = ‘CUSTOMER COPY’.
ENDIF.
Output parameter V1.
Select the code in left panel. Right click -> create -> text. Double click on text. Click on editor. &V1&
Click on back. Save, check, activate.
At the time of print preview in the print program provide output device ‘LP01’. Provide number of copies 3. click on print preview & absorb the different headings by click on next page.

Note: -SFSY is the structure which contains all the smart forms system variables. If we want to print the page number
&SFSY-PAGE&
If we want to print total number of pages
&SFSY-FORM PAGES&
DATE -> &SFSY-DATE&
Final window is used to print the total amount in the last page.

Final window :

Final window is used to print the total amount in last page.
Note : In real time, before modifying the any smart form, we must maintain the backup of smart form because smart form does not have version management (ABAP editor have version management)

Steps to maintain the backup of sap ABAP SMARTFORM or download the SMARTFORMS:

-> Execute SMARTFORMS.
-> Provide the smart form name
-> in menu bar click on utilities-> download form

Steps to reload the backup SMARTFORM: –

->  Execute SMARTFORMS.
-> Provide the smart form name
-> in menu bar click on utilities-> upload form

Conversion of smartform output to pdf format:

This is a 2 step procedure

1.Genarate a spool request number
2.Convert the spool request number to pdf format by using RSTXPDFT4 Standard program

Steps to generate the spool request number :

-> Execute the print program in se38
-> provide the input
-> Execute
-> provide the output device is LP01
-> Select the new spool request checkbox
-> click on print

Steps to identify the spool request number

-> Execute SP01/ SP02
-> Provide the output device LP01
-> Execute
-> Identify the spool request number (10700)

Steps to convert the spool to pdf format

-> Execute SE38
-> Provide the program name RSTXPDFT4
-> Execute
-> provide spool request number
-> Execute
-> Provide .pdf file name

Note : By using RSTXPDFT4 Standard program, we can convert the smartform output to pdf format
Note : We can convert any output to pdf format by using RSTXPDFT4 standard program , if the output is available in spool request number.

Working with table: –

Table is used to print the data in a tabular format. Table contains 3 sections.
1. Header
2. Main
3. Footer
In the output/ layout, which part is varying based on the input, that part consider as a main area.
Above main area consider as a header & below main area consider as footer.

Object: Based on the given purchasing document number, to design the purchase order layout as shown in the below.

Note: Whenever we are working with table then we must create different lines with different cells based on the requirement.

For footer:

We can use line1.

Note: – SPELL_AMOUNT is the function module which is used to convert the amount in words. The input for the above function module is amount & currency and output for the above function module is amount in words.
Smart form name: ZBBST_S_TE1.

Form Attributes:

Output options
Styles: ZSOUP_O_S2

Form interface: –

Import tab:
I_ebeln type ekpo-ebeln

Global definitions

Types tab:
Types: begin of Ty_ekpo,
ebeln type ekpo-ebeln,
ebelp type ekpo-ebelp,
menge type ekpo-menge,
meins type ekpo-meins,
netpr type ekpo-netpr,
end of ty_ekpo.
Global data tab:
Wa_ekpo type ty_ekpo
It_ekpo type table of ty_ekpo
V_total type ekpo-netpr
WA type SPELL
Initialization tab:
I_EBELN IT_EKPO
IT_EKPO V_TOTAL
WA_EKPO WA
V_TOTAL

Select EBELN EBELP MENGE MEINS NETPR from EKPO into table it_ekpo where Ebeln = I_EBELN.
loop at it_ekpo into wa_ekpo.
v_total = v_total + wa_ekpo-netpr.
endloop
.
CALL FUNCTION ‘SPELL_AMOUNT’
EXPORTING
AMOUNT = v_total
CURRENCY = ‘INR’

IMPORTING
IN_WORDS = WA.
Double click on main window in the left panel. Click on output options tab.
Provide the co ordinations of main window.

Left margin 1 CM                   Width 18.5

CM Upper margin 1CM           height 20 CM

Select the main window in the left panel right click -> create -> table. Double click on table. In the data tab provide internal table name into work area name (IT_EKPO into WA_EKPO). Click on tables tab. Select the LTYPE1. Right click -> rename line. Provide new name as line1. Select the ‘Line1’. Click on select pattern under table tab. Click on display framed pattern. Select the pattern. Select the ‘Line1’. Right click -> insert -> empty line underneath. Select the ‘Ltype1’. Right click -> rename line. Provide the new name as ‘Line2’. Select the line2. Click on details in top right. Provide the each call width.
Line1 18.5 cm
Line2 3.5cm 3cm 5cm 2cm 5cm
Click on table painter in the top right. Select the ‘Line2’. Click on select pattern under table tab. Select the pattern.

 

Save, check, activate the smart form.

Style creation (ZBBST_HTE_M_O2)

H1
Helve, 16, Bold, Center
H2
Helve, 14, Bold, center
Center M1
Helve, 14, Bold, Left alignment, Left margin 0.2 cm
M2
Helve, 14, Bold, Right alignment, Right margin 0.2 cm
F1
Helve, 14, Bold, Left alignment, Left margin 0.2 cm
Tab position
1. 11.5 cm left alignment
2. 18.3 cm right alignment

Based on the function module develop the print program in se38.

Format options:-
Format options are used to display the output or print the output as per client requirement.

Format Options                        Syntax                            Example                                             Output
Omitting leading zeros            &symbol(z)&                  &a& = 000100.00                    &a(z)& = 100.00
Omitting sign                            &symbol(s)&                  &a& = -100.00                          &a(s)& = 100.00
Leading sign at left                  &symbol(<)&                  &a& = 100.00-                          &a(<)& = -100.00
Leading sign right                    &symbol(>) &                 &a& = -100.00                          &a(>)& = 100.00-
Compress output                     &symbol(c)&                  &a& = 100.00                           &a(c)& = 100.00
Ignore the separators              &symbol(t)&                  &a& = 1,00,000.00                   &a(t)& = 100000.00
Number of decimals               &symbol(.number)&     &a& = 10.3215                         &a(.2)& = 10.32
                                                                                                                                               &a(.0)& = 10

Ignore conversions &symbol(k)& &a& = &WA_EKPO-MEINS(K)&

Working with template: –

Template is used to print the data in a fixed column & fixed rows.
Object: Based on the given purchasing document number, display as show in below.

 

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Smart form name: ZBBSTE_S_WAO
Form interface
Import
I_EBELN TYPE EKKO-EBELN

Global definitions
Types
TYPES: BEGIN OF TY_EKKO,
              EBELN TYPE EKKO-EBELN,
              BEDAT TYPE EKKO-BEDAT,
              LIFNR TYPE EKKO-LIFNR,
              BUKRS TYPE EKKO-BUKRS,
     END OF TY_EKKO.
Global data
WA_EKKO TYPE TY_EKKO
Initialization
I_EBELN WA_EKKO

SELECT SINGLE EBELN BEDAT LIFNR BUKRS FROM EKKO INTO WA_EKKO WHERE EBELN = I_EBELN.
-> Select the main window in the left panel. Right click -> create -> Template.
-> In the template tab select the C1. Right click -> rename line. Provide new name as L1.
-> Select the L1. Click on details in the top right. Provide the height, each cell width.
-> Click on table painter in the top right. Select the L1.
-> Click on select pattern under template tab.
-> Select the required pattern
-> Repeat the same steps for all the lines.
-> Select the template in the left panel. Right click -> Create -> Text. Double click on text.
-> Click on editor under general attributes tab. (Pur.doc: &wa_ekko-ebeln&).
-> Click on back. Click on output options tab.
-> Provide the line number and column number in the bottom.
-> Repeat the same steps for all other text.
-> Save, check activate the smart form.

REPORT ZBBSI_A_OP2.
parameter p_ebeln type ekko-ebeln.
CALL FUNCTION ‘/1BCDWB/SF00000321’
EXPORTING
I_EBELN = P_EBELN.

Please visit SAP ABAP Smart Forms : How to Implement and Configure Part 2

For SAP ABAP smart Forms: How to implement and Configure Part2 please click here

For complete ABAP tutorial please click here

To learn SAP ABAP from SAP please click here

materialized view sql materialized view oracle materialized view materialised view sql materialised views view and materialized view view and materialized view in sql

LEAVE A REPLY

Please enter your comment!
Please enter your name here