Search This Blog


Friday, January 30, 2015

How to find extended ASCII characters present in a string.

Lets take an example of ADDRESS record in PeopleSoft.
To identify extended ASCII character first we need to know the ASCII characters range.
ASCII characters range is from 0 - 255 and of them extended ASCII characters range is from 128 to 255.

Let's see the character value of ASCII code 229.

select chr(229) from dual;
Output: å

Below SQL will help us in getting the non-ASCII charactes.

SQL to execute:
select * from ps_addresses where regexp_like(address1,'['||chr(128)||'-'||chr(255)||']');

If we observe, chr function is used to identify the ascii character value and iphen  is used to get range (similar to BETWEEN and AND )

The above SQL will get all the rows that have extended ASCII characters present in address1 field.

Sunday, January 25, 2015

Oracle Initialization Error

Oracle Initialization Error while logging to App Designer.
Check the TNS entries are correct or not.
Check the ORACLE_HOME/TNS_ADMIN and PATH variable is set to correct values or not.

Make changes if needed to these variables and test the login again.
This should resolve the issue.

Saturday, December 13, 2014

Application Engine: State Record

State Record:

1. The record that ends with '_AET' is identified as State Record.
2. Used in Application Engine program.
3. As name itself says 'state' meaning we get to know the state of data (snapshot) that is passed through the program.
4. quite useful in restart logic, where if a process goes to NoSuccess, after correction we can restart the program from the point where it got abend.
5. State Record can by derived work record or a physical record.
6. When a program is designed for Restart enabled logic, then it would be ideal to have state record type as physical record as it stores the data to the database before the abend.
7. In case of Derived work record, during restart failure the fields would be initialized to default values.
8. There can be 200 state records but only one of them can be primary record.
9. While passing parameters to State record, if it is primary one then no need to mention the record.field format. we can directly assign to the field using %select and %bind variables.
10.To refer fields in the State record, use %BINDS.
11.It should contain Process instance as the first and the only Key field.
12.We can also share the data of one state record from one AE program to another.
13.State Record contains only one row of data for each process instance.
14.Along with passing data, we can also have other fields to store the flag values. Flag values usage helps us in Parallel processing.
15.To set values in the State record, use %SELECT.

Snapshot of Sample State Record shown below.

Friday, December 12, 2014

How to run COBOL from Application Engine using CreateProcessRequest()

Before running a Cobol , we need to make sure that the process definition is created.
When running from AE, make sure you pass runcontrolID and Process Type along with other required parameters.
 We can also use Remotecall procedure to call COBOL procedure from AE.

Sample Code:

Local ProcessRequest &ProcessRequest;
&ProcessRequest= CreateProcessRequest();

/* Set all the Required Properties */
/* Enter the RunControlID
&ProcessRequest.RunControlID = STATERECORD_AET.RUN_CNTL_ID;
&ProcessRequest.ProcessType = "COBOL SQL";
&ProcessRequest.ProcessName = "";
/* Schedule the Process */

Wednesday, December 10, 2014

What is UTF-8 encoding

Each character we key in is stored in database and occupies some space.
Certain characters require less space and some require more space.

Earlier ASCII (American Standard Code for Information Interchange) is used but it supports upto maximum of 128 characters. English is suitable language for ASCII. If we see other languages in the world like chinese , japanese etc. they have characters which need more space.

With UTF-8 (Unicode Transformation Format) , we can accommodate almost all characters from all languages in the world. The number 8 denotes 8 bits.

UTF-8 stores characters ranging 1 to 4 bytes long.(Note: 1byte = 8 bits)
Like for example, character 'A' requires 1 byte and some Japanese character might require 3 bytes.

Note: First 128 characters of ASCII are same as the first 128 characters of UTF-8. So ASCII is a subset of UTF-8

Even in PeopleSoft installation, while creating database we will be asked for the type of database which needs to be created. Since most of the clients nowadays have global presence, they would prefer Unicode database.

We also hear about UTF-16, its nothing but accommodating more space. Usually UTF-16 format is used by Operating systems etc.

Below is the code for Telugu language
 Character Name            Character     OS X Option Code     Win XP ALT Code     Entity     Hex Entity
TELUGU LETTER A          అ          Option+0C05               ALT+3077                   అ    &#x0C05
TELUGU LETTER AA       ఆ          Option+0C06               ALT+3078                   ఆ    &#x0C06
Below is the code for Indian Rupee.
Char     Dec     Hex     Entity     Name
₹    8377    20B9         INDIAN RUPEE SIGN

 UTF-8 encoding for Telugu language &#3108 &#3142 &#3122 &#3137 &#3095 &#3137
 UTF-8 encoding for English language &#84 &#69 &#76 &#85 &#71 &#85

Below is the HTML version where above codes are converted(encoded) with UTF-8 format.
UTF-8 encoding for Telugu language తెలుగు
UTF-8 encoding for English language TELUGU

Wednesday, November 26, 2014

SQR: How to create Summary Charts using print-chart

Usually Summary reports, show up break up of count of records processed of the total records.
Representing these Summary reports through diagrams will help client understand better.

 Declare-Chart is used to describe the layout of the chart.
Array is created to store data.
Through Print-Chart we read data from Array and print onto the chart.

Below is one sample code to retrieve data and display in chart.

 Create-Array    ! This Array is passed to the Print-Chart
    Name = emp_hired
    Size = 10    ! Maximum of 10 rows of data
    Field = count:number:3    ! Fields in each row
  Declare-Chart tot_emp_hired
    Chart-Size = ( 30,30)
    Title = 'Employee Fetched'
    Type = histogram
    3D-Effects = yes
    X-Axis-Label = 'Company'
    Y-Axis-Label = 'Employee Hired'

 do Stdapi-Init        !stdapi.sqc
 do Init-DateTime    ! datetime.sqc
 do Init-Number        ! number.sqc
 do Get-Current-DateTime! curdttim.sqc
 do EmpChartReport
 do Stdapi-Term            !stdapi.sqc

begin-procedure EmpChartReport
! Load the array with the Chart Data. Max rows is specified in Create-Array
  Put  20
  Into emp_hired(0)  count(0)
  Put  12
  Into emp_hired(1)  count(0)   
  Put  4
  Into emp_hired(2)  count(0)

  Move 5 TO #x
  Move 10 TO #y
  Move 3 TO #row
  Move 3 TO #col

 Print-Chart tot_emp_hired (#x,#y)
    Fill = color
    Sub-Title = 'Employee hired report'
    Data-Array-Row-Count = #row   
    Data-Array-Column-Count = #col
    Data-Array-Column-Labels = ('ABC1', 'ABC2', 'ABC3')
    Data-Array = emp_hired

Sample Output:

How to create PDF file through AE using Java Class

The example mentioned below will give basic insights on how to create PDF file through Application Engine using Java classes.
Other way is to use BI Publisher and call the report definition and then publish the report.

To start with, firstly the Appserver/Classes path should contain the JAR file starting with itext.
Write the java code in AE to create PDF file.

Below is the sample code:
/* Create a Document object */
Local JavaObject &Obj_CreateiTextTable = CreateJavaObject("com.lowagie.text.Document");

/* Cretae PDF Writer object */
Local JavaObject &obj_writePDFoutput = GetJavaClass("com.lowagie.text.pdf.PdfWriter").getInstance(&Obj_CreateiTextTable, CreateJavaObject("", "/ TESTPDF11262014.pdf", True));
&; /*open the document for writing */
 /* Array with 3 columns */
Local JavaObject &Obj_myPDFTable = CreateJavaObject("com.lowagie.text.pdf.PdfPTable", 3);
 /* Add data to each cell */
&Obj_myPDFTable.addCell("Emp ID");
&Obj_myPDFTable.addCell("Main Street");
 /* Add Table to Document */
&Obj_CreateiTextTable.close();  /* close the document */

Output Snapshot: