Starting an entry every now and then that I'm going to call "code dump". Whenever I used or remember to use a common code that I'm sure I'll be using again.
Code dump #1:
GetGrid(Page.UX_DIRECTS_PLT, "<page field name>").GetColumn("<page field name>").Label = "Vacation Balance";
PSoftTechGuy
Currently in Tools Release 8.54.03 and Application Release HRMS 9.2
Wednesday, January 13, 2016
Friday, January 8, 2016
Get Description from Prompt Table
I created a method on App Package to get the description of most commonly used prompt table in HCM. You need to tweak it to work on your purpose.
method GetPromptTableDescr
/+ &fld as Field +/
/+ Returns String +/
Local string &string_descr, &prompt, &fldtype, &fldCd, &cd;
Local Field &recfld;
Local Record &recpr;
Local Rowset &rs;
Local integer &i, &fldlen;
Local boolean &effdtd;
&recfld = &fld;
&cd = &fld.Value;
&fldlen = &recfld.FieldLength;
&fldtype = &recfld.Type;
&prompt = &recfld.PromptTableName;
&recpr = CreateRecord(@("RECORD." | &prompt));
For &i = 1 To &recpr.FieldCount
If &recpr.GetField(&i).IsKey And
&fldlen = &recpr.GetField(&i).FieldLength And
&fldtype = &recpr.GetField(&i).Type Then
&fldCd = &recpr.GetField(&i).Name;
End-If;
/*Added to accomodate EFFDTed Prompts*/
If &recpr.GetField(&i).Name = "EFFDT" Then
&effdtd = True;
End-If;
/*End */
End-For;
&rs = CreateRowset(@("RECORD." | &recpr.Name));
If &effdtd Then
&rs.Fill("WHERE FILL." | &fldCd | " = :1 AND %EffdtCheck(" | &recpr.Name | " FILL_ED, FILL, %CurrentDateIn)", &cd);
Else
&rs.Fill("WHERE FILL." | &fldCd | " = :1", &cd);
End-If;
&string_descr = &rs(1).GetRecord(@("RECORD." | &recpr.Name)).DESCR.Value;
Return &string_descr;
end-method;
method GetPromptTableDescr
/+ &fld as Field +/
/+ Returns String +/
Local string &string_descr, &prompt, &fldtype, &fldCd, &cd;
Local Field &recfld;
Local Record &recpr;
Local Rowset &rs;
Local integer &i, &fldlen;
Local boolean &effdtd;
&recfld = &fld;
&cd = &fld.Value;
&fldlen = &recfld.FieldLength;
&fldtype = &recfld.Type;
&prompt = &recfld.PromptTableName;
&recpr = CreateRecord(@("RECORD." | &prompt));
For &i = 1 To &recpr.FieldCount
If &recpr.GetField(&i).IsKey And
&fldlen = &recpr.GetField(&i).FieldLength And
&fldtype = &recpr.GetField(&i).Type Then
&fldCd = &recpr.GetField(&i).Name;
End-If;
/*Added to accomodate EFFDTed Prompts*/
If &recpr.GetField(&i).Name = "EFFDT" Then
&effdtd = True;
End-If;
/*End */
End-For;
&rs = CreateRowset(@("RECORD." | &recpr.Name));
If &effdtd Then
&rs.Fill("WHERE FILL." | &fldCd | " = :1 AND %EffdtCheck(" | &recpr.Name | " FILL_ED, FILL, %CurrentDateIn)", &cd);
Else
&rs.Fill("WHERE FILL." | &fldCd | " = :1", &cd);
End-If;
&string_descr = &rs(1).GetRecord(@("RECORD." | &recpr.Name)).DESCR.Value;
Return &string_descr;
end-method;
Thursday, January 7, 2016
Find your Component!
This SQL helped me a lot and I still use it. Finding Page in PIA is a lot easier now if you have the new releases of PeopleSoft that has SES. But I still find my component using this;
SELECT E.PORTAL_LABEL, D.PORTAL_LABEL, C.PORTAL_LABEL, B.PORTAL_LABEL,
A.PORTAL_LABEL FROM PSPRSMDEFN A
LEFT JOIN PSPRSMDEFN B ON A.PORTAL_PRNTOBJNAME = B.PORTAL_OBJNAME
AND A.PORTAL_NAME = B.PORTAL_NAME
LEFT JOIN PSPRSMDEFN C ON B.PORTAL_PRNTOBJNAME = C.PORTAL_OBJNAME
AND B.PORTAL_NAME = C.PORTAL_NAME
LEFT JOIN PSPRSMDEFN D ON C.PORTAL_PRNTOBJNAME = D.PORTAL_OBJNAME
AND C.PORTAL_NAME = D.PORTAL_NAME
LEFT JOIN PSPRSMDEFN E ON D.PORTAL_PRNTOBJNAME = E.PORTAL_OBJNAME
AND D.PORTAL_NAME = E.PORTAL_NAME WHERE A.PORTAL_OBJNAME LIKE '%PROCESSMONITOR%'
SELECT E.PORTAL_LABEL, D.PORTAL_LABEL, C.PORTAL_LABEL, B.PORTAL_LABEL,
A.PORTAL_LABEL FROM PSPRSMDEFN A
LEFT JOIN PSPRSMDEFN B ON A.PORTAL_PRNTOBJNAME = B.PORTAL_OBJNAME
AND A.PORTAL_NAME = B.PORTAL_NAME
LEFT JOIN PSPRSMDEFN C ON B.PORTAL_PRNTOBJNAME = C.PORTAL_OBJNAME
AND B.PORTAL_NAME = C.PORTAL_NAME
LEFT JOIN PSPRSMDEFN D ON C.PORTAL_PRNTOBJNAME = D.PORTAL_OBJNAME
AND C.PORTAL_NAME = D.PORTAL_NAME
LEFT JOIN PSPRSMDEFN E ON D.PORTAL_PRNTOBJNAME = E.PORTAL_OBJNAME
AND D.PORTAL_NAME = E.PORTAL_NAME WHERE A.PORTAL_OBJNAME LIKE '%PROCESSMONITOR%'
Wednesday, January 6, 2016
Hey, I'm back!
I'll be posting again some random PeopleSoft stuff. Some tips and tricks here and there, some complicated, some simple one liner code. To start things off, here's pretty simple code that I used every time I need multiple "OR" in my IF statement;
If CreateArray("ACME", "GOOG", "ORCL").Find(JOB.COMPANY.Value) <> 0 Then
/*Do logic if one of the company above is found. Please take note on the "<>" sign, Find function
returns 0 if no value match.*/
End-if;
Friday, August 22, 2008
Using Dynamic View
Since I wrote the article titled "Running Dynamic SQL Object in PeopleCode" I got a hand full of feedback that the title is confusing. They always thought that it was about Dynamic View, well its probably a bad choice of title on my part. I will make it up to anyone who's looking for the Dynamic View code or how to use it.
Suppose the requirements is to have a different prompt table depending on the settings of other fields. To illustrate, if the user enter name on the other field, they want to see a prompt of personel number. If they enter product information, they want to see the inventory number, lot number, etc.. You could use %EDITTABLE to dynamically specify the prompt table. However
in this case there are too many possible values or involved combinations . These will require you to create too many views. It would be nice if you can create view on the fly depending on what the end-user wants. The answer is YES, we can do that, we can generate the desired SQL text in the PeopleCode based on what the user enters.
1. Get the field that has a promt using GetField function.
&fld_CarNbr = GetField(Field.CAR_NBR);
2. Get all the information user enters.
&data_Name = CAR_TBL.NAME;
&data_Model = CAR_TBL.MODEL;
3. Create the SQLTEXT.
&sqltext = "SELECT ID, NAME, MODEL, NBR FROM INV_TBL WHERE NAME = " &data_Name " AND MODEL = " &data_Model;
4. Override Dynamic View SQL
&fld_StdntCarNbr.SqlText = &sqltext;
Here another example. These replaces the data of the dynamic view.
&sqltext = CreateSQL("SELECT ID, NAME, MODEL, NBR FROM INV_TBL WHERE NAME = " &data_Name " AND MODEL = " &data_Model);
&RSTemp = GetRowset(Scroll.DYNAMIC_VW);
&RSTemp.Flush();
&Rec = CreateRecord(Record.DYNAMIC_VW);
While &Sql.Fetch(&Rec) &i = &i + 1;
&RSTemp.InsertRow(&i);
&Rec.CopyFieldsTo(&RSTemp.GetRow(&i).DYNAMIC_VW);
End-While;
Suppose the requirements is to have a different prompt table depending on the settings of other fields. To illustrate, if the user enter name on the other field, they want to see a prompt of personel number. If they enter product information, they want to see the inventory number, lot number, etc.. You could use %EDITTABLE to dynamically specify the prompt table. However
in this case there are too many possible values or involved combinations . These will require you to create too many views. It would be nice if you can create view on the fly depending on what the end-user wants. The answer is YES, we can do that, we can generate the desired SQL text in the PeopleCode based on what the user enters.
1. Get the field that has a promt using GetField function.
&fld_CarNbr = GetField(Field.CAR_NBR);
2. Get all the information user enters.
&data_Name = CAR_TBL.NAME;
&data_Model = CAR_TBL.MODEL;
3. Create the SQLTEXT.
&sqltext = "SELECT ID, NAME, MODEL, NBR FROM INV_TBL WHERE NAME = " &data_Name " AND MODEL = " &data_Model;
4. Override Dynamic View SQL
&fld_StdntCarNbr.SqlText = &sqltext;
Here another example. These replaces the data of the dynamic view.
&sqltext = CreateSQL("SELECT ID, NAME, MODEL, NBR FROM INV_TBL WHERE NAME = " &data_Name " AND MODEL = " &data_Model);
&RSTemp = GetRowset(Scroll.DYNAMIC_VW);
&RSTemp.Flush();
&Rec = CreateRecord(Record.DYNAMIC_VW);
While &Sql.Fetch(&Rec) &i = &i + 1;
&RSTemp.InsertRow(&i);
&Rec.CopyFieldsTo(&RSTemp.GetRow(&i).DYNAMIC_VW);
End-While;
Labels:
%EDITTABLE,
CopyFieldsTo,
CreateSQL,
Dynamic View,
Fetch,
GetField,
Prompt,
SqlText
Subscribe to:
Posts (Atom)