Showing posts with label peoplecode. Show all posts
Showing posts with label peoplecode. Show all posts

Wednesday, 7 October 2020

Handling File Attachment Size Dynamically

 Handling File Attachment Size Dynamically:

We can easily hardcode the File Size limit by setting a value to the &size variable in below code.

But if we want to use it dynamically, then we can get the value and use Int to convert the value to an integer and use it. Since Value(&size) returns a decimal value, it is not accepted.


&size = Int(&fsize);

&RETCODE = AddAttachment(URL.AF_MOBILE_USER_SS_FILE, &UniqueSysFilename, "", &ATTACHUSERFILE, &size * 1024);


The dynamic value can be stored in any setup or in a message catalog and pulled using below code, where 678 id default value in case message catalog 123,45 doesnt have this value.

&fsize = MsgGetText(123, 45, "678");

Tuesday, 29 September 2020

Query to find which App Class is used in IB

Query to find which App Class is used in IB 

select IB_OPERATIONNAME, HANDLERNAME, PACKAGEID, PACKAGEROOT pkg, QUALIFYPATH, APPCLASSID clas5, APPCLASSMETHOD m3thod from psoperationac ;

Query to get peoplecode in a project

Query to get peoplecode in a project 

select PROJECTNAME,p1.OBJECTVALUE1, p1.OBJECTVALUE2,p1.OBJECTVALUE3, p1.OBJECTVALUE4,p1.OBJECTVALUE5, OBJECTID6, OBJECTVALUE6,'~`~`~`', PCTEXT,'~`~`~`' from pspcmtxt p1,psprojectitem p2

where

PROJECTNAME like 'AF_RP_WEEKLY_SCHEDULE' and

p1.OBJECTVALUE1 = p2.OBJECTVALUE1 and

p1.OBJECTVALUE2 = p2.OBJECTVALUE2 and

p1.OBJECTVALUE3 = p2.OBJECTVALUE3 ;

Tuesday, 23 September 2014

How to get Field Value from its Description?

How to get Field Value from its Description?

How to get Translate Field Value from its Description?

A brief overview 1st.

What are XLAT Tables in PeopleSoft?

XLATTABLE: Stores translate values (PeopleSoft version prior to 8.4).
PSXLATDEFN: Stores all fields that have Xlat values. This table does not store any Xlat values.
PSXLATITEM: Stores fields with their actual translate values (PeopleSoft version 8.4 and above).

Some Functions:

LongTranslateValue: This property returns a string that contains the Long translate (XLAT) value of the field if the field is based on a translate table.
ShortTranslateValue: This property returns a string that contains the Short translate (XLAT) value of the field if the field is based on a translate table.

How to get Translate Field Value from its Description?

What are the important Fields in the PSXLATITEM table?

PeopleSoft Field NameDescription
FIELDNAMEField Name
FIELDVALUEField Value
EFFDTEffective DateDefault: %date
EFF_STATUSEffective Status
XLATLONGNAMETranslate Long Name
XLATSHORTNAMETranslate Value Short Name

SQL For getting Translate Field From Description?

SELECT FIELDVALUE FROM PSXLATITEM WHERE FIELDNAME = :1 AND
(FIELDVALUE= :2 OR XLATLONGNAME = :2 OR XLATSHORTNAME= :2) AND
EFFDT=(SELECT MAX(B.EFFDT) FROM PSXLATITEM B
WHERE B.FIELDNAME = FIELDNAME AND B.FIELDVALUE = FIELDVALUE AND B.EFFDT <= SYSDATE)
AND EFF_STATUS = 'A';

Method to get the Translate Field from Description:

method GetValueFromXlatDescr
   /+ &FieldSrc as Field, +/
   /+ &FieldTrgt as Field, +/
   /+ &effDt as Date, +/
   /+ &refFieldName as String +/
Variables:
Source Field
Target Field
Reference Date
Xlat Field Name
   Local Record &rec = CreateRecord(Record.PSXLATITEM);
   Local string &SQL, &value, &sError;
   If All(&FieldSrc.Value) Then
If Field has some value then
      &SQL = "SELECT A.FIELDVALUE FROM PSXLATITEM A  WHERE
 A.FIELDNAME = :1 AND %EffdtCheck(PSXLATITEM B, A, %Datein(:2))
 AND A.EFF_STATUS = 'A' AND (upper(A.XLATLONGNAME) = upper(:3) or A.FIELDVALUE = :3)";
SQL
      SQLExec(&SQL, &refFieldName, &effDt, &FieldSrc.Value, &FieldTrgt.Value);
      %This.ErrorIfNoFieldValue(&FieldSrc, &FieldTrgt);
   End-If;
end-method;
Execute the SQL
 &
Check for Errors

Explanation:

I have written method in App Pkg style. Since this is the new style of coding and is object oriented, we should adopt this as much as possible.
We could have passed many variables, but to adopt a Object Oriented approach (pass by reference) I am using the Fields.
The Field object can carry all these and we need not worry about the limitation of returning more than one value.
After verification that the field has some value, we formulate the SQL. In the WHERE clause I have used the FIELDVALUE check along with the intended XLATLONGNAME just in case we get the actual FIELDVALUE and want to validate it. Also I have used upper to not limit the case of recieved strings.
Post execution of the SQL, we are passing it to Check and Error so that we dont retain the null values, and use them for loading in the final targets.



Tuesday, 13 September 2011

Dynamic SQL in App Engine

Dynamic SQL in App Engine
Some time we need to run a dynamic sql in App Enigne.
Some would prefer creating the entire query in a string and run it in PeopleCode.
But SQL is much faster than PeoleCode.

How do we achieve this functionality in SQL?
We could have an AET record field hold the value and use it in SQL.

How to implement this?
We need to push the required condition in the AET record field value and use %SQL and %BIND to implement this.

Though your SQL might be complicated, done with many if, else, case, etc,  Lets say the SQL is a simple condition.

If condition Then
   AET_REC.SQL_FIELD= "AND T1.FLD1 = T2.FLD1 AND T1.FLD2 = T3.FLD2";
Else
   AET_REC.SQL_FIELD.Value = ":
End-If;

Now in AE Action SQL we can use as follows
UPDATE TBL4
SET FLDX = 'VAL'
WHERE FLDX IS NULL
%SQL(%Bind(SQL_FIELD),NOQUOTES)


Why do we need NOQUOTES?
%Bind assumes the content of the variable to be a string and put quotes around it. To avoid it we must use NOQUOTES.