SAP Adobe Interactive Form Tutorial. Part IV. Dynamically Hide and Display Fields using Javascript in Adobe Form Based on Conditions

Conditions (IF-ENDIF, CASEs, WHILE, etc.) are a fundamental part of our projects and indeed any programming language. However, not everything is straightforward, and developers may need to handle exceptions. For example, all employees of your client need to print the time zone as GMT – 6 in the form signature they print from their office. Thus, 98% of your clients would use GMT – 6 hours as their time, but there would be 2% who live in another state and use GMT – 7 hours. In such cases, you need to implement dynamically hide and display fields using Javascript in Adobe Form Based on Conditions so that the signature shows GMT – 7 for those specific clients.

For show reason:
Say, in your driver program you have recognized the representative’s time region and you have set the banner v_regular_employee = ‘X’ or clear depending where they work from.

IF v_regular_employee = abap_true.
v_time_sign = 'GMT - 6'.
ELSEIF v_regular_employee = abap_false.
v_time_sign = 'GMT - 7'.
ENDIF.

So our Adobe structure would progressively print ‘GMT – 6’ or ‘GMT – 7’ relying upon the condition esteem. What’s more, the magnificence is, we will compose a little Javascript and not the ABAP code as displayed previously. Doesn’t it sound intriguing? ABAPers composing javascript. Welcome back to the wavy supports coding.

PS: There may be numerous ways of accomplishing the above situation. We have saved it basic for clearness.

I think, we have given sufficient secret to our the present instructional exercise. We should watch the full film now.

We expect that you have been following our series bit by bit. That is the explanation we have determined the Part number in every instructional exercise title so you can study and advance methodicallly, part by part. In the event that you are a fledgling in the field of Adobe structures and you have not checked our previous series, we would recommend you stop here. Return to our prior instructional exercises and invigorate your Adobe abilities. Basically know the t-codes and Structure, Point of interaction, Setting and Driver program ideas.

Be that as it may, assuming you as of now those ideas or you are truly intrigued to be aware of stowing away/showing fields powerfully, kindly proceed this article. This article is absolutely no chance connected to past posts. . The idea and cautioning above were on the grounds that we believed the novices should concentrate consecutively so they can help more.

Exchange Code: SFP.

Enter the Point of interaction name and Make (Point of interaction is compulsory for Adobe structure).

Adobe Forms

Enter the short depiction and Save.

sap adobe form for beginners

Enter the Bundle name and Save.

Step by Step tutorial on SAP Adobe Form

Allow us to add our own custom Boundary Name. Select the Import choice under Structure Connection point (left side) and press the Make button (right side) to add a Bringing in Boundary.

Tutorial on SAP Adobe Form

IV_NAME is of type NAME1 (Data Element). IV_FLAG is of type CHAR1. Save, Check and Activate the Interface.

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

Adobe Forms for Beginners

Press on make button
Give the short depiction and Point of interaction name which you have made before.

Step by step to Adobe Form

Enter the Package name and Save.

Drag IV_NAME and IV_FLAG from Interface which we created earlier and drop them to the Context area.

drag from interface to layout

Go to Layout

Go to Data View and Drag and drop the field IV_NAME.

Select the field IV_NAME and go to Palettes->Script Editor.

You will see below screen.

Javascript in SAP Adobe Form

Go to Show option and select form: ready from the drop down list.

Javascript in SAP ABAP

Here you will be able to compose Javascript or Form Calc Code.

We will go with Javascript for now. Lucky ABAPer!!

if($record.IV_FLAG.value != "X")
{
this.presence = "hidden";
}
Adobe Form example with Javascript

Check, Save and Enact.

Let us Test our product now: 

Case 1 : When IV_FLAG = ‘X’.

Execute the Structure or Press F8 which is at the highest point of your screen. Enter values against IV_NAME and IV_FLAG.

stand alone test of Adobe Form

Press F8. Press on Print See button.

How to use Javascript in Adobe Form


Since the content to conceal the components didn’t get set off as we passed IV_FLAG = X. Hence the components are not secret in the result.

Case 2 : When IV_FLAG = ‘ ’.
Press F8. Enter values against IV_NAME and pass blank value to IV_FLAG.

Press F8. Press on Print Review button. This time the Javascript code gets set off to conceal the component. So the Result is a clear page this time.


You can call the above Structure from driver program and get a similar result. Kindly check the underneath working code.

Choice Screen of the Program:

Result would be same as remain solitary test, contingent upon what you pass on the determination screen . So considered not consuming more memory of this page.

Give this short hands a shot Adobe Structure and Driver program in your framework and have a good time.

*&---------------------------------------------------------------------*
*======================================================================*
* YRAM_ADOBE_FORM_PROGRAM4 *
*======================================================================*
* Project : SAP Adobe Forms Tutorial *
* Author : Varad (www.elearning.com) *
* Description : Dynamically Hiding & Displaying a field on the Adobe Form
* Layout based on Condition *
*======================================================================*
REPORT yram_adobe_form_program4.

*======================================================================*
* Selection Screen
*======================================================================*
PARAMETERS: p_name TYPE name1,
p_flag TYPE char1.

**&&~~ Data Objects
DATA: gv_fm_name TYPE rs38l_fnam, " FM Name
gs_fp_docparams TYPE sfpdocparams,
gs_fp_outputparams TYPE sfpoutputparams.

CONSTANTS : gv_form_name TYPE fpname VALUE 'YRAM_ADOBE_FORM4'.

*======================================================================*
* START of Calling the Form
*======================================================================*
*&---------------------------------------------------------------------*
**&&~~ Form Processing: Call Form - Open
*
CALL FUNCTION 'FP_JOB_OPEN'
CHANGING
ie_outputparams = gs_fp_outputparams
EXCEPTIONS
cancel = 1
usage_error = 2
system_error = 3
internal_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
" Suitable Error Handling
ENDIF.
*&---------------------------------------------------------------------*
**&&~~ Get the Function module name based on Form Name
*
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
EXPORTING
i_name = gv_form_name
IMPORTING
e_funcname = gv_fm_name.
IF sy-subrc <> 0.
" Suitable Error Handling
ENDIF.
*&---------------------------------------------------------------------*
**&&~~ Take the FM name by execuing the form - by using Pattern-
**&&~~ call that FM and replace the FM Name by gv_fm_name
**&&~~ Call the Generated FM
CALL FUNCTION gv_fm_name
EXPORTING
/1bcdwb/docparams = gs_fp_docparams
iv_name = p_name
iv_flag = p_flag
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
*&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*
*&---- Close the spool job
CALL FUNCTION 'FP_JOB_CLOSE'
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
* <error handling>
ENDIF.

I’m certain that dynamically hide and display fields using Javascript in Adobe Form Based on Conditions will be a valuable skill for every Adobe Form project. No matter what exceptions your client requests, you can handle them with confidence. You now know how to manage these requirements effectively.

 

YOU MAY BE INTERESTED IN

ABAP on SAP HANA. Part VI. New Age Open SQL ABAP 740

Create and Consume Business Add-in(BAdI) in ABAP

A to Z of OLE Excel in ABAP 7.4

X
WhatsApp WhatsApp us