Monday, February 7, 2011

Custom Dialog Box Message while Saving the Adobe Form without filling the Mandatory Fields

Pre–requisite:

It is assumed that the reader of this article has basic knowledge in WebDynpro and adobe forms.

Requirement:

The Requirement is to generate a pop-up message dialog box, to the user while saving the adobe forms without filling in the Mandatory fields.

Procedure:

The requirement cannot be achieved as adobe doesn’t have such functionality, not to allow saving the document without filling in the mandatory fields. We would be using Java Script to generate a Dialog box custom message, and if the user clicks OK then the document would not be closed and if Cancel a Blank copy of the document would be save.

1. Create a WebDynpro Component in SE80

2. Go to the Context Tab of the View V_SENDEMAIL_DEMO

3. Create a NODE with LFA1 as DDIC Reference

4. Select the Attributes for the Node LFA1

5. Create an Attribute as PDFSOURCE

6. The Context of the View would look as below.

7. Create an Element “Interactive Form” by Insert Element in Layout tab





8. The Property of the Interactive FORM would be as shown below.

9. Change the Layout Type to ZCI

10. Create a Input Filed on the Layout and Bind as shown below

11. Make the Field property as Required to make it Mandatory

12. In the same way create another field City and make it Optional.

13. Select any ONE of the Input Field (in our case its Vendor Name). Just above the Tool Bar of the Adobe there is a space to write the Java Script or go to Palettes and Click Java Script. Show Box Select preSave event which triggers when the Document is saved.



14. Write the Below Mentioned Java Script in the Editor.

function IsSpecified(oField)
{
return (oField.rawValue != null) && (oField.rawValue.length > 0);
}
var bCanSubmit = true;
var message = "Message: Entry for the below Mandatory Fields are Missing! \n";
if (!IsSpecified(LFA1.P1.NAME1)) // The Field Node Name
{
message += "\n Vendor Name"; // \n = New Line
bCanSubmit = false;
}
if (!bCanSubmit)
{
var oDlg =
{
description:
{
name: "Test Dialog",
elements:
[
{
type: "cluster",
name: "---- ERROR MESSAGE ----",
elements:
[
{
name: "Some Mandatory Fields are Missing!",
type: "static_text",
},
{
name: "Please Click 'OK' and Save Again! By Filling the Mandatory Fields",
type: "static_text",
},
{
name: "If 'CANCLE' is Clicked, a Blank Copy of the Form would be Saved.",
type: "static_text",
},
{
type: "ok_cancel",
},
]
}
]
}
};
// Dialog Activation
if ("cancel" == app.execDialog(oDlg))
{
xfa.host.resetData(); // Reset The Form
}
}

15. Create a Web Dynpro Application

16. Test the Application

17. In the below case if the Mandatory field is empty. In any case as it’s a standard Property of adobe we can’t stop it from saving. But we can change the data before saving.

18. If the mandatory field is missing a POP up would be generated with the below message as mentioned in the Java Script.

19. If OK is selected then the form would be Open and user can fill in the mandatory fields. If Cancel is selected then the Form would be refreshed and the enter data would be cleared in the saved form.

20. The same is also applicable for the Close Button as well.


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