Tuesday, 7 February 2017

MWA/MSCA: How to enable DFF on Reciept Information Page in WMS Mobile

In one of my project, the client wanted to enable the DFF (descriptive flexfield) on Receipt Info Page (last page during the Receiving Transaction). In WMS Mobile (MWA Framework) we could enable the DFF for LPN uisng MWA Personalization Architecture. 

But the Receipt Information Page don't have a DFF field to personalize.
Navigation :
WMA Server Manager --> WMA Server Manager --> MWA Personalization Framework.


Solution:
We can enable the RCV_SHIPMENT_HEADERS DFF on the Receipt Information page by following the below steps.

Steps:
1. Define the DFF Segments for the DFF 'RCV_SHIPMENT_HEADERS'
2. Modify the Form Function (eg: INV_MOB_PO_RCPT [Mobile PO Receive]) and add ' SHOW_HEADER_DFF=YES' at the end of the Parameter. 

Now you can see the DFF field in the Receipt Information Page (last page on PO Receive transaction)





Feel free to point out if anything is missing/wrong in this blog.

Wednesday, 1 February 2017

Oracle Apps: Setting NULL value for DFF segment on FND_LOOKUP

This blog is about setting NULL value for DFF segment on FND_LOOKUP from lookup form or using API.

Assume we have a DFF enabled on FND Lookup and the segment already have a value. Now we need to clear the value of that segment. What we normally do is open the Lookup and open the DFF values and delete the value from the Form for that segment and save the record. This will not clear the value, if you open the lookup again, you can still see the old value.

The reason for this is because, the underlying API uses a decode statement in the update procedure, which overides the NULL value with old value.

code snippet from package spec FND_LOOKUP_VALUES_PKG
 null_char varchar2(8) := '*NULL*';  

code snippet from package body FND_LOOKUP_VALUES_PKG
 l_null varchar2(20) := fnd_lookup_values_pkg.null_char;  
 update FND_LOOKUP_VALUES A  
   set  
   A.TAG = X_TAG,  
   A.ATTRIBUTE_CATEGORY = X_ATTRIBUTE_CATEGORY,  
   A.ATTRIBUTE1 = decode(x_attribute1,l_null,null, null,A.attribute1, x_attribute1) ,  
   A.ATTRIBUTE2 = decode(x_attribute2,l_null,null, null,A.attribute2, x_attribute2) ,  
   A.ATTRIBUTE3 = decode(x_attribute3,l_null,null, null,A.attribute3, x_attribute3) ,  
   A.ATTRIBUTE4 = decode(x_attribute4,l_null,null, null,A.attribute4, x_attribute4) ,  
   A.ATTRIBUTE5 = decode(x_attribute5,l_null,null, null,A.attribute5, x_attribute5) ,  
   A.ATTRIBUTE6 = decode(x_attribute6,l_null,null, null,A.attribute6, x_attribute6) ,  
   A.ATTRIBUTE7 = decode(x_attribute7,l_null,null, null,A.attribute7, x_attribute7) ,  
   A.ATTRIBUTE8 = decode(x_attribute8,l_null,null, null,A.attribute8, x_attribute8) ,  
   A.ATTRIBUTE9 = decode(x_attribute9,l_null,null, null,A.attribute9, x_attribute9) ,  
   A.ATTRIBUTE10 = decode(x_attribute10,l_null,null, null,A.attribute10, x_attribute10) ,  
   A.ATTRIBUTE11 = decode(x_attribute11,l_null,null, null,A.attribute11, x_attribute11) ,  
   A.ATTRIBUTE12 = decode(x_attribute12,l_null,null, null,A.attribute12, x_attribute12) ,  
   A.ATTRIBUTE13 = decode(x_attribute13,l_null,null, null,A.attribute13, x_attribute13) ,  
   A.ATTRIBUTE14 = decode(x_attribute14,l_null,null, null,A.attribute14, x_attribute14) ,  
   A.ATTRIBUTE15 = decode(x_attribute15,l_null,null, null,A.attribute15, x_attribute15) ,  
   A.ENABLED_FLAG = X_ENABLED_FLAG,  
   A.START_DATE_ACTIVE = X_START_DATE_ACTIVE,  
   A.END_DATE_ACTIVE = X_END_DATE_ACTIVE,  
   A.TERRITORY_CODE = X_TERRITORY_CODE,  
   A.LAST_UPDATE_DATE = X_LAST_UPDATE_DATE,  
   A.LAST_UPDATED_BY = X_LAST_UPDATED_BY,  
   A.LAST_UPDATE_LOGIN = X_LAST_UPDATE_LOGIN  
  where A.LOOKUP_TYPE = X_LOOKUP_TYPE  
  and A.SECURITY_GROUP_ID = sgid  
  and A.VIEW_APPLICATION_ID = X_VIEW_APPLICATION_ID  
  and A.LOOKUP_CODE = X_LOOKUP_CODE;  

Explanation:
A.ATTRIBUTE1 = decode(x_attribute1,l_null,null, null,A.attribute1, x_attribute1)

If the new value is *NULL*, then set the value to null
If the new value is null, then set the value to old value
Else set the new value

Solution :
So to clear the DFF segment value on FND Lookup from the form, use the string *NULL*, instead of deleting the value.




Feel free to point out if anything is missing/wrong in this blog.

Thursday, 8 December 2016

Oracle Apps: Reset FND User password from backend

Sample code to reset FND_USER password from backend
 declare   
      v_user_name varchar2(30)  := upper('AJ_TEST');   
      v_password  varchar2(30)  := 'johnytips'; -- new password  
      v_status    boolean;   
 begin   
      v_status := fnd_user_pkg.changepassword (   
                                    username    => v_user_name   
                                   ,newpassword => v_password );   
      if v_status = true then   
           dbms_output.put_line ('Password for '||v_user_name || ' got changed successfully !!!'); 
           commit;  
      else   
           dbms_output.put_line ('Unable to reset password  for '|| v_user_name ||' : '||SUBSTR(SQLERRM, 1, 1000));   
      end if;  
 end;  

Related blog: Oracle Apps: Create User and Add Responsibility from backend


Feel free to point out if anything is missing/wrong in this blog.

Saturday, 3 December 2016

PL/SQL: Extract XML Data using SQL

Few examples to extract xml data in a SQL query.

#1. Extract Master Child xml using xmltable
XMLTABLE
 select header_row.department_id
       ,header_row.department_name  
       ,child_row.employee_id  
       ,child_row.first_name
       ,child_row.last_name  
 from XMLTABLE(
               XMLNAMESPACES(default 'http://johnytips.blogspot.com.au/ns/department')  
              ,'/department'  
          PASSING xmltype(  
              '<department xmlns="http://johnytips.blogspot.com.au/ns/department" id="1">  
                    <department_name>Research</department_name>  
                    <employees>  
                         <employee id="1">  
                              <first_name>ANOOP</first_name>  
                              <last_name>JOHNY</last_name>  
                         </employee>  
                         <employee id="2">  
                              <first_name>ANISH</first_name>  
                              <last_name>JOHNY</last_name>  
                         </employee>  
                    </employees>  
               </department>')  
          COLUMNS   
               department_id   VARCHAR2(30) PATH '@id',  
               department_name VARCHAR2(10) PATH 'department_name',  
               child_rows XMLTYPE PATH 'employees'  
              ) header_row  
     ,XMLTABLE(
               XMLNAMESPACES(default 'http://johnytips.blogspot.com.au/ns/department')  
              ,'/employees/employee'  
          PASSING header_row.child_rows  
          COLUMNS  
               employee_id NUMBER PATH '@id',   
               first_name  VARCHAR2(30) PATH 'first_name',  
               last_name   VARCHAR2(30) PATH 'last_name'
              ) child_row;  

#2. EXTRACTVALUE
 with t as  
  (select   
          xmltype('<employee>  
                        <employee_id>1</employee_id>  
                        <first_name>ANOOP</first_name>  
                        <last_name>JOHNY</last_name>  
                   </employee>') str   
   from dual)  
 select extractvalue(str,'/employee/employee_id') EMPLOYEE_ID  
       ,extractvalue(str,'/employee/first_name')  FIRST_NAME  
       ,extractvalue(str,'/employee/last_name')   LAST_NAME  
 from t;  
#3.EXTRACT
 with t as  
  (select   
          xmltype('<employee>  
                        <employee_id>1</employee_id>  
                        <first_name>ANOOP</first_name>  
                        <last_name>JOHNY</last_name>  
                   </employee>') str   
   from dual)  
 select extract(str,'/employee/employee_id/text()') EMPLOYEE_ID  
       ,extract(str,'/employee/first_name/text()')  FIRST_NAME  
       ,extract(str,'/employee/last_name/text()')   LAST_NAME  
 from t;  

#4. To extract with the xml tag
 with t as  
  (select   
          xmltype('<employee>  
                        <employee_id>1</employee_id>  
                        <first_name>ANOOP</first_name>  
                        <last_name>JOHNY</last_name>  
                   </employee>') str   
   from dual)  
 select extract(str,'/employee/employee_id') EMPLOYEE_ID  
       ,extract(str,'/employee/first_name')  FIRST_NAME  
       ,extract(str,'/employee/last_name')   LAST_NAME  
 from t;  

#5. Prior to Oracle Database 10g Release 2 using xmlsequence
XMLSEQUENCE
 select extractvalue(column_value, '/employee/first_name') "FIRST_NAME"  
       ,extractvalue(column_value, '/employee/last_name')  "LAST_NAME"  
 from table(xmlsequence(xmltype('<employees>  
                                      <employee>  
                                           <employee_id>1</employee_id>  
                                           <first_name>ANOOP</first_name>  
                                           <last_name>JOHNY</last_name>  
                                      </employee>  
                                      <employee>   
                                           <employee_id>2</employee_id>  
                                           <first_name>ANISH</first_name>  
                                           <last_name>JOHNY</last_name>  
                                      </employee>  
                                 </employees>').extract('/employees/employee')));  


Feel free to point out if anything is missing/wrong in this blog

Friday, 25 November 2016

OAF: java.lang.NoClassDefFoundError: Could not initialize class oracle.apps.fnd.common.WebAppsContext

Error while trying to run a custom OA Page from Jdeveloper:
 500 Internal Server Error  
 java.lang.NoClassDefFoundError: Could not initialize class oracle.apps.fnd.common.WebAppsContext  
      at oracle.apps.fnd.framework.server.OAUtility.getWebAppsContext(Unknown Source)  
      at oracle.apps.fnd.framework.webui.OAServerDelegate.getWebAppsContext(Unknown Source)  
      at oracle.apps.fnd.framework.webui.OAJSPHelper.handleErrorStackDisplay(Unknown Source)  
      at _OAErrorPage._jspService(_OAErrorPage.java:135)  
      [/OAErrorPage.jsp]  
      at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.5.0) ].http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)  
      at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:473)  
      at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)  
      at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)  
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)  
      at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:734)  
      at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:391)  
      at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ServletRequestDispatcher.unprivileged_forward(ServletRequestDispatcher.java:280)  
      at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ServletRequestDispatcher.access$100(ServletRequestDispatcher.java:68)  
      at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ServletRequestDispatcher$2.oc4jRun(ServletRequestDispatcher.java:214)  
      at oracle.oc4j.security.OC4JSecurity.doPrivileged(OC4JSecurity.java:284)  
      at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:219)  
      at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.EvermindPageContext.handlePageThrowable(EvermindPageContext.java:871)  
      at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.EvermindPageContext.handlePageException(EvermindPageContext.java:816)  
      at _runregion._jspService(_runregion.java:193)  
      [/runregion.jsp]  
      at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.5.0) ].http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)  
      at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:473)  
      at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)  
      at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)  
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)  
      at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:734)  
      at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:391)  
      at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:908)  
      at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:458)  
      at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:226)  
      at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:127)  
      at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:116)  
      at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)  
      at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:234)  
      at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:29)  
      at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:879)  
      at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:298)  
      at java.lang.Thread.run(Thread.java:662)  


In my case :

Problem : The dbc file was old and not updated.  

Solution : Get the latest dbc file from the server and copy it to your local folder and refer that in the Project properties. [Also verify the JDBC string in the DBC file and compare the database connection in Jdeveloper Database Connections window]

To get the location of dbc file in the server :

1. Navigate to any of the OA Page in the application.
2. Click on the 'About this page' link at the bottom.
3. Select the tab 'Java System Properties'.
 



Feel free to point out if anything is missing/wrong in this blog.



Sunday, 18 September 2016

Oracle Apps: Project Number disappear when the OTL Timecard is saved.

In one of the project We came across an issue in OTL Timecard. It took some time to finally figure out the reason, none of the google GOD or metalink notes helped. So I thought of sharing the details here, which might help someone.

The OTL Timecard was customized, but if the employee save the timecard before submitting, the Project Number gets disappeared from the screen. If he/she continue and submit the timecard without saving, it works fine. If he/she tries to update and existing timecard, then also the Project Number does not appear in the LOV field.

The customization done was as follows :

1. Expenditure Type was made hidden by modifying the Timecard Layout ldt file.
2. Customized the ProjectVO and added SYSLink and Expenditure Type to the Project VO and default the SysLinkFunc and ExpType when the Project Number is selected from the Project LOV.

The issue was the Sequence Number of the Expenditure Type field in the TIMECARD layout ldt. In the standard ldt, the sequence Numbers are as follows.

SYSTEMLINKAGEFUNCTION  --> 200
PROJECT                                  --> 210
TASK                                          --> 220
EXPENDITURETYPE                --> 230

Since the timecard is customized and the Expenditure is getting defaulted from the Project LOV the sequence number of component EXPENDITURETYPE should be less than the component PROJECT. Otherwise when the page tries to load the Project, the EXPENDITURETYPE component's value will come as NULL and the Project LOV will not return any value. The value of ExpenditureType field and the SysLink field will be added as a dynamic whereclause when the page tries to query the Project Number. This happens if the EXPTYPE and SYSLINKFUNC is specified in the QUALIFIER_ATTRIBUTE7.

So the solution was to change the sequence of EXPENDITURETYPE to 205.

Sample from the Layout ldt:
PROJECT:
 BEGIN HXC_LAYOUT_COMPONENTS "XXAJ Employee Timecard Layout - Project"  
      OWNER = "ORACLE12.1.3"  
      COMPONENT_VALUE = "XXAJPROJ"  
      REGION_CODE = "HXC_CUI_TIMECARD"  
      REGION_CODE_APP_SHORT_NAME = "HXC"  
      ATTRIBUTE_CODE = "HXC_TIMECARD_PROJECT"  
      ATTRIBUTE_CODE_APP_SHORT_NAME = "HXC"  
      SEQUENCE = "210"  
      COMPONENT_DEFINITION = "LOV"  
      RENDER_TYPE = "WEB"  
      PARENT_COMPONENT = "XXAJ Employee Timecard Layout - Day Scope Building blocks for worker timecard matrix"  
      LAST_UPDATE_DATE = "2004/05/24"  
      BEGIN HXC_LAYOUT_COMP_QUALIFIERS "XXAJ Employee Timecard Layout - Project"  
           OWNER = "ORACLE12.1.3"  
           QUALIFIER_ATTRIBUTE_CATEGORY = "LOV"  
           QUALIFIER_ATTRIBUTE1 = "XXAJEmpProjVO"  
           QUALIFIER_ATTRIBUTE2 = "N"  
           QUALIFIER_ATTRIBUTE3 = "XXAJ_EMP_PROJ_LOV"  
           QUALIFIER_ATTRIBUTE4 = "809"  
           QUALIFIER_ATTRIBUTE5 = "12"  
           QUALIFIER_ATTRIBUTE6 = "HxcCuiProjectNumber|XXAJPROJ-DISPLAY|CRITERIA|N|HxcCuiProjectId|XXAJPROJ|RESULT|N|HxcCuiProjectNumber|XXAJPROJ-DISPLAY|RESULT|N|HxcCuiExptypeExpType|EXPTYPE|RESULT|N|HxcCuiExptypeSysLinkFunc|SYSLINKFUNC|RESULT|N"  
           QUALIFIER_ATTRIBUTE7 = "EXPTYPE|ExpType|SYSLINKFUNC|SysLink"  
           QUALIFIER_ATTRIBUTE8 = "ProjectNumber"  
           QUALIFIER_ATTRIBUTE9 = "ProjectId#NUMBER"  
           QUALIFIER_ATTRIBUTE10 = "xxaj.oracle.apps.hxc.selfservice.timecard.server.XXAJEmpProjVO"  
           QUALIFIER_ATTRIBUTE11 = "TIMECARD_BIND_START_DATE|TIMECARD_BIND_START_DATE"  
           QUALIFIER_ATTRIBUTE17 = "OraTableCellText"  
           QUALIFIER_ATTRIBUTE20 = "N"  
           QUALIFIER_ATTRIBUTE21 = "Y"  
           QUALIFIER_ATTRIBUTE22 = "L"  
           QUALIFIER_ATTRIBUTE25 = "FLEX"  
           QUALIFIER_ATTRIBUTE26 = "PROJECTS"  
           QUALIFIER_ATTRIBUTE27 = "Attribute1"  
           QUALIFIER_ATTRIBUTE28 = "XXAJPROJ"  
           LAST_UPDATE_DATE = "2004/05/24"  
      END HXC_LAYOUT_COMP_QUALIFIERS  
 END HXC_LAYOUT_COMPONENTS  

EXPENDITURETYPE :
 BEGIN HXC_LAYOUT_COMPONENTS "XXAJ Employee Timecard Layout - Expenditure Type"  
      OWNER = "ORACLE12.1.3"  
      COMPONENT_VALUE = "EXPENDITURETYPE"  
      SEQUENCE = "205"  
      COMPONENT_DEFINITION = "HIDDEN_FIELD"  
      RENDER_TYPE = "WEB"  
      PARENT_COMPONENT = "XXAJ Employee Timecard Layout - Day Scope Building blocks for worker timecard matrix"  
      LAST_UPDATE_DATE = "2004/05/24"  
      BEGIN HXC_LAYOUT_COMP_QUALIFIERS "XXAJ Employee Timecard Layout - Expenditure Type"  
           OWNER = "ORACLE12.1.3"  
           QUALIFIER_ATTRIBUTE_CATEGORY = "HIDDEN_FIELD"  
           QUALIFIER_ATTRIBUTE18 = "EXCLUDE"  
           QUALIFIER_ATTRIBUTE19 = "|CSV|"  
           QUALIFIER_ATTRIBUTE20 = "N"  
           QUALIFIER_ATTRIBUTE21 = "Y"  
           QUALIFIER_ATTRIBUTE22 = "L"  
           QUALIFIER_ATTRIBUTE23 = "FORM"  
           QUALIFIER_ATTRIBUTE25 = "FLEX"  
           QUALIFIER_ATTRIBUTE26 = "PROJECTS"  
           QUALIFIER_ATTRIBUTE27 = "Attribute3"  
           QUALIFIER_ATTRIBUTE28 = "EXPTYPE"  
           LAST_UPDATE_DATE = "2004/05/24"  
      END HXC_LAYOUT_COMP_QUALIFIERS  
 END HXC_LAYOUT_COMPONENTS  


Feel free to point out if anything is missing/wrong in this blog.

Friday, 1 July 2016

Oracle Apps: Create User and Add Responsibility from backend

Sample code to create a user (FND_USER) from backend and add responsibility.
 declare  
   v_user_name varchar2(30) :='AJ_TEST';   -- User Name  
   v_password  varchar2(30) :='johnytips';  -- Password  
   -- List of responsibilities to be added automatically  
   cursor cur_get_responsibilities  
   is  
     select resp.responsibility_key  
           ,resp.responsibility_name  
           ,app.application_short_name        
     from  fnd_responsibility_vl resp  
          ,fnd_application       app  
     where resp.application_id = app.application_id   
     and   resp.responsibility_name in ( 'System Administrator'  
                                        ,'Application Developer'  
                                        ,'Functional Administrator') ;  
 begin  
   fnd_user_pkg.createuser (  
           x_user_name             => upper(v_user_name)  
          ,x_owner                 => null  
          ,x_unencrypted_password  => v_password  
          ,x_session_number        => userenv('sessionid')  
          ,x_start_date            => sysdate  
          ,x_end_date              => null );  
   dbms_output.put_line ('User '||v_user_name||' created !!!!!');  
   for c_get_resp in cur_get_responsibilities   
   loop  
     fnd_user_pkg.addresp ( 
                username        => v_user_name  
               ,resp_app        => c_get_resp.application_short_name  
               ,resp_key        => c_get_resp.responsibility_key  
               ,security_group  => 'STANDARD'  
               ,description     => null  
               ,start_date      => sysdate  
               ,end_date        => null);  
     dbms_output.put_line('Responsibility '||c_get_resp.responsibility_name||' added !!!!!!');    
   end loop;  
   commit;  
 exception  
   when others then  
   dbms_output.put_line ('Exception : '||SUBSTR(SQLERRM, 1, 500));  
   rollback;  
 end;  

Related blog: Oracle Apps: Reset FND User password from backend


Feel free to point out if anything is missing/wrong in this blog.