Thursday, May 10, 2018

Find File Header Version in Unix

My requirement was to update File Header for one of the SR with Oracle, Generally DBA's take care of this activity , but during odd hours one can also find out the File header version with "adident" Command.

Example:

SR Asked to update the file version for the file named "appvndrb.pls" from AP_TOP

Login into Putty

Go to path where file is kept in Server

cd $AP_TOP/patch115/sql


Execute below Command

$ adident Header appvndrb.pls  (file name)


It Should give you the file header version.


Tuesday, May 08, 2018

Sed Command in Linux/Unix with examples


SED command in UNIX is stands for stream editor and it can perform lot’s of function on file like, searching, find and replace, insertion or deletion.
Though most common use of SED command in UNIX is for substitution or for find and replace.

1.Replacing or substituting string : Sed command is mostly used to replace the text in a file. The below simple sed command replaces the word "shobhit" with “sharma” in the file.

$sed 's/shobhit/sharma/' Demofile.txt

Here the “s” specifies the substitution operation. The “/” are delimiters.

By default, the sed command replaces the first occurrence of the pattern in each line and it won’t replace the second, third…occurrence in the line by this command.


2.Replacing the nth occurrence of a pattern in a line : Use the /1, /2 etc flags to replace the first, second occurrence of a pattern in a line. The below command replaces the second occurrence of the word "shobhit" with "sharma” in each line of the file.

$sed 's/shobhit/sharma/2' Demofile.txt

3.Replacing all the occurrence of the pattern in a line : The substitute flag /g (global replacement) specifies the sed command to replace all the occurrences of the string in the line.

$sed 's/shobhit/sharma/g' Demofile.txt


4.Replacing string on a range of lines : You can specify a range of line numbers to the sed command for replacing a string.

$sed '1,3 s/shobhit/sharma/' Demofile.txt

Here the sed command replaces the lines with range from 1 to 3. Another example is

       $sed '2,$ s/shobhit/sharma/' Demofile.txt

Here $ indicates the last line in the file. So the sed command replaces the text from second line to last line in the file.


5.Deleting lines from a particular file : SED command can also be used for deleting lines from a particular file. SED command is used for performing deletion operation without even opening the file


 Examples:

1. To Delete a particular line say n in this example

$ sed 'nd' Demofile.txt
Example:
$ sed '5d' Demofile.txt


2. To Delete a last line
$ sed '$d' Demofile.txt


3. To Delete line from range x to y

$ sed 'x,yd' Demofile.txt
Example:
$ sed '3,6d' Demofile.txt

5. To Delete from nth to last line

$ sed 'nth,$d' Demofile.txt
Example:
$ sed '12,$d' Demofile.txt


6. To Delete pattern matching line

$ sed '/pattern/d' Demofile.txt
Example:
$ sed '/abc/d' Demofile.txt

Monday, May 07, 2018

grep command in Unix

grep (globally search for regular expression and print out) command in Unix/Linux

The grep filter searches a file for a particular pattern of characters, and displays all lines that contain that pattern.

grep [options] pattern [files]

Options Description
-c : This prints only a count of the lines that match a pattern
-h : Display the matched lines, but do not display the filenames.
-i : Ignores, case for matching
-l : Displays list of a filenames only.
-n : Display the matched lines and their line numbers.
-v : This prints out all the lines that do not matches the pattern
-e exp : Specifies expression with this option. Can use multiple times.
-f file : Takes patterns from file, one per line.
-E : Treats pattern as an extended regular expression (ERE)
-w : Match whole word
-o : Print only the matched parts of a matching line,
 with each such part on a separate output line.



 1. Case insensitive search : The -i option enables to search for a string case insensitively in the give file.   It Can matches the words like “SHOBHIT”, “Shobhit”, “shobhit”, "ShoBhit"
 
$grep -i "ShoBhit" Demofile.txt

2. Displaying the count of number of matches : We can find the number of lines that matches the given string/pattern

$grep -c "Shobhit" Demofile.txt

3. Display the file names that matches the pattern : We can just display the files that contains the given string/pattern.

$grep -l "Shobhit" *

or
 
$grep -l "Shobhit" Demofile1.txt Demofile2.txt Demofile3.txt 

4. Checking for the whole words in a file : By default, grep matches the given string/pattern even if it found as a substring in a file.The -w option to grep makes it match only the whole words.

$ grep -w "Shobhit" Demofile.txt

5. Show line number while displaying the output using grep -n : To show the line number of file with the line matched.

$ grep -n "Shobhit" Demofile.txt

6. Inverting (Exlude) the pattern match : You can display the lines that are not matched with the specified search sting pattern using the -v option.

$ grep -v "Shobhit" Demofile.txt

7. Matching the lines that start with a string : The ^ regular expression pattern specifies the start of a line. This can be used in grep to match the lines which start with the given string or pattern.

$ grep "^Shobhit" Demofile.txt

8.Matching the lines that end with a string : The $ regular expression pattern specifies the end of a line.This can be used in grep to match the lines which end with the given string or pattern.
 
$ grep "hit$" Demofile.txt

9.Specifies expression with -e option. Can use multiple times :

$grep –e "Shobhit" –e "Sobhit" –e "Shobit" Demofile.txt

Thursday, February 01, 2018

Initial Setup in JDeveloper for OAF Development

Initial Setup in JDeveloper for OAF Development


If you want to do some OAF Development in JDeveloper for the first time, you will need to do the following things.
1] Download JDeveloper Patch
Based on your instance release level, check out the version of JDeveloper to use using below link.
You can identify the OA Framework version in your instance by activating diagnostics and click the “About This Page” from any OAF page. Click the “Technology Components” tab. The OA Framework version in the top row of the table can then be matched to the JDeveloper Patch.
Download the JDeveloper Patch.
2] Extract the JDeveloper patch in a directory say D:\DevSuiteHome_1\jdev
The patch actually contains below three directories
  • jdevbin – Includes an extended version of the Oracle JDeveloper 10g executable and OA Framework class libraries.
  • jdevhome – Includes the OA Framework Toolbox Tutorial source and developer working area.
  • jdevdoc – Contains documentation.
3] Define an environment variable
Define an environment variable JDEV_USER_HOME for your local machine. This has to be set to jdevhome\jdev directory. In above example it has to be D:\DevSuiteHome_1\jdev\jdevhome\jdev.
My Computer – Properties – Advanced tab – Environment Variables – New
Variable: JDEV_USER_HOME
Value: D:\DevSuiteHome_1\jdev\jdevhome\jdev
4] Extract Tutorial.zip
Extract D:\DevSuiteHome_1\jdev \jdevbin\Tutorial.zip into D:\DevSuiteHome_1\jdev \jdevhome.
It will create following directories
D:\DevSuiteHome_1\jdev \jdevhome\jdev\myhtml
D:\DevSuiteHome_1\jdev \jdevhome\jdev\myprojects
5] Get the DBC file
Obtain the FND database connection (.dbc) file from the system administrator who installed the OA Framework database where you want to do your development.
For the instance to use, you can get the .dbc file from $FND_SECURE and put it in <JDEV_USER_HOME>\dbc_files\secure i.e. D:\DevSuiteHome_1\jdev\jdevhome\jdev \dbc_files\secure
6] Creating a Desktop Shortcut to JDeveloper
To facilitate launching JDeveloper, create a desktop shortcut to jdevbin\jdev\bin\jdevw.exe.
7] Configuring the Environment Encoding of JDeveloper
Confirm the environment encoding of your JDeveloper if it is appropriately set.
Go to Tools – Preferences – Environment – Encoding
If Encoding is not set to “UTF-8”, set it to “UTF-8”.
The initial setup is now complete!….Now you are ready to develop your first OAF page. For more information you can refer OAF Developer’s Guide

Thursday, December 14, 2017

Create ASN in 'EXPECTED' or 'FULLY_RECEIVED' Status.

Create ASN in 'EXPECTED' or 'FULLY_RECEIVED' Status.

We can create an ASN in Oracle apps in either 'EXPECTED' or 'FULLY RECEIVED' Status.

This can be achieved or bifurcated using 'AUTO_TRANSACT_CODE' Column.

A)- In case of ASN to be created in 'EXPECTED' Status then

Insert in RHI and RTI with below values.

AUTO_TRANSACT_CODE  = 'SHIP'


INTO rcv_headers_interface (header_interface_id,
                                                GROUP_ID,
                                                processing_status_code,
                                                receipt_source_code,
                                                transaction_type,
                                                last_update_date,
                                                last_updated_by,
                                                creation_date,
                                                created_by,
                                                shipped_date,
                                                vendor_id,
                                                employee_id,
                                                validation_flag,
                                                ship_to_organization_code,
                                                expected_receipt_date,
                                                shipment_num,
                                                asn_type,
                                                auto_transact_code)
                  VALUES (v_header_interface_id,
                          v_group_id,
                          'PENDING',
                          'VENDOR',
                          'NEW',
                          gd_date,
                          gn_user_id,
                          gd_date,
                          gn_user_id,
                          gd_date,
                          v_vendor_id,
                          v_agent_id,
                          'Y',
                          v_organization_code,
                          gd_date,
                          'REFERENCE_VALUE'--- user specified value
                          'ASN',
                          'SHIP');

--------------------------------------------------------------------------------

INSERT
                       INTO rcv_transactions_interface (
                               interface_transaction_id,
                               header_interface_id,
                               GROUP_ID,
                               last_update_date,
                               last_updated_by,
                               creation_date,
                               created_by,
                               transaction_type,
                               transaction_date,
                               processing_status_code,
                               processing_mode_code,
                               transaction_status_code,
                               quantity,
                               unit_of_measure,
                               auto_transact_code,
                               receipt_source_code,
                               source_document_code,
                               po_header_id,
                               po_line_id,
                               po_line_location_id,
                               ship_to_location_id,
                               validation_flag,
                               to_organization_code,
                               item_num)
                     VALUES (v_interface_transaction_id,
                             v_header_interface_id,
                             v_group_id,
                             SYSDATE,
                             fnd_global.user_id,
                             SYSDATE,
                             fnd_global.user_id,
                             'SHIP',
                             SYSDATE,
                             'PENDING',
                             'BATCH',
                             'PENDING',
                             a_detail.shipped_quantity,
                             v_unit_of_measure,
                             'SHIP',
                             'VENDOR',
                             'PO',
                             a_detail.PO_HEADER_ID,
                             a_detail.PO_LINE_ID,
                             v_line_location_id,
                             v_ship_to_location_id,
                             'Y',
                             v_org_code,
                             v_item_num);
----------------------------------------------------------------------------------

                     INSERT
                       INTO mtl_transaction_lots_interface (
                               transaction_interface_id,
                               last_update_date,
                               last_updated_by,
                               creation_date,
                               created_by,
                               lot_number,
                               lot_expiration_date,
                               transaction_quantity,
                               primary_quantity,
                               product_code,
                               product_transaction_id)
                     VALUES (mtl_material_transactions_s.NEXTVAL,
                             SYSDATE,
                             fnd_global.user_id,
                             SYSDATE,
                             fnd_global.user_id,
                             v_lot_number,
                             v_exp_date,
                             a_detail.shipped_quantity,
                             v_primary_quantity,
                             'RCV',
                             v_interface_transaction_id);


----- *******************************************************************------

B)- In case of ASN to be created in 'FULLY_RECEIVED' Status then 

Insert in RHI and RTI with below values.

AUTO_TRANSACT_CODE  = 'RECEIVE'


INTO rcv_headers_interface (header_interface_id,
                                                GROUP_ID,
                                                processing_status_code,
                                                receipt_source_code,
                                                transaction_type,
                                                last_update_date,
                                                last_updated_by,
                                                creation_date,
                                                created_by,
                                                shipped_date,
                                                vendor_id,
                                                employee_id,
                                                validation_flag,
                                                ship_to_organization_code,
                                                expected_receipt_date,
                                                shipment_num,
                                                asn_type,
                                                auto_transact_code)
                  VALUES (v_header_interface_id,
                          v_group_id,
                          'PENDING',
                          'VENDOR',
                          'NEW',
                          gd_date,
                          gn_user_id,
                          gd_date,
                          gn_user_id,
                          gd_date,
                          v_vendor_id,
                          v_agent_id,
                          'Y',
                          v_organization_code,
                          gd_date,
                          'REFERENCE_VALUE'--- user specified value
                          'ASN',
                          'RECEIVE');

--------------------------------------------------------------------------------

INSERT
                       INTO rcv_transactions_interface (
                               interface_transaction_id,
                               header_interface_id,
                               GROUP_ID,
                               last_update_date,
                               last_updated_by,
                               creation_date,
                               created_by,
                               transaction_type,
                               transaction_date,
                               processing_status_code,
                               processing_mode_code,
                               transaction_status_code,
                               quantity,
                               unit_of_measure,
                               auto_transact_code,
                               receipt_source_code,
                               source_document_code,
                               po_header_id,
                               po_line_id,
                               po_line_location_id,
                               ship_to_location_id,
                               validation_flag,
                               to_organization_code,
                               item_num)
                     VALUES (v_interface_transaction_id,
                             v_header_interface_id,
                             v_group_id,
                             SYSDATE,
                             fnd_global.user_id,
                             SYSDATE,
                             fnd_global.user_id,
                             'RECEIVE',
                             SYSDATE,
                             'PENDING',
                             'BATCH',
                             'PENDING',
                             a_detail.shipped_quantity,
                             v_unit_of_measure,
                             'RECEIVE',
                             'VENDOR',
                             'PO',
                             a_detail.PO_HEADER_ID,
                             a_detail.PO_LINE_ID,
                             v_line_location_id,
                             v_ship_to_location_id,
                             'Y',
                             v_org_code,
                             v_item_num);
----------------------------------------------------------------------------------

                     INSERT
                       INTO mtl_transaction_lots_interface (
                               transaction_interface_id,
                               last_update_date,
                               last_updated_by,
                               creation_date,
                               created_by,
                               lot_number,
                               lot_expiration_date,
                               transaction_quantity,
                               primary_quantity,
                               product_code,
                               product_transaction_id)
                     VALUES (mtl_material_transactions_s.NEXTVAL,
                             SYSDATE,
                             fnd_global.user_id,
                             SYSDATE,
                             fnd_global.user_id,
                             v_lot_number,
                             v_exp_date,
                             a_detail.shipped_quantity,
                             v_primary_quantity,
                             'RCV',
                             v_interface_transaction_id);



C)- Then Call receiving Transaction processor

  fnd_request.submit_request (application   => 'PO',
                                                 program       => 'RVCTP',
                                                 start_time    => SYSDATE,
                                                 description   => NULL,
                                                 sub_request   => FALSE,
                                                 argument1     => 'BATCH',
                                                 argument2     => v_group_id);

Friday, December 08, 2017

Add Sec/Min/Hour Functionality in oracle


Interval Function can be use to achieve the functionality to add or subtract Sec/Min/our intervals in Date.


SELECT SYSDATE,
       SYSDATE + (1 / (24 * 60 * 60)) "1Sec Addition",
       sysdate + interval '1' second "1SecAddition Intervalfunc",
       SYSDATE + (1 / (24 * 60)) "1Min Addition",
       sysdate + interval '1' minute "1MinAddition Intervalfunc",
       SYSDATE + (1 / 24) "1HR Addition",
       sysdate + interval '1' hour "1hourAddition Intervalfunc"
  FROM DUAL

Generating a Random Number by Using DBMS_RANDOM Function

Generating a Random Number by Using DBMS_RANDOM Function


select dbms_random.value , --- Positive Number between (0,1)
      dbms_random.value (n,m), --- Positive decimal Number between (n,m), where n,m are Numbers
      trunc(dbms_random.value (n,m)), --- returns only Integer value between (n,m)
      dbms_random.string ('A',n),  -- alpha characters only (mixed case both upper and lower)
      dbms_random.string ('p',n),  -- any printable char (ASCII subset) including Special characters
      dbms_random.string ('U',n), --upper case alpha characters only and with range of n
      dbms_random.string ('L',n), --Lower case alpha characters only and with range of n
      dbms_random.string ('X',n),  -- any alpha-numeric characters (upper case only)
      sysdate + trunc(dbms_random.value (1,n)) ------- Random dates 
from dual
connect by level <=m  --- m rows


Clear BNE Cache for WebADI Changes

It Sometime happens that WebAdi Changes doesn't reflect once migrated in controlled instances. Here are the quick steps(Generally perfor...