Saturday, May 8, 2010

Extract All Application Engine PeopleCode

Most of us do come across situations where we would like to see the actual usage of a function in PeopleCode. The standard feature of Find In with the Save PeopleCode to File check-box checked is the most commonly used approach. However, I prefer the below approach. I'm guessing that this function is available from Tools 8.50 as I came across this in latest PeopleBooks. The function GetProgText() can retrieve PeopleCode from a step for an Application Engine program. This function, however, cannot be used online. Hence, I went ahead and created an Application Engine program to retrieve all the PeopleCode written in all the Application Engine programs in FSCM 91. Though I was surprised to see that there were certain Application Engine programs with PeopleCode actions, but no PeopleCode. What is also nice about the function is that while extracting, it actually compiles the PeopleCode. This was evident, when I received compilation errors for
1. Fields not defined on State Records
2. Incorrect reference of an Import statement
etc.,

----Sample Program----
Do Select SQL - Please be mindful, that the Do Select Type for this Action has to be set to Reselect
%Select(AE_APPLID, AE_SECTION, MARKET, EFFDT, AE_STEP)
SELECT AE_APPLID
, AE_SECTION
, A.MARKET
, A.EFFDT
, AE_STEP
FROM PSAESTMTDEFN A
WHERE AE_APPLID > %Bind(AE_APPLID)
AND AE_STMT_TYPE = 'P'

PeopleCode Action
import SCM_UTILITIES:ExceptionUtilities:ExceptionHandler;

try
If FileExists("D:\Temp\AllAEPC.out", %FilePath_Absolute) Then
REM *** Coming in for the nth time ***;
&fAEPCFile_ = GetFile("D:\Temp\AllAEPC.out", "A", "UTF8", %FilePath_Absolute);
Else
REM *** Coming in for the first time ***;
&fAEPCFile_ = GetFile("D:\Temp\AllAEPC.out", "W", "UTF8", %FilePath_Absolute);
End-If;
&PeopleCodeText = GetProgText(PPAEPCEXT_AET.AE_APPLID.Value, PPAEPCEXT_AET.AE_SECTION.Value, PPAEPCEXT_AET.MARKET.Value, "default", PPAEPCEXT_AET.EFFDT.Value, PPAEPCEXT_AET.AE_STEP.Value, "OnExecute");

&fAEPCFile_.WriteLine("REM *** Application Engine - " | PPAEPCEXT_AET.AE_APPLID.Value | " *** " | " Section - " | PPAEPCEXT_AET.AE_SECTION.Value | " *** " | " Step - " | PPAEPCEXT_AET.AE_STEP.Value | " ***");

&fAEPCFile_.WriteLine(">---------------------------------------------------------------<"); REM *** Write only if there is something to write ***;
If All(&PeopleCodeText) Then
&fAEPCFile_.WriteLine(&PeopleCodeText);
End-If;

&fAEPCFile_.WriteLine(">---------------------------------------------------------------<"); REM *** Generic Exception Handling ***;

catch Exception &ex
Local SCM_UTILITIES:ExceptionUtilities:ExceptionHandler &handler = create SCM_UTILITIES:ExceptionUtilities:ExceptionHandler();
REM *** Display the Message Text and Message Explain Text and then FAIL it!!! ***;
REM Error (&handler.getMessageText(&ex));
REM Be careful, since you’re using the messagebox and it causes an implicit COMMIT in certain tools version;
MessageBox(0, "", 0, 0, "Exception Logged > " | &handler.getMessageText(&ex));
Error (&handler.getMessageExplainText(&ex));
end-try;

3 comments:

Unknown said...

Man, I am surprised that there are no comments from hardcore PeopleSoft techies on this. I just happens to be what I was looking for. Thank-you, GRK

Stephen Phillips said...

I've wanted to explore this for a while, and your post was helpful. The problem is that it only takes care of PeopleCode inside of an Application Engine. I wanted something that would dump all of the PeopleCode in the whole system.

Instead, I found a new tool called Decode PeopleCode.

Here are my notes.

Ciphersbak said...

@Stephen Phillips
Yes, this only extracts the AE PeopleCode and the Decode PeopleCode project you have highlighted is ideal for extracting PeopleCode. Here is a link to a similar post http://psftpp.blogspot.in/2011/03/extract-project-peoplecode-and-sql.html

PS - This was created some time back hence the Decode Project might not be the latest version.

Also, with PeopleTools, I find it easier to query PSPCMPROGTXT to find/extract the PeopleCode.