Oracle GL Journal Import Program Backend


DECLARE
   l_conc_id         NUMBER;
   l_int_run_id      NUMBER;
   l_access_set_id   NUMBER;
   l_org_id          NUMBER := 81;
   l_sob_id          NUMBER := 2021;
   l_user_id         NUMBER := FND_GLOBAL.USER_ID;
   l_resp_id         NUMBER := FND_GLOBAL.RESP_ID;
   l_resp_app_id     NUMBER := FND_GLOBAL.RESP_APPL_ID;
BEGIN
   fnd_global.apps_initialize (user_id        => l_user_id,   --User Id
                               resp_id        => l_resp_id,    
                                                        --Responsibility Id
                               resp_appl_id   => l_resp_app_id 
                                           --Responsibility Application Id
                                                              );


   mo_global.set_policy_context ('S', l_org_id);


   SELECT gl_journal_import_s.NEXTVAL INTO l_int_run_id FROM DUAL;


   SELECT access_set_id
     INTO l_access_set_id
     FROM gl_access_sets
    WHERE name = 'VISION OPERATIONS SET';


   INSERT INTO gl_interface_control (je_source_name,
                                     interface_run_id,
                                     status,
                                     set_of_books_id)
        VALUES ('Receivables',
                l_int_run_id,
                'S',
                l_sob_id);


   l_conc_id :=
      fnd_request.submit_request 
            (application   => 'SQLGL',
              program       => 'GLLEZL',
              description   => NULL,
              start_time    => SYSDATE,
              sub_request   => FALSE,
              argument1     => l_int_run_id, --interface run id
              argument2     => l_access_set_id, --data access set_id
              argument3     => 'N',      --post to suspense
              argument4     => NULL,            --from date
              argument5     => NULL,              --to date
              argument6     => 'N',          --summary mode
              argument7     => 'N',            --import DFF
              argument8     => 'Y'         --backward mode
             );


   COMMIT;


   DBMS_OUTPUT.PUT_LINE ('GL Import Submitted. Request Id : ' || l_conc_id);
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.PUT_LINE ('Error while submitting the GL Import Program.');
      DBMS_OUTPUT.PUT_LINE 
      ('Error : ' || SQLCODE || '-' || SUBSTR (SQLERRM, 1, 240));
END;

Oracle User Defined Aggregate Function Script

The WM_CONCAT function and LISTAGG function if not supported then  you can create your own user defined aggregate function as below:
 
-----------------------
CREATE OR REPLACE TYPE xxtex_string_agg AS OBJECT
(
  g_string  VARCHAR2(32767),

  STATIC FUNCTION ODCIAggregateInitialize(sctx  IN OUT  xxtex_string_agg)
    RETURN NUMBER,

  MEMBER FUNCTION ODCIAggregateIterate(self   IN OUT  xxtex_string_agg,
                                       value  IN      VARCHAR2 )
     RETURN NUMBER,

  MEMBER FUNCTION ODCIAggregateTerminate(self         IN   xxtex_string_agg,
                                         returnValue  OUT  VARCHAR2,
                                         flags        IN   NUMBER)
    RETURN NUMBER,

  MEMBER FUNCTION ODCIAggregateMerge(self  IN OUT  xxtex_string_agg,
                                     ctx2  IN      xxtex_string_agg)
    RETURN NUMBER
);



------------------------------
CREATE OR REPLACE TYPE BODY xxtex_string_agg IS
  STATIC FUNCTION ODCIAggregateInitialize(sctx  IN OUT  xxtex_string_agg)
    RETURN NUMBER IS
  BEGIN
    sctx := xxtex_string_agg(NULL);
    RETURN ODCIConst.Success;
  END;

  MEMBER FUNCTION ODCIAggregateIterate(self   IN OUT  xxtex_string_agg,
                                       value  IN      VARCHAR2 )
    RETURN NUMBER IS
  BEGIN
    SELF.g_string := self.g_string || ',' || value;
    RETURN ODCIConst.Success;
  END;

  MEMBER FUNCTION ODCIAggregateTerminate(self         IN   xxtex_string_agg,
                                         returnValue  OUT  VARCHAR2,
                                         flags        IN   NUMBER)
    RETURN NUMBER IS
  BEGIN
    returnValue := RTRIM(LTRIM(SELF.g_string, ','), ',');
    RETURN ODCIConst.Success;
  END;

  MEMBER FUNCTION ODCIAggregateMerge(self  IN OUT  xxtex_string_agg,
                                     ctx2  IN      xxtex_string_agg)
    RETURN NUMBER IS
  BEGIN
    SELF.g_string := SELF.g_string || ',' || ctx2.g_string;
    RETURN ODCIConst.Success;
  END;
END;


---------------------------------------
CREATE OR REPLACE FUNCTION xxtex_string_agg_f (p_input VARCHAR2)
   RETURN VARCHAR2 PARALLEL_ENABLE AGGREGATE
   USING xxtex_string_agg;


------------------------------using in select statement -----------------
SELECT  xxtex_string_agg_f(distinct pa.name) AS project_name
FROM po_distributions_all po_dist,pa_projects_all pa
     WHERE po_dist.po_header_id= :po_header_id
           AND po_dist.project_id=pa.project_id;

Return 91234,92345,93456,94567,95678