How to send multiple pdf files in email by peoplecode of peoplesoft

How to send multiple pdf files in email by peoplecode of peoplesoft

How to send multiple pdf files in email by peoplecode of peoplesoft. You can use this code for send other type of file such as txt, csv.

&filenamepaht1=””C:\temp\filename1.pdf””;
&filenamepaht2=””C:\temp\filename2.pdf””;
&filenamepaht2=””C:\temp\filename-.pdf””;

&MAIL_FILES=&filenamepaht1| “”;”” |&filenamepaht2| “”;”” |&filenamepaht3;
&MAIL_TITLES = “”filename1.pdf;filename2.pdf;filename3.pdf””;

&RET = SendMail(&MAIL_FLAGS, &MAIL_TO, &MAIL_CC, &MAIL_BCC, &MAIL_SUBJECT, &MAIL_TEXT, &MAIL_FILES, &MAIL_TITLES, &MAIL_SENDER, “”;””, &CONTTYPE);

Createsql in Peoplecode

Createsql in Peoplecode

How to use Createsql in Peoplecode? You can use createsql for dynamic SQL or static sql of each purpose. There are many ways you can create SQL text.

 

Syntax of Create SQL

CreateSQL([{sqlstring | SQL.SqlName}[, paramlist]])

Where paramlist is an arbitrary-length list of values in the form:

inval1 [, inval2] ..

Use the CreateSQL function to instantiate a SQL object from the SQL class and opens it on the given sqlstring and input values. sqlstring is a PeopleCode string value giving the SQL statement.

Any errors in the SQL processing cause the PeopleCode program to be terminated with an error message.

You can use CreateSQL with no parameters to create an empty SQL object that can be used to assign properties before being populated and executed.

 

Example 1: You want to select all employee name and blood of deptid and mgrid.

You can create dynamic sql to text in peopolecode such as

&RPT = “select emplid,name,blood form table where deptid = :1 and MGRID=:2”

Local SQL &sql2 = CreateSQL(&RPT, TABLE.DEPTID, TABLE.MGRID);

While (&sql2.Fetch(&emplid,&name,&blood))
&file.WriteLine(&emplid | “‘”|&name | “‘”| &blood);
End-While;

Example 2: Create Sql Text in Message Catalog
You can use PeopleCode function all sql text in a message and pass the value in the message catalog.

&SQL_RPT = MsgGetExplainText(20003, 107, “Message not found.”, TABLE.DEPTID, TABLE.MGRID);

&sql1 = CreateSQL(&SQL_RPT);

While (&sql1.Fetch(&deptid,&name))
&file.WriteLine(&deptid| “‘”|&name);
End-While;
This peoplecode function or create sql by peoplecode language have many way such use static sql or dynamic sql depend on purpose and the method of store sql for example store sql in table or message catalog and hard code in your event action of each requirement job. I recommend this function Create sql in Peoplecode can help you.
Reference: https://docs.oracle.com/cd/E26239_01/pt851h3/eng/psbooks/tpcl/chapter.htm?File=tpcl/htm/tpcl02.htm%2337ee99c9453fb39_ef90c_10c791ddc07__3df9

How to Convert Date Format using Peoplecode in Peoplesoft

How to Convert Date Format using Peoplecode in Peoplesoft

How to Convert Date Format using Peoplecode in Peoplesoft by function  is DateTimeToLocalizedString of peoplesoft

&StartDT = DateTimeToLocalizedString(DERIVED_TT.KTB_START_DT, “yyyyMMdd”);

&DT= DateTimeToLocalizedString(%date, “dd-MM-yyyy”);

 

For example on how to apply the above function.

%date in as 2018-09-07 out as 20180907:
&date = DateTimeToLocalizedString(%Date, “yyyyMMdd”);
%Datetime in as 2018-09-07.15.41.000000 out as 20180907-154109:
&datetime = DateTimeToLocalizedString(%Datetime, “yyyyMMdd-HHmmss”);

 

Date and Time in Meta-SQL

For input or output of the current date or time:

  • %CurrentDateIn

The %CurrentDateIn meta-SQL variable expands to a platform-specific SQL substring representing the current date in the Where clause of a SQL Select or Update statement, or when the current date is passed in an Insert statement.

  • %CurrentDateOut

The %CurrentDateOut meta-SQL variable expands to platform-specific SQL for the current date in the Select clause of a SQL query.

  • %CurrentDateTimeIn

The %CurrentDateTimeIn meta-SQL variable expands to a platform-specific SQL substring representing the current datetime in the Where clause of a SQL Select or Update statement, or when the current date time is passed in an Insert statement.

  • %CurrentDateTimeOut

The %CurrentDateTimeOut meta-SQL variable expands to platform-specific SQL for the current datetime in the Select clause of a SQL query.

  • %CurrentTimeIn

The %CurrentTimeIn meta-SQL variable expands to a platform-specific SQL substring representing the current time in the Where clause of a SQL Select or Update statement, or when the current time is passed in an Insert statement.

  • %CurrentTimeOut

The %CurrentTimeOut meta-SQL variable expands to platform-specific SQL for the current time in the Select clause of a SQL query.

For input or output of any date or time:

  • %DateIn

The %DateIn meta-SQL variable expands into platform-specific SQL syntax for the date. Use %DateIn whenever a date literal or Date bind variable is used in a comparison in the Where clause of a Select or Update statement, or when a Date value is passed in an Insert statement.

Restrictions Using COBOL

You can only use string literals when using this construct in COBOL. You cannot use it with bind parameters in COBOL. For example, the following works in COBOL:

The following SQL fails:

  • %DateOut

The %DateOut meta-SQL variable expands to either a platform-specific SQL substring or datetime value, depending on the database platform, representing a datetime column in the Select clause of a SQL query

  • %DateTimeIn

The %DateTimeIn meta-SQL variable expands to platform-specific SQL for a DateTime value in the Where clause of a SQL Select or Update statement, or when a DateTime value is passed in an Insert statement.

  • %DateTimeOut

Restrictions Using COBOL

You can only use string literals when using this construct in COBOL. You cannot use it with bind parameters in COBOL. For example, the following works in COBOL:

The following SQL fails:

  • %TimeIn

%TimeIn expands to platform-specific SQL for a Time value in the Where clause of a SQL Select or Update statement, or when a time value is passed in an Insert statement.

Restrictions Using COBOL

You can only use string literals when using this construct in COBOL. You cannot use it with bind parameters in COBOL. For example, the following works in COBOL:

The following SQL fails:

  • %TimeOut

When  input date/time goes in the WHERE clause (conditions) and output date/time goes in the SELECT clause (returned data).

For input/output of a null date/time:

  • %DateNull
  • %DateTimeNull
  • %TimeNull

For getting part of a date/time:

  • %DatePart gets the date
  • %TimePart gets the time

For date arithmetic:

  • %DateAdd(date_from, days_to_add) gives the resulting date. You can use negative numbers to get a past date. So this is also the DateSubtract function.

  • %DateDiff(date_from, date_to) gives the difference between two dates in days

The following usage is illegal (always use %Datein for inputting date literals):

  • %DateTimeDiff(date_from, date_to) gives the difference between two date/times in minutes

The following example returns the difference in hours between the current datetime and the requested datetime:

The following example returns the difference in minutes:

 

 

References:

http://peoplesoft.wikidot.com/date-and-time-in-meta-sqlhttps://docs.oracle.com/cd/E57990_01/pt853pbh2/eng/pt/tape/langref_UsingApplicationEngineMeta-SQL-0771d9.html#topofpage

sqlexec peoplecode

sqlexec peoplecode

How to use sqlexec peoplecode for select update insert or delete  of each requirements by syntax of function in peoplesoft.

sqlexec ({sqlcmd | SQL.sqlname}, bindexprs, outputvars)

The sqlexec function can only select a single row of data. If your sql statement (or your sql.sqlname statement) retrieves more than one row of data, the function peoplecode send result only the first row to its output variables.

For example

sqlexec(“select name from ps_name where emplid =:1”,&Emplid,&Name_Emp);

/*———————————————————-*/

sqlexec(SQL.SELECT_NAME,&Emplid,&Name_Emp);

/*———————————————————-*/

&sqltext = “select name from ps_name “;
&sqltext = &sqltext | ” where emplid =:1″;

SQLExec(&sqltext, &Emplid,&Name_Emp);

 

How to use LongTranslateValue and ShortTranslateValue

How to use LongTranslateValue and ShortTranslateValue

How to use LongTranslateValue and ShortTranslateValue for get description of translate value of field.

ShortTranslateValue Systax :
&VALUE = &MYFIELD.ShortTranslateValue;

LongTranslateValue Systax :
&VALUE = &MYFIELD.LongTranslateValue;

How to use OriginalValue and PriorValue in peoplecode function

How to use OriginalValue and PriorValue in peoplecode function

How to use OriginalValue and PriorValue in peoplecode function for compare field value.

OriginalValue

OriginalValue function use syntax recordname.fieldname.OriginalValue.

This a useful property of a field class if you want to revert the changes or compare with the previous value of the field.

&FieldValue = recordname.fieldname.OriginalValue;

This statement always returns the value of the field in the database at that particular point of time. For the same reason, this property will not work for derived records.

Say my field has value “first” in the database and I change it to “second” and save it. Let us analyze the return field value at various point of time.

Step 1.  Component Loaded & value not yet changed.

&Value = recordname.fieldname.OriginalValue; /* Returns first value */

&Value = recordname.fieldname.Value;/* Returns first value */

Step 2.  After  changing the value to second & before saving

&Value = recordname.fieldname.OriginalValue; /* Returns first value */

&Value = recordname.fieldnameValue;/* Returns second value*/

Step 3. After saving the changes

&Value = recordname.fieldname.OriginalValue; /* Returns second value*/

&Value = recordname.fieldname.Value;/* Returns second value */

This function can be used to compare the field value with previous field value and do some complex functionality. It is, if the change in amount field is more than 10%, then trigger the workflow.

Another use case will be to revert the changes back if some criteria is not met.

Well this is quite useful, but if the field is a derived work record field, this property will not work at all. PriorValue() is a lifesaver here.

PriorValue

PriorValue function use syntax PriorValue( recordname.fieldname)

Use the PriorValue function in FieldEdit and FieldChange: Returns value in field before field was changed by user. If used in other PeopleCode programs, returns current value. The advantage is that you can use this function for a derived record also as the value is fetched from buffer and not from database.

Note:- There are two restrictions for usage of PriorValue to work correctly.

ref : http://www.peoplesoftjournal.com/2013/01/originalvalue-and-priorvalue.html

How to accessing related field on grid or scroll area through peoplecode

How to accessing related field on grid or scroll area through peoplecode

How to accessing related field on grid or scroll area through peoplecode. You can use peoplecode for accessing related field on grid or scroll area both get description of related field and hide/ unhide/ gray/ displayonly/ Enabled of eache requirement of work by use below code.

Local Field &FIELD, &REL_FIELD;

&FIELD = GetField(DEPT_TBL.DEPTID);
/* control field object */
&REL_FIELD = &FIELD.GetRelated(DEPT_TBL.DESCR);
/* related display object */
&REL_FIELD.displayonly= true;

How to Use Split Function Peoplesoft in Peoplecode

How to Use Split Function Peoplesoft in Peoplecode

How to Use Split Function Peoplesoft in Peoplecode by use below syntax

Split(string, separator)

Use the Split function to convert a string into an array of strings by looking for the string separator in the given string.

For example: You read filename  from your path and split file for write it to report.

&file_name = %FilePath | &Attachsysfilename;
MessageBox(0, “file_name”, 0, 0, ” &file_name= ” | &file_name);

&In_File = GetFile(&file_name, “E”, %FilePath_Absolute);

If &In_File.IsOpen Then
While &In_File.ReadLine(&file);

     &line = Split(&file, “,”);

      &EMPLID = &line [1];
      &EFFDT   = &line [2];
      &EFFSEQ = &line [3];

   /* Each statement */

end-while;

end-if;

 

ref:https://docs.oracle.com/cd/E13292_01/pt849pbr0/eng/psbooks/tpcl/chapter.htm?File=tpcl/htm/tpcl02.htm%23g037ee99c9453fb39_ef90c_10c791ddc07__3c45

How to use scrollselect in peoplecode

How to use scrollselect in peoplecode

How to use scrollselect in peoplecode : You can use scrollselect  function of peoplecode for flush data from record, table and record view that populate data to scroll area/ grid on page of peoplesoft.

You can use scrollselect in many level of grid or scroll area by use this syntax at below

ScrollSelect(levelnumber of grid or scroll area, [record.level1_recname, [record.level2_recname,]] record.target_recname, record.sel_recname [, sqlstr [, bindvars]] [, turbo])

where bindvars is an arbitrary-length list of bind variables in the form: bindvar1 [, bindvar2].

 

ref : https://docs.oracle.com/cd/E13292_01/pt849pbr0/eng/psbooks/tpcl/chapter.htm?File=tpcl/htm/tpcl02.htm