Managing Master Data with webMethods OneData 10.5 | Managing Master Data with webMethods OneData | Developing for webMethods OneData | OneData Hooks | How are hooks used in OneData? | Hook Types | iHooks Sample Code | Stored Procedure
 
Stored Procedure
iHook Required Section
hookInput      t_hookInput;
hookOutput     t_hookOutput := t_hookOutput();
 
begin-- Gets the rows that the user has clicked on.
 hookInput := iHook.getHookInput (v_data_in);--
 hookOutput.invocationNumber := hookInput.invocationNumber;
 hookOutput.originalRowset := hookInput.originalRowset;
Hello World in iHooks Example
CREATE OR REPLACE PROCEDURE spHelloWorldHook (v_data_in in
   clob, v_data_out out clob) as
 hookInput      t_hookInput;
 hookOutput     t_hookOutput := t_hookOutput();
 
begin-- Gets the rows that the user has clicked on.
 hookInput := iHook.getHookInput (v_data_in);--
 hookOutput.invocationNumber :=
hookInput.invocationNumber;   hookOutput.originalRowset :=
hookInput.originalRowset;
 
-- Sets the message to be displayed
  hookOutput.message := 'Hello World!';
 
-- Displays the message at the top of the OneData screen
 v_data_out := iHook.getHookOutput(hookOutput);end;/
Creating a Showable Rowset from an Existing Object
IF hookInput.invocationNumber = 0 THEN
  rows := t_rows ();
  FOR cur IN potentially_matching_persons LOOP
   row := t_row();
   iHook.setColumnValue (row,'PDS_PER_ID',cur.pds_per_id);
   rows.extend;
   rows (rows.last) := row;
   v_found := true;
  END LOOP;
  IF v_found THEN
   showRowset := t_showableRowset (rows,'PDS_PERSON_MASTER',1,
'single');
   hookOutput.showRowset := showRowset;
  END IF;
  -
   answers := t_answers();
   answer := t_answer(1, 1, 'Associate');
   answers.extend;
   answers (answers.last) := answer;
   answer := t_answer (2,2,'Create New');
   answers.extend;
   answers(answers.last) := answer;
   question := t_question ('Select a row to associate and click
"Associate" or click on "Create New" to create a
new row', answers);
   hookOutput.question := question;END IF;
Creating a Showable Rowset for a Custom Object
for cur in cur_find_new_accounts loop
 row := t_row();
  j:=j+1;
   iHook.setColumnValue (row,'ACCT_CD',cur.ACCT_CD);
   iHook.setColumnValue (row,'ACCT_NM',cur.ACCT_NM);
    rows.extend;
    rows (rows.last) := row;
end loop;
if (j>0)
then
  showRowset := t_showableRowset (rows,'various', 4,'single');
  hookOutput.showRowset := showRowset;
  answers := t_answers();
  answer := t_answer(1,1,'Next');
  answers.extend;
  answers (answers.last) := answer;
  answer := t_answer (2,2,'Cancel');
  answers.extend;
  answers(answers.last) := answer;
  question := t_question ('Select applicable accounts:', answers);
  hookOutput.question := question;
end if;
Insert Action
FOR int_id IN to_be_inserted_rows LOOP
  row := t_row();
  iHook.setColumnValue (row,'SYS_ID', int_id.app_id);
  iHook.setColumnValue (row,'SRC_VAL_ID', int_id.int_id);
  iHook.setColumnValue (row,'TRGT_VAL_ID', v_to_map_item_id );
  rows.extend;
  rows (rows.last) := row;
end loop;
 
action := t_actionRowset (rows,'CODE_TRSLTN',1, 1,'insert');
actions.extend;
actions(actions.last) := action;
hookOutput.actions := actions;
hookOutput.message := 'Update/Insert Completed Successfully';
Conceptual Object DML
When a series of action queried need to be executed from the iHook and internally within OneData needs to be linked to one conceptual transaction, a conceptual object context needs to be given in the iHook. Highlighted in bold below.
rows := t_rows();
row := t_row();
 
SELECT NVL (MAX (pds_person_master_id) + 1,1)INTO v_pds_person_master_id
FROM pds_person_master;
 
iHook.setColumnValue (row,'PDS_PERSON_MASTER_ID', v_pds_person_master_id);
iHook.setColumnValue (row,'PERSON_LNAME',
iHook.getColumnValue (row_ori,'CLNSD_EMP_LNAME'));
iHook.setColumnValue (row,'PERSON_FNAME',
iHook.getColumnValue (row_ori,'CLNSD_EMP_FNAME'));
iHook.setColumnValue (row,'SRC_SYS_ID',
iHook.getColumnValue (row_ori,'SRC_SSY_ID'));
iHook.setColumnValue (row,'PERSON_TYP_ID',
iHook.getColumnValue (row_ori,'CLNSD_EMP_TYP'));
 
rows.extend;
rows (rows.last) := row;
 
action := t_actionRowset (rows,'PDS_PERSON_MASTER',1,1,'insert',
  'Person (Gold View)');
actions.extend;actions(actions.last) := action;
 
rows := t_rows();row := t_row();
 
SELECT NVL (MAX (pds_person_address_id) + 1,1) INTO v_pds_person_address_id
 
FROM pds_person_address;
  /*insert into address */
 
iHook.setColumnValue (row,'PDS_PERSON_ADDRESS_ID',v_pds_person_address_id);
iHook.setColumnValue (row,'PERSON_ID', v_pds_person_master_id);
iHook.setColumnValue (row,'PDS_ADDR_LINE_1',
iHook.getColumnValue (row_ori,'CLNSD_ADDR_LINE_1'));
iHook.setColumnValue (row,'PDS_ADDR_LINE_2',
iHook.getColumnValue (row_ori,'CLNSD_ADDR_LINE_2'));
iHook.setColumnValue (row,'CITY_NM',
iHook.getColumnValue (row_ori,'CITY_NM'));
iHook.setColumnValue (row,'ST_NM',
iHook.getColumnValue (row_ori,'ST_NM'));
iHook.setColumnValue (row,'CNTRY_ID',
iHook.getColumnValue (row_ori,'CNTRY_ID'));
 
rows.extend;
rows(rows.last) := row;
 
action := t_actionRowset (rows,'PDS_PERSON_ADDRESS',1, 2,'insert',
  'Person (Gold View)');
--
actions.extend;
actions (actions.last) := action;
Form
CREATE OR REPLACE procedure formTestHook (in_xml in clob, out_xml out clob)as
 
hookInput t_hookInput;
hookOutput     t_hookOutput := t_hookOutput();
 
question t_question;
answer t_answer;
answers t_answers;
forms t_forms;
form1 t_form;
form2 t_form;
 
begin
 hookInput := ihook.getHookInput(in_xml);
 hookOutput.invocationNumber := hookInput.invocationNumber;
 hookOutput.originalRowset := hookInput.originalRowset;
 if hookInput.invocationNumber = 0 then
  hookOutput.message := 'Form Test Hook';
  answers := t_answers();
  answer := t_answer(1, 1, 'OK');
  answers.extend; answers(answers.last) := answer;
  question := t_question('Choose action', answers);
  hookOutput.question := question;
  forms := t_forms();
  form1 := t_form('Data Object 1', 2, 2);
  forms.extend; forms(forms.last) := form1;
  hookOutput.forms := forms;
   
 else
  forms := hookInput.forms;
  form1 := forms(1);
  hookOutput.message := ihook.getColumnValue(form1.rowset.rowset(1), 'N')
  || '<br>' || ihook.getColumnValue(form1.rowset.rowset(1), 'S')
  || '<br>' || ihook.getColumnValue(form1.rowset.rowset(1), 'D');
 end if;
  out_xml := ihook.getHookOutput(hookOutput);
  end;
/

Copyright © 2011-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.