Skip to Content
avatar image
Former Member

Hiding a table column for a particular condition

Hello,

I have defined a table (flowed) with 7 columns. I want to hide the 6th column (type Decimal field) completely if a condition is True. This condition is passed to the Form from an ABAP program as an import parameter of the Form Interface.

I've written a FormCalc Script on that particular column cell which is:

if ( $.rawValue == null or $.rawValue == "" ) then
  $.presence = "hidden";
endif

This works fine except the column header is still displayed on the form as a result the format of the table has gone wrong and it looks weird.

Last column header "Advertised" should be shifted left to replace the 6th column header - As you can see the values of the 6th column are hidden but the column header is still displayed. I was unable to put any script on the column header as it is a type Text field.

Has anyone had a similar problem like this in the past? I know I can use Alternatives->True/False in the form context but I don't want to go there if there is something simple which I'm missing. Any ideas?

Thanks!

Sougata.

Table.JPG (31.4 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Jun 20, 2013 at 01:20 AM

    This is how I solved it:

    1. Declare a boolean variable in the form interface and flag it true or false depending on whether the condition was met or not in the Code Initialization of the form. Example code below:

    DATA:
      ls_items TYPE zlo_s_promo_item.

    LOOP AT it_promo_items INTO ls_items
      WHERE prom_sell_price IS NOT INITIAL.
      EXIT.
    ENDLOOP.

    lv_psell_flag = boolc( sy-subrc IS NOT INITIAL ).

    2. Define the column header as Text Field then bind it to the boolean variable declared in step 1. FormCalc script for the column header should be as under:

    if ( $.rawValue == "X" ) then$.presence = "hidden";endif

    3. The FormCalc script for the column value (defined as Decimal field in my case) should be as under:

     if ( $.rawValue == null or $.rawValue == "" or $.rawValue == 0.00 ) then  $.presence = "hidden"; endif

    Result is the entire column (including the column header) is displayed or hidden depending on the value of the boolean variable.

    Hope this helps someone in future who might be stuck at a similar issue.

    Cheers,

    Sougata.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hello Sougata,

      I have a requirement to hide all the columns who has no value in it including the column header.

      For example, I would like to hide three columns Customer material, unit and Price.

      Column width should be adjusted accordingly.

              Item

      Material Material desc

      Customer

      Material

      Quantity Unit Price Price in USD 10 MAT1 Material1 2 200 20 MAT2 Material1 3 300 30 MAT3 Material1 4 400

      BR//Tirumal

  • May 22, 2013 at 07:03 AM

    Hi Sougata,

    You can easily put a script in a text field. But yes if it is a normal text only then you cant put any script.

    change it to a text field from library and put a script there.

    BR,

    Sandeep Katoch

    Add comment
    10|10000 characters needed characters exceeded

    • That is why it is giving a problem.

      If it is not wrapped inside a subform then you need to put a script explicitly on each page and on every table row.

      Best practice is to wrap the table inside a subform and make the subform as flowed. All the properties of parent are by default applied to consequent pages.

      BR,

      Sandeep Katoch

  • avatar image
    Former Member
    May 26, 2013 at 11:28 AM

    Hi Sougata,

    Can you try moving the column header which you dont want to be displayed inside a subform and write the below script in the subform.

    $.presence = "hidden"

    if ( Exists(Column_Name) eq 1) then

    $.presence = 'visible'

    endif.

    Regards,

    Sanjeev.

    Add comment
    10|10000 characters needed characters exceeded