on 08-03-2013 5:40 PM
My form displays item-level data from a table provided by the Interface. The table has fields TYPE and AMOUNT (character and currency respectively). If the TYPE is filled, then I want to display the AMOUNT; otherwise I don't want to display the AMOUNT. To achieve that, I use Conditions on the AMOUNT field in the Context so that the AMOUNT is not shown if the TYPE is <space>.
If I have data like this, then everything is ok:
Item: 1 2 3 4
Type: A A B C
Amount: 1.00 0.00 2.00 3.00
But if the data is like this, then there is a problem:
Item: 1 2 3 4
Type: A B C
Amount: 1.00 0.00 2.00 3.00
For item 2, the Condition is not met, so I don't want to display the AMOUNT. But it goes wrong.
Instead of just suppressing the AMOUNT field, the form (for some reason) takes the AMOUNT from the next available item, and displays as if the data was like this:
Item: 1 2 3 4
Type: A B C
Amount: 1.00 2.00 3.00
So for item 2, the AMOUNT is displayed without a TYPE, and no AMOUNT is displayed for item 4.
How can I prevent or avoid this strange behaviour?
Thanks,
Dave
Hi Dave,
Can you provide the screenshot of the condition logic you have applied in the context?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dave,
As per my understanding, if you want to hide the 'Amount' field when 'Type' is initial, you can write the FormCalc logic at the layout level in script editor (Note: you have to remove the conditions mentioned in the context).
select the row 'FIELD47_3' in Hierarchy palette, and select 'Form Ready' from the drop down.
Write the below logic.
if ($.TYPE == null) then
$.AMNT.presence = "hidden"
endif
if you want to hide entire row, then write the below logic
if ($.TYPE == null and $.AMNT == "0.00") then
$.presence = "hidden"
endif
Hi Raghu,
Thanks for that interesting and positive approach.
In the Layout editor, FIELD47_3 does not appear in the Hierarchy palette (only in the Data View palette). Only the individual fields appear in the Hierarchy palette.
Selecting FIELD47_3 (or any other data element) in the Data View palette doesn't cause the script editor to change, so I guess no event code can be entered at that level. The form:ready window continues to refer to the first element of the form:
data.#pageSet[0].Page1.P1::ready:form - (Formcalc, client)
Instead, I went back to the Hierarchy palette, and tried this script code for the AMNT field (the TYPE field is x47_3a, and the AMNT field is x47_3b):
data.#pageSet[0].Page2.P2.x47_3a[0]::ready:form - (Formcalc, client)
if (data.#pageSet[0].Page2.P2.x47_3a[0] == null) then
data.#pageSet[0].Page2.P2.x47_3b[0].presence = "hidden"
endif
But it didn't work - the value 0,00 was still shown. I also tried specifying ' ' instead of null, with the same result.
Any further guidance would be appreciated - thanks,
Dave
Hi Raghu,
After some experimentation, I found that it is necessary to use the "Validate" event instead of the "Form Ready" event to control the output. I think that's because the latter event is only fired for sub-forms, whereas my fields are on a Master Form.
Then using code more-or-less as you described, everything works ok now.
Thanks again,
Dave
Dave,
Please mention if you want to hide only the AMOUNT field or the total column??
Regards,
Naveen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dave,
I am not sure if the alternative can enter NULL.
As normally in formcalc i will check 2 things one is "" and null.
I have a suggestion which might be simpler solution for you.
Go to form interface, in the initialization tab, do ABAP code to delete those record(s) with TYPE IS INITIAL. Put a break-point, so that you can debug your code(if your form is not from portal).
And you no need to do any headache condition / alternative / formcalc scripting in form
Good luck.
regards,
Xiang Li
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.