Code to insert any data from file to Record using Appengine

Your rating: None Average: 2.8 (5 votes)

we need to create an AET record and Base Record (if it is anew record or else we can use the existing Record). Then create a RunControl Page with the fields File Path Name, Record Name.

SQL Code:
%SelectInit (FILE_PATH_NAME, RECNAME)
 SELECT FILE_PATH_NAME
 , RECNAME
  FROM %Table (XX_XXXXX_RUN1)
 WHERE OPRID=%OperatorId
   AND RUN_CNTL_ID=%RunControl

People Code:

Local File &MYFILE, &MYFILE1;
Local string &PATH_READ, &PATH_WRITE, &REC, &rec_value;
Local array of string &values;
Local Record &rec1;
&DATE = %Datetime;
&PROCESS_INSTANCE = XX_XXXXX_AET.PROCESS_INSTANCE.Value;

&REC = XX_XXXXX_AET.RECNAME.Value;
&PATH_READ = XX_XXXXX_AET.FILE_PATH_NAME.Value;
&MYFILE = GetFile(&PATH_READ, "R", %FilePath_Absolute);
&rec_name = "RECORD." | &REC;
&rec1 = CreateRecord(@&rec_name);

While &MYFILE.ReadLine (&rec_value)
   &values = Split(&rec_value, ",");
   For &j = 1 To &values.Len
     
      &rec1.GetField(&j).Value = &values [&j];
   End-For;
   &rec1.Insert();
End-While;

Type:2
Local File &MYFILE, &MYFILE1;
Local date &date;
Local string &PATH_READ, &PATH_WRITE, &REC, &rec_value;
Local array of string &values;
Local Record &rec1;

rem local datetime &DATE1;
rem &DATE1 = %Datetime;

&RECNAME = XX_XXXXX_AET.RECNAME.Value;
&FILE_PATH_NAME = XX_XXXXX_AET.FILE_PATH_NAME.Value;
&MYFILE = GetFile(&FILE_PATH_NAME, "R", %FilePath_Absolute);
&rec_name = "RECORD." | &RECNAME;
&rec1 = CreateRecord(@&rec_name);

While &MYFILE.ReadLine(&rec_value)
   &values = Split(&rec_value, "|");
   
   For &j = 1 To &values.Len
      &val = &values [&j];
      If IsDate(&values [&j]) Then
         SQLExec("SELECT TO_DATE(:1,'YYYY/MM/DD') FROM PS_INSTALLATION", &values [&j], &date);
         &rec1.GetField(&j).Value = &date;
      Else
         &rec1.GetField(&j).Value = &values [&j];
      End-If;
   End-For;
   rem &rec1.Insert();
End-While;

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!