declare
p_api_version_number NUMBER;
p_init_msg_list VARCHAR2(2000);
V_return_status VARCHAR2(2000);
V_msg_data VARCHAR2(2000);
p_action_code VARCHAR2(2000);
p_delivery_id NUMBER ;
V_trip_id VARCHAR2(30);
V_trip_name VARCHAR2(30);
V_msg_details VARCHAR2(3000);
V_msg_summary VARCHAR2(3000);
V_msg_count NUMBER;
V_init_msg_list VARCHAR(2000);

begin

p_delivery_id := 7102;           — dELIVERY ID FROM SALES TRANSACTION SCREEN
p_action_code :=’CONFIRM’;

WSH_DELIVERIES_PUB.Delivery_Action(
                                    p_api_version_number => 1.0,
                                    p_init_msg_list => V_init_msg_list,
                                    x_return_status => V_return_status,
                                    x_msg_count => V_msg_count,
                                    x_msg_data => V_msg_data,
                                    p_action_code => p_action_code,
                                    p_delivery_id => p_delivery_id,
                                    x_trip_id => V_trip_id,
                                    x_trip_name => V_trip_name);

  IF (V_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
              WSH_UTIL_CORE.get_messages(‘Y’, V_msg_summary, V_msg_details, V_msg_count);
             dbms_output.put_line(V_msg_details);
  END IF;
end;

1) Custom Table to store account segments.

create table XX_ACCOUNT_COMBINATIONS (CODE VARCHAR2(2000))

===========================================================================================


2) Function to Create or Check the Code Combinations in GL


create or replace function create_ccid
( p_concat_segs in varchar2
) return varchar2
is
-- pragma autonomous_transaction; -- if you need autonomy!
l_keyval_status BOOLEAN;
l_coa_id NUMBER;
l_err_msg varchar2(2000);
l_error varchar2(255);
begin
begin
select chart_of_accounts_id
into l_coa_id
from gl_sets_of_books
where set_of_books_id = fnd_profile.value('GL_SET_OF_BKS_ID');
exception
when no_data_found then
dbms_output.put_line('Chart of Accounts ID not found from profile option GL_SET_OF_BKS_ID');
dbms_output.put_line('Try setting up your environment with fnd_global.apps_initialize');
raise;
end;
-- keyval_mode can be one of CREATE_COMBINATION CHECK_COMBINATION FIND_COMBINATION
--create will only work if dynamic inserts on and cross validation rules not broken
l_keyval_status := fnd_flex_keyval.validate_segs(
'CHECK_COMBINATION',
'SQLGL',
'GL#',
l_coa_id,
p_concat_segs,
'V',
sysdate,
'ALL', NULL, NULL, NULL, NULL,
FALSE,FALSE, NULL, NULL, NULL);

if l_keyval_status then
return 'S';
else
--return l_error;
l_err_msg:=substr(fnd_flex_keyval.error_message, 1, 240); --fnd_message.get;

l_error := substr(fnd_flex_keyval.error_message, 1, 240);
dbms_output.put_line(l_error);
dbms_output.put_line('ERROR SEGMENT :');
l_error := to_char(fnd_flex_keyval.error_segment);
dbms_output.put_line(l_error);
dbms_output.put_line('ERROR ENCODED :');
l_error := substr(fnd_flex_keyval.encoded_error_message, 1, 240);
dbms_output.put_line(l_error);
dbms_output.put_line('FALSE');

dbms_output.put_line(l_err_msg||substr(sqlerrm,150,3));
return l_error;
end if;
end create_ccid;
/

3) Table to store Segments and Error / Success Status

CREATE TABLE XX_COMBINATION_ERROR_STATUS
(
CODE VARCHAR2(2000 BYTE),
STATUS VARCHAR2(2000 BYTE)
)


4) Procedure to Call Function to create combinations from the custom table


CREATE OR REPLACE procedure APPS.XX_CREATE_GL_ACC_COMBINATION
IS
V_COMBINATION VARCHAR2(240);
CURSOR C1 IS
SELECT DISTINCT CODE
FROM XX_ACCOUNT_COMBINATIONS;
--where rownum=1;

begin

FOR I IN C1 LOOP

select create_ccid(I.CODE) into V_COMBINATION from dual;

dbms_output.put_line (V_COMBINATION);

insert into xx_combination_error_status (code,status) values (i.code,v_combination);

END LOOP;


end;
/