cancel
Showing results for 
Search instead for 
Did you mean: 

Requirements to hide objects at runtime

Former Member
0 Kudos

Hi,

what are the requirements to hide objects at runtime?

I have a form (non-interactive) which uses a DDIC interface. I create the PDF via the common function moduls (no shared context by WD4A and ADOBE form...)

The only thing I want is to hide certain fields when certain condition apply. E.g., when the the material is raw material, i need to display the vendors, otherwise I need to hide them.

So is this possible? What Do I have to do to make it possible?

I have created a FormCalc script at "initialization" of the field, I checkmarked the "DYNAMIC" field in the structure of my form function modul, I declared in the form that scripts should run server/client side --> but it does not work.

My script at initialization of $object is:

if ( HasValue($object) = 1 )

then $object.presence = 'hidden'

endif.

My question is really just about dynamic hiding via script. I know that I can hide via binding of subforms under certain situations but thats not the issue here.

If you can give me any hint with the corresponding details, I would be happy!

Accepted Solutions (1)

Accepted Solutions (1)

OttoGold
Active Contributor
0 Kudos

Becuase when you have two sub forms S1 and S2 and depending on Text Field value placed in S1 you want to show TextField2 under S2.

lets have SM a subform which is a parent of S1 and S2, just to be clear.

That gives us (JS) script placed (for example) on the target textfield2:

 if (this.parent.parent.S1.testField.rawValue == null) this.presence = "hidden"; 

first parent: S2 (parent sub of field)

second parent: SM (parent sub of S2)

in this context goto S1, field testField

Regards, Otto

chintan_virani
Active Contributor
0 Kudos

We are not on same level. I am referring as what would you do when we have following hierarchy.

form1
|-- Master Page
     |-- Page1
          |-- Content Area
|-- Subform1  
     |-- TextField1
|-- Subform2
     |--  TextField2

So Subform1 and Subform2 are not under a parent and are two pages.

Chintan

Former Member
0 Kudos

Timeout guys!

Concentrate on my problem!!!

Ok, I will now give it a last try to solve my issue via scripting. Your comment regarding it a very appreciated as I have no Java experience.

Anyhow, the only problem i face right now is that I cant set FILLABLE to 'X' and thats maybe because ADS is not configured correctly. I get a corresponding expection. I can set it to "N" but that does not let me same the form with data, as I understood you.

But looking at the details of SAP license agreement make we wonder whether my approach is reasonable at all.

I mean I just want to hide a lausi field, but need to make the whole form interactive and exactly thats where SAP wants to have the money. Maybe its better so solve my issue via changes to the interface structure and binded subforms.

Anyhow, thank you two very much for your help!

Get ready for round two! Haha!!

chintan_virani
Active Contributor
0 Kudos

Yes unfortunately Interactive features come at a price. In fact even displaying a tooltip is considered to be interactive !!

And sorry for hijacking your thread with discussion. Also mark the thread as answered if your question has been answered.

Chintan

Answers (4)

Answers (4)

OttoGold
Active Contributor
0 Kudos

You´re trying to tell me, that "this" pointer is not working on this span pages?:P

chintan_virani
Active Contributor
0 Kudos

Nopes what I am saying as a general practive always write fully qualified names if you multiple sub forms.

Becuase when you have two sub forms S1 and S2 and depending on Text Field value placed in S1 you want to show TextField2 under S2.

If I have to write such a script in the initialize or form:ready then it makes sense to use fully qualified names for both fields.

Chintan

OttoGold
Active Contributor
0 Kudos

Hello,

1) you set values on 'X' or SPACE or let it blank, or CLEAR it to be sure it is blank (at least ABAP)

2) interactive costs money, why would one set this true if that is not inevitable? DYNAMIC (at least, ok, ok, maybe you´re right, Chintan) or FILLABLE must be set to make the form a real form, without that it is not a form at all (try to clear both and print the form, next open it in LCD outside SAP and check if it opens the form for you, it will offer you a import or conversion or something.

3) your scripting terrifies me:)) why don´t you use relative addressing? do you know "this" pointer and "parent" pointer in JavaScript? If not, read about it:))

4) when testing something for without-a-value, use field.rawValue == null

Regards, Otto

chintan_virani
Active Contributor
0 Kudos

Well infact writing completely hierarchy is essential for the field element when you have multiple subforms spanning across multiple pages. So I would not say it's a bad practice.

Chintan

OttoGold
Active Contributor
0 Kudos

Hello,

Chintan means DYNAMIC = 'X', he has a little mismatch about these form attributes:)) Regards, Otto

p.s.: I don´t use FormCalc at all, so I cannot tell if there is a syntactic error. Maybe you can use JS: if (condition) { this.presence = "hidden"; }. In JS you can use app.a-l-e-r-t("message") (without -) to get a popup with the "message" string. If you put this at the end of your script and can see the message at runtime, there is no syntactic problem (if there was one, the scripting would stop at the error). You can use this to check the important variables and their values at runtime, just replace the "message" by the variable number.

chintan_virani
Active Contributor
0 Kudos

Well if you check the help [here|http://help.sap.com/saphelp_nw70/helpdata/en/44/a36a5cdee42aabe10000000a1553f7/content.htm] , it clearly states that DYNAMIC is not valid until you set the FILLABLE parameter. 😛

Chintan

Former Member
0 Kudos

Hello Otto,

I am still struggeling with the task.

First:

I made DYNAMIC = ''X', I made FILLABLE = 'X'.

The generation dumps (even without my coding!) with the message "File does not begin with %PDF-" or something like that.

Do you know what happens here?

First:

I made DYNAMIC = ''X', I made FILLABLE = 'N'.

The generation is successfull, but my coding does not work. The field is just there visible.

You offered your help with Java so I will post my coding here. If the field has no data (is initial/empty/NULL) I dont want to display it. thats all. I use:


if (data.SubFormPage1.SF_NONMONETARY_DETAILS.DATA.UOM_DIMID_SHORTDESC == '') 
    { 
    data.SubFormPage1.SF_NONMONETARY_DETAILS.DATA.UOM_DIMID_SHORTDESC.presence = "hidden"; 
    }

Do you know what is going wrong? I once heared the rumor that scrips, especially hiding objects is only possible with an XML interface BUT NOT with an DDIC interface. Is that just a rumor or actually my problem?

Best regards!

Former Member
0 Kudos

Thanks for you answer!

As I already told Otto I tried it out with the following results:

First:

I made DYNAMIC = ''X', I made FILLABLE = 'X'.

The generation dumps (even without my coding!) with the message "File does not begin with %PDF-" or something like that.

Do you know what happens here?

First:

I made DYNAMIC = ''X', I made FILLABLE = 'N'.

The generation is successfull, but my coding does not work. The field is just there visible.

You mentioned these parameters. Do you know what is going wrong with the first case? The message appears even when I have no coding, so it cant be a script problem.

Best Regards!

Former Member
0 Kudos

Otto, one other question:

When I set FILLABLE to "N", the form is displayed but NONE of my data - and all the fields are only readable - are saved when i save the PDF on my local PC

I only want to use ADOBE forms to make a nice and pretty printout of data and even if I hide some objects the user must be able to save the data as PDF. And the objects should of course still be hidden if the user openes one of these PDF-files stored on his PC...

I am confused, but can my requirement be realilized or is there so much restriction in these ADOBE forms that its not possible what I described as my requirement?

chintan_virani
Active Contributor
0 Kudos

Well regarding the error you can make a search on SCN as there are lot of threads with same issue and you would easily find the solution.

Now in the script compare the value with " " and not ' '.

if (data.SubFormPage1.SF_NONMONETARY_DETAILS.DATA.UOM_DIMID_SHORTDESC == "") 
{ 
    data.SubFormPage1.SF_NONMONETARY_DETAILS.DATA.UOM_DIMID_SHORTDESC.presence = "hidden"; 
}

Also you will need to set both the parameters if you want to

1. Allow users to save the form on their local desktop with data they entered.

2. Manipulate elements/fields by hiding them.

Chintan

Former Member
0 Kudos

Thanks you very much for the hint regarding java. Anyhow nothing works as expected. My fields are not hidden.

So you mean its mandatory to set FILLABLE to an "X" and not an "N".

But I cant somehow solve the problem with "FIle does not begin with &PDF-".

I checked SDN, but my Acrobat Reader has "in browser" settings. Do you have an idea what the problem could be?

I did not thought that i run into so many issues when trying to hide a simple field

Thanks for your patience and help!

chintan_virani
Active Contributor
0 Kudos

Hiding objects is supported only in Interactive forms. You will need to change it to interactive by setting the FILLABLE parameter of SFPDOCPARAMS structure.

Chintan