cancel
Showing results for 
Search instead for 
Did you mean: 

Need to hide a subform dynamically

Former Member
0 Kudos

Hi,

I have  a subform with name formz007 with only one field.

This subform is binded to table data and the field is binded to the field of table data.

Repeat subform with min 1 is applied to subform.

I need to hide the subform when the table data is empty.

Please provide me the java script or form calc and the event in which I need to write.

I tried all the ways but I'm helpless.

Accepted Solutions (1)

Accepted Solutions (1)

varun_vadnala3
Active Participant
0 Kudos

Hello Swat,

There are two ways in which you can hide the subform dynamically.

1.Check the records of the table, if its '0' , then pass a flag to the form.

2.Now in the form add a text field(ABC) above the subrofmz007 and bind this flag to that textfield.Text field will be hidden.

3.Now write the formcalc in the event:FormReady of the subform :

if($.parent.ABC == 'X');

$.presence = "hidden"

endif

the other way is directly write the formcalc script in the calculation event of the subform.Hope you know the field(mandatory) which fills,if that field doest fill then the table is hidden.

if (Not(HasValue($.subformz007.rawValue))) then


$.presence = "hidden"

endif


Answers (2)

Answers (2)

Abhijit74
Active Contributor
0 Kudos

Hello,

In the form interface or in your driver program count number of records by using .

Describe table I_TAB lines lv_lines.

if lv_flines = 0 .

     lv_nooutputflag = 'X'.

endif.

Pass this parameter lv_nooutputflag to Data view of form.

In the same subform  (Table ) pass you lv_nooutputflag. Make it hidden from layout.

Now in your subform initialize, form ready and layout ready even

Write Java script or Calc

If (lv_nooutputflag == 'X')

     $.presence = "hidden".

endif

Thanks & Regards,

Abhijit

pavan_prabhu
Active Participant
0 Kudos

Hello Swat,

     There are many ways to achieve this.

One easy way is to send a flag as an importing parameter in the Form Interface. It goes like this.

Set the flag when the table is empty as below in ABAP.

IF int_table IS INITIAL.

     flag = 'X'.

ENDIF.

Now in Layout, drag and drop the flag parameter from DATA VIEW into formz007 sub form.

Now write the below Java script on formz007 Sub form in Initialize event.

if ( this.flag.rawvalue == "X" )

{

     this.presence = "hidden";

}

The script will hide the sub form(entire table) when the flag is set.