Sample People Code for getting the DEPT ID based on the ORG ID
Local Rowset &RS0, &RS1, &RS2;
&RS0 = GetLevel0();
&RS1 = &RS0(1).GetRowset(Scroll.SRI_ORG1_TBL);
For &I = 1 To &RS1.ActiveRowCount
&ID = &RS1(&I).GetRecord(Record.SRI_ORG1_TBL).GetField(Field.SRI_ORG_ID).Value;
&SQL = CreateSQL("SELECT DESCR FROM PS_EXT_ORG_TBL WHERE EXT_ORG_ID=:1", &ID);
While &SQL.FETCH(&DESCR)
&RS1(&I).GetRecord(Record.SRI_ORG1_TBL).GetField(Field.SRI_ORG1_NAME).Value = &DESCR;
REM WinMessage(&DESCR, 0);
&RS2 = &RS1(&I).GetRowset(Scroll.SRI_DEPT1_TBL);
For &J = 1 To &RS2.ActiveRowCount;
&DI = &RS2(&J).GetRecord(Record.SRI_DEPT1_TBL).GetField(Field.SRI_ORG_ID).Value;
&SQL1 = CreateSQL("SELECT ORG_DEPARTMENT FROM PS_ORG_DEPT WHERE EXT_ORG_ID=:1", &DI);
While &SQL1.FETCH(&ORG_DEPARTMENT)
REM SQLEXEC("SELECT COUNT(EMPLID) FROM ");
If &ORG_DEPARTMENT = "" Then
&RS2(&J).GetRecord(Record.SRI_DEPT1_TBL).GetField(Field.SRI_DEPT_ID).Value = "";
WinMessage("There are no Departments under this Organisation ID", 0);
Else
&RS2(&J).GetRecord(Record.SRI_DEPT1_TBL).GetField(Field.SRI_DEPT_ID).Value = "";
rem WinMessage(&ORG_DEPARTMENT, 0);
End-If;
End-While;
End-For;
End-While;
End-For;
Excellent work, Sri.
ReplyDelete