🚀 Mastering Uniface moveocc: Moving Field Values Between Occurrences Like a Pro
Peter + AI

Peter + AI @petercode

Joined:
Jul 12, 2025

🚀 Mastering Uniface moveocc: Moving Field Values Between Occurrences Like a Pro

Publish Date: Jul 19
0 0

Working with Uniface ProcScript can be incredibly powerful, especially when you need to manipulate data occurrences efficiently. Today, let's dive deep into one of the most useful statements for data manipulation: moveocc! 📊

This article is based on the official Uniface documentation 10.4 and was created with the assistance of AI to ensure comprehensive coverage of the topic.

🎯 What is moveocc?

The moveocc statement is your go-to tool when you need to move field values from the current occurrence to another occurrence within an entity. Think of it as a sophisticated "cut and paste" operation that not only moves data but also handles all the underlying modification flags and validation states automatically.

📝 Syntax Breakdown

The moveocc statement comes in two flavors:

moveocc {Entity,} OccurrenceNumber {, FieldList}
moveocc/allfields Entity, OccurrenceNumber
Enter fullscreen mode Exit fullscreen mode

🔧 Parameters Explained

Parameter Type Description
Entity String Entity name (optional - uses current entity if omitted)
OccurrenceNumber Number Target occurrence number (integer values only)
FieldList String Comma-separated list of fields to move

🎛️ The /allfields Qualifier

When you use the /allfields qualifier, all fields from the current occurrence are moved to the target occurrence. It's like saying "move everything!" 📦

💡 Practical Example

Here's a real-world scenario where moveocc shines:

operation uupdate ENT
params
 occurrence pEntity :IN
endparams

findkey pEntity 
moveocc pEntity, $result, $fields$

end ; end occurrence
Enter fullscreen mode Exit fullscreen mode

This example demonstrates updating an entity by finding an occurrence with the same key and moving specified fields to it. Clean and efficient! ✨

🔄 What Happens Behind the Scenes

When you execute moveocc, several important things happen automatically:

  • Data Transfer: Field values move from current to target occurrence
  • Current Occurrence Changes: Target becomes the new current occurrence
  • Old Occurrence Cleanup: Original occurrence gets deleted
  • Modification Flags: $fieldmod sets to 1 for all moved fields
  • Validation States: All relevant validation functions update accordingly

⚠️ Error Handling Like a Pro

Always check your $status and $procerror values:

$status Meaning
< 0 Error occurred - check $procerror
>= 0 Success - returns sequence number of new current occurrence

🚨 Common Error Codes

  • -1102: Invalid entity name or entity not painted on component
  • -1203: Value out of range
  • -1101: Incorrect field name provided
  • -302/-303: Key incorrect

🎨 Best Practices

  1. Always validate inputs: Check entity names and field lists before execution
  2. Handle errors gracefully: Implement proper error checking
  3. Use meaningful variable names: Makes debugging much easier
  4. Consider performance: Moving large field sets can impact performance

🌟 Component Compatibility

Good news! moveocc works in all component types except Dynamic and Static Server Pages. This gives you flexibility across most of your Uniface applications.

🎯 Conclusion

The moveocc statement is an incredibly powerful tool for data manipulation in Uniface. Whether you're updating records, consolidating data, or implementing complex business logic, understanding how to use moveocc effectively will make your ProcScript code more efficient and maintainable.

Remember to always handle errors properly and test thoroughly with your specific use cases. Happy coding! 🎉

Comments 0 total

    Add comment