---
title: "Conditional Logic in Automation Components"
slug: "best-practices-for-using-conditional-logic-in-panaya-test-automation-components"
updated: 2025-05-19T08:58:14Z
published: 2025-05-19T08:58:14Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://success.panaya.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Conditional Logic in Automation Components

Follow the guidelines below so that components remain clean and easy to maintain, and promote reuse.

Use conditional logic in components, when -

- The variations are small and localized (e.g., one or two fields change per process type).
- You have dozens of processes using the same transaction (like VA01 with ZOR, ZRE, RE, etc.), but 80–90% of the logic is shared.
- You want to avoid duplication and reduce script maintenance when SAP UI changes.

Avoid using conditional logic when -

- The process variations are too large, or logic becomes unreadable (many IFs, deeply nested conditions).
- When testers can't easily understand the script without reading all the branches.
- If debugging becomes hard, script readability suffers.

Consider splitting and having a dedicated version of the component per major variant (e.g., `VA01_CreateZOR`, `VA01_CreateRE`). These can still share subcomponents internally (e.g., partner tab, item entry), so you can modularize at a finer level. We recommend splitting if more than ~20–30% of the steps are conditional.

> [!NOTE]
> Tips!
> 
> - Start with a base component with shared logic (e.g., fill header fields).
> - Create process-specific wrappers that call the base component with parameters or slight overrides.
> - Consider breaking VA01 into smaller pieces like: VA01_Header, VA01_Items, VA01_Partners and mix them per process.
> - If your script becomes a tangle of `IF ProcessType = ...`, it's probably time to split.
> 
> But if a handful of fields toggled by order type, controlled via script variables, dynamic logic is a strong way to reduce duplication, especially when used in well-scoped components.
