Monday, 13 March 2017

Read CSV file in Peoplecode

Local File &MYFILE;
Local Record &REC;
Local array of string &ARRAY;
Local string &FilePath, &FileName;

Local Rowset &GRD_RS;

&GRD_RS = GetLevel0()(1).GetRowset(Scroll.IOBM_PHN_NO_WRK);
&GRD_RS.Flush();
SQLExec("Delete  from PS_IOBM_PHN_NO_WRK ");
SQLExec("commit");

&FILE = IOBM_SMSATT_WRK.ATTACHUSERFILE.Value;

&URL = GetURL(URL.IOBM_FINANCE_UPLOAD);

&MYFILE = GetFile(&URL | &FILE, "r", "a", %FilePath_Absolute);


&REC = CreateRecord(Record.IOBM_PHN_NO_WRK);
&ARRAY = CreateArrayRept("", 0);


If &MYFILE.IsOpen Then
 
   While &MYFILE.ReadLine(&STRING);
     
      &ARRAY = Split(&STRING, ",");
      &REC.EMPLID.Value = &ARRAY [1];
      SQLExec("select Distinct phone  from PS_PERSON_PHONE where Emplid = :1 ", &ARRAY [1], &PHONE);
      &REC.PHONE.Value = ☎
      &REC.Insert();
      rem  MessageBox(0, "", 0, 0, "" | &REC.EMPLID.Value | "" | &REC.PHONE.Value);
     
   End-While;
End-If;
GetLevel0().Refresh()

No comments:

Post a Comment