on 05-22-2013 1:38 AM
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Continued to have the same problem that Formcalc script did not work from page 2 onwards.
The right way to go about this is to create an Alternative in the Context of the data table then set the Alternate Condition via a variable which is set at the Code Initialization event of the form Interface. Within the Alternative we can then Deactivate the required columns within the True & False condition.
The approach to insert client side scripting on a table column header in order to hide it is incorrect and thus should be avoided.
Note that steps 2 & 3 of the above post should be avoided - Step 1 is however required to make the Alternative work.
Hello Sougata,
can you please explain more detailled how you did that? Especially how you can deactivate the columns within the True&False condition. My problem is that the headerline hasat just text an no binded data so I cannot make any conditions to them in the context. I tried to use the true path in the hierachie of the layout, this is a bad idea, the field was printet when it shouldn't be printet and whe it should be printet I got ten or more headerlines. Can anyone give me some advise?
Thanks,
Marco
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sandeep,
Thanks for your help. It works...I'm able to hide the header row but now the column appears with blank value from page 2 onwards. In other words the FormCalc script for the value cell does not work from subsequent page onwards. The script for the header works fine for all pages when I changed it to Text field from library as you had suggested.
Any idea how to make it work on all pages?
Sougata.
Hi Sougata,
Are you using subform as table or simple table.
If you are using subform as table then you need to put script at both header level and at details level.
Try putting the script at details level also.
PS : For more details refer to this thread
http://scn.sap.com/thread/1694807
BR,
Sandeep Katoch
Doesn't work. I read the link you had sent me - I can't see anything wrong with my script but I can't make the table as part of Master Pages. The table is perfectly fine on page 1 but the script fails from page 2 onwards. Its a simple table, its not wrapped in a Subform. Any idea what is going wrong in subsequent pages?
Sougata.
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
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.