Author: digitaleagle

Pinging and Posting from PeopleCode

I had a need to Ping a server to see if the server could get to it.  I also tried to post to it.  This code could be helpful for others, so I want to share it.  A post should normally go through the Integration Broker, but I first developed it at a time when I had a product that was supposed to go on servers with diverse versions of Integration Broker.

The Ping code doesn’t seem very reliable for some reason.  Something on the Java side doesn’t always work.  Still it might be helpful.

   Local JavaObject &url;
   Local JavaObject &conn;
   Local JavaObject &r;
   Local any &line;
   Local string &output;
   Local JavaObject &inet;
   Local string &address;

   MessageBox(0, "", 0, 0, "hostname: " | GetJavaClass("java.net.InetAddress").getLocalHost().getHostName());

   &address = "localhost";
   &inet = GetJavaClass("java.net.InetAddress").getByName(&address);
   MessageBox(0, "", 0, 0, &address | "(" | &inet.getHostAddress() | ") reachable: " | &inet.isReachable(5000));
   &address = "www.google.com";
   &inet = GetJavaClass("java.net.InetAddress").getByName(&address);
   MessageBox(0, "", 0, 0, &address | "(" | &inet.getHostAddress() | ") reachable: " | &inet.isReachable(5000));

   &url = CreateJavaObject("java.net.URL", "http://www.google.com");
   &conn = &url.openConnection();
   &conn.setRequestProperty("content-type", "application/x-www-form-urlencoded");
   &conn.setRequestProperty("accept", "text/xml/html");
   &conn.setRequestProperty("accept-charset", "utf-8, iso_8859-1");
   &conn.setRequestProperty("userid", "????");
   &conn.setRequestProperty("pwd", "?????");
   &conn.setDoOutput( True);

   &output = "";
   &r = CreateJavaObject("java.io.BufferedReader", CreateJavaObject("java.io.InputStreamReader", &conn.getInputStream()));
   &line = &r.readLine();
   While &line <> Null
      &output = &output | Char(10) | Char(13) | &output;
      &line = &r.readLine();
   End-While;
   &r.close();

   MessageBox(0, "", 0, 0, &output);

Please make sure to adjust the URLs and hostnames to what you need.

Resources

Searching with USEEDIT

Because many of the record properties are hidden in the Bit Map field USEEDIT, it is hard to search for properties.  If you are on Oracle, here’s some SQL that might help…

This SQL lists all of the fields with their properties broken out of that field:

SELECT FIELDNAME,
       USEEDIT,
       Bitand(USEEDIT, 1)         KEY,
       Bitand(USEEDIT, 2)         DUP_KEY,
       Bitand(USEEDIT, 4)         SYS_MAINT,
       Bitand(USEEDIT, 8)         AUDIT_ADD,
       Bitand(USEEDIT, 16)        ALT_SEARCH_KEY,
       Bitand(USEEDIT, 32)        LIST_BOX_ITEM,
       Bitand(USEEDIT, 64)        ASCENDING_KEY,
       Bitand(USEEDIT, 128)       AUDIT_CHANGE,
       Bitand(USEEDIT, 256)       REQUIRED,
       Bitand(USEEDIT, 512)       XLAT,
       Bitand(USEEDIT, 1024)      AUDIT_DEL,
       Bitand(USEEDIT, 2048)      SEARCH_KEY,
       Bitand(USEEDIT, 4096)      EDIT_REASONABLE_DATE,
       Bitand(USEEDIT, 8192)      EDIT_YES_NO,
       Bitand(USEEDIT, 16384)     EDIT_PROMPT_TABLE,
       Bitand(USEEDIT, 32768)     AUTO_UPDATE,
       Bitand(USEEDIT, 65536)     BIT65536,
       Bitand(USEEDIT, 131072)    BIT131072,
       Bitand(USEEDIT, 262144)    FROM_SEARCH,
       Bitand(USEEDIT, 524288)    TO_SEARCH,
       Bitand(USEEDIT, 1048576)   EDIT_BINARY,
       Bitand(USEEDIT, 2097152)   DISABLE_ADV_SEARCH,
       Bitand(USEEDIT, 4194304)   REGULAR_FIELD,
       Bitand(USEEDIT, 8388608)   DEFAULT_SEARCH_FIELD,
       Bitand(USEEDIT, 16777216)  BIT16777216,
       Bitand(USEEDIT, 33554432)  SEARCH_EDIT_KEYS,
       Bitand(USEEDIT, 67108864)  BIT67108864,
       Bitand(USEEDIT, 134217728) BIT134217728,
       Bitand(USEEDIT, 268435456) BIT268435456
FROM   PSRECFIELDALL
WHERE  RECNAME = 'JOB'; 

Read More

Search for a Field with Translates

I was looking for an “Internal/External” field.  I wanted a field already built that had two translate values: “E” and “I”.  This SQL did the trick:

SELECT A.FIELDNAME,
A.XLATLONGNAME,
B.XLATLONGNAME,
A.XLATSHORTNAME,
B.XLATSHORTNAME
FROM   PSXLATITEM A,
PSXLATITEM B
WHERE  A.FIELDNAME = B.FIELDNAME
AND A.FIELDVALUE = 'E'
AND B.FIELDVALUE = 'I'
AND Upper(A.XLATLONGNAME) LIKE 'EXT%'
AND NOT EXISTS (SELECT 'X'
FROM   PSXLATITEM C
WHERE  A.FIELDNAME = C.FIELDNAME
AND C.FIELDVALUE NOT IN ( 'E', 'I' )) 

I found the INTERNAL_EXTERNAL field, which works just perfect for me.

Anyone need remote help?

Does anyone know of any good contracts that would support mostly remote work?

I started this blog years ago with the idea that it would be a good place to search for work should I ever need it. I think the time has come to just ask to see if projects are available through this avenue. If you know of anything, I would love to speak with you. Would you mind commenting below or sending me a “Linked In” message?

New PeopleCode Dump Method

One of my old tricks was to create a PeopleCode dump from the system.  Then I could use a text editor tool such as gVim or Ultraedit to search through the code to find examples or certain uses of definitions.

Basically, a PeopleCode dump is easily created by searching for (Edit > Find In) a semicolon.  Because every statement must have a semicolon, it matches every statement of code in the system.  On the Find In dialog, checking the Save to File option will write out each line to a text file.

The problem is that Application Designer seems to load every line into memory.  If you don’t have a client machine with a ton of memory, you end up looking like this:

App Designer Out of Memory Error

 

Instead, I found this new tool called Decode PeopleCode.  You can download the latest zipped version of the program from here.

Once extracted, I had to configured the URL property in the DecodePC.properties file.  I set it to something like this:

url=jdbc:oracle:thin:@<server name>:1521/<db name>

I also had a problem with the JDBC driver for some reason.  It didn’t find the odbc5.jar file that was delivered.  I already had a copy of the odbc6.jar, so I just adjusted the classpath to include that.  If you run into the same problem, adjust the DecodePCODE.sh or DecodePCODE.bat file to contain the full path to the jar file.

Also, adjust the “outdir” property in the DecodePC.properties file to point to the directory where you want the output dumped.  Note that it will create a bunch of folders and files in that directory, so you may want to point it to an empty directory.

Then, I ran the program with this command to capture everything:

sh DecodePCODE.sh since 1901/01/01

Now, that creates each PeopleCode program in its own file.  The problem is that I want it all in a single file that I can run regular expressions against.  I could use grep, but I am used to a single file.  I cobbled this script together to build that single file:

#!/bin/bash


processFile() {
   outdirlen=$((${#OUTDIR} + 1))
   filename=$1
   lastUpdateFile=$( echo "$filename" | sed 's/\.pcode$/.last_update/' )
   peoplecodePath=${filename:$outdirlen}
   peoplecodePath=$( echo "$peoplecodePath" | sed 's/\//: /' | sed 's/\.pcode$//' | sed 's/\//./g')
   echo -e "\e[0K\r Writing: $peoplecodePath"
   echo "[$peoplecodePath]" >> "$OUTFILE"
   echo '/*   Details:' >> "$OUTFILE"
   echo '   Last Update User: ' $(head -n 1 "$lastUpdateFile") >> "$OUTFILE"
   echo '   Last Update Date/Time: ' $(tail -n 1 "$lastUpdateFile") >> "$OUTFILE"
   echo '*/' >> "$OUTFILE"
   cat "$filename" >> "$OUTFILE"
}


#  ------------------------------
#    Main
#  ------------------------------

OUTDIR=$( grep "outdir=" DecodePC.properties | sed 's/^outdir=//' | sed 's/\r//')
DUMPDATE=$(stat -c %y $(ls -rt | tail -n 1) | cut -d ' ' -f1 )
DATABASE=$( grep "^url=" DecodePC.properties | sed 's/^url=.*\///' | sed 's/\r//')
OUTFILE="$OUTDIR/all.pcode"
echo "outdir -- $OUTDIR  dump date -- $DUMPDATE  database -- $DATABASE"

echo "PeopleCode Dump $DATABASE   $DUMPDATE" > "$OUTFILE"
find "$OUTDIR" -type f -name \*.pcode | while read file; do processFile "$file"; done

That seemed to get the trick done for me nicely.

This program has more features than just this. You should explore it. It can check the code into a sourcecode repository to track changes. Kudos to whoever wrote it!

Resources

 

Jethro List: Data Mover Woes

Ok.  Maybe this is a rant, but Data Mover can sometimes get under my skin!  Some things you just expect to work, and when they don’t, it is very frustrating.

Here’s my problem.  I created this very, very simple data import:


set log C:\temp\aa_setup_import_FADEV.log;
set input C:\temp\aa_setup_export_AATST.dat;

replace_data RQ_GRP_SHR_SET;
delete PS_RQ_GRP_TBL where RQRMNT_USEAGE = 'ADV';
import RQ_GRP_TBL where RQRMNT_USEAGE = 'ADV';

It gave me this error:

Importing RQ_GRP_TBL
Error: Syntax error in where clause for RQ_GRP_TBL 

Then, when I changed it to use parameters, it suddenly works:


set log C:\temp\aa_setup_import_FADEV.log;
set input C:\temp\aa_setup_export_AATST.dat;

replace_data RQ_GRP_SHR_SET;
delete PS_RQ_GRP_TBL where RQRMNT_USEAGE = 'ADV';
import RQ_GRP_TBL where RQRMNT_USEAGE = :1;CHAR,ADV;

In my opinion, there is no call for that error.  I thought both syntaxes were supposed to work the same.  Am I missing something?  Or, is this a bug in data mover?

 

Next, I ran into a worse problem.  I couldn’t make my subquery work on the import, so I had to move it to the export script instead.  I tried this:


set log C:\temp\aa_setup_export_AATST.log;
set output C:\temp\aa_setup_export_AATST.dat;

export RQ_GRP_SHR_SET;
export RQ_GRP_TBL where RQRMNT_USEAGE = :1;CHAR,ADV;
export RQ_GRP_DETL_TBL where
EXISTS (SELECT 'X' FROM PS_RQ_GRP_TBL A
 WHERE A.RQRMNT_GROUP = PS_RQ_GRP_DETL_TBL.RQRMNT_GROUP
 AND A.RQRMNT_USEAGE = :1);CHAR,ADV;

Every time that I tried it, it would crash Data Mover.  Data Mover closed with no error message, warning, or anything.  When I changed it to this, it worked fine:


set log C:\temp\aa_setup_export_AATST.log;
set output C:\temp\aa_setup_export_AATST.dat;

export RQ_GRP_SHR_SET;
export RQ_GRP_TBL where RQRMNT_USEAGE = :1;CHAR,ADV;
export RQ_GRP_DETL_TBL where
EXISTS (SELECT 'X' FROM PS_RQ_GRP_TBL A
 WHERE A.RQRMNT_GROUP = PS_RQ_GRP_DETL_TBL.RQRMNT_GROUP
 AND A.RQRMNT_USEAGE = 'ADV');

Again, why?  I don’t care what your argument is, it is a bug when a program closes with no message.  If I did something wrong, tell me.  Don’t just close.

Resources

Oracle Forums: DATAMOVER: Error: Syntax error in where clause for PSOPRDEFN

PeopleSoft HCM PUM Image with PeopleTools 8.54

I just noticed that the HCM PUM image is now available on PeopleSoft support.  You can download it for the HCM updates, but you can also take a peak at what PeopleTools 8.54 looks like.  If you have an Oracle Support account, here’s the link:   PeopleSoft Update Image HCM 9.2.008.

PUM HCM Image

Just for reference, the image is a total of 11 files and 34.7G.

PUM HCM Image Files List

Resources