Tuesday, January 31, 2012

OTL submit and Save time card through API's

The timecards are first saved using p_mode = 'SAVE' (hxc_timestore_deposit.execute_deposit_process) and when the user is ready he submits his timecard using p_mode = 'SUBMIT'.


Sample code for submit and save the time cards.
DECLARE
  v_tbl_timecard_info         hxc_self_service_time_deposit.timecard_info;      
  v_tbl_attributes_info       hxc_self_service_time_deposit.app_attributes_info;
  v_tbv_messages              hxc_self_service_time_deposit.message_table;
  v_new_timecard_id           NUMBER; 
  v_new_timecard_ovn          NUMBER;
  i                           PLS_INTEGER;
  v_message                   fnd_new_messages.message_text%TYPE;
BEGIN
  FND_GLOBAL.APPS_INITIALIZE( user_id => 75375
                             ,resp_id => 65477       
                             ,resp_appl_id => 809 ); 
 
  hxc_timestore_deposit.update_building_block(p_building_block_id => 23717233,
                                              p_app_blocks        => v_tbl_timecard_info,
                                              p_app_attributes    => v_tbl_attributes_info);
 
  hxc_timestore_deposit.execute_deposit_process (
    p_validate        => FALSE,
    p_app_blocks      => v_tbl_timecard_info,
    p_app_attributes  => v_tbl_attributes_info,
    p_messages        => v_tbv_messages,
    p_mode            => 'SUBMIT',
    p_deposit_process => 'OTL Deposit Process',
    p_timecard_id     => v_new_timecard_id,
    p_timecard_ovn    => v_new_timecard_ovn);
 
  -- messages have been returned
  IF v_tbv_messages.COUNT != 0 THEN
    i := v_tbv_messages.FIRST;
    LOOP
      EXIT WHEN (NOT v_tbv_messages.EXISTS (i));
 
      -- First translate the message as the messagetable returned does not give the actual
      -- message, only the message_name which doesn't mean anything to the user.
      v_message := fnd_message.get_string (appin  => v_tbv_messages (i).application_short_name,
                                           namein => v_tbv_messages (i).message_name);
 
      -- returns 4: 4
      dbms_output.put_line(v_tbv_messages(i).message_name||': '||v_message);
 
      i := v_tbv_messages.NEXT (i);
    END LOOP;
  END IF;
END;