How to apply condition on subform in adobe form in sap | Community
Skip to main content
September 13, 2024
Solved

How to apply condition on subform in adobe form in sap

  • September 13, 2024
  • 1 reply
  • 3020 views

Hello all,

How to apply the condition on subform in adobe form in sap abap without using javascript?
i will pass the value from driver code and if 'that' value matches to the 1st condition let's say 'ABC' then first subform should be display and if it matches to 2nd condition let's say 'PQR' then second subform should display.
(if subform get hidden or visible according to condition it is also -OK)

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by radzmar

You can use predicates in the data bindings to create conditions. As an example, you can have the following XML with addresses: 

<addresses> <address> <country>DE</country> <city>Berlin</city> <street>Brandenburger Tor</street> </address> <address> <country>DE</country> <city>München</city> <street>Stachus</street> </address> <address> <country>UK</country> <city>London</city> <street>Oxford street</street> </address> <address> <country>US</country> <city>New York</city> <street>Times Square</street> </address> </addresses>

 

Create a data connection based on that XML to your form.

Then create a related fields by dragging the elements from the data connection palette into the design window ob by double clicking them. 

 

Select that newly created subform „address“ and open its binding palette. By default it's bound to $.address[*]. This needs to changed. 

 

Change the string into $.address.[country == "DE"], so it contains a predicate which dictates under which condition the binding should happen. Rename the subform accordingly and remove the Min count. This subform now is only visible, when the XML data contains at least one element where the country is set to "DE". 

 

Duplicate the subform and change the binding for the copy to $.address.[country == "UK"] for UK and so on. The forms hierarchy could looks like this. 

When the XML data is populated into the form, the subforms will be added depending on the conditions met. The colors are just for demonstrations. 

 

 

 

 

 

 

 

1 reply

radzmar
radzmarAccepted solution
Level 10
September 16, 2024

You can use predicates in the data bindings to create conditions. As an example, you can have the following XML with addresses: 

<addresses> <address> <country>DE</country> <city>Berlin</city> <street>Brandenburger Tor</street> </address> <address> <country>DE</country> <city>München</city> <street>Stachus</street> </address> <address> <country>UK</country> <city>London</city> <street>Oxford street</street> </address> <address> <country>US</country> <city>New York</city> <street>Times Square</street> </address> </addresses>

 

Create a data connection based on that XML to your form.

Then create a related fields by dragging the elements from the data connection palette into the design window ob by double clicking them. 

 

Select that newly created subform „address“ and open its binding palette. By default it's bound to $.address[*]. This needs to changed. 

 

Change the string into $.address.[country == "DE"], so it contains a predicate which dictates under which condition the binding should happen. Rename the subform accordingly and remove the Min count. This subform now is only visible, when the XML data contains at least one element where the country is set to "DE". 

 

Duplicate the subform and change the binding for the copy to $.address.[country == "UK"] for UK and so on. The forms hierarchy could looks like this. 

When the XML data is populated into the form, the subforms will be added depending on the conditions met. The colors are just for demonstrations.