Wednesday, February 9, 2011

Making subform behave as table and data part as body row

Whenever we use a table in an adobe form using drag & drop, following are the common problems faced:

  • Whenever the column fields are rearranged randomly into many rows, the data is displayed in a improper fashion.
  • In debugging, if we delete any row, and the data that is displayed becomes improper.

Solution: This demo will help us rectify the problem by making the subform behave as table and the data part as body row.

This is achieved by assigning binding to the subform.

Step1: Go to SFP transaction and create interface for the Adobe form.

Step2: Passing the table as import parameters, which will be passed through driver program.

Step3: Activate the interface.

Step4: Create Form by going to SFP transaction.

Step5: The form contains the context area, which will display the contents of interface. Drag and drop the table 'IT_SFLIGHT' from context area under the folder 'YDEMO_SUBFORMS'.

Step6: Deactivate the fields of the table, which will not be used in the layout, it adds to the performance.

Step7: Go to layout tab, under the layout change the content area adding a static text to the top of master page. Name the content area. Click on the tab body pages.

For the body page the subform content has to be positioned.

Move the fields, which you want to view from data view on to the body page individually.

Note: When we try to move the individual fields of the table the binding with the table is affected and the data that is displayed becomes inconsistent, this demo will help you retain the binding with the table by making the subform act as a table.

Step8: The field 'FLDATE' can be displayed in different formats as per the requirements, which will be explained by below snapshots.

Step9: Select all the fields being displayed on the layout and wrap them in subform.

The Accessibility of the form should be bodyrow. Create another subform for ex: Sflight details and wrap the fields in this subform and give the subform content as positioned and for the bodyrow subform give the subform contents as flowed. The check box "Allow page breaks within content" has to be marked for the data which is being flowed.




Step10: If the data is flowing to multiple pages then we direct the over flown data.

Move to pagination tab under object tab, under that if dataset is paginated under overflow give the name of content area and overflow leader as header row. By adding this whenever an overflow occurs the header will be displayed in all the pages.

We need to create two subforms, the reason is that the body of the table can be flowed to multiple pages and if we make the subform as flowed all the elements will be aligned either top to bottom or western text (left to right). So as we need to display the table contents in two rows we created two subforms, first one will be flowed and the second one under first one which will be positioned.

Step11: Creating Header row for the table.

Drag a static text element from the library and drop it above the body row. Wrap the text in a subform giving the accessibility as header row.

Step12: Creating a table subform. The content of the subform should be flowed and the accessibility should be table.

Name the untitled subform (Page 1) as "Bodypage1". After doing this change the content of the body page as flowed then click on pagination tab, under that if dataset is paginated under overflow give the name of content area same as what we performed for body row. (In body page we gave overflow leader as header row but in body page pagination do not use that)

Step13: Giving borders to the table and header.




Step14: Giving bindings to each of the subforms.

Table Binding: YDEMO_SUBFORMS->IT_SFLIGHT.

Bodyrow Binding: YDEMO_SUBFORMS->IT_SFLIGHT->DATA. The checkbox repeat subform for each data item has to be checked giving Min.Count = 1.

Step15: Save and activate the form.

Step16: Creating a Driver Program which will call the form and on execution will display the adobe form.


*&---------------------------------------------------------------------*
*& Report yh_demo *
*&---------------------------------------------------------------------*
*&Purpose: Demonstrating driver program to display adobe form *
*&---------------------------------------------------------------------*
REPORT  yh_demo.
*Data Declarations
DATA : it_sflight TYPE sflight_tab1.
DATA :
w_doc_param TYPE sfpdocparams,"Doc Parameters
w_output_param TYPE sfpoutputparams,
"Output Parameters
result TYPE sfpjoboutput. "Joboutput
DATA :
fm_name TYPE rs38l_fnam. "Function Module name
* Determine print data, Data which will be displayed on the form
SELECT * FROM sflight
INTO TABLE it_sflight
UP TO 20 ROWS.
IF sy-subrc NE 0 .
ENDIF.
* Determine the function module which is generated at the runtime for
* the pdf form used
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
EXPORTING
i_name = 'YDEMO_SUBFORMS'
IMPORTING
e_funcname = fm_name.
* This function module is used to specify settings for the form output.
* To specify whether you want the form to be printed, archived, or sent
* back to the application program as a PDF.
* The form output is controlled using the parameters (w_ouput_param)
* with the type SFPOUTPUTPARAMS.
CALL FUNCTION 'FP_JOB_OPEN'
CHANGING
ie_outputparams = w_output_param
EXCEPTIONS
cancel = 1
usage_error = 2
system_error = 3
internal_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Set the language field the component of structure /1bcdwb/docparams
w_doc_param-langu = 'EN'.
* Call the function module and passing the form interface values
CALL FUNCTION fm_name
EXPORTING
/1bcdwb/docparams = w_doc_param
it_sflight = it_sflight
* IMPORTING
* /1BCDWB/FORMOUTPUT =
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* To complete the processing of the form
CALL FUNCTION 'FP_JOB_CLOSE'
* IMPORTING
* E_RESULT = result
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

Step17: Activating the report and executing it would pop a window.

Give the device name which is configured for ADS. Click on Print Preview to see the preview of the form.

The form output

Page 1:

Page2:




No comments:

Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)

Userexits/BADIs

Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

Blog Archive

goodsites