1- Create a new Component Interface with Application designer
In application Designer, Select File->New->Component InterfaceSelect The Component you want to access to
Answer YES to following question
Now your componet has been created, you can just save IT
2- Write Peoplecode for you CI
2.1- Drag and drop the Component Interface to the Peoplecode text window. Il will create a template to adapt:
[vb] Local File &fileLog; Local ApiObject &oSession, &oMYCINAMEPoRecv; 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; &fileLog.WriteLine(&sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText); End-For; rem ***** Delete the Messages from the collection *****; &oPSMessageCollection.DeleteAll(); End-Function; try rem ***** Set the Log File *****; &fileLog = GetFile("C:\temp\MY_CI_NAME.log", "w", "a", %FilePath_Absolute); &fileLog.WriteLine("Begin"); rem ***** Get current PeopleSoft Session *****; &oSession = %Session; rem ***** Set the PeopleSoft Session Error Message Mode *****; rem ***** 0 - None *****; rem ***** 1 - PSMessage Collection only (default) *****; rem ***** 2 - Message Box only *****; rem ***** 3 - Both collection and message box *****; &oSession.PSMessagesMode = 1; rem ***** Get the Component Interface *****; &oMYCINAMEPoRecv = &oSession.GetCompIntfc(CompIntfc.MY_CI_NAME_RECV); If &oMYCINAMEPoRecv = Null Then errorHandler(); throw CreateException(0, 0, "GetCompIntfc failed"); End-If; rem ***** Set the Component Interface Mode *****; &oMYCINAMEPoRecv.InteractiveMode = False; &oMYCINAMEPoRecv.GetHistoryItems = True; &oMYCINAMEPoRecv.EditHistoryItems = False; rem ***** Set Component Interface Get/Create Keys *****; rem ***** Execute Get *****; If Not &oMYCINAMEPoRecv.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 *****; rem ***** Get/Set Level 0 Field Properties *****; &fileLog.WriteLine("&oMYCINAMEPoRecv.INV_LOT_ID = " | &oMYCINAMEPoRecv.INV_LOT_ID); rem &oMYCINAMEPoRecv.INV_LOT_ID = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.INV_ITEM_ID = " | &oMYCINAMEPoRecv.INV_ITEM_ID); rem &oMYCINAMEPoRecv.INV_ITEM_ID = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.SERIAL_ID = " | &oMYCINAMEPoRecv.SERIAL_ID); rem &oMYCINAMEPoRecv.SERIAL_ID = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.STORAGE_AREA = " | &oMYCINAMEPoRecv.STORAGE_AREA); rem &oMYCINAMEPoRecv.STORAGE_AREA = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.STOR_LEVEL_1 = " | &oMYCINAMEPoRecv.STOR_LEVEL_1); rem &oMYCINAMEPoRecv.STOR_LEVEL_1 = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.STOR_LEVEL_2 = " | &oMYCINAMEPoRecv.STOR_LEVEL_2); rem &oMYCINAMEPoRecv.STOR_LEVEL_2 = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.STOR_LEVEL_3 = " | &oMYCINAMEPoRecv.STOR_LEVEL_3); rem &oMYCINAMEPoRecv.STOR_LEVEL_3 = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.STOR_LEVEL_4 = " | &oMYCINAMEPoRecv.STOR_LEVEL_4); rem &oMYCINAMEPoRecv.STOR_LEVEL_4 = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.CONTAINER_ID = " | &oMYCINAMEPoRecv.CONTAINER_ID); rem &oMYCINAMEPoRecv.CONTAINER_ID = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.UNIT_OF_MEASURE = " | &oMYCINAMEPoRecv.UNIT_OF_MEASURE); rem &oMYCINAMEPoRecv.UNIT_OF_MEASURE = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.RECEIVER_ID = " | &oMYCINAMEPoRecv.RECEIVER_ID); rem &oMYCINAMEPoRecv.RECEIVER_ID = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.QTY = " | &oMYCINAMEPoRecv.QTY); rem &oMYCINAMEPoRecv.QTY = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.SCHED_NBR = " | &oMYCINAMEPoRecv.SCHED_NBR); rem &oMYCINAMEPoRecv.SCHED_NBR = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.SETID = " | &oMYCINAMEPoRecv.SETID); rem &oMYCINAMEPoRecv.SETID = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.SHIPTO_ID = " | &oMYCINAMEPoRecv.SHIPTO_ID); rem &oMYCINAMEPoRecv.SHIPTO_ID = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.VENDOR_ID = " | &oMYCINAMEPoRecv.VENDOR_ID); rem &oMYCINAMEPoRecv.VENDOR_ID = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.SHIPMENT_NO = " | &oMYCINAMEPoRecv.SHIPMENT_NO); rem &oMYCINAMEPoRecv.SHIPMENT_NO = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.CARRIER_ID = " | &oMYCINAMEPoRecv.CARRIER_ID); rem &oMYCINAMEPoRecv.CARRIER_ID = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.BILL_OF_LADING = " | &oMYCINAMEPoRecv.BILL_OF_LADING); rem &oMYCINAMEPoRecv.BILL_OF_LADING = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.BUSINESS_UNIT_PO = " | &oMYCINAMEPoRecv.BUSINESS_UNIT_PO); rem &oMYCINAMEPoRecv.BUSINESS_UNIT_PO = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.PO_ID = " | &oMYCINAMEPoRecv.PO_ID); rem &oMYCINAMEPoRecv.PO_ID = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.LINE_NBR = " | &oMYCINAMEPoRecv.LINE_NBR); rem &oMYCINAMEPoRecv.LINE_NBR = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.BUSINESS_UNIT_IN = " | &oMYCINAMEPoRecv.BUSINESS_UNIT_IN); rem &oMYCINAMEPoRecv.BUSINESS_UNIT_IN = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.VENDOR_LOT_ID = " | &oMYCINAMEPoRecv.VENDOR_LOT_ID); rem &oMYCINAMEPoRecv.VENDOR_LOT_ID = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.TAG_NUMBER = " | &oMYCINAMEPoRecv.TAG_NUMBER); rem &oMYCINAMEPoRecv.TAG_NUMBER = [*]; &fileLog.WriteLine("&oMYCINAMEPoRecv.TRANSACTION_CODE = " | &oMYCINAMEPoRecv.TRANSACTION_CODE); rem &oMYCINAMEPoRecv.TRANSACTION_CODE = [*]; rem ***** End: Get/Set Component Interface Properties *****; rem ***** Execute Save *****; rem If Not &oMYCINAMEPoRecv.Save() Then; rem errorHandler(); rem throw CreateException(0, 0, "Save failed"); rem End-If; rem ***** Execute Cancel *****; rem If Not &oMYCINAMEPoRecv.Cancel() Then; rem errorHandler(); rem throw CreateException(0, 0, "Cancel failed"); rem End-If; catch exception &ex rem Handle the exception; &fileLog.WriteLine(&ex.ToString()); end-try; &fileLog.WriteLine("End"); &fileLog.Close();
2.2- Make changes so that you can include the CI code in a single function
This way, your CI will be easyer to use from any application, with a single function call.Change the errorHandler function to get File & Session as a parameter:
[vb] Function errorHandler(&fileLog As File, &oSession As ApiObject) 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; &fileLog.WriteLine(&sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText); End-For; rem ***** Delete the Messages from the collection *****; &oPSMessageCollection.DeleteAll(); End-Function;
Create Functions containing Your CI operations, so that it will be easier to integrate in any peoplecode program.
[vb] // Function returns a rowset from MY_BCODE_TBL corresponding to &barcode parameter Function getBarcodeRecord(&barcode As string) Returns Record Local Rowset &RwsBarcode; Local Record &REcBarcode; &RwsBarcode = CreateRowset(Record.MY_BCODE_TBL); &RwsBarcode.Fill("WHERE RECV_CARD_ID = :1", &barcode); &REcBarcode = CreateRecord(Record.MY_BCODE_TBL); &REcBarcode = &RwsBarcode(1).GetRecord(1); Return &REcBarcode; End-Function; // This Function is scheduling a job Function RunJobRecv(&barcode As string) Returns boolean Local boolean &success = False; Local ProcessRequest &prcsrqst; Local JavaObject &Obj; Local Record &RecRECVLOAD; Local Record &RecRECVPUSH; Local Record &RecINPSSTGE; // Select data using barcode ID - start; Local Record &REcBarcode; &REcBarcode = getBarcodeRecord(&barcode); // Select data using barcode ID - end; &jobname = "MYRECVJOB"; // Create Data In Needed Run Control Parameters; // 01 - RECVLOAD; &RecRECVLOAD = CreateRecord(Record.RUN_CNTL_RECVLD); &RecRECVLOAD.OPRID.Value = %UserId; &RecRECVLOAD.RUN_CNTL_ID.Value = &jobname; &RecRECVLOAD.RECVLOAD_OPT.Value = "2"; &RecRECVLOAD.BUSINESS_UNIT.Value = &REcBarcode.BUSINESS_UNIT_IN.Value; &RecRECVLOAD.WHERE_CLAUSE.Value = "BUSINESS_UNIT = '" | &RecRECVLOAD.BUSINESS_UNIT.Value | "'"; If Not &RecRECVLOAD.Insert() Then &RecRECVLOAD.Update(); End-If; // 02 - RUN_PO_RECEIPT; &RecRECVPUSH = CreateRecord(Record.RECV_RUN_CNTL); &RecRECVPUSH.OPRID.Value = %UserId; &RecRECVPUSH.RUN_CNTL_ID.Value = &jobname; &RecRECVPUSH.RECEIVER_ID.Value = ""; &RecRECVPUSH.BUSINESS_UNIT.Value = &REcBarcode.BUSINESS_UNIT_IN.Value; If Not &RecRECVPUSH.Insert() Then &RecRECVPUSH.Update(); End-If; REM Schedule the Job; &prcsrqst = CreateProcessRequest("PSJob", &jobname); &prcsrqst.RunControlID = &jobname; &prcsrqst.JobName = &jobname; &prcsrqst.Schedule(); If &prcsrqst.Status = 0 Then /* Schedule succeeded. */ &success = True; Else /* Process (job) not scheduled, do error processing */ &success = False; End-If; /* &Obj = CreateJavaObject("java.lang.Thread"); &Obj.start(); &RunStatus = "0"; While &RunStatus <> "9" And &RunStatus <> "3" And &RunStatus <> "1" And &RunStatus <> "10" REM Directly use the Java sleep() Method for 5 seconds; &Obj.sleep(5000); SQLExec("SELECT RUNSTATUS FROM PSPRCSRQST WHERE PRCSINSTANCE = :1", &prcsrqst.ProcessInstance, &RunStatus); REM MessageBox(0, "", 0, 0, "Sleep(), Runstatus = %1", &RunStatus); End-While; &Obj.stop(); rem WriteLog("Process MYRECVJOB is Finished"); If &prcsrqst.Status = 10 Or &prcsrqst.Status = 3 Then REM Process your errors; &success = False; Else REM Process your success; &success = True; End-If; */ Return &success; End-Function; // Adds data to a log table Function LogBarcode(&barcode As string, &qty As number, &transaction_code As string) Returns boolean Local Record &RecLog; &RecLog = CreateRecord(Record.PH_RECV_BCD_LOG); &RecLog.RECV_CARD_ID.Value = &barcode; &RecLog.QTY.Value = &qty; &RecLog.TRANSACTION_CODE.Value = &transaction_code; &RecLog.DT_TIMESTAMP.Value = %Datetime; &RecLog.OPRID.Value = %UserId; Return &RecLog.Insert(); End-Function; // ErrorHandler Function Function errorHandler(&fileLog As File, &oSession As ApiObject) 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; &fileLog.WriteLine(&sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText); End-For; rem ***** Delete the Messages from the collection *****; &oPSMessageCollection.DeleteAll(); End-Function; /* Jean-Baptiste HEREN This function Gets Barcode and Qty from the barcode entry screen- Transaction 103; - Then it Uses a Component Interface to simulate the manual entry on; The Data Exchange > Create Transactions > Receiving > Purchasing Receiving;*/ Function WriteReceipt(&barcode As string, &qty As number) Returns boolean Local File &fileLog; Local ApiObject &oSession, &oMYCINAMEPoRecv; // Jean-Baptiste HEREN - Select data using barcode ID - start; Local Record &REcBarcode; &REcBarcode = getBarcodeRecord(&barcode); // Jean-Baptiste HEREN - Select data using barcode ID - end; try rem ***** Set the Log File *****; If %UserId = "jean-baptiste.heren" Then &fileLog = GetFile("\\MyMachine\temp\CI\MY_CI_NAME_RECV_WriteReceipt.log", "w", "a", %FilePath_Absolute); Else &fileLog = GetFile("MY_CI_NAME_RECV.log", "w", "a", %FilePath_Relative); End-If; &fileLog.WriteLine("Begin"); rem ***** Get current PeopleSoft Session *****; &oSession = %Session; rem ***** Set the PeopleSoft Session Error Message Mode *****; rem ***** 0 - None *****; rem ***** 1 - PSMessage Collection only (default) *****; rem ***** 2 - Message Box only *****; rem ***** 3 - Both collection and message box *****; &oSession.PSMessagesMode = 1; rem ***** Get the Component Interface *****; &oMYCINAMEPoRecv = &oSession.GetCompIntfc(CompIntfc.MY_CI_NAME_RECV); If &oMYCINAMEPoRecv = Null Then errorHandler(&fileLog, &oSession); throw CreateException(0, 0, "GetCompIntfc failed"); End-If; rem ***** Set the Component Interface Mode *****; &oMYCINAMEPoRecv.InteractiveMode = True; &oMYCINAMEPoRecv.GetHistoryItems = True; &oMYCINAMEPoRecv.EditHistoryItems = False; rem ***** Set Component Interface Get/Create Keys *****; rem ***** Execute Get *****; If Not &oMYCINAMEPoRecv.Get() Then rem ***** No rows exist for the specified keys.*****; errorHandler(&fileLog, &oSession); throw CreateException(0, 0, "Get failed"); End-If; rem ***** Begin: Get/Set Component Interface Properties *****; rem ***** Get/Set Level 0 Field Properties *****; // Jean-Baptiste HEREN - Write the session related to creation of a new reception line; &transaction_code = "0103"; &oMYCINAMEPoRecv.TRANSACTION_CODE = &transaction_code; // Jean-Baptiste HEREN - Fill with the barcode ID data; &oMYCINAMEPoRecv.SETID = &REcBarcode.SETID.Value; &oMYCINAMEPoRecv.SHIPTO_ID = &REcBarcode.SHIPTO_ID.Value; &oMYCINAMEPoRecv.VENDOR_ID = &REcBarcode.VENDOR_ID.Value; &oMYCINAMEPoRecv.BUSINESS_UNIT_IN = &REcBarcode.BUSINESS_UNIT_IN.Value; &oMYCINAMEPoRecv.CARRIER_ID = &REcBarcode.CARRIER_ID.Value; &oMYCINAMEPoRecv.BILL_OF_LADING = &REcBarcode.BILL_OF_LADING.Value; &oMYCINAMEPoRecv.BUSINESS_UNIT_PO = &REcBarcode.BUSINESS_UNIT_PO.Value; &oMYCINAMEPoRecv.PO_ID = &REcBarcode.PO_ID.Value; &oMYCINAMEPoRecv.LINE_NBR = &REcBarcode.LINE_NBR.Value; &oMYCINAMEPoRecv.UNIT_OF_MEASURE = &REcBarcode.UNIT_OF_MEASURE.Value; REM Still use Quantyty from Barcode screen; &oMYCINAMEPoRecv.QTY = &qty; rem ***** End: Get/Set Component Interface Properties *****; rem ***** Execute Save *****; If Not &oMYCINAMEPoRecv.Save() Then; errorHandler(&fileLog, &oSession); &success = False; throw CreateException(0, 0, "Save failed"); Else &success = True; If Not LogBarcode(&barcode, &qty, &transaction_code) Then &fileLog.WriteLine("LogBarcode Failed"); End-If; End-If; rem ***** Execute Cancel *****; rem If Not &oMYCINAMEPoRecv.Cancel() Then; rem errorHandler(&fileLog, &oSession); rem throw CreateException(0, 0, "Cancel failed"); rem End-If; catch Exception &ex rem Handle the exception; &fileLog.WriteLine(&ex.ToString()); end-try; &fileLog.WriteLine("End"); &fileLog.Close(); Return &success; End-Function; /* Jean-Baptiste HEREN This function Closes the Receipt session - Transaction 105; - It Uses a Component Interface to simulate the manual entry on; The Data Exchange > Create Transactions > Receiving > Purchasing Receiving;*/ Function CloseReceipt(&barcode) Returns boolean Local File &fileLog; Local ApiObject &oSession, &oMYCINAMEPoRecv; // Jean-Baptiste HEREN - Select data using barcode ID - start; Local Record &REcBarcode; &REcBarcode = getBarcodeRecord(&barcode); // Jean-Baptiste HEREN - Select data using barcode ID - end; try rem ***** Set the Log File *****; If %UserId = "jean-baptiste.heren" Then &fileLog = GetFile("\\MyMachine\temp\CI\MY_CI_NAME_RECV_CloseReceipt.log", "w", "a", %FilePath_Absolute); Else &fileLog = GetFile("MY_CI_NAME_RECV.log", "w", "a", %FilePath_Relative); End-If; &fileLog.WriteLine("Begin"); rem ***** Get current PeopleSoft Session *****; &oSession = %Session; rem ***** Set the PeopleSoft Session Error Message Mode *****; rem ***** 0 - None *****; rem ***** 1 - PSMessage Collection only (default) *****; rem ***** 2 - Message Box only *****; rem ***** 3 - Both collection and message box *****; &oSession.PSMessagesMode = 1; rem ***** Get the Component Interface *****; &oMYCINAMEPoRecv = &oSession.GetCompIntfc(CompIntfc.MY_CI_NAME_RECV); If &oMYCINAMEPoRecv = Null Then errorHandler(&fileLog, &oSession); throw CreateException(0, 0, "GetCompIntfc failed"); End-If; rem ***** Set the Component Interface Mode *****; &oMYCINAMEPoRecv.InteractiveMode = True; &oMYCINAMEPoRecv.GetHistoryItems = True; &oMYCINAMEPoRecv.EditHistoryItems = False; rem ***** Set Component Interface Get/Create Keys *****; rem ***** Execute Get *****; If Not &oMYCINAMEPoRecv.Get() Then rem ***** No rows exist for the specified keys.*****; errorHandler(&fileLog, &oSession); throw CreateException(0, 0, "Get failed"); End-If; rem ***** Begin: Get/Set Component Interface Properties *****; rem ***** Get/Set Level 0 Field Properties *****; // Jean-Baptiste HEREN - Write the session related to creation of a new reception line; &qty = 0; &transaction_code = "0105"; &oMYCINAMEPoRecv.TRANSACTION_CODE = &transaction_code; REM JBH - Fill with the barcode ID data.value; &oMYCINAMEPoRecv.SETID = &REcBarcode.SETID.Value; &oMYCINAMEPoRecv.SHIPTO_ID = &REcBarcode.SHIPTO_ID.Value; REM &oMYCINAMEPoRecv.VENDOR_ID = &REcBarcode.VENDOR_ID.Value; REM &oMYCINAMEPoRecv.BUSINESS_UNIT_IN = &REcBarcode.BUSINESS_UNIT_IN.value; &oMYCINAMEPoRecv.CARRIER_ID = &REcBarcode.CARRIER_ID.Value; &oMYCINAMEPoRecv.BILL_OF_LADING = &REcBarcode.BILL_OF_LADING.Value; REM &oMYCINAMEPoRecv.BUSINESS_UNIT_PO = &REcBarcode.BUSINESS_UNIT_PO.value; REM &oMYCINAMEPoRecv.PO_ID = &REcBarcode.PO_ID.value; REM &oMYCINAMEPoRecv.LINE_NBR = &REcBarcode.LINE_NBR.value; REM &oMYCINAMEPoRecv.UNIT_OF_MEASURE = &REcBarcode.UNIT_OF_MEASURE.value; REM Still use Quantyty from Barcode screen; REM &oMYCINAMEPoRecv.QTY = &qty; rem ***** End: Get/Set Component Interface Properties *****; rem ***** Execute Save *****; // Jean-Baptiste HEREN - Usually, you want you CI to save your component at end, so uncomment the SAVE part If Not &oMYCINAMEPoRecv.Save() Then; errorHandler(&fileLog, &oSession); &success = False; throw CreateException(0, 0, "Save failed"); Else &success = True; If Not LogBarcode(&barcode, &qty, &transaction_code) Then &fileLog.WriteLine("LogBarcode Failed"); End-If; End-If; rem ***** Execute Cancel *****; rem If Not &oMYCINAMEPoRecv.Cancel() Then; rem errorHandler(&fileLog, &oSession); rem throw CreateException(0, 0, "Cancel failed"); rem End-If; catch Exception &ex rem Handle the exception; &fileLog.WriteLine(&ex.ToString()); end-try; &fileLog.WriteLine("End"); &fileLog.Close(); Return &success; End-Function;
3- Write a program witch is using your CI
This kind of code is usually called from a Fast entry screen or External Interface[vb] // JBH - Declare Custom Functions Using Component Interface; Declare Function WriteReceipt PeopleCode MY_RECV_TABLE.RECV_CARD_ID FieldFormula; Declare Function CloseReceipt PeopleCode MY_RECV_TABLE.RECV_CARD_ID FieldFormula; REM Run the Component Interface; If All(MY_RECV_TABLE.RECV_CARD_ID.Value) And All(MY_RECV_TABLE.QTY.Value) Then MY_RECV_TABLE.RECV_CARD_ID.Value = RTrim(MY_RECV_TABLE.RECV_CARD_ID.Value); REM Check That This Barcode has not already been used; SQLExec("SELECT 1 FROM PS_PH_RECV_BCD_LOG WHERE RECV_CARD_ID = :1", MY_RECV_TABLE.RECV_CARD_ID.Value, &result); If &result <> 1 Then // Here we call our Component Interface If Not WriteReceipt(MY_RECV_TABLE.RECV_CARD_ID.Value, MY_RECV_TABLE.QTY.Value) Then WinMessage("Reception Failed!"); Else SetCursorPos(%Page, MY_RECV_TABLE.RECV_CARD_ID, CurrentRowNumber()); REM Save The succesfully recorded barcode; MY_RECV_TABLE.RECV_CARD_ID_OK.Value = MY_RECV_TABLE.RECV_CARD_ID.Value; REM Clean Screen; MY_RECV_TABLE.RECV_CARD_ID.Value = ""; MY_RECV_TABLE.QTY.Value = 0; End-If; Else WinMessage("Card ID has already been scanned !"); SetCursorPos(%Page, MY_RECV_TABLE.RECV_CARD_ID, CurrentRowNumber()); REM Clean Screen; MY_RECV_TABLE.RECV_CARD_ID.Value = ""; MY_RECV_TABLE.QTY.Value = 0; End-If; End-If;
0 comments:
Post a Comment
Phaniraavi@gmail.com