addattachment peoplecode

addattachment peoplecode

addattachment peoplecode example

AddAttachment :  You can use the this function to upload one file from an end user machine to a specified storage location. To upload more than one file with a single function call, use the MAddAttachment function.

Syntax of AddAttachment:

AddAttachment(URLDestination, DirAndFilePrefix, FileType, UserFileName[, MaxSize [, PreserveCase[, UploadPageTitle[, AllowLargeChunks]]]])

&retcode = AddAttachment(“record://PSFILE_ATTDET”, ATTACHSYSFILENAME, “”, ATTACHUSERFILE, 0);

If you can upload more find then using peoplecode function “MAddAttachment”

 

Syntax of MAddAttachment:

MAddAttachment(URLDestination, DirAndFilePrefix, Prompts, &UserFileArray, &ActualSizeArray, &DetailedReturnCodeArrayName [, MaxSize [, PreserveCase[, UploadPageTitle[, AllowLargeChunks[, StopOnError]]]]])

Example
&retcode = MAddAttachment(URL.MYFTP, ATTACHSYSFILENAME, 4, &MyFileArray, &MySzArray, &MyRtrnCodeArray, 0, False, “Upload Attachments”, False, True);
The following example demonstrates initialization of the arrays used to store the values returned by MAddAttachment:

&prompts = 2;
Local array of string &AttachUsrFiles;
&AttachUsrFiles = CreateArrayRept(“”, 0);

Local array of number &AttachSzs;
&AttachSzs = CreateArrayRept(0, 0);

Local array of number &AttachRtrnCds;
&AttachRtrnCds = CreateArrayRept(0, 0);

If Exact(Left(&URL_ID, 4), “URL.”) Then
&sum_rt_cd = MAddAttachment(@(&URL_ID), ATTACHSYSFILENAME, &prompts, &AttachUsrFiles, &AttachSzs, &AttachRtrnCds);
Else
&sum_rt_cd = MAddAttachment(&URL_ID, ATTACHSYSFILENAME, &prompts, &AttachUsrFiles, &AttachSzs, &AttachRtrnCds);
End-If;

 

 

Reference:https://docs.oracle.com/cd/E25688_01/pt852pbr0/eng/psbooks/tpcl/chapter.htm?File=tpcl/htm/tpcl02.htm%2348df64020f1b7a4_5c62bc_1229ed4fbbe__7483

Reference:https://docs.oracle.com/cd/E80738_01/pt854pbh2/eng/pt/tpcl/langref_PeopleCodeBuilt-inFunctionsAndLanguageConstructs_M.html#topofpage

Peoplecode Events pdf

peoplecode events pdf

peoplecode events pdf of peoplesoft component processor flow.

PeopleSoft Componet Processor Flow

Reference: http://www.aaronwhincop.com/wp-content/uploads/2013/02/PeopleSoft-Component-Processor-Flow.pdf

split function in peoplecode

split function in peoplecode

You can using split function in peoplecode of peoplesoft.  This function to convert a string into an array of strings by looking for the string separator in the given string but this function does not split an array.

Split(string, separator)

If separator is omitted, a blank is used.
If separator is a null string (“”), the string is split into single characters.
If separator is the last character in the string, you will not get an empty string.

For example 1, in the following code, &array only has a value of 2:

&test = “value1:value2:”;
&array = Split(&test, “:”);

For example 2, you can get file and read file.

 

If &In_File.IsOpen Then
While &In_File.ReadLine(&file);
&line = Split(&file, “,”);
MessageBox(0, “Lenght of separate , in file”, 0, 0, ” i len= ” | &line.Len);
End-while;
End-if;

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

How to Remove Carriage Returns (CR) in peoplecode

How to Remove Carriage Returns (CR) in peoplecode

How to Remove Carriage Returns (CR) in peoplecode of peoplesoft. Using peoplecode function is clean() for remove all non-printable characters.

Syntax of clean:  Clean(string)

You can use the clean function to remove all non-printable characters, such as control codes, end of line marks, and unpaired Unicode combining marks, from a text string and returns the result as a String value. It is intended for use on text imported from other applications that contains characters that may not be printable. Frequently, low-level characters appear at the beginning and end of each line of imported data, and they cannot be printed.

Returns

Returns a String value purged of non-printable characters.

Example 1

Because Char(7) (U+0007) is a non-printable character, the following Clean function returns a null string:

&CLEANSTR = Clean(Char(7));

 

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

substitute and replace peoplecode

substitute and replace peoplecode

Different substitute and replace peoplecode function of peoplesoft.

Use the Substitute function to replace every occurrence of a substring found in a string with a new substring. To replace text that occurs in a specific location in a text string using the Replace function.

The syntax of Substitute:  

Substitute(source_text, old_text, new_text)

source_text is a string in which you want to replace substrings.
old_text is a string equal to the substring of source_text you want to replace.

For example 1

Substitute(“2003* 0723* * * * ~”, “* ~”, “~”);

The result:  2003~0723~~~~~

 

Replace function to replace a specified number of characters in a string.

Syntax: Replace(old_text, start, num_chars, new_text)

old_text: A String value, part of which is to be replaced.
start: A Number designating the position in old_text from which to start replacing characters.
num_chars: A Number, specifying how many characters to replace in old_text.
new_text: A String value that replaces num_chars characters.

For example 2

Replace(“2000″,3,2,”18”);

The result of example 2 is  2018

For example 3

Replace(“MeeToo”,4,3,”kkk”);

The result of example 2 is  Meekkk

 

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

isnew function in peoplecode

isnew function in peoplecode

How to use isnew function in peoplecode.

IsNew: This property is True if the row is a new (inserted) row.
Example
&tmp = &ROW.IsNew;

 

 

Reference:https://docs.oracle.com/cd/E41633_01/pt853pbh1/eng/pt/tpcr/langref_RowClassProperties-c07c69.html#IsNew-c07c62

How to Get Current Row Number in a Grid or Scroll Area

How to Get Current Row Number in a Grid or Scroll Area

How to Get Current Row Number in a Grid or Scroll Area by peoplecode function of PeopleSoft.  The CurrentRowNumber function returns the current row on level one, or the parent row of the level two row where the PeopleCode program is executing.

Using function peopolecode is currentrownumber(scrolllevel);

This PeopleCode get value current row number in a grid or scroll by level.

if your grid or scroll area is @level 1 then use Currentrownumber(1) method spell.

if your grid or scroll area is @level 2 then use Currentrownumber(2) method spell.

For example 1. I have scrollarea level 1 on page and show row number of record in scroll area level 1 by peoplecode at below picture.

You define field number or character and replace peoplecode in rowinit event of this field.

DERIVED.SEQ.value = CurrentRowNumber(1);

——————————————————————————————————————–

Using Peoplecode for rearrange row equal rownum of grid area

Local Rowset &LEVEL0, &LEVEL1;

If %Page = Page.TS_TRF_JOB_DATA Then

Local Row &LEVEL0_ROW;

&LEVEL0 = GetLevel0();
&LEVEL0_ROW = &LEVEL0(1);
&LEVEL1 = &LEVEL0_ROW.GetRowset(Scroll.TS_TRF_JOBDATA);

For &i = 1 To &LEVEL1.ActiveRowCount
&LEVEL1_ROW = &LEVEL1(&i);
&LEVEL1(&i).TS_TRF_JOBDATA.SEQ.Value = &i;
End-For;
End-If;

References:

  1. https://it.toolbox.com/question/current-row-number-in-a-grid-081313
  2. https://docs.oracle.com/cd/E41509_01/pt852pbh2/eng/psbooks/tpcd/chapter.htm?File=tpcd/htm/tpcd05.htm%23g037ee99c9453fb39_ef90c_10c791ddc07__4b04

GetHTMLText PeopleCode

GetHTMLText PeopleCode

GetHTMLText PeopleCode is function.

For Example Using HTML Definitions and the GetHTMLText Function

1. Create HTML Object in Application Designer and define name is TABLE_HTML

<P> <TABLE> <TR bgColor=#008000> <TD> <P><FONT color=#f5f5dc face=”Arial, Helvetica, sans-serif” size=2> %bind(:1) </FONT></P></TD></TR> <TR bgColor=#0000cd> <TD> <P><FONT color=#00ffff face=”Arial, Helvetica, sans-serif” size=2>%bind(:2)</FONT></P></TD></TR> </TABLE></P>

2.  Call HTML object by use GetHTMLText Function and pass parameter.

Local Field &HTMLField; &HTMLField = GetField();
&string = GetHTMLText(HTML.TABLE_HTML,”message 1″,”message 2″);

&HTMLField.Value = &string;

3. Result of GetHTMLText

Ref: https://docs.oracle.com/cd/E41509_01/pt852pbh2/eng/psbooks/tpcd/chapter.htm?File=tpcd/htm/tpcd08.htm%23g037ee99c9453fb39_ef90c_10c791ddc07__4a9a

How to use a single quote in PeopleCode

How to use a single quote in PeopleCode

How to use a single quote in PeopleCode. You can use a function of PeopleCode is Quote() and using “‘”

For Example 1 : &WHERE= ” Where emplid = “| “‘” | &emplid | “‘” | ;

For Example 2 : &WHERE= ” Where emplid = “| Quote(&emplid);