Question How to Use Table name Dynamically in this Programe?

"table_capture.p"

{Table_Audit.i} /*here we included the session.i file that is used for auditing*/
define variable lChoice as logical no-undo.
define variable iCustNum as integer no-undo.

/*Frame for all the Creating or Updating activities*/
define frame CustInfo
with size 500 by 20.

display "Do you want to update the Customer yes/no".
set lChoice.
/*If we want to update this will be execute*/
if lChoice then
do:
for each Customer:
update Customer with frame CustInfo.
end.
message "Customer updated".
end.
/*If we want to create this will be execute*/
else
do:
set iCustNum.
create Customer.
assign
Customer.CustNum = iCustNum.
update Customer with frame f with size 100 by 20.
message "created".
end.


"Table_Audit.i"

/*ABL Program for Crating EventLog table that audit the trigger activity*/
DEFINE VARIABLE hOldRecord AS HANDLE NO-UNDO.
DEFINE VARIABLE hNewRecord AS HANDLE NO-UNDO.
DEFINE VARIABLE hOldField AS HANDLE NO-UNDO.
DEFINE VARIABLE hNewField AS HANDLE NO-UNDO.
DEFINE VARIABLE cChangedFields AS CHARACTER NO-UNDO.
DEFINE VARIABLE iChangedFields AS INTEGER NO-UNDO.

ON WRITE OF Customer NEW newcust OLD oldcust
do:
/*compare the old buffer and new buffer */
BUFFER-COMPARE newcust TO oldcust SAVE RESULT IN cChangedFields NO-ERROR.
IF cChangedFields <> "" THEN
DO:
/*Assigning the String buffer to the handle Records*/
ASSIGN
hOldRecord = BUFFER oldcust:HANDLE
hNewRecord = BUFFER newcust :HANDLE.

DO iChangedFields = 1 TO NUM-ENTRIES(cChangedFields):
/*creating the Table where i want capture the Trigger Activity*/
CREATE EventLog.
ASSIGN

EventLog.cDate = TODAY
EventLog.cTime = STRING(TIME,"HH:MM:SS")
EventLog.cTableName = hOldRecord:NAME
EventLog.cFieldName = ENTRY(iChangedFields, cChangedFields)
hnewField = hnewRecord:BUFFER-FIELD(ENTRY(iChangedFields, cChangedFields))
EventLog.cNewStringValue = hnewField:BUFFER-VALUE

holdField = holdRecord:BUFFER-FIELD(ENTRY(iChangedFields, cChangedFields))
EventLog.cOldStringValue = holdField:buffer-VALUE
EventLog.action = if new newcust then "create" else "Update".
END.
end.
END.


***In this Instead of Particular Customer I want to use this for some other table means I want to use Dynamic table name.
 
Top