Hi Team,
I have written a sample program to update the data file.
PROGRAM UPDATE.DATA.DRV* Declare variables CUSTOMER.ID = "" NOTE = "" RECORD = ""* Get the CUSTOMER ID (2nd word from the sentence) CUSTOMER.ID = FIELD(@SENTENCE, " ", 2)* Get the NOTE (3rd word and onwards from the sentence) NOTE = FIELD(@SENTENCE, " ", 3, LEN(@SENTENCE))* Strip double quotes if present IF NOTE[1,1] = '"' THEN NOTE = NOTE[2,LEN(NOTE) - 2]* Open the CUSTOMER file OPEN "CUSTOMER" TO CUSTOMER.FILE ELSE PRINT "ERROR: Unable to open CUSTOMER data file." RETURN END* Read the record for the given CUSTOMER ID READ RECORD FROM CUSTOMER.FILE, CUSTOMER.ID ELSE PRINT "ERROR: No record found for CUSTOMER ID: ": CUSTOMER.ID RETURN END* Update the NOTE attribute (assuming the note is in attribute 2) RECORD<2> = NOTE* Write the updated record back to the file WRITE RECORD ON CUSTOMER.FILE, CUSTOMER.ID PRINT "CUSTOMER ID ": CUSTOMER.ID: " updated successfully with note: ": NOTERETURNENDPROGRAM UPDATE.DATA.DRV message in the unit test file? I would appreciate it if you could help with this.SHOULD.NOT.UPDATE.NOTE.IF.NOT.FOUND.CUSTOMER.ID:********************************** * Test 2: CUSTOMER ID not found PRINT "Test 2: Attempt to update non-existent CUSTOMER ID" @SENTENCE = 'UPDATE.DATA.DRV NONEXISTENT "Non-existent ID test"' CALL UPDATE.DATA.DRV EXPECTED.OUTPUT = "ERROR: No record found for CUSTOMER ID: NONEXISTENT" * Assuming that the error message is in SYSTEM(0) ACTUAL.OUTPUT = SYSTEM(0) * Compare expected and actual results IF ACTUAL.OUTPUT = EXPECTED.OUTPUT THEN PRINT "PASS: Test 2 passed successfully." END ELSE PRINT "FAIL: Test 2 failed." PRINT "Expected: ": EXPECTED.OUTPUT PRINT "Actual: ": ACTUAL.OUTPUT TEST.PASSED = 0 ENDPRINT "***********************************************************************************************************"RETURN------------------------------
Gnanaseelan gnanapirakasam
SSE
Rocket Forum Shared Account
------------------------------