Tuesday, 25 February 2025

How to migrate Equation Engine equations from one instance to another

 We created some Equation that need to be migrated from one instance to another, and we need to know the steps to do this, other than recreating the equation in each instance.




First of all, for both the equation export/import as well as this sql export/import, the security trees will have to be updated ahead of time in case the target auth classes do not already exist. E.g., to list the auth classes used by a particular EQTN_OPERAND_SQL, you would do the query:

SELECT DISTINCT
EQTN_SQ_AUTH_CLASS
FROM PS_EQTN_SQAUTH_TBL
ORDER BY
EQTN_SQ_AUTH_CLASS

Likewise, for equations:
SELECT DISTINCT
EQTN_ID_AUTH_CLASS
FROM PS_EQTN_ID_NAMAUTH
ORDER BY
EQTN_ID_AUTH_CLASS

This is so that when you import the respective auth table, the security tree node already exists. Auth tables hold the contents of equation security tree nodes.

The datamover script to export the equations would be:

SET LOG EQUATION_EXPORT.LOG;
SET OUTPUT EQUATION.DAT;
EXPORT EQUATION_TBL WHERE EQUATION_NAME = '?';
EXPORT EQUATION_DTL WHERE EQUATION_NAME = '?';
EXPORT EQTN_ID_NAMAUTH WHERE EQUATION_NAME = '?';

The datamover script to import the equations would be:
SET LOG EQUATION_IMPORT.LOG;
SET INPUT EQUATION.DAT;

DELETE FROM PS_EQUATION_PCODE WHERE EQUATION_NAME = '?';
DELETE FROM PS_EQUATION_TBL WHERE EQUATION_NAME = '?';
DELETE FROM PS_EQUATION_DTL WHERE EQUATION_NAME = '?';
DELETE FROM PS_EQTN_ID_NAMAUTH WHERE EQUATION_NAME = '?';
COMMIT;
IMPORT EQUATION_TBL;
IMPORT EQUATION_DTL;
IMPORT EQTN_ID_NAMAUTH;


The datamover export script to export the SQL for the equations would be:

SET LOG EQTNSQL_EXPORT.LOG;
SET OUTPUT EQTNSQL.DAT;

EXPORT EQTN_SQL_TBL
WHERE EQTN_OPERAND_SQL = 'XXXXXXXXX';

EXPORT EQTN_SQL_CHUNKS
WHERE EQTN_OPERAND_SQL = 'XXXXXXXXX';

EXPORT EQTN_SQAUTH_TBL
WHERE EQTN_SQ_AUTH_CLASS = 'XXXXXXXXX';

The import script for the SQL would look like:
SET LOG EQTNSQL_IMPORT.LOG;
SET INPUT EQTNSQL.DAT;

DELETE FROM PS_EQTN_SQL_TBL
WHERE EQTN_OPERAND_SQL = 'XXXXXXXXX';

DELETE FROM PS_EQTN_SQL_CHUNKS
WHERE EQTN_OPERAND_SQL = 'XXXXXXXXX';

DELETE FROM PS_EQTN_SQAUTH_TBL
WHERE EQTN_SQ_AUTH_CLASS = 'XXXXXXXXX';

COMMIT;

IMPORT EQTN_SQL_TBL;
IMPORT EQTN_SQL_CHUNKS;
IMPORT EQTN_SQAUTH_TBL;


Monday, 24 February 2025

Query to find Tables / View associated with a component

 SELECT R.RECNAME AS RECORD_NAME,

       ( CASE
           WHEN R.RECTYPE = 0 THEN 'Table'
           WHEN R.RECTYPE = 1 THEN 'View'
           WHEN R.RECTYPE = 2 THEN 'Derived'
           WHEN R.RECTYPE = 3 THEN 'Sub Record'
           WHEN R.RECTYPE = 5 THEN 'Dynamic View'
           WHEN R.RECTYPE = 6 THEN 'Query View'
           WHEN R.RECTYPE = 7 THEN 'Temporary Table'
           ELSE 'Unknown'
         END )   AS RECORD_TYPE
FROM   PSRECDEFN R
WHERE  R.RECNAME IN (SELECT DISTINCT RECNAME
                     FROM   PSPNLFIELD
                     WHERE  PNLNAME IN (SELECT DISTINCT B.PNLNAME
                                        FROM   PSPNLGROUP A,
                                               PSPNLFIELD B
                                        WHERE  ( A.PNLNAME = B.PNLNAME
                                                  OR A.PNLNAME = B.SUBPNLNAME )
                                           AND A.PNLGRPNAME=:1 --Comp Name
                                           AND RECNAME <> ' ')
                     UNION
                     SELECT DISTINCT RECNAME
                     FROM   PSPNLFIELD
                     WHERE  PNLNAME IN (SELECT DISTINCT B.SUBPNLNAME
                                        FROM   PSPNLGROUP A,
                                               PSPNLFIELD B
                                        WHERE  ( A.PNLNAME = B.PNLNAME
                                                  OR A.PNLNAME = B.SUBPNLNAME )
                                           AND A.PNLGRPNAME=:1--Comp Name))
   AND R.RECNAME <> ' '
ORDER  BY R.RECTYPE ;

Saturday, 5 October 2024

Looping in PL SQL

 

These are the examples to update table data using loop in PL SQL.


BEGIN FOR I IN (

SELECT A.EMPLID, A.ACAD_PROG

  FROM PS_ACAD_PROG A , ps_UOD_STU_ADV_UPL B

  WHERE ( A.EFFDT =

        (SELECT MAX(A_ED.EFFDT) FROM PS_ACAD_PROG A_ED

        WHERE A.EMPLID = A_ED.EMPLID

          AND A.ACAD_CAREER = A_ED.ACAD_CAREER

          AND A.STDNT_CAR_NBR = A_ED.STDNT_CAR_NBR

          AND A_ED.EFFDT <= SYSDATE)

    AND A.EFFSEQ =

        (SELECT MAX(A_ES.EFFSEQ) FROM PS_ACAD_PROG A_ES

        WHERE A.EMPLID = A_ES.EMPLID

          AND A.ACAD_CAREER = A_ES.ACAD_CAREER

          AND A.STDNT_CAR_NBR = A_ES.STDNT_CAR_NBR

          AND A.EFFDT = A_ES.EFFDT))

          AND A.EMPLID = B.EMPLID

          AND B.OPRID = 'dar.tech2' ) LOOP


UPDATE  ps_UOD_STU_ADV_UPL D

SET D.acad_prog1 = I.acad_prog

WHERE D.EMPLID = I.EMPLID;



END LOOP;

END;





------------------------------------------------------------------------------------------




BEGIN

    FOR I IN (

        SELECT COUNT(A.EMPLID) AS TOT, A.CLASS_NBR, A.STRM  

        FROM ps_stdnt_enrl A 

        WHERE A.strm = '2241' 

          AND A.STDNT_ENRL_STATUS = 'E' 

        GROUP BY A.CLASS_NBR, A.STRM 

    ) LOOP

        UPDATE PS_CLASS_TBL K  

        SET K.ENRL_TOT = I.TOT 

        WHERE K.strm = I.STRM 

          AND K.class_nbr = I.CLASS_NBR;


    END LOOP;


    COMMIT; -- Commit changes after the loop

EXCEPTION

    WHEN OTHERS THEN

        RAISE; -- Handle exceptions if needed

END;


Sunday, 8 September 2024

CI Peoplecode to update Student Name

 /* ===>

This is a dynamically generated PeopleCode template to be used only as a helper

to the application developer.

You need to replace all references to '[*]' OR default values with  references to

PeopleCode variables and/or a Rec.Fields. */

Local File &fileLog;

Local ApiObject &oSession, &oCiPersonalData;

Local ApiObject &oCollNameTypeVwCollection, &oCollNameTypeVw;

Local ApiObject &oCollNamesCollection, &oCollNames;


Function errorHandler()

   Local ApiObject &oPSMessageCollection, &oPSMessage;

   Local number &i;

   Local string &sErrMsgSetNum, &sErrMsgNum, &sErrMsgText, &sErrType;

   

   &oPSMessageCollection = &oSession.PSMessages;

   For &i = 1 To &oPSMessageCollection.Count

      &oPSMessage = &oPSMessageCollection.Item(&i);

      &sErrMsgSetNum = &oPSMessage.MessageSetNumber;

      &sErrMsgNum = &oPSMessage.MessageNumber;

      &sErrMsgText = &oPSMessage.Text;

      Error MsgGet(&oPSMessage.MessageSetNumber, &oPSMessage.MessageNumber, &sErrMsgText);

      rem &fileLog.WriteLine(&sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText);

   End-For;

   rem ***** Delete the Messages from the collection *****;

   &oPSMessageCollection.DeleteAll();

End-Function;




Function UpdatePersonalData(&EmplId As string, &NameType As string, &EffDate As date, &CountryFormat As string, &LastName As string, &FirstName As string, &MiddleName As string, &SecondLastName As string) Returns boolean

   Local number &WorkAround;

   Local integer &CollCount1, &NameCount;

   

   

   try

      /* Initialize session */

      &oSession = %Session;

      &oSession.PSMessagesMode = 1;

      

      /* Get the Component Interface */

      &oCiPersonalData = &oSession.GetCompIntfc(CompIntfc.CI_PERSONAL_DATA);

      If &oCiPersonalData = Null Then

         errorHandler();

         throw CreateException(0, 0, "GetCompIntfc failed");

      End-If;

      

      /* Set Component Interface Mode */

      &oCiPersonalData.InteractiveMode = True;

      &oCiPersonalData.GetHistoryItems = True;

      &oCiPersonalData.EditHistoryItems = True;

      

      /* Set Component Interface Get/Create Keys */

      &oCiPersonalData.KEYPROP_EMPLID = &EmplId;

      

      /* Execute Get */

      If Not &oCiPersonalData.Get() Then

         errorHandler();

         throw CreateException(0, 0, "Get failed");

      End-If;

      

      /* Set/Get COLL_NAME_TYPE_VW Collection Field Properties */

      &oCollNameTypeVwCollection = &oCiPersonalData.COLL_NAME_TYPE_VW;

      &oCollNameTypeVw = &oCollNameTypeVwCollection.insertitem(&oCollNameTypeVwCollection.count);

      &WorkAround = &oCollNameTypeVw.itemnum;

      &CollCount1 = &oCollNameTypeVwCollection.count;

      &oCollNameTypeVw = &oCollNameTypeVwCollection.Item(&CollCount1);

      &oCollNameTypeVw.KEYPROP_NAME_TYPE = &NameType;

      

      /* Set Names */

      &oCollNamesCollection = &oCollNameTypeVw.COLL_NAMES;

      &NameCount = 0;

      Local integer &i122;

      For &i122 = 1 To 1

         &NameCount = &NameCount + 1;

         If &NameCount > 1 Then

            &oCollNames = &oCollNamesCollection.insertitem(&oCollNamesCollection.count);

            &WorkAround = &oCollNames.itemnum;

         End-If;

         

         &CollCount1 = &oCollNamesCollection.count;

         &oCollNames = &oCollNamesCollection.Item(&CollCount1);

         &oCollNames.KEYPROP_NAME_TYPE = &NameType;

         &oCollNames.KEYPROP_EFFDT = &EffDate;

         &oCollNames.PROP_COUNTRY_NM_FORMAT = &CountryFormat;

         &oCollNames.PROP_NAME_PREFIX = "";

         &oCollNames.PROP_NAME_SUFFIX = "";

         &oCollNames.PROP_LAST_NAME = &LastName;

         &oCollNames.PROP_FIRST_NAME = &FirstName;

         &oCollNames.PROP_MIDDLE_NAME = &MiddleName;

         &oCollNames.PROP_SECOND_LAST_NAME = &SecondLastName;

      End-For;

      

      /* Execute Save */

      If Not &oCiPersonalData.Save() Then

         errorHandler();

         throw CreateException(0, 0, "Save failed");

      End-If;

      

      /* Execute Cancel */

      If Not &oCiPersonalData.Cancel() Then

         errorHandler();

         throw CreateException(0, 0, "Cancel failed");

      End-If;

      

      /* Return True if successful */

      Return True;

      

   catch Exception &ex1

      Error MsgGet(0, 0, "Caught exception: " | &ex1.ToString());

      /* Return False if an error occurs */

      Return False;

   end-try;

   

End-Function;


Local boolean &isSuccessful;


&SQL1 = CreateSQL("select distinct emplid ,initcap(last_name) , initcap(first_name) ,initcap(middle_name) ,initcap(second_last_name) from ps_uod_name_load WHERE descr = 'rr' and ROWNUM <= 400");


While &SQL1.Fetch(&emplid, &LastName, &FirstName, &MiddleName, &SecondLastName)

   

   &isSuccessful = UpdatePersonalData(&emplid, "PRI", %Date, "001", &LastName, &FirstName, &MiddleName, &SecondLastName);

   

   If &isSuccessful Then

      

      SQLExec("update ps_uod_name_load set descr='true' where emplid =:1", &emplid);

      rem   MessageBox(0, "", 0, 0, "Update was successful.");

      

   Else

      rem MessageBox(0, "", 0, 0, "Update failed.");

      SQLExec("update ps_uod_name_load set descr='false' where emplid =:1 ", &emplid);

   End-If;

   

End-While;


Monday, 2 September 2024

Code to delete term activation using peoplecode - component interface

 

/* ===>

This is a dynamically generated PeopleCode template to be used only as a helper

to the application developer.

You need to replace all references to '[*]' OR default values with references to

PeopleCode variables and/or a Rec.Fields. */


Local File &fileLog;

Local ApiObject &oSession, &oTermActivationCi;

Local ApiObject &oStdntCareerCollection, &oStdntCareer;

Local ApiObject &oStdntCarTermCollection, &oStdntCarTerm;

Local boolean &result;


Function errorHandler()

   Local ApiObject &oPSMessageCollection, &oPSMessage;

   Local number &i;

   Local string &sErrMsgSetNum, &sErrMsgNum, &sErrMsgText, &sErrType;

   

   &oPSMessageCollection = &oSession.PSMessages;

   For &i = 1 To &oPSMessageCollection.Count

      &oPSMessage = &oPSMessageCollection.Item(&i);

      &sErrMsgSetNum = &oPSMessage.MessageSetNumber;

      &sErrMsgNum = &oPSMessage.MessageNumber;

      &sErrMsgText = &oPSMessage.Text;

      rem &fileLog.WriteLine(&sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText);

   End-For;

   rem ***** Delete the Messages from the collection *****;

   &oPSMessageCollection.DeleteAll();

End-Function;


Function ProcessTermActivation(&emplid As string, &strm As string) Returns boolean

   

   &fileLog = GetFile("C:\Users\mmlatif\AppData\Local\Temp\TERM_ACTIVATION_CI.log", "w", "a", %FilePath_Absolute);

   &fileLog.WriteLine("Begin");

   

   

   &result = False; /* Initialize the result as False */

   

   try

      rem ***** Get current PeopleSoft Session *****;

      &oSession = %Session;

      

      rem ***** Set the PeopleSoft Session Error Message Mode *****;

      &oSession.PSMessagesMode = 1;

      

      rem ***** Get the Component Interface *****;

      &oTermActivationCi = &oSession.GetCompIntfc(CompIntfc.TERM_ACTIVATION_CI);

      If &oTermActivationCi = Null Then

         errorHandler();

         throw CreateException(0, 0, "GetCompIntfc failed");

      End-If;

      

      rem ***** Set the Component Interface Mode *****;

      &oTermActivationCi.InteractiveMode = False;

      &oTermActivationCi.GetHistoryItems = True;

      &oTermActivationCi.EditHistoryItems = False;

      

      rem ***** Set Component Interface Get/Create Keys *****;

      &oTermActivationCi.EMPLID = &emplid;

      

      rem ***** Execute Get *****;

      If Not &oTermActivationCi.Get() Then

         rem ***** No rows exist for the specified keys. *****;

         errorHandler();

         throw CreateException(0, 0, "Get failed");

      End-If;

      

      rem ***** Begin: Get/Set Component Interface Properties *****;

      &oStdntCareerCollection = &oTermActivationCi.STDNT_CAREER;

      Local integer &i132;

      For &i132 = &oStdntCareerCollection.Count To 1 Step - 1

         &oStdntCareer = &oStdntCareerCollection.Item(&i132);

         

         rem ***** Set STDNT_CAR_TERM Collection Field Properties -- Parent: STDNT_CAREER Collection *****;

         &oStdntCarTermCollection = &oStdntCareer.STDNT_CAR_TERM;

         Local integer &i235;

         For &i235 = &oStdntCarTermCollection.Count To 1 Step - 1

            &oStdntCarTerm = &oStdntCarTermCollection.Item(&i235);

            If &oStdntCarTerm.STRM = &strm Then

               rem ***** Delete the row with the specified STRM *****;

               &oStdntCarTermCollection.DeleteItem(&i235);

            End-If;

         End-For;

      End-For;

      

      rem ***** Save the changes *****;

      If Not &oTermActivationCi.Save() Then

         errorHandler();

         throw CreateException(0, 0, "Save failed");

      End-If;

      

      rem ***** Cancel the CI (cleanup) *****;

      If Not &oTermActivationCi.Cancel() Then

         errorHandler();

         throw CreateException(0, 0, "Cancel failed");

      End-If;

      

      &result = True; /* If all steps succeed, set the result to True */

      

   catch Exception &ex

      

      &fileLog.WriteLine(&ex.ToString());

      

      

      &result = False; /* Ensure the result remains False if any exception is thrown */

   end-try;

   

   Return &result;

End-Function;


&SQL1 = CreateSQL("select distinct emplid  from PS_UOD_STDDEL_TERM ");


While &SQL1.Fetch(&emplid)

   

   Local boolean &isSuccess;

   &isSuccess = ProcessTermActivation(&emplid, "2241");

   

   If &isSuccess Then

      

      

      &fileLog.WriteLine("Term Activation processed successfully.");

      REM MessageBox(0, "", 0, 0, "Term Activation processed successfully.");

   Else

      &fileLog.WriteLine("Failed to process Term Activation.");

      

      REM MessageBox(0, "", 0, 0, "Failed to process Term Activation.");

   End-If;

   

End-While;


Wednesday, 26 June 2024

PeopleSoft - Blackboard Integration

End Point 1:    https://absc-staging.blackboard.com/learn/api/public/v1/oauth2/token

End Point 2:     https://absc-staging.blackboard.com/learn/api/public/v3/courses 

Function get_BB_token() Returns array of string

   Local boolean &ret;

   Local string &authStr, &clientId, &clientSecret, &responseStr;

   Local array of string &result = CreateArrayRept("", 20);

      /* Application Key */

   &clientId = "9c18bcc1-8be4-4f61-a2e8-815baaac9e2e1";

      /*Secret*/

   &clientSecret = "KlT4VdO0sclGwtQuGvcLkPlALo7fF3Kk1";

    &request = CreateMessage(Operation.X_RCVD_BB_TOKEN_POST);

   &ret = &request.IBInfo.LoadRESTHeaders();

    &request.URIResourceIndex = 1;

   &request.SegmentContentType = "application/x-www-form-urlencoded;charset=UTF-8";

   Local object &plainStr = CreateJavaObject("java.lang.String", &clientId | ":" | &clientSecret);

   Local object &encoder = GetJavaClass("com.peoplesoft.tools.util.Base64");

   &authStr = &encoder.encode(&plainStr.getBytes());

    Local string &postData = "grant_type=client_credentials";

   &ret = &request.IBInfo.IBConnectorInfo.AddConnectorProperties("Authorization", "Basic " | &authStr, %HttpHeader);

   &ret = &request.SetContentString(&postData);

   &response = %IntBroker.SyncRequest(&request);

    If &response.ResponseStatus = %IB_Status_Success Then

     

      Local string &jsonRespStr = &response.GetContentString();

      Local JsonParser &parser = CreateJsonParser();

      &ret = &parser.Parse(&jsonRespStr);

      Local JsonObject &jsonResp = &parser.GetRootObject();

   

      &result [1] = &jsonResp.GetProperty("access_token");

      &result [2] = &jsonResp.GetProperty("token_type");

      &result [3] = &jsonResp.GetProperty("expires_in");

      &result [4] = &jsonResp.GetProperty("scope");

            

      rem   MessageBox(0, "", 0, 0, "Response: " | &result [1]);

      Return &result;

   Else

      rem MessageBox(0, "", 0, 0, "Error: " | &response.ErrorText);

      Return &response.ErrorText;

   End-If;

End-Function;



/*----------------------------------------------------------------------*/


Local array of string &result1 = get_BB_token();


/* Use the result */

&access_token = &result1 [1];

&token_type = &result1 [2];

If &access_token = "" Then

   /* Handle error case */

   Error MessageBox(0, "", 0, 0, "Error: Token is not valid");

Else

Local boolean &ret1, &organization, &allowGuests, &allowObservers, &closedComplete, &force;

   Local object &rootJSON, &availabilityJSON, &durationJSON, &enrollmentJSON, &localeJSON;

   

   &Request_MSG = CreateMessage(Operation.X_RCVD_BB_TOKEN_POST);

   &ret1 = &request.IBInfo.LoadRESTHeaders();

   

   &ret1 = &Request_MSG.IBInfo.IBConnectorInfo.AddConnectorProperties("Method", "POST", %Property);

   &ret1 = &Request_MSG.IBInfo.IBConnectorInfo.AddConnectorProperties("Authorization", "Bearer " | &access_token, %HttpHeader);

   &ret1 = &Request_MSG.IBInfo.IBConnectorInfo.AddConnectorProperties("Content-Type", "application/json", %HttpHeader);

   

   rem Error MessageBox(0, "", 0, 0, "1" | &_accessToken);

   &rootJSON = CreateJsonObject();

   Local string &url = "learn/api/public/v3/courses";

   

   &Request_MSG.IBInfo.ConnectorOverride = True;

   &Request_MSG.OverrideURIResource(" ");

   If Len(&url) > 0 Then

      &Request_MSG.OverrideURIResource(&url);

   End-If;

  

   

   Local SQL &sqlHeader = CreateSQL(SQL.X_GET_COURSE_DTL, "2401");

   While &sqlHeader.Fetch(&CRSE_ID, &CRSE_OFFER_NBR, &STRM, &SESSION_CODE, &CLASS_SECTION, &CLASS_NBR, &SUBJECT, &CATALOG_NBR, &DESCR);

      &externalId = &CRSE_ID | "-" | NumberToString("%02", &CRSE_OFFER_NBR) | "-" | &STRM | "-" | &SESSION_CODE | "-" | &CLASS_SECTION | "-" | NumberToString("%05", &CLASS_NBR);

      &courseId = &SUBJECT | &CATALOG_NBR | "-" | NumberToString("%02", &CRSE_OFFER_NBR) | "-" | &STRM | "-" | &SESSION_CODE | "-" | &CLASS_SECTION | "-" | NumberToString("%05", &CLASS_NBR);

      &name = &DESCR | " " | &CLASS_SECTION | "-" | NumberToString("%05", &CLASS_NBR);

      &description = &SUBJECT | " " | &CATALOG_NBR;

      &organization = False;

      &ultraStatus = "Ultra";

      &allowGuests = False;

      &allowObservers = False;

      &closedComplete = False;

      &termId = "_241_1";

      &available = "Yes";

      &type = "Continuous";

      &type1 = "InstructorLed";

      &force = True;

      

      /*-------------------------------------------------*/

      

      

      &durationJSON = CreateJsonObject();

      &durationJSON.AddProperty("type", "Continuous");

      &durationJSON.AddProperty("start", "2024-06-24T12:46:26.588Z");

      &durationJSON.AddProperty("end", "2024-06-24T12:46:26.588Z");

      &durationJSON.AddProperty("daysOfUse", 0);

      

      

      &availabilityJSON = CreateJsonObject();

      &availabilityJSON.AddProperty("available", "Yes");

      &availabilityJSON.AddProperty("duration", &durationJSON);

      

      

      

      &enrollmentJSON = CreateJsonObject();

      &enrollmentJSON.AddProperty("type", "InstructorLed");

      &enrollmentJSON.AddProperty("start", "2024-06-24T12:46:26.588Z");

      &enrollmentJSON.AddProperty("end", "2024-06-24T12:46:26.588Z");

      &enrollmentJSON.AddProperty("accessCode", "01");

      

      

      &localeJSON = CreateJsonObject();

      &localeJSON.AddProperty("id", "string");

      &localeJSON.AddProperty("force", True);

      

      

      &rootJSON.AddProperty("externalId", &externalId);

      &rootJSON.AddProperty("courseId", &courseId);

      &rootJSON.AddProperty("name", &name);

      &rootJSON.AddProperty("description", &description);

      &rootJSON.AddProperty("organization", &organization);

      &rootJSON.AddProperty("ultraStatus", &ultraStatus);

      &rootJSON.AddProperty("allowGuests", &allowGuests);

      &rootJSON.AddProperty("allowObservers", &allowObservers);

      &rootJSON.AddProperty("closedComplete", &closedComplete);

      

      &rootJSON.AddProperty("availability", &availabilityJSON);

      &rootJSON.AddProperty("enrollment", &enrollmentJSON);

      &rootJSON.AddProperty("locale", &localeJSON);

      

      &jsonString = &rootJSON.ToString();

          

      /* Set the request body */

      &ret1 = &Request_MSG.SetContentString(&jsonString);

      

      /* Send the request */

      &Response_MSG = %IntBroker.SyncRequest(&Request_MSG);

      

      If &Response_MSG.ResponseStatus = %IB_Status_Success Then

         Local string &jsonRespStr = &Response_MSG.GetContentString();

         

         Local JsonParser &parser = CreateJsonParser();

         &ret1 = &parser.Parse(&jsonRespStr);

         Local JsonObject &jsonResp = &parser.GetRootObject();

         MessageBox(0, "", 0, 0, "" | &jsonRespStr);

         

      End-If;

      

   End-While;

   End-If;





Friday, 15 March 2024

Read CSV file stored in database

 Local File &MYFILE;

Local array of string &ARRAY;

Local Record &REC;

Local Rowset &studentList ;

&studentList = GetLevel0()(1).GetRowset(Scroll.L_TRNS_CRSE_TBL);

&REC = CreateRecord(Record.L_TRNSCRS_FILE);

SQLExec("SELECT ATTACHSYSFILENAME FROM PS_L_TRNS_CRS_ATCH WHERE OPRID =:1 AND RUN_CNTL_ID=:2", %UserId, L_TRNS_CRS_ATCH.RUN_CNTL_ID.Value, &FileName);

rem Messagebox(0,"",0,0,""|&FileName);


&SQL = CreateSQL("%SelectAll(:2)  WHERE ATTACHSYSFILENAME =:1 ", &FileName, Record.L_TRNSCRS_FILE);

While &SQL.Fetch(&REC)  

   &FILE1 = GetFile(&FileName, "w", "a", %FilePath_Absolute);

    rem Messagebox(0,"",0,0, " | %FilePath_Absolute | "File Open:" | &FILE1.IsOpen);

   

   If &FILE1.IsOpen Then

      try

         &FILE1.WriteRaw(&REC.FILE_DATA.Value);

         &FILE1.Close();

         

      catch Exception &ex2

         throw CreateException(0, 0, "Unable to write  file: " | &ex2.ToString());

      end-try;

   End-If;

End-While;


&MYFILE = GetFile(&FileName, "r", "a", %FilePath_Absolute);

&ARRAY = CreateArrayRept("", 0);

rem MessageBox(0, "", 0, 0, "" | &MYFILE.IsOpen);

If &MYFILE.IsOpen Then

   If &MYFILE.SetFileLayout(FileLayout.L_TRNS_CRSE_MNL_FL) Then

            While &MYFILE.ReadLine(&STRING);

               &ARRAY = Split(&STRING, ",");

         For &i = 1 To &ARRAY.Len

            MessageBox(0, "", 0, 0, "" | ("Value of &ARRAY[" | &i | "]: " | &ARRAY [&i]));

         End-For;

         

         End-while;

end-if;

end-if;