Code to get the record and count from the data base

Your rating: None Average: 5 (2 votes)

Step:1 PeopleCode:
Local File &MYFILE;
Local string &str_cnt;
Local string &FPath;

&str_cnt = "Record Name" | Char(9) | "Count";
&FPath = "\\psapsftt\TTEF\OneSource\PC-Inbound\Record.xls";
&MYFILE = GetFile(&FPath, "W", %FilePath_Absolute);
&MYFILE.WriteLine(&str_cnt);

Step2:Doselect

%SelectInit(RECNAME)
SELECT RECNAME
FROM %Table(PSRECDEFN)
WHERE RECNAME NOT IN (Record Names)
AND RECTYPE NOT IN (2,3,5) /*2 - Derived/Work 3- Sub-Record 5- Dynamic View */

Step:3:SQl
%SelectInit(COUNTER1)
SELECT COUNT(*)
FROM %Table(%bind(RECNAME))

Step:4:PeopleCode:
Local File &MYFILE;
Local string &str_cnt;
Local string &FPath;

&str_cnt = XXX_REC_AET.RECNAME.Value | Char (9) | XXX_REC_AET.COUNTER1.Value;
&FPath = "\\psapsftt\TTEF\OneSource\PC-Inbound\Record.xls";
&MYFILE = GetFile(&FPath, "W", %FilePath_Absolute);
&file.WriteLine (&str_cnt);

OUTBOUND Code with creating file Layout.

rem *****************************************************************;
rem * PeopleCode to Export Data from Record to File *;
rem *****************************************************************;

Global string &Filepath;
Local Record &Rec;
Local File &FILE;
Local SQL &SQL;

rem &FILE = GetFile(&Filepath | "PSPO_COST_COMP_" | %Date | ".txt", "w", %FilePath_Absolute);
&FILE = GetFile(&Filepath | "PSPO_COST_COMP.txt", "w", %FilePath_Absolute);

If &FILE.IsOpen Then
If &FILE.SetFileLayout(FileLayout.PSS_COST_COMP_FL) Then
&Rec = CreateRecord(Record.PSPO_COST_COMP);
&SQL = CreateSQL("%Selectall(:1)", &Rec);

While &SQL.Fetch(&Rec)
&FILE.WriteRecord(&Rec);
End-While;

Else
/* do error processing -; filelayout not correct */
End-If;

Else /* do error processing -; file not open */
End-If;
&FILE.Close();

Step:5:Peoplecode
Global File &file;
&file.Close();

Please try to help out with unanswered topics on the forum. Chances are you have had the same issue/question some time in your IT career!

Comments

Have a question? Please ask it on the forum instead.

Post new comment

CAPTCHA
The question below is to prevent automated spam submissions.
14 + 4 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.