Sunday, 3 July 2016

Losing Data During Validation In Apex Tabular Form !!! - Check In

Step:1: On Submit, Before Computation and Validation - Insert into Collections.
  BEGIN
         apex_collection.add_member
                               (p_collection_name      => 'PDVD_MASTER_ITEM_DTLS',
                                p_c001                 => apex_application.g_f03
                                                                           (i),
                                p_c002                 => NVL
                                                             (:p77_master_pdvd_id,
                                                              NULL
                                                             ),
                                p_c003                 => apex_application.g_f04
                                                                           (i),
                                p_c004                 => apex_application.g_f05
                                                                           (i),
                                p_c005                 => apex_application.g_f06
                                                                           (i),
                                p_c006                 => apex_application.g_f07
                                                                           (i),
                                p_c007                 => apex_application.g_f08
                                                                           (i),
                                p_c008                 => apex_application.g_f09
                                                                           (i),
                                p_c009                 => apex_application.g_f10
                                                                           (i),
                                p_c010                 => lv_v_master_repli_of,
                                p_c011                 => lv_v_delivery_types,
                                p_c012                 => apex_application.g_f15
                                                                           (i)
                               );
      EXCEPTION
         WHEN OTHERS
         THEN
            raise_application_error (-20001, 'Error' || lv_v_exists);
      END;
   END LOOP;

   COMMIT;
END;
Step:2:
On Submit, after computation and validation
Insert into Collections to Main table
BEGIN
  FOR i IN (SELECT   c001, c002, c003, c004, c005, c006, c007, c008, c009,
                      c010, c011, c012
                 FROM apex_collections
                WHERE UPPER (collection_name) = 'PDVD_MASTER_ITEM_DTLS'
             ORDER BY c001)
   LOOP
      BEGIN
         SELECT 'Y', item_type, item_id
           INTO lv_v_exst, lv_n_item_type, lv_v_item_iden
           FROM pdvd_tb_master_item_dtls
          WHERE master_item_id = i.c001;
      EXCEPTION
         WHEN NO_DATA_FOUND
         THEN
            lv_v_exst := 'N';
      END;

      IF NVL (lv_v_exst, 'N') = 'N'
      THEN
         BEGIN
            lv_v_item_iden :=
               pdvd_pk_get_values.pdvd_fn_get_item_identifier
                       (iv_n_master_pdvd_id      => TO_NUMBER
                                                          (:p77_master_pdvd_id),
                        iv_n_item_type           => i.c008
                       );
         EXCEPTION
            WHEN NO_DATA_FOUND
            THEN
               lv_v_item_iden := NULL;
            WHEN OTHERS
            THEN
               raise_application_error (-20001,
                                        'Error1' || SQLERRM || SQLCODE
                                       );
         END;

         BEGIN
            /* raise_application_error(-20001,'Inside Main Insertion'||i.c001||':'||i.c002||':'||i.c003
                                                                   ||i.c004||':'||i.c005||':'||i.c006
                                                                   ||i.c007||':'||i.c008||':'||i.c009
                                                                   ||i.c010||':'||i.c011);*/
            pdvd_pk_dml_master.pdvd_pr_ins_master_item
                                  (iv_n_master_item_id          => i.c001,
                                   iv_n_master_pdvd_id          => :p77_master_pdvd_id,
                                   iv_v_item_id                 => lv_v_item_iden,
                                   iv_v_program_name            => i.c004,
                                   iv_v_output_name             => i.c005,
                                   iv_v_title                   => i.c006,
                                   iv_n_theme                   => TO_NUMBER
                                                                       (i.c007),
                                   iv_n_item_type               => TO_NUMBER
                                                                       (i.c008),
                                   iv_v_uniq_rep_indicator      => i.c009,
                                   iv_v_replicate_of            => i.c010,
                                   iv_v_delivery_types          => i.c011,
                                   iv_n_created_by              => :ai_user,
                                   iv_d_created_date            => SYSDATE,
                                   iv_v_record_source           => 'N',
                                   ov_v_error_msg               => lv_v_error_msg,
                                   ov_v_error_code              => lv_v_error_code
                                  );
         END;
END LOOP;
END;

Step:3:
On Page Load, Delete from Collections and move table data to collections and display report from collections

DECLARE
   l_query    VARCHAR2 (32767);
   l_exists   BOOLEAN;
   lv_n_user_id NUMBER;
BEGIN
   :AI_DEL_CHECK := 'N';
   lv_n_user_id := pdvd_pk_get_values.pdvd_fn_get_user_id (:app_user);
   

   BEGIN
      l_exists :=
         apex_collection.collection_exists
                                (p_collection_name      => 'PDVD_MASTER_ITEM_DTLS');
   END;

   IF (l_exists)
   THEN
      apex_collection.delete_collection
                                (p_collection_name      => 'PDVD_MASTER_ITEM_DTLS');
   END IF;

   BEGIN
      l_query :=
            'SELECT MASTER_ITEM_ID,
                         MASTER_PDVD_ID,
                         ITEM_ID,
                         PROGRAM_NAME,
                         OUTPUT_NAME,
                         TITLE,
                         THEME,
                         ITEM_TYPE,
                         UNIQ_REP_INDICATOR,
                         REPLICATE_OF_NAME,
                         DELIVERY_TYPES,
                         ACTIVE_IND
                         FROM PDVD_tb_master_item_dtls
                         WHERE MASTER_PDVD_ID = '
         || :p77_master_pdvd_id
         || ' UNION 
                  SELECT master_item_id,master_pdvd_id,item_id,
                         program_name, output_name, title ,theme ,
                         item_type , uniq_rep_indicator ,
                         replicate_of_name,delivery_types, active_ind
                   FROM pdvd_pt_master_item_dtls ppmid
                     WHERE master_pdvd_id ='
         || :p77_master_pdvd_id
         || ' AND user_id ='
         || lv_n_user_id
         || ' AND session_id='
         || :app_session;
      apex_collection.create_collection_from_query
                                (p_collection_name      => 'PDVD_MASTER_ITEM_DTLS',
                                 p_query                => l_query,
                                 p_generate_md5         => 'YES'
                                );
   END;
END;


Step:4:
Include newly added row at top to avoid losing newly added records,

javascript:addRowTop();
function addRowTop() 
{
    apex.widget.tabular.addRow();
apex.jQuery(apex.widget.tabular.gTabForm).find("tr").last().insertBefore(apex.jQuery(apex.widget.tabular.gTabForm).find("tr").first());
}




Field Locks In Oracle Apex

     

Step:1: On-change of items, insert into locks table.

Dynamic Action : On-Change
   Selector : JQuery Selector
             [name=f05]
Execute Javascript Code,
   /* Getting the Program Name Details*/

var c=($(this.triggeringElement ).attr('name').substr(0,3));
var d=this.triggeringElement.id;
//alert(d);
 var str = d.substring(4,8);
if(c=="f05")
{
// Assigning PDVD Type

var p_pdvd_type="Master";
//alert(p_pdvd_type);

//getting column header value

idheader ="#f05_0001_LABEL" ;
var p_field_name = $(idheader).closest("label").html();   
//alert(p_field_name);

//getting Master PDVD ID

var p_pdvd_id=$('#P77_MASTER_PDVD_ID').val();
//alert(p_pdvd_id);


//getting Item ID

var p_item_id=$(this.triggeringElement ).attr('id');
//alert(p_item_id);

//getting Item value

var p_item_val=$x(p_item_id).value;
//alert(p_item_val);

var p_item_val1    = $x("f04_"+str).value;
var p_mas_item_id  = $x("f03_"+str).value;
//alert(p_item_val1);

//p_item_val1  =$x("f03_"+new1).value;
//alert(p_item_val1);
//p_item_val2  =j_item_id;
apex.server.process ( 
  "AP_FIELD_LOCKS"
,   {   x01: p_pdvd_id
    ,   x02: p_pdvd_type
    ,   x03: p_field_name
    ,   x04: p_item_id
    ,   x05: p_item_val
    ,  x06:  p_item_val1
    ,  x07:  p_mas_item_id
    }
 , { dataType: 'text'
 ,success: function(pData){
//alert(pData)
}
}
);
};

Application Process: 
DECLARE
   lv_n_user_id   NUMBER;
BEGIN
   IF apex_application.g_x06 IS NOT NULL
   THEN
      lv_n_user_id := pdvd_pk_get_values.pdvd_fn_get_user_id (:app_user);

/*
      DELETE FROM pdvd_tb_mstr_user_restriction
            WHERE session_id = :app_session;
            */
      INSERT INTO pdvd_tb_field_locks
                  (lock_id, app_id, page_no,
                   session_id, pdvd_id,
                   pdvd_type, field_name,
                   item_id, item_value,PDVD_ITEM_ID,item_identifier,
                   created_by, created_date
                  )
           VALUES (pdvd_sq_field_locks.NEXTVAL, :app_id, :app_page_id,
                   :app_session, apex_application.g_x01,
                   apex_application.g_x02, apex_application.g_x03,
                   apex_application.g_x04, apex_application.g_x05,
                   apex_application.g_x07,apex_application.g_x06,
                   lv_n_user_id, SYSDATE
                  );
   END IF;
END;

Step:2:
On-page load check for locked items in field locks table and  locked field items been represented in different color using below javascript,

var example = $("#P77_RESTRICT_FIELD_NAME").val();
var session_id =$("#P77_SESSION").val();
var cur_session=$("#P77_CURRENT_SESSION").val();
var user_name =$("#P77_USER_NAME").val();
var session_spl =session_id.split(',');
var numbers = example.split(',');
var user_spl =user_name.split(',');
var my_condition = true;
var session_check="";
var user_check="";
var master_item_row ="";
for (var i = 0; i < numbers.length; i++) {
if  (typeof session_spl[i]  !== 'undefined')
{
session_spl[i] = session_spl[i].replace(/^\s*/, "").replace(/\s*$/, "");
if (typeof user_spl[i] !== 'undefined')
{    
user_spl[i] =  user_spl[i].replace(/^\s*/, "").replace(/\s*$/, "");
session_check=session_spl[i];
user_name = user_spl[i]; 

/*Checking for Session value that is not user's current session*/
   if (session_check !=cur_session)
{   
    var ind = numbers[i].indexOf(":");
    var len = numbers[i].length;
    var id = numbers[i].substring(0,ind);
if ( id.length !=0)
{
/*Getting Master Item ID*/ 
    var id1 =id.trim();
    var item_id = numbers[i].substring(ind+1,len);   
    var item_id1=item_id.trim();
//alert(item_id1);
    
/*Getting the Row Value Using the Master Item ID */
    for (K=0;K<=10;K++)
    {
     b = "000" + K;
    b = pad(K, 4);
    var item_check = $("#f03_"+b).val();
    if (item_check == item_id1)
    {
    master_item_row = b;       
numbers[i] = numbers[i].replace(/^\s*/, "").replace(/\s*$/, "");
var ind1 = numbers[i].indexOf(":");
/*Getting the Field Value from the field lock  table for the Master Item ID */
var id2 = numbers[i].substring(0,ind1);

/*Getting the Field Value first four Characters like  "f05_"*/
var ind_col_id =id2.substring(0,4);

/*Concatenate both field id and Master item id row*/  
   var id3 = ind_col_id+master_item_row;

/*Making a fields as read only*/ 
    $("#" + id3).prop("readonly", true);
    $("#" + id3).prop("onclick", false);
    $("#" + id3).css("color", "red");
    $("#" + id3).on('mousedown focus',function(e) {
        if (my_condition) {
            e.preventDefault();
/*Application Process for getting the User Name who Locked the fields*/
          var get = new htmldb_Get(null, $x('pFlowId').value,
    'APPLICATION_PROCESS=AP_USER_NAME', 0);
get.add('AI_USER_ID', user_name);
gReturn = get.get();
var ret = gReturn;
user_check=ret.trim();
          $("#alert").html("<font size=2>   This field has been locked by  " +user_check+"</font>");
           $("#alert").dialog({
                modal: true,
                resizable: false,
                minHeight: 105,
                width: 420,
                dialogClass: 'testclass'
            });  
}
    });
break;
    }  
    }    
    }
}
}
}
}

Application Process:
DECLARE
   lv_v_user_name   VARCHAR2 (50);
BEGIN
   SELECT initcap(first_name)||' '|| initcap(last_name) 
     INTO lv_v_user_name
     FROM pdvd_tb_user_defn
    WHERE user_id = :AI_USER_ID;

   IF lv_v_user_name IS NOT NULL
   THEN
      HTP.p (lv_v_user_name);
   END IF;
END;


Step:3: On-focus of locked items, alert been displayed with locked-user using following javascript,

var a = event.target.id;
if (a!==undefined)
{
var b=a.substring(0, 3);
//alert('b:'+b);
var c=a.replace(b,"f03");
//alert('c:'+c); 
var d=$("#"+c).val();
//alert('d: '+d);
var e=$("#"+a).val();
//alert('e:'+e);
var get = new htmldb_Get(null, $x('pFlowId').value,
    'APPLICATION_PROCESS=AP_FOCUS_CHECK', 0);
get.add('AI_MASTER_ITEM_ID', d);
get.add('AI_FIELD_ID', b);
gReturn = get.get();
var ret = gReturn.trim();
//alert ('ret:'+ ret);
if (ret != 'Not_Exists')
{
//alert('Can be locked');
         $("#"+a).prop("readonly", true);
         $("#"+a).prop("onclick", false);
         $("#"+a).css("color", "red");
         $("#"+a).on('click', function(e) {return false;});
 $("#" + a).on('mousedown focus',function(e) {
            e.preventDefault();
 $("#alert").html("<font size=2>   This field has been locked by  </font> "+ret);
           $("#alert").dialog({
                modal: true,
                resizable: false,
                minHeight: 105,
                width: 420,
                dialogClass: 'testclass'
            });  
    });
}
}

Application Process:

DECLARE
   lv_n_lock_id      NUMBER;
   lv_n_created_by   NUMBER;
   lv_v_result       VARCHAR2 (100);
BEGIN
   BEGIN
      SELECT lock_id, created_by
        INTO lv_n_lock_id, lv_n_created_by
        FROM pdvd_tb_field_locks
       WHERE UPPER (pdvd_type) = 'MASTER'
         AND pdvd_item_id = :ai_master_item_id
         AND SUBSTR (item_id, 1, INSTR (item_id, '_') - 1) = :ai_field_id
         AND session_id != :ai_app_session;
   EXCEPTION
      WHEN NO_DATA_FOUND
      THEN
         lv_n_lock_id := 0;
         lv_n_created_by := 0;
      WHEN TOO_MANY_ROWS
      THEN
         BEGIN
            SELECT DISTINCT created_by
                       INTO lv_n_created_by
                       FROM pdvd_tb_field_locks
                      WHERE UPPER (pdvd_type) = 'MASTER'
                        AND pdvd_item_id = :ai_master_item_id
                        AND SUBSTR (item_id, 1, INSTR (item_id, '_') - 1) =
                                                                  :ai_field_id
                        AND session_id != :ai_app_session;
         EXCEPTION
            WHEN OTHERS
            THEN
               lv_n_created_by := NULL;
         END;
   END;

   IF lv_n_lock_id <> 0
   THEN
      /*SELECT pdvd_pk_get_values.pdvd_fn_get_user_name (lv_n_created_by)
        INTO lv_v_result
        FROM DUAL;*/
      SELECT INITCAP (first_name) || ' ' || INITCAP (last_name)
        INTO lv_v_result
        FROM pdvd_tb_user_defn
       WHERE user_id = lv_n_created_by;

      HTP.p (lv_v_result);
   ELSE
      HTP.p ('Not_Exists');
   END IF;
END;

Field Locks - Link level
On-hover of link, field locks table been checked and alert been displayed of locked user.

Wednesday, 22 June 2016

Third Party Process - Colombia

This page explains the steps involved in generating the Colombia Third party report balances.

This process ensures the passage of the third party details to GL. This is mandatory in reporting the third party details to the Colombian government and to comply with the regulations of the Commercial Code, Decree 2649 of 1993 and No.5 Orientation Professional Technical Council of Public Accounting for submitting tax information.

The report should be generated by the system recorded books so as to provide a clear, complete and reliable business history trader, subject to regulations issued by the Colombian government.

Colombia GL à CLL F041: Generate Magnetic Media SLA à
1.       Third Party Maintenance Balances
2.       Third Party Report Attributes
3.       Third Party Report Balances


Electronic File Transfer in AR – Brazil – Technical Information

Companies in Brazil use bank services to collect customers. The Brazilian Electronic File Transfer for Receivables (CLL F034) provides the functionality to electronically transfer collection documents to banks using files in the standard CNAB format. The CLL F034 features allows companies to meet Brazilian Bank Transfer requirements by providing customers with the most important bank file formats in Brazil, as each bank has its own format.
Tables:
Setup Tables:
JL_BR_AR_BANK_INSTRUCTIONS à Bank Instruction table
JL_BR_AR_BANK_OCCURENCES à Bank Occurrences table
JL_BR_AR_REC_MET_ACCTS_ExT_ALL à Receipt Method Accounts table

Transaction Tables:
JL_BR_AR_SELECT_CONTROLS_ALL à Bank Transfer Remittance Batches selection criteria table
JL_BR_AR_SELECT_ACCOUNTS_ALL à Bank Account Distributions selection criteria table
JL_BR_AR_BORDEROS_ALL à Header for Remittance and Occurrence batches
JL_BR_AR_REMIT_BORDEROS_ALL à Bordero remittance additional information
JL_BR_AR_COLLECTION_DOCS_ALL à Collection documents associated to remittance borderos
JL_BR_AR_OCCURRENCE_DOCS_ALL à All occurrences related to the collection documents
JL_BR_AR_RET_INTERFACE_ALL à Interface table for Bank returns
JL_BR_AR_RET_INTERFACE_EXT_ALL à Interface table with rejected lines

JL_BR_AR_BANK_RETURNS_ALL à Temporary table to store bank returned occurrences.