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

26 comments:

  1. Thanks Saad, keep 'em coming.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. Hello Saad, I have a few questions about writing Java and C components:

    1. After code is developed and files are put in desired directories, how would one go about compiling it?
    2. Before implementing a C or Java function, what is the best way to go about testing it?
    3. Which editors/IDEs do you recommend for above?

    Thank you very much for taking the time to write to this blog; I am learning a lot! I hope to hear from you.

    ReplyDelete
    Replies
    1. ant can be used for all java code. You will see a build.xml file in $LESDIR. C code can be compiled using make and standard compilers.

      But if you are doing server side components - there will hardly be a need to do java or C - groovy pretty much provides you all you need.

      Delete
  4. Hello Saad,

    I have a question regarding moca command "process inventory adjustment".
    We have a requirement to mass upload all the available inventory in the warehouse.

    Can you please provide any suggestion on what can be the method for mass uploading the inventory?

    I am totally confused if the process inventory adjustment command can somehow be used for bulk uploads or if there is some other way to do that.

    Thank you.

    ReplyDelete
  5. Hi Varuni,
    You can do that by running a command like this:
    publish data where prtnum ='ITEM NUMBER' and lotnum = 'BATCH INFO' and stoloc = 'STORAGE_LOCATION' and untqty = '4' and expire_dte = '20181101000000' and mandte = '20180430000000' and usr_id = 'USER_ID' and adj_ref1 = 'REFERENCE' and invsts = 'INVENTORY_STATS'.

    I've got an excel that creates these commands in bulk for me, you just need to paste all the information needed in some columns.

    I hope this helps.

    ReplyDelete
    Replies
    1. Hello Chrille,

      Thank you. The issue I am facing is that process inventory adjustment has a whereclause create inventory.

      This is where I am stuck in creating excel.

      Can you please suggest anything on that.

      Thank you.

      Delete
    2. Hi,
      Inventory adjustment is just that, adjustment of inventory already in stock. WHat is it exactly that you want to achieve?

      Delete
    3. I want to do a mass upload of inventory.

      Delete
  6. Hello Chrille,
    I am new to MOCA, could you please tell me what is the use of "publish" command. is it like update or anything else?

    Thanks.

    ReplyDelete
    Replies
    1. MOCA execution context is a stack. Much like use of |s in Windows or Unix OS. Output of one command becomes input of the next. So for example you do "dir" its output is list of files in a directory. The next command can work on this "output" as "input", e.g. a copy command or delete command.

      "publish data" is a simple command whose only purpose is to simply publish what is passed in. So it serves as a tool to manipulate the execution context.

      In SQL world on Oracle we sometimes to select from dual. or in SQLsever we do select without a table - this is in some ways similar to that idea. Or if working in shells; we can use echo to enter data to a stack stream.

      Delete
  7. what does the sprintf MOCA function do?Can you give some example about sprintf function and other complex MOCA function?

    ReplyDelete
  8. How do i run 2 of the same commands at the same time

    ReplyDelete
  9. I am very new to MOCA and I am trying to capture user input via a workflow with a move inventory trigger. Is there a MOCA command that allow you to accept user entry beyond the Y/N workflow response?

    what does @@ mean

    ReplyDelete
    Replies
    1. If we write @@varriable it means it will take parameter from environment varriable like user id or warehouse id

      Delete
  10. Hello Saad,

    is there any detail document on mtf_server_config.properties
    was mainly looking for more details on below configuration

    terminal.floodprotection
    terminal.maxcon
    terminal.maxqueued

    ReplyDelete
  11. HI Sir I am totally new for MOCA. Can you please, suggest any link or PDF Tutorial with command set for beginners

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. I am working on a new client https://github.com/IkeRolfe/JdaTools/releases
    give it a try and drop some feedback.
    This a VERY early version.

    ReplyDelete
  14. All thanks to Mr Anderson for helping with my profits and making my fifth withdrawal possible. I'm here to share an amazing life changing opportunity with you. its called Bitcoin / Forex trading options. it is a highly lucrative business which can earn you as much as $2,570 in a week from an initial investment of just $200. I am living proof of this great business opportunity. If anyone is interested in trading on bitcoin or any cryptocurrency and want a successful trade without losing notify Mr Anderson now.Whatsapp: (+447883246472 )
    Email: tdameritrade077@gmail.com

    ReplyDelete
  15. Îi mulțumesc enorm doctorului Reethesh pentru ajutorul extraordinar pe care mi l-a oferit. În ultimele cinci luni, eu și partenerul meu am trecut prin conflicte grave care amenințau să ducă la divorț. Eram foarte fericiți împreună și relația noastră mergea excelent. Pe 14 februarie anul acesta, am ieșit la o întâlnire și totul părea în regulă, dar ulterior au început problemele. Pe 10 martie, el a avut un interviu la care trebuia să participe, lucru pe care l-a și făcut. În aceeași lună, a început să primească apeluri și mesaje de la un anumit număr, prin care i se cerea să se întâlnească din nou cu acea persoană. Când l-am întrebat despre asta, mi-a spus că era doar o prietenă care voia să vadă ce mai face. Situația a continuat, așa că am insistat să aflu adevărul, ceea ce a dus la certuri între noi. Apoi, în săptămâna următoare, mi-a spus că vrea să divorțăm; și-a făcut bagajele și a plecat de acasă. Eram devastată și plină de tristețe, pentru că îmi iubeam partenerul. În plus, simțeam că nu acționa din proprie inițiativă. Pe 15 mai, am primit o scrisoare de la instanță prin care mi se cerea să semnez actele. Pe parcursul lunilor iunie și iulie, situația a stagnat, iar avocatul meu m-a sfătuit să renunț, spunând că nu mai poate face nimic și că ultima înfățișare în instanță urma să aibă loc pe 5 septembrie. Tocmai când eram pe punctul de a renunța la tot, verișorul meu m-a sfătuit să iau legătura cu doctorul Reethesh, fiind convins că acesta mă va putea ajuta. Când am contactat doctorul Reethesh, i-am explicat întreaga situație. El mi-a cerut fotografiile noastre (a mea și a partenerului meu) și plata pentru materialele necesare ritualului. Am achitat totul. Atunci, doctorul Reethesh a descoperit că avocata care îl reprezenta pe partenerul meu era cea care instiga la toate conflictele dintre noi; ea îi făcuse un blestem de dragoste malefic pentru a mi-l lua. Doctorul Reethesh mi-a spus că, în ziua ultimei înfățișări la tribunal, partenerul meu își va reveni în fire și îmi va cere iertare. Totul s-a întâmplat chiar pe 5 septembrie, în ultima zi de audieri în instanță. În fața tuturor celor prezenți în sala de judecată, partenerul meu m-a implorat să-l iert și și-a cerut scuze. De asemenea, avocata a recunoscut că ea a stat la baza întregii situații și m-a rugat să o iert pentru faptele sale greșite. În timp ce citiți acest mesaj, eu și partenerul meu suntem din nou împreună, iar relația noastră este mai puternică și mai bună ca niciodată. Îl puteți contacta pe DR. REETHESH dacă aveți nevoie de ajutorul său; îl găsiți pe WhatsApp la numărul +2349012999010 sau prin e-mail la reethesh60@gmail.com

    ReplyDelete
  16. DR WALE, vreau să-ți mulțumesc pentru toate lucrurile bune pe care le-ai făcut pentru familia mea. Părinții mei întâmpinau dificultăți în a-și rezolva problemele, dar nimic nu părea să funcționeze pentru ei. S-au separat, iar acest lucru a fost extrem de greu pentru noi, copiii. Ne doream să-i vedem pe ambii părinți din nou împreună, așa că am apelat la DR WALE, deoarece el fusese cel care o ajutase pe sora mea să-și salveze căsnicia când avea probleme cu soțul ei. Așadar, l-am contactat pe DR WALE să vedem dacă îi poate reuni pe părinții noștri. Când am luat legătura cu el, ne-a întrebat de cât timp erau separați părinții noștri. I-am spus că de șase ani. A zis că nu e nicio problemă. După ce totul a fost finalizat, am descoperit că cea mai bună prietenă a mamei noastre fusese cea care făcuse tot posibilul ca părinții noștri să nu mai fie împreună. Datorită lui Dr. Wale, părinții noștri sunt în sfârșit din nou împreună. Acum suntem uniți, ca o familie mare. Dacă părinții tăi sunt divorțați și vrei să se împace, Dr. Wale este persoana potrivită pe care să o contactezi. Îl poți contacta pe Dr. Wale prin WhatsApp sau Viber la numărul +2347054019402 ori prin e-mail la drwalespellhome@gmail.com

    ReplyDelete
  17. Pe când eram însărcinată, nu am știut nicio clipă că soțul meu și bona aveau o aventură. Nu am bănuit niciodată că așa ceva se întâmpla pe la spatele meu. Ceea ce am observat a fost că bona îmi ignora constant deciziile ori de câte ori încercam să o corectez; se uita la mine cu dispreț și nu-mi lua niciodată cuvintele în serios. Situația a continuat așa. Într-o zi, am încercat să o întreb despre comportamentul ei necorespunzător în casă, dar, înainte să apuc să spun ceva, a explodat, cerându-mi să nu-i mai pun la îndoială acțiunile. În acel moment, mi s-a încețoșat privirea, iar ea m-a împins violent. Când soțul meu s-a întors de la serviciu, i-am povestit ce s-a întâmplat, dar el nu a făcut nimic. Când am încercat să-mi susțin punctul de vedere, soțul meu și bona m-au atacat. Apoi, soțul meu a intrat în camera noastră, mi-a făcut bagajele și m-a dat afară din casă, spunându-mi că nu mai este interesat de mine. Am plecat din casă plângând și suferind, întrebându-mă unde a greșit totul. Anterior, citisem pe internet despre un anume DR REETHESH, care primise recenzii foarte bune. I-am luat numărul de telefon și i-am explicat prin ce trec. Mi-a cerut să plătesc pentru materialele necesare, lucru pe care l-am făcut. DR REETHESH a efectuat un ritual spiritual și a descoperit că bona punea o substanță malefică în mâncarea și apa soțului meu, cu scopul ca acesta să se poarte urât cu mine și să mă alunge de acasă. Din fericire, DR REETHESH mi-a sărit în ajutor. Bona a fost demascată, iar planurile ei diabolice au eșuat. Astăzi, soțul meu și cu mine ne-am întâmpinat copilul și trăim din nou fericiți împreună. Vă sfătuiesc să luați legătura cu DR REETHESH dacă aveți probleme care vă frământă. Îl puteți contacta prin WhatsApp la +2349012999010 sau prin e-mail la reethesh60@gmail.com

    ReplyDelete