Professional Documents
Culture Documents
S S O O S: Description Key Fields
S S O O S: Description Key Fields
Basically, the line has the necessary for load Personal Data (names, address, national ids...) and Job Data (positions, departments, jobcodes, BUs...). The thing is: if i dont find any position, department, etc.. i must create it and give it the proper security for load it using the Job Data CI. The issue comes when i read the description of any of these data, for example, a department. The description in the file has 30 characters, that's ok, but has a character with accent (, , , any of these...), and that causes that the File Layout read as if had 31, interrupting the process. For now on, i can remove these characters from the description, but i would like if there is any specific charset i must set when i do the GetFile(&Path, "r", &Charset, %FilePath_Absolute) in order to read the character with accent as one and no as two different, and load it as appears in the file.. Answer: Try this character set.
ISO-8859-1
Meta-SQL
One of the most useful development shortcuts in PeopleSoft is Meta-SQL. If you don't know about Meta-SQL then this example of how to refactor standard SQL to Meta-SQL should help you get an idea of what it can do.
Key Fields
SQLID, SQLTYPE
PSSQLTEXTDEFN
Here's how you might write a query that joins these records to give you the latest effective dated unique fields from these tables:
select S.SQLID, S.SQLTYPE, S.VERSION, S.LASTUPDOPRID, S.LASTUPDDTTM, S.ENABLEEFFDT, S.OBJECTOWNERID, ST.MARKET, ST.DBTYPE, ST.EFFDT, ST.SEQNUM, ST.SQLTEXT from PSSQLDEFN S, PSSQLTEXTDEFN ST where ST.SQLID = S.SQLID and ST.SQLTYPE = S.SQLTYPE and ST.EFFDT = ( select from max(EFFDT) PSSQLTEXTDEFN
SQLID = ST.SQLID SQLTYPE = ST.SQLTYPE MARKET = ST.MARKET DBTYPE = ST.DBTYPE SEQNUM = ST.SEQNUM EFFDT <= sysdate
Note that the SEQNUM field is used to partition long SQL statements. If you have a SQLID with a SEQNUM greater than 0, it is because it is too long to fit in one row for the SQLTEXT long field. Since you would want to return all SEQNUM rows, there is no need to add any conditions for SEQNUM in the query above.
Replacing the hard coded database table names with %Table and the PeopleSoft record definition names Using %Join to perform the join on common keys between PSSQLDEFN and PSSQLTEXTDEFN Replacing the effective date logic with %EffdtCheck
, S.ENABLEEFFDT , S.OBJECTOWNERID , ST.MARKET , ST.DBTYPE , ST.EFFDT , ST.SEQNUM , ST.SQLTEXT FROM %Table(PSSQLDEFN) S , %Table(PSSQLTEXTDEFN) ST WHERE %Join(COMMON_KEYS, PSSQLDEFN S, PSSQLTEXTDEFN ST) AND %EffdtCheck(PSSQLTEXTDEFN ST_ED, ST, %CurrentDateTimeIn)
Show the resolved Meta-SQL Note that because we are selecting fields from more than one table (and not all the fields), the %SelectAll construct is not going to work in this case.
The relevant Meta-SQL date and time functions constructs The %Table construct with record names instead of database table names. See this article about why you should be doing this. Essentially, like the other MetaSQL constructs it reduces the impact of changes to the system to your code.
Remember to always resolve your Meta-SQL to verify that it creates the correct SQL statement for your database platform.
Sample code to read a file using file layouts and to insert data into a record
Sample code to read a file using file layouts and to insert data read into a record. Local Local Local Local File &MYFILE; Record &REC; array of string &ARRAY; string &FILE_DIRECTORY, &FileName;
&FileName = "MY_FILE_NAME.txt"; &FILE_DIRTORY = "/MYDIRECTORY/" /*open file for reading*/ &MYFILE = GetFile(&FILE_DIRECTORY &FileName, "R", %FilePath_Absolute); /*create record object*/ &REC = CreateRecord(Record.MY_RECORD); &ARRAY = CreateArrayRept("", 0); /*check if file is open*/ If &MYFILE.IsOpen Then /*The SetFileLayout method is a file layout method. It associates a specific file layout definition with the file object executing this method, providing easy access to rowset data.(PeopleBooks)*/ If &MYFILE.SetFileLayout(FileLayout.FILE_LAYOUT_NAME) Then /*read line into &STRING*/ While &MYFILE.ReadLine(&STRING); &ARRAY = Split(&STRING, ","); For &I = 1 To &REC.FieldCount &REC.GetField(&I).Value = RTrim(LTrim(&ARRAY [&I])); End-For; /* do additional processing here for converting values */ &REC.Insert(); /*count rows inserted into record*/ &COUNT = &COUNT + 1; End-While; Else /* do error processing - filelayout not correct */ End-If; Else /* do error processing - file not open */ End-If;