Friday, December 7, 2012

Calling java system utilities for the environment specification



The following program would give details on the user environment and also the java class path:


Local string &file_sep = GetJavaClass("org.apache.commons.lang.SystemUtils").FILE_SEPARATOR;
MessageBox(0, "", 0, 0, "The file seperator is: " | &file_sep);

Local string &file_encode = GetJavaClass("org.apache.commons.lang.SystemUtils").FILE_ENCODING;
MessageBox(0, "", 0, 0, "The file encoder: " | &file_encode);

Local string &java_ext_dirs = GetJavaClass("org.apache.commons.lang.SystemUtils").JAVA_EXT_DIRS;
MessageBox(0, "", 0, 0, "The java external directory is: " | &java_ext_dirs);

Local string &java_home = GetJavaClass("org.apache.commons.lang.SystemUtils").JAVA_HOME;
MessageBox(0, "", 0, 0, "The java home is: " | &java_home);

Local string &os_name = GetJavaClass("org.apache.commons.lang.SystemUtils").OS_NAME;
MessageBox(0, "", 0, 0, "The operating system is: " | &os_name);

Local string &java_vendor = GetJavaClass("org.apache.commons.lang.SystemUtils").JAVA_VENDOR;
MessageBox(0, "", 0, 0, "The java vendor is: " | &java_vendor);

Local string &usr_home = GetJavaClass("org.apache.commons.lang.SystemUtils").USER_HOME;
MessageBox(0, "", 0, 0, "The user home is: " | &usr_home);

Local string &user_lng = GetJavaClass("org.apache.commons.lang.SystemUtils").USER_LANGUAGE;
MessageBox(0, "", 0, 0, "The user language is: " | &user_lng);


The following would be the output file:

PeopleTools 8.50 - Application Engine
Copyright (c) 1988-2012 PeopleSoft, Inc.
All Rights Reserved


The file seperator is: \ (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The file seperator is: \ (0,0) (0,0)

The file encoder: Cp1252 (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The file encoder: Cp1252 (0,0) (0,0)

The java external directory is: C:\PT8.50\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The java external directory is: C:\PT8.50\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext (0,0) (0,0)

The java home is: C:\PT8.50\jre (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The java home is: C:\PT8.50\jre (0,0) (0,0)

The operating system is: Windows 2003 (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The operating system is: Windows 2003 (0,0) (0,0)

The java vendor is: Sun Microsystems Inc. (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The java vendor is: Sun Microsystems Inc. (0,0) (0,0)

The user home is: C:\Documents and Settings\Administrator (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The user home is: C:\Documents and Settings\Administrator (0,0) (0,0)

The user language is: en (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The user language is: en (0,0) (0,0)
Application Engine program TST_APPENGIN ended normally


String escaping utilities in Peoplecode



The following is the peoplecode program to show string escaping utilities:


[code]
Local JavaObject &escUtils = GetJavaClass("org.apache.commons.lang.StringEscapeUtils");

Local string &String = """Hello World!""";

Local string &jescString = &escUtils.escapeJava(&String);
MessageBox(0, "", 0, 0, "The string in java escape sequence is" | ": " | &jescString);

Local string &htmlescString = &escUtils.escapeHtml(&String);
MessageBox(0, "", 0, 0, "The string in html escape sequence is" | ": " | &htmlescString);

Local string &jscriptescString = &escUtils.escapeJavaScript(&String);
MessageBox(0, "", 0, 0, "The string in javascript escape sequence is" | ": " | &jscriptescString);


Local string &sqlescString = &escUtils.escapeSql(&String);
MessageBox(0, "", 0, 0, "The string in sql escape sequence is" | ": " | &sqlescString);


Local string &xmlescString = &escUtils.escapeXml(&String);
MessageBox(0, "", 0, 0, "The string in xml escape sequence is" | ": " | &xmlescString);
[/code]

The following is the output:



PeopleTools 8.50 - Application Engine
Copyright (c) 1988-2012 PeopleSoft, Inc.
All Rights Reserved


The string in java escape sequence is: \"Hello World!\" (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The string in java escape sequence is: \"Hello World!\" (0,0) (0,0)

The string in html escape sequence is: "Hello World!" (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The string in html escape sequence is: "Hello World!" (0,0) (0,0)

The string in javascript escape sequence is: \"Hello World!\" (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The string in javascript escape sequence is: \"Hello World!\" (0,0) (0,0)

The string in sql escape sequence is: "Hello World!" (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The string in sql escape sequence is: "Hello World!" (0,0) (0,0)

The string in xml escape sequence is: "Hello World!" (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The string in xml escape sequence is: "Hello World!" (0,0) (0,0)
Application Engine program TST_APPENGIN ended normally


Based on the language like java,javascript or xml, the string gets seperated. This would be useful for pattern matching.

Tuesday, December 4, 2012

Calling java.util and java.lang.System packages in PeopleSoft




This is a basic program which would call the packages java.util.* and java.lang.System packages in peoplesoft PeopleCode using GetJavaClass function:



Local string &userhome = GetJavaClass("java.lang.System").getProperty("user.home");

Local string &lng = GetJavaClass("java.lang.System").getProperty("user.language");

Local string &username = GetJavaClass("java.lang.System").getProperty("user.name");


Local string &osname = GetJavaClass("java.lang.System").getProperty("os.name");


Local string &osversion = GetJavaClass("java.lang.System").getProperty("os.version");

Local string &timezone = GetJavaClass("java.util.TimeZone").getDefault().getDisplayName();

Local string &country = GetJavaClass("java.lang.System").getProperty("user.country");


MessageBox(0, "", 0, 0, "The os name and version is " | ": " | &osname | "-" | &osversion);

MessageBox(0, "", 0, 0, "The user home-path is " | ": " | &userhome);

MessageBox(0, "", 0, 0, "The default language is " | ": " | &lng);

MessageBox(0, "", 0, 0, "The default user is " | ": " | &username);

MessageBox(0, "", 0, 0, "The default timezone is " | ": " | &timezone);

MessageBox(0, "", 0, 0, "The default country is " | ": " | &country);



The following would produce the output:



PeopleTools 8.50 - Application Engine
Copyright (c) 1988-2012 PeopleSoft, Inc.
All Rights Reserved


The os name and version is : Windows 2003-5.2 (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The os name and version is : Windows 2003-5.2 (0,0) (0,0)

The user home-path is : C:\Documents and Settings\Administrator (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The user home-path is : C:\Documents and Settings\Administrator (0,0) (0,0)

The default language is : en (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The default language is : en (0,0) (0,0)

The default user is : Administrator (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The default user is : Administrator (0,0) (0,0)

The default timezone is : GMT+05:30 (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The default timezone is : GMT+05:30 (0,0) (0,0)

The default country is : US (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The default country is : US (0,0) (0,0)
Application Engine program TST_APPENGIN ended normally


Monday, December 3, 2012

Usage of string functions in PeopleCode using Java Objects



Here is the code for performing string manipulations in peoplesoft using JavaObjects, i have used the string utilities from "org.apache.commons.lang.StringUtils" which are part of "java.lang.object"



Local JavaObject &original = CreateJavaObject("java.lang.String", "Hello World!");

Local JavaObject &jClass = GetJavaClass("org.apache.commons.lang.StringUtils");

Local string &reversed = &jClass.reverse(&original);

Local string &caps = &jClass.upperCase(&original);

Local string &lower = &jClass.lowerCase(&original);

Local string &index_of = &jClass.indexOf(&original, "o");

Local string &removed = &jClass.remove(&original, "o");

Local string &substr = &jClass.substring(&original, 3);

MessageBox(0, "", 0, 0, "This is original " | ": " | &original.toString());

MessageBox(0, "", 0, 0, "The length of the string is " | ": " | &original.length());

MessageBox(0, "", 0, 0, "This is reversed " | ": " | &reversed);

MessageBox(0, "", 0, 0, "This is capitalised " | ": " | &caps);

MessageBox(0, "", 0, 0, "This is lower " | ": " | &lower);

Rem MessageBox(0, "", 0, 0, "This is splitted " | ": " | &splitted);

MessageBox(0, "", 0, 0, "The index of " | "o is" | ": " | &index_of);

Running the above program in the Application Engine would produce the following output:


PeopleTools 8.50 - Application Engine
Copyright (c) 1988-2012 PeopleSoft, Inc.
All Rights Reserved


This is original : Hello World! (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: This is original : Hello World! (0,0) (0,0)

The length of the string is : 12 (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The length of the string is : 12 (0,0) (0,0)

This is reversed : !dlroW olleH (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: This is reversed : !dlroW olleH (0,0) (0,0)

This is capitalised : HELLO WORLD! (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: This is capitalised : HELLO WORLD! (0,0) (0,0)

This is lower : hello world! (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: This is lower : hello world! (0,0) (0,0)

The index of o is: 4 (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The index of o is: 4 (0,0) (0,0)

String after o is removed : Hell Wrld! (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: String after o is removed : Hell Wrld! (0,0) (0,0)

Substr : lo World! (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: Substr : lo World! (0,0) (0,0)
Application Engine program TST_APPENGIN ended normally



Reference: http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/StringUtils.html ; http://docs.oracle.com/cd/E28394_01/pt852pbh1/eng/psbooks/index.htm

Sunday, December 2, 2012

Some Python Code



-As usual, Python program to print Hello World:


print("Hello World!")


- Python program to print Fibonnaci using Recursion:

Recursion - The programming technique where function calls itself till it encounters a break condition and then exits. So there must be condition to check the exit condition, or else, the program would loop till infinity which would cause memory overflow error, as the computer has got limited memory.




#To compute Fibonacci number
#using Recursion

def Fib(n):
 
    if n == 0 or n == 1: return 1  
    else: return Fib(n-1) + Fib(n-2)
 
print(Fib(4))


-Python program to reverse a string:


def Str_reverse(Str1):
 
    #return Str1
 
 
    return Str1[::-1]

print(Str_reverse("Hello World!"))







Monday, November 26, 2012

Writing a file using CreateJavaObject in peoplesoft peoplecode


I was trying to create a peoplesoft program which would use java objects to create an output file, as Java objects can be used to create binary files in peoplesoft. So here is the code:

Local JavaObject &jFile;
Local JavaObject &msg;
&msg = CreateJavaObject("java.lang.String", "Hello World!");

Local JavaObject &buf = &msg.getBytes();
Local number &byteCount = &buf.length;
&jFile = CreateJavaObject("java.io.FileOutputStream", "C:\Temp\java.txt", True);
&jFile.write(&buf, 0, &byteCount);
&jFile.close();

The key here is to keep in mind that we are dealing with java objects in peoplesoft, Hence we must use java functions and java classes. 

Saturday, July 21, 2012

Exactly what is the problem with Engineering education in India?

Now that I have started to learn some seroius PROGRAMMING with PYTHON langauge and recently I saw another programming language R, a language for STATISTICAL AND GRAPHICAL processing of data, I thought to write a blog regarding the frailities of INDIAN ENGINEERING EDUCATION SYSTEM.

This blog does not cover IIT/IIIT/BITS/IISC, the premier institutions of india, as their GRADUATES are world best. Also, the focus is mainly on COMPUTER SCIENCE/INFORMATION SCIENCE

During the first semester of our ENGINEERING, the university had kept a course on PROGRAMMING LANGUAGES, and they had asked the affiliated colleges to teach 'C', a  language meant to do serious programming which virtually runs all the machines on this earth. Now i was a beginner in the field of Computers as my school did not have the option to take computer science where C++ was the language being taught in schools. Hell, to make matters worst, our school had only two option, choose biology/hindi for PHYSICS, CHEMISTRY, MATHEMATICS and those who did not want to study MATHEMATICS, they will study BIOLOGY with HINDI, a combination which would make everyone to get a JOVIAL laugh, and people do get laughter when I tell them that i have studied HINDI along with SCIENCE subjects.

Now coming back to the point, I believe that teaching 'C' as a first langauge in an engineering course, during first semester in itself is a crime the way studying mathematics and hindi together. The reason is that PROGRAMMING is nothing but problem solving. It is nothing related with langauges. Languages are a tool  to solve problems. During the engineering courses,the focus should be kept on solving problems especially using mathematics, statistics and tools etc.

For Computer Science and Information Science, the important courses are AUTOMATA, COMPILERS, ARTIFICIAL INTELLIGENCE, DATA MINING, DATA STRUCTUCRES, DBMS,OS. The AUTOMATA is one of the most important course which teaches about CONTEXT FREE GRAMMAR, REGULAR EXPRESSIONS which are very important to construct PARSERS or to find patterns of data. Same is DATA MINING using STATISTICS.

When a subject like 'C' is taught, which takes many years of pracitce to learn, that too the one who teaches virtually has no idea about writing programs, that too, for the people who have tryst with the computers for the first time in their life, people are bound to lose their interest as it is really a moral crusher when we cannot write programs.

And then, we had 'C++', JAVA', VC++, also in our courses during the subsequent years. And the end result is same, - we had only bookish knowledge not the real one.

Now when i think on the course curriculum of my university, I tried to figure out that what our university was trying to do at the first place? Were they really interested in making ENGINEERS or they just wanted people to get degrees, who would be hired by infosys etc just by solving some crap puzzles, which would give them a space in TOI. This type of course is usually set for DIPLOMA colleges, which churns out technicians. Yes, you have read it right- TECHNICIANS,. ITI was an institute or rather, it is still there which produces technicians who do VOCATION jobs like plumbing, electiricians etc. Same are the SOFTWARE ENGINEERS produced by such universities of india. We are all, SOFTWARE PLUMBERS, TECHNICIANS who work in a TOP DOWN hirearchy with a proper system set up in place who is managed by a CLERK, who is hailed as MANAGER as these titles are EAR PLEASING and SOOTHING for the GROOM'S FATHER IN LAW, who is just happy that his SON IN LAW has travelled to US of A on a PROJECT, which is nothing but working as a labor and killing your own interests and life. But then, india is a changed place now and people really don't want to live their own life the way they want.

I really get laughter and  I DO LAUGH, when I look back into my GRADUATION DAYS. I mean, is it really possible to learn langauges like 'C', 'C++', 'JAVA' into 4 months? And that too, in the industry, even a basic technique of PROGRAMMING is not even used, then why did our UNIVERSITY set up or design such curiculum? If you would say that by learning these things, you would get a job in MNC, then let me tell you that those MNCs of india never look for TECHNICAL SKILLS first of all, rather they want people who are UNDERCOOKED and INCOMPETENT technically, as these people are best choices to work as SLAVES for their life and they are pretty much happy also.

And this is precisely the reason that why all engineers in india want to do MBA, want to become MANAGERS, as they really have not got the GLIMPSE of ENGINEERING. What it takes to be an ENGINEER, no one has idea on this in india, not even me, because I am yet to do a WORK which an ENGINEER does. Until and unless, mathematics, statistics, algorithms, etc are not used to solve a problem, whatever I will do, it will not be ENGINEERING.

Monday, July 2, 2012

ESSENCE of ENGINEERING

What exactly is ESSENCE of ENGINEERING? or to be frank, what is the PHILOSOPHY of ENGINEERING?

I am yet to receive or do a work which is related with ENGINEERING. No SOFTWARE ENGINEERING is not ENGINEERING, it is a CRAFT WORK. SKILLED WORKERS do all these craft/mason works.

Since i have a little bit knowledge of ancient BHARTIYA SCRIPTURES, i can tell that engineering works is connected with the knowledge work. and software engineering is related with shudra/workers/labors work.

Then who exactly is an ENGINEER.

Engineer is someone who builds a pracitical system using the scientific system which are reliable and fault tolerant. This includes bridges, aeroplanes, or all military systems. Even we have plant engineers who designs plant for manufacturing unit. Same for nuclear enginners, electircal engineer. Engineers always use scientific technique to model/simulate the real world event. And above all, the quality/reliability is not compromised.

This then brings us to the important question- In modern times, are ENGINEERS doing ENGINEERING works?

It appears that CAPITALISM have nearly killed ENGINEERS. we only see the jobs which the CORPORATIONS want, not what engineers are supposed to do. Those who are in position of power are controlling the dynamics of market. If tomorrow a vocation arises that they need people who are only good in dancing, it appears that we will soon have dancing schools flourishing. This is the beauty of market economics.

And then in a country like india, where education means only to get a job, it is even more tougher or people don't want to sit back for a moment and ponder that what exactly is wrong. No, if you say that we have not cleared IIT-JEE (BTW, i had cleared IIIT-Bangalore written examination, it is a different story) and you are not a capable engineer, then i will tell you to read EDISON or TESLA who never completed their engineering degree, yet it is they who changed the world. Neither is IIT any source of engineering nor is it bigger than india.

One of the most important point regarding with an ENGINEER is that he builds the NATION. In vedic era, VISHWKARMA were the ENGINEERS who used to build maginificent forts, palaces and other things. So for indian, engineering is nothing, only if true thinking emerges.

"ENGINEERS PRACTICE THEIR ENGINEERING"

PS: This is not to belittle others who are not ENGINEERS. For me, even a GENUINE ART work is important or great, as it allows people to express themselves.

Learning PYTHON Progarmming

It has been two weeks that I started my journey with this beatiful programming language PYTHON. PYTHON is an object oriented scripting language which is an open source language. The thing about PYTHON is its simplicity. The syntaxes are clean and also.It is high level language.

I also would post about good books related with PYTHON PROGRAMMING LANGUAGE. As of now, i am taking help from stackoverflow website.

Sunday, June 3, 2012

Combined Engineering Exam- Mixed Responses

Recently, it has been decided by the GOI ministry of india that there would be a combined engineering entrance examinations for IIT/NIT/IIIT where 50% weightage would be given to this engineering entrance exam while the rest of 50% weightage would be given to the pre universitites schools or class X11th exam..as per CBSE..now this is a good move on the part of government considering that many talented people lose their chance to get admission into these coveted school of engineering of nations, considering that engineering is in absymal state in the entire nation itself...but the rest 50% is not normazlied..here are some issues:

1) All states in india have three boards of examinations, CBSE, ICSE and state syllabus..the syllabus, degree of marking, and also, the paper level have lot of gaps..hence, state candidates always get higher marks...compared to CBSE and ICSE....this also explains that why BITS-PILANI always used to be dominated by MAHARASHTRA and AP, as there state syllabus was too easy to achieve 99.99%.


2) what sort of examination would be good to judge engineering candidates? engineering education in india means only to get IT industry jobs..the good candidates would get job offers with GOOGLE,FACEBOOK,MICROSOFT etc and rest of the crown goes into INFOSYS,TCS etc....there is no scope for advanced research in the space of aeronautics,nanotechnology etc..and there is this passion with MBA also..


3) the thing is that candidate neglect their class X11 examinations to prepare for IIT-JEE etc, hence this move is being taken..but these exam are also book based...now if there is emphasis on more of pracitcal knowledge and less on theory, then 50% weightage is justified..at the basic level only, kids must get exposure to tinker with machines etc..only then we would be able to proudce engineers..


let us hope that move is first step ahead to build a strong nation