SAP Adobe Interactive Form Tutorial - Part 2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 39

SAP Adobe Interactive Form Tutorial.

Part II. Tables in Adobe Form


By
SAP Yard
-
December 13, 2016
7

Share on Facebook

Tweet on Twitter

In our first tutorial on Adobe Form, we showed the steps to create our
basic form and the driver program. One of our readers asked for
configuration steps of driver program and adobe form.

Question from our reader: Can u please explain where we will configure
the driver program and associated adobe form name, to trigger in any
transaction?
Answer: Go to t-code NACE==>Select any application. For example : V3
==> Press on “Output type” button ==> Select any output type. For
Example : RD00 ==> Press on “Processing Routines” ==> here we can
configure Medium / Program / Form Routine / Form / PDF-SmartForm
Form.

Under PDF-Smartform Form, we can configure the adobe form.

In PP Module – we can configure in OPK8 Transaction.

In the previous part, we saw how we can display a variable. In actual


projects, we hardly have a requirement where we need to display only one

field. . Today, we will learn how to create tables in Adobe Form.


Broadly speaking there are two ways to create the tables in Adobe Form.

1. Normal Table Method using Table Object


2. Create Table using Sub Forms in Adobe

Table Object Method:


Advantages:
It is simple and easy. When we have few fields which can fit into the single
line in the layout, we can use this
The designer knows that you are working with tables. Designer allows
selecting rows or columns, to simultaneously resize a column.
We have a check box to repeat the table header on each page

Disadvantages:
If we deactivate the fields in the context, it will be difficult to use if needed
in the form anywhere. For example in Script editor ( to have some
conditional printing etc)
Difficult to handle when we want to print the nested tables
Limitation when we want to print non-standard tables
SubForm Method:
What is Subform?
The subform is part of the form which is used for organizing the different
elements like input fields, tables, texts present body pages and rarely
master pages.
In other words, Subform is nothing but a group of elements. If we want to
group certain elements on the layout we can use subform and wrap them
into it.

Advantages:
Using subforms gives us more flexibility when laying out tables.
When we want to print multiple rows of table, subform is more useful
We can rearrange cells in subform (Print wherever we want )
It is very useful when we are printing nested tables in the form.

There are no much disadvantages, because internally, tables are handled


as subform structures. We can easily check this if we look at the XML
source of the template in Designer.
If we want the header to be repeated in case of page breaks we have to
use “Overflow Leaders” (instead of the convenient check box if we are
using tables). We need to set them on the “Pagination” tab of the object
palette).

So depending on what we want to achieve we might have to use subforms


instead of a table. But for standard tables, the recommendation is to use
the table object directly. Follow the KIS strategy. Keep It Simple (KIS).

I am sure if you have not worked in Tables before, the above advantages
and disadvantages might have definitely confused you. Do not worry.
Ignore the above comparison. We will do a hands-on with step by step
guide and by the time you finish creating the tables using both the methods
mentioned, the picture would be clear.
In this tutorial, our aim is to display Customer Data from Customer Master
Table KNA1 using both the methods. Let’s Adobe.

Building the Interface which would be common for both methods.

Transaction Code: SFP.

Enter the Interface name and Create (Interface is mandatory for Adobe
form).

Enter the short description and Save.

Enter the Package name and Save.


Let us add our own custom Parameter Name. Select the Import option
under Form Interface (left side) and press the Create button (right side) to
add an Importing Parameter

Importing Parameter IT_KNA1 is of type CCRCTT_KNA1. CCRCTT_KNA1 is a


table type of KNA1. In Adobe form interface / Function module you need
to use Table Type Parameters to pass table data to the form from your
program. (In Function module, Tables parameter is obsolete).

Save, Check, Activate the Interface.

Go to back SFP Transaction main screen. Create the form.


Press on create button

Provide the short description and Interface name which you have created
earlier.

Enter the Package name and Save.

Drag IT_KNA1 from Interface which we created earlier to the Context.


Interested in SAP HANA? Check this. SAP HANA for Beginners from a
Beginner.
Method 1: Create Table in Adobe Form using Table Object

You should deactivate the fields from the Table which are not required to
print since there are many fields in the table, it will not fit in the form.

Select the fields which are not required to be displayed.

Right click and select deactivate.


Then it looks like below.
We have only 6 active fields.

Go to layout tab
Insert a text variable to have some heading on the form.
Change the text as required.

You can change the font and size of the text in the marked section above.
————————————————————————————————
Ram’s Tip 1: If you do not find Font toolbar by default, you can activate it
as shown below.

Go to Palettes -> Press on Font.

————————————————————————————————

Now go to Data view.


Select IT_KNA1, Drag and drop it into the layout.

You can adjust the column height or width, by drag and drop option. If you
want to be very precise, you can also go to the properties in the right hand
side and adjust the width and height.
Save, Check, Activate the form.

Please note: If you have data in the IT_KNA1 table more than 1-page
size, it would not flow to the next page. You have to do the following two

activities if you want to see all data.

The subform must be Flowed.

Select IT_KNA1 And check the check box ‘Allow Page Breaks within
Content’.
——————————————————————————————————————
——

Begin of Update on 27th February 2017

Some clients in some countries would like the table to have the row Layout
from Right to Left.

By default, it is Left to Right Rows.

But, in case you want your rows from Right to Left, choose the layout from
the Table properties.
End of Update on 27th February 2017

——————————————————————————————————————
——

Execute the Driver program: YRAM_ADOBE_FORM_PROGRAM2. The code


snippet is provided at the end.

The output would display the table with the Customer Master data.
At this point, we are tempted to end this article. Reason being two. First, it
is 11:20 PM in the night and second, the article is already long. But we
decided to continue the post and include the Method 2 in the same post so
that the readers do not lose the continuity and flow of learning. So take a
quick water break and proceed to the next Method. It would be more

interesting and challenging.

Also Read: GPS like Tool in SAP

Method 2: Create Table using Sub Forms


By using this method, we can display the fields in any order and the fields
in multiple rows of lines.

Go to layout
Every form will have Master page and Body page by default (Untitled
Subform) (page1).

In Simple definition, we can use Master page to print the header data
and Body page for printing the item data.

The content area is used for printing the data in Body page. We can change
the length or width of the content area in Master page.

We are keeping the header in Master page

————————————————————————————————
Ram’s Tip 3: At any point of your development, if you want to see the
basic output of your form, you just need to click on Preview PDF Tab.
————————————————————————————————

Go to design view

To print the Table data the Subform must be FLOWED.


This is a very important step. We need to insert the SubForm.
You can change the height or width of the window in Layout tab. You can
also drag and adjust.

This Subform can be used as the header. Please note Untitled SubForm has
been renamed as Header in the left hand side.

Change the header form content to Flowed, and Flow direction to Western
text, so that fields will be displayed side by side.

Select your header Subform go to insert -> 0 – Standard -> Text field.
You need to change the properties of the text field for better display and
appearance.

Select the TextField1. Change the appearance from Sunken box -> Solid
box.
Change the position from left -> none.
Value entered from user entered from -> Read-only.
Select the Border as the solid color.

Now, you can reuse this TextField1.

Copy and Paste the TextField1 in Header sub from. (In this case paste 4
times because we need 5 fields to display)
You can Change the name of the field.

You can pass hard coded text to these fields.


You can change the description and Value for all the remaining fields.

We have created the Header row. Now, it is time to print the item data of
the table.

Create one more Subform and name it as Items.


Change the item Subform content to Flowed, and Flow direction to Western
text, so that fields will be displayed side by side.

Copy the five fields Customer No, Country, Name, Street, and Telephone
and paste under items subform.

Remove the default values for all the fields.


Bind the data table, i.e IT_KNA1 to the Items Subform.

Binding is a very important part of Adobe. Make sure you bind the data
correctly.
Bind the fields as:
CustomerNo to KUNNR,
Country to LAND1,
Name to NAME1
Street to STRAS
Telephone to TELF1
You must check the checkbox Repeat Subform for each data item.

Run the Driver Program: YRAM_ADOBE_FORM_PROGRAM2


The output should be same.

Did you check this? 4 Versions of the same program to learn OOPs
ABAP

In both the Methods above, we used the below driver program to call the
Adobe Form. Snap it in your development SAP system and test your newly
created tables in the Adobe.

1  
2 *&---------------------------------------------------------------------*
3 *=======================================================
4 ===============*
5 * YRAM_ADOBE_FORM_PROGRAM2 *
6 *=======================================================
7 ===============*
8 * Project : SAP Adobe Forms Tutorial *
9 * Author : Ramanjula Naidu DARURU (www.SAPYard.com) *
1 * Description : Driver Program for Printing the Customer data *
0 *=======================================================
1 ===============*
1 REPORT yram_adobe_form_program2.
1  
2 **&&~~ Data Objects
1 DATA: gv_fm_name TYPE rs38l_fnam, " FM Name
3 gs_fp_docparams TYPE sfpdocparams,
1 gs_fp_outputparams TYPE sfpoutputparams,
4 gt_kna1 TYPE STANDARD TABLE OF kna1.
1  
5 CONSTANTS : gv_form_name TYPE fpname VALUE 'YRAM_ADOBE_FORM2'.
1  
6 *=======================================================
1 ===============*
7 * START of TREATMENT *
1 *=======================================================
8 ===============*
1 START-OF-SELECTION.
9 SELECT * FROM kna1 INTO TABLE gt_kna1 UP TO 50 ROWS.
2 *&---------------------------------------------------------------------*
0 **&&~~ Form Processing: Call Form - Open
2 *
1 CALL FUNCTION 'FP_JOB_OPEN'
2 CHANGING
2 ie_outputparams = gs_fp_outputparams
2 EXCEPTIONS
3 cancel = 1
2 usage_error = 2
4 system_error = 3
2 internal_error = 4
5 OTHERS = 5.
2 IF sy-subrc <> 0.
6 " Suitable Error Handling
2 ENDIF.
7 *&---------------------------------------------------------------------*
2 **&&~~ Get the Function module name based on Form Name
8 *
2 CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
9 EXPORTING
3 i_name = gv_form_name
0 IMPORTING
3 e_funcname = gv_fm_name.
1 IF sy-subrc <> 0.
3 " Suitable Error Handling
2 ENDIF.
3 *&---------------------------------------------------------------------*
3 **&&~~ Take the FM name by execuing the form - by using Pattern-
3 **&&~~ call that FM and replace the FM Name by gv_fm_name
4 *
3 **&&~~ Call the Generated FM
5 CALL FUNCTION gv_fm_name "'/1BCDWB/SM00000176'
3 EXPORTING
6 /1bcdwb/docparams = gs_fp_docparams
3 it_kna1 = gt_kna1
7 EXCEPTIONS
3 usage_error = 1
8 system_error = 2
3 internal_error = 3
9 OTHERS = 4.
4 IF sy-subrc <> 0.
0 * Implement suitable error handling here
4 ENDIF.
1 *&---------------------------------------------------------------------*
4 **&&~~ Form Processing: Call Form - Open
2 *
4 CALL FUNCTION 'FP_JOB_CLOSE'.
3 IF sy-subrc <> 0.
4 * Implement suitable error handling here
4 ENDIF.
4 *&---------------------------------------------------------------------*
5 *&---- Close the spool job
4 CALL FUNCTION 'FP_JOB_CLOSE'
6 EXCEPTIONS
4 usage_error = 1
7 system_error = 2
4 internal_error = 3
8 OTHERS = 4.
4 IF sy-subrc <> 0.
9 * <error handling>
5 ENDIF.
0 *&---------------------------------------------------------------------*
5
1
5
2
5
3
5
4
5
5
5
6
5
7
5
8
5
9
6
0
6
1
6
2
6
3
6
4
6
5
6
6
6
7
6
8
6
9
7
0
7
1
7
2
7
3
7
4
7
5
7
6
7
7
7
8
7
9
8
0
8
1
8
2
8
3
8
4
8
5
8
6

Hopefully, you were not overwhelmed by this long long article.  The future
tutorials on Adobe would not be this long. Promise!! As we keep saying, we
cannot learn to swim unless we wade through the water. So try practicing
the exercises in your system and I am sure you will have no issue. If any
issue just shoot an email to [email protected] or leave your
questions in the comment section and you will definitely have a quick
response.

Next Post in Series: Adobe Form Tutorial Part III : Date, Time and
Floating Fields in Adobe.

If you want to get such useful articles directly to your inbox, please
SUBSCRIBE. We respect your privacy and take protecting it seriously.

If you liked this post, please hit the share buttons and like us on
facebook.

Do you have anything to add to this article? Have you faced any issue using
Adobe Forms? Do you want to share any real project requirement or
solutions? Please do not hold back. Please leave your thoughts in the
comment section.

Thank you very much for your time!!

You might also like