Friday, May 26, 2017

Some Handy Moca Commands

Overview

In this blog post I am listing some handy MOCA commands that can help when performing adhoc support tasks on a RedPrairie server.
Command Description Sample Call Sample Use Case
Manage data via in memory tables
File System
remove file Remove a file on the file system remove file where filnam = 'xxxx' You can remove a file on the file system
sl_cat file get contents of a file in a single string sl_cat file where filename = @@DCSDIR || '.../move_inventory.mcmd' You can read a file in one string and then you could search for text within tha file
write output file write file on the file system write output file where path = @@LESDIR || '/log' and filnam = 'temp.log' and data = 'test' You can write a file on the file system
find file Look for files on the file system /* * This simple snippet traverses * all custom code and lists * all source code files */ find file where pathname = @@LESDIR || '/src/cmdsrc/*' | { if ( @type = 'D' ) find file where pathname = @pathname || '/*.m*' } You can query all commands for a certain text without going at the file system
Command Repository
list active commands This will list all active commands on the server without need of going to the file system. It will return business logic as well list active commands where command = "list carrier details" You can query all commands for a certain text without going at the file system
list active command arguments This will list all command arguments for a command list active command arguments where command = "move inventory" You can query all command arguments for a certain text without going at the file system
list active triggers This will list all command triggers for a command list active triggers where command = "move inventory" You can query all command triggers for a certain text without going at the file system
Database. RedPrairie supports multiple databases. These commands make it easy to query data dictionary without worrying about specific database being used
sl_get db_info Get important information about the database we are connected to sl_get db_info get basic information like database type, name, instance, schema, version, etc.
dbtype Function to get database type, i.e. ORACLE or SQLSERVER publish data where x = dbtype() Useful if you every have to write database specific code
list user tables Get all the tables in the database /* * Return all authentication * tables */ list user tables where table_name like 'LES%ATH%' Useful to do adhoc database operations
list table columns Get all the columns for a table list table columns where table_name = 'les_usr_ath' Useful to do see columns of a table
list tables with column Get all the tables in data dictionary that have a certain column list tables with column where column_name = 'usr_id' To find affect of changing value of a column or other adhoc support tasks
list table indexes Get all indexes for a table list table indexes where table_name = 'invlod' To see indexes for a table and then columns within the index in easy to read format as a coma-separated list
Groovy Groovy Groovy
And best of all is Groovy - you can do almost anything you can imagine. Call web services, perform complex string operations etc. etc. etc. With groovy available there is hardly ever a need to write components in C or Java