Tuesday, February 8, 2011

Adding rows dynamically in a table using interactive Adobe Forms

The requirement is to add the table rows dynamically in the table. This document is dealt with how to create dynamic table in interactive form using offline scenario.

Step1: Go to SFP transaction and provide interface name.

Click on Create button and provide the meaningful description for the interface.

Step2: Now create import parameter ZMAT as shown below.

Save and activate the interface.

Step3: Now again go to transaction SFP to create form. Provide the form name.

Click on Create button. A popup will appear where provide the interface name and meaningful description of the form.

Step4: Now drag the import parameter ZMAT to context as shown.

Step5: Now go to layout.

Drag the table ZMAT to body page.

Drag the button from library on to body page below the table as shown.

Step6: Now go to Hierarchy tab,

Go to OBJECT palette of DATA and provide the min count is 3 (when we execute the form initially it shows 3 default rows) as shown below.

Step7: Now click on ‘Insert’ Button.

In the script editor, write the following code which generates the rows dynamically at run time.

In script editor:

var anInstanceManager = data.Bodypage.ZMAT.DATA.instanceManager; 
var newInstance = anInstanceManager.addInstance(1);
var aToIndex = data.Bodypage.ZMAT.DATA.index + 3; (Adds the rows from 4th postion)
var aFromIndex = newInstance.index;
anInstanceManager.moveInstance(aFromIndex, aToIndex);
Save and activate the form.

REPORT ZOFFLINE_MAT_01.

data:
fs_venbank
type zwd_mat,
it_mat
type zwd_t_mat,
l_fm_name
TYPE rs38l_fnam,
l_formname
TYPE fpname VALUE 'ZOFFLINE_MAT_FORM',
fp_docparams
TYPE sfpdocparams,
FP_FORMOUTPUT
TYPE FPFORMOUTPUT,
fp_outputparams
TYPE sfpoutputparams.

START-
OF-SELECTION.
PERFORM get_function_module.
*&---------------------------------------------------------------------*
*& Form GET_FUNCTION_MODULE
*&---------------------------------------------------------------------*

form GET_FUNCTION_MODULE .
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
EXPORTING
i_name = l_formname
IMPORTING
e_funcname = l_fm_name.
* E_INTERFACE_TYPE =

* fp_outputparams-nodialog = 'X'.
* fp_outputparams-getpdf = 'X'.

CALL FUNCTION 'FP_JOB_OPEN'
CHANGING
ie_outputparams = fp_outputparams
EXCEPTIONS
cancel =
1
usage_error =
2
system_error =
3
internal_error =
4
OTHERS = 5.
IF sy-subrc <> 0.
CASE sy-subrc.
WHEN OTHERS.
ENDCASE. " CASE sy-subrc
ENDIF.

fp_docparams-langu =
'X'.
fp_docparams-
country = 'US'.
fp_docparams-fillable =
'X'.

fp_docparams-dynamic = 'X'.

CALL FUNCTION l_fm_name
EXPORTING
/1bcdwb/docparams = fp_docparams
zmat = it_mat
IMPORTING
/1BCDWB/FORMOUTPUT = FP_FORMOUTPUT
EXCEPTIONS
usage_error =
1
system_error =
2
internal_error =
3
OTHERS = 4.

IF sy-subrc <> 0.
CASE sy-subrc.
WHEN OTHERS.
ENDCASE. " CASE sy-subrc
ENDIF. " IF sy-subrc <> 0

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.
CASE sy-subrc.
WHEN OTHERS.
ENDCASE. " CASE sy-subrc
ENDIF. " IF sy-subrc <> 0.
endform. " GET_FUNCTION_MODULE

Note: To add the rows dynamically in the form, we have to pass the value ‘X’ to parameter DYNAMIC of the structure /1BCDWB/DOCPARAMS.

Output: execute the program

Now when you click on button Insert, a new row will be added after 3 rows.



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