Question on populating a field based on 2 other fields

Hi,
I am looking for a solution wherein I need to populate a field (say no of days) based on the other two fields selected by the user (say date from and date to). As soon as user selects the value on "date to" field, "no of days" field should be auto-populated as the value from "date to - date from". I have tried using setter and getter methods on all three field, set valuechangelistener on date to field, set auto submit to true and in the valuechangelistener event code, I am doing the calculations as mentioned in the below snippet.
public void onChangeDateTo(ValueChangeEvent evt){
this.dtDateTo= (java.util.Date)evt.getNewValue();
this.dtDateFrom = (java.util.Date)getDateFrom();//This is the getter method for date from field
System.out.println("onChangeDateTo "+ this.dtDateFrom+":"+this.dtDateTo);
if (evt.getNewValue() != null){
int intCalcNoOfDays = DateHelper.getBusinessDaysCount(this.getDateFrom(),this.getDateTo()) + 1;// my custom class which does the calculation
String strCalcNoOfDays = String.valueOf(intCalcNoOfDays);
System.out.println("strCalcNoOfDays "+strCalcNoOfDays);
this.setNoOfDays(strCalcNoOfDays);
I am getting NullPointerException while getting the value for date from (this.dtDateFrom). I have tried other approaches like attaching a binding to date from field, passing attributes etc but no luck. Can someone assist me in achieving this? Basically I need to populate one field automatically based on values entered on two other fields whenever tab event/user selects value on second field AND it shouldn't fire any other validations on the form (basically partial trigger).
Thanks very much for the help in advance.
Thanks
Shree

Thanks Lilly.
I don't have a backing bean associated with the page. I have managed bean instead. JSF source code snippet below
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich" xmlns:h="http://java.sun.com/jsf/html">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document title="LMS" id="d1">
<af:messages id="m1"/>
<af:form id="f1">
<af:panelStretchLayout id="psl1" startWidth="160px">
<f:facet name="top">
<af:panelGroupLayout id="pgl1" layout="vertical" halign="center">
<af:panelFormLayout id="pfl1" rows="1" maxColumns="1">
<af:outputText value="LMS" id="ot1"
inlineStyle="color:Blue; font-family:'Times New Roman', 'Arial Black', times, Serif; font-size:175%; font-weight:bold; text-align:center;"/>
</af:panelFormLayout>
</af:panelGroupLayout>
</f:facet>
<f:facet name="bottom">
<af:panelGroupLayout id="pgl2"/>
</f:facet>
<f:facet name="center">
<af:panelGroupLayout layout="scroll" id="pgl4">
<af:outputText value="Dashboard" id="ot6"
inlineStyle="color:Green; font-size:150%; font-family:'Times New Roman', 'Arial Black', times, Serif; font-weight:bold; text-align:center;"
visible='#{clickActionHandlerBean.clickLink== "HOME"}'/>
<af:spacer width="10" height="10" id="s1"
visible='#{clickActionHandlerBean.clickLink== "HOME"}'/>
<af:spacer width="10" height="25" id="s5"
visible='#{clickActionHandlerBean.clickLink=="APPLY"}'/>
<af:panelFormLayout id="pfl2" rows="1" maxColumns="1"
visible='#{clickActionHandlerBean.clickLink=="APPLY"}'>
<af:selectOneChoice label="Type" id="soc1" showRequired="true"
immediate="true" value="#{bean1.type}">
<af:selectItem label="X1" value="X1" id="si1"/>
<af:selectItem label="X2" value="X2 id="si2"/>
<af:selectItem label="X3" value="X3" id="si3"/>
<af:selectItem label="X4 value="X4" id="si4"/>
</af:selectOneChoice>
</af:panelFormLayout>
<af:panelFormLayout id="pfl3" rows="1" maxColumns="3"
visible='#{clickActionHandlerBean.clickLink=="APPLY"}'>
<af:inputDate label=" Date From" id="id1"
rendered='true'
showRequired="true" inlineStyle="vertical-align:baseline;"
value="#{bean1.dateFrom}">
<af:convertDateTime pattern="dd-MMM-yyyy" secondaryPattern="MM/dd/yyyy"/>
</af:inputDate>
<af:inputDate label="Date To" id="id2"
rendered='true'
showRequired="true" value="#{bean1.dateTo}" partialTriggers="it1"
valueChangeListener="#{bean1.onChangeDateTo}"
autoSubmit="true">
<af:convertDateTime pattern="dd-MMM-yyyy" secondaryPattern="MM/dd/yyyy"/>
</af:inputDate>
<af:inputText label="No of Days" id="it1" columns="7" showRequired="true"
rendered="true" value="#{bean1.noOfDays}" maximumLength="2">
<af:validateRegExp pattern="[0-9]{1,10}"
messageDetailNoMatch="No of days can have only numbers"/>
</af:inputText>
</af:panelFormLayout>
<af:spacer width="10" height="50" id="s6"/>
<af:group id="g1">
<af:spacer width="250" height="10" id="s7"
visible='#{clickActionHandlerBean.clickLink=="APPLY"}'/>
<af:commandButton text="Save" id="cb1" partialSubmit="true" blocking="false"
immediate="false"
visible='#{clickActionHandlerBean.clickLink=="APPLY"}'
actionListener="#{bean1.ApplyButtonClicked}">
</af:commandButton>
<af:spacer width="20" height="10" id="s8"/>
<af:commandButton text="Cancel" id="cb2"
visible='#{clickActionHandlerBean.clickLink=="APPLY"}'/>
</af:group>
</af:panelGroupLayout>
</f:facet>
<f:facet name="start">
<af:panelGroupLayout id="pgl3" halign="left">
<p>
<af:outputText value="#{userinfo.userInfo.firstName}" id="otWel"
inlineStyle="color:Maroon;" rendered="false"/>
</p>
<af:spacer width="1" height="50" id="s2"/>
<p>
<af:commandLink text="Home" id="glHome" action="#{clickActionHandlerBean.showHomeRN}"/>
</p>
<p>
<af:commandLink text="Apply" id="glApply"
action="#{clickActionHandlerBean.showApplyRN}"/>
</p>
</af:panelGroupLayout>
</f:facet>
</af:panelStretchLayout>
</af:form>
</af:document>
</f:view>
</jsp:root>
Thanks
Shree

Similar Messages

  • Need Trigger that format a field based on two other fields

    Hello!
    I need to write a trigger, that reads on field and made some changes to it and saves the result in an other field in the same row. The trigger should work in insert and update cases.
    Does anybody can send me a frame, where i can fill my logic?
    Regards
    Heiko Glaeske

    In this example, column1 and column2 are the values being examined and the resultant expression is saved in column3.
    create or replace trigger trigger_name
    before insert or update on table_name
    for each row
    begin
      :new.column3 := :new.column1 + :new.column2;
    end;
    /

  • Validating text field based on 2 other fields.

    I've tried a string of if/else but somewhere I am missiing something.
    I've assigned variables to my fields and I will use them here.
    vdd1 = a dropdown with 5 options, " ", "Breakfast", "Lunch" "Dinner" and "Snack"
    vMad1 = A text field into which the user enters a dollar amount
    var vdd1 = this.getField("DropDown1").value;
    var vMar1 = this.getField("MealsAmountRow1").value;
    Here is what I need in English.
    If (vdd1 = "Breakfast") and (vMad > 25) then app.alert("NOTE: The amount you have entered exceeds the $25.00 per day breakfast limit.  Please reduce the amount to $25.00", 3)
    If (vdd1 = "Lunch") and (vMad > 35) then app.alert("NOTE: The amount you have entered exceeds the $35.00 per day lunch limit.  Please reduce the amount to $35.00", 3)
    If (vdd1 = "Dinner") and (vMad > 65) then app.alert("NOTE: The amount you have entered exceeds the $65.00 per day dinner limit.  Please reduce the amount to $65.00", 3)
    If (vdd1 = "Snack") and (vMad > 25) then app.alert("NOTE: The amount you have entered exceeds the $25.00 per day snack limit.  Please reduce the amount to $25.00", 3)

    You've almost got it. Try this:
    var vdd1 = getField("DropDown1").value;
    var vMad1 = +getField("MealsAmountRow1").value;
    if (vdd1 === "Breakfast" && vMad1 > 25) {
        app.alert("NOTE: The amount you have entered exceeds the $25.00 per day breakfast limit.  Please reduce the amount to $25.00", 3);
    } else if (vdd1 === "Lunch" && vMad1 > 35 {
        app.alert("NOTE: The amount you have entered exceeds the $35.00 per day lunch limit.  Please reduce the amount to $35.00", 3);
    } else if (vdd1 = "Dinner" &&  vMad1 > 65) {
        app.alert("NOTE: The amount you have entered exceeds the $65.00 per day dinner limit.  Please reduce the amount to $65.00", 3);
    } else if (vdd1 = "Snack" && vMad1 > 25) {
        app.alert("NOTE: The amount you have entered exceeds the $25.00 per day snack limit.  Please reduce the amount to $25.00", 3);
    The biggest problem is it's not clear when you want this code to be triggered. Where do you currently have it placed?

  • Update a text field based on a SelectOneChoice field

    Hi,
    I have a set of Create, Confirm and Thankyou screens. These screens are bound to a global view object. The create screen has a SelectOneChoice element which allows the user to pick an employee. When the selection is made, I need to display the employee's department in a read only text field below the dropdown. The Employees list(SelectOneChoice) is associated to the read only view object and this view object also has the employee's department information. Im dont know how to set the department name in the text field and refresh the screen. Any help is appreciated. Thank You.

    Frank, thanks for you time. Please see my answers below.
    Hi,
    can you help me creating a reproducable testcase
    based on the HR schema where we have a Departments
    and Employees tables. To understand your usecase I
    have some questions:
    Im not too familiar with HR Schema.
    >
    First of all however, what is a "global view object",
    and is it safe to assume you are using ADF Business
    Components?
    Its the "Globals View Object" as described in the SRDemo for creating a new Service Request and yes I am using ADF Business Components.
    >
    Which version of Oracle JDeveloper do you use ?
    10.1.3
    >
    The usecase I understand is that you have a
    selectOneChoiceList that whenever you select a new
    name should update a read-only text field with the
    department name. Is this correct ? Or is there more
    in it ?
    Heres the complete description. There are 4 fields on the screen
    1. Program Name (text input field, - required field)
    2. Program Category (SelectOneChoice field - required field)
    3. Employee Name (SelectOneChoice field - required field)
    4. Employee Department (Text output field - based on 3 above)
    What you have described above is working for me now, but everytime I select a value for 3, it does the required fields check and gives a message like "1 & 2 are required and a value must be entered", this validation should only occur when my continue button is clicked.
    >
    The department name should be displayed only (read
    only), or is it also bound to what you call "global
    view"?
    Yes its read only but I need to bind to the Globals view as I need to display it in the confirmation screen.
    >
    Also, just to be sure, is the department name part of
    the VO or is it the departmentId?
    The screen is bound to the Globals View, the selectOneChoice values are displayed from another view(EmployeeList view) which has the department name.
    >
    Frank

  • Deriving 1 Value from 2 Fields Based on Values in Fields

    I have a query that needs to return 1 of my values based on the values from 2 fields from 2 tables. However, the value should only be returned in 1 field and one of the fields should be evaluated first. If this first evaluated field has a certain value ('Y') then the other field is ignored.
    To be more clear, per the normal query below, what I want is to somehow, if possible, combine the case t2.el_contr and case t1.contr_type statements so that one field, say: mbr_contr_type_desc returns a value.
    So that if the value of t2.el_contr is 'Y' then 'SUB CHILD' is returned. It is important that this field should be evaluated first (If the value of it is 'Y' then the other field evaluation can be ignored). If this is not 'Y', then t1.contr_type should be evaluated and the values as listed below also returned to mbr_contr_type_desc.
    I know the following isn't correct, but it might better illustrate what I'm trying to do (the normal query is below this)
    case t2.el_contr
    when 'Y' then 'SUB CHILD'
    case t1.contr_type
    when 'A' then '1 PARTY MALE SUB'
    when 'B' then '1 PARTY FEMALE SUB'
    when 'C' then '2 PARTY MALE SUB'
    when 'D' then '2 PARTY FEMALE SUB'
    when 'F' then 'FAMILY MALE SUB'
    when 'G' then 'FAMILY FEMALE SUB'
    end as mbr_contr_type_desc
    In an Access query I would do the following in a column:
    iif([el_contr]='Y',"SUB CHILD',SWITCH([contr_type]="A","1 PARTY MALE SUB",[contr_type]="B" etc.))
    *NORMAL QUERY*
    select t1.ssn
    t1.type,
    t1.grp_id,
    t1.contr_type,
    t2.el_contr,
    case t2.el_contr
    when 'Y' then 'SUB CHILD'
    end as mbr_contr_type_desc_2,
    case t1.contr_type
    when 'A' then '1 PARTY MALE SUB'
    when 'B' then '1 PARTY FEMALE SUB'
    when 'C' then '2 PARTY MALE SUB'
    when 'D' then '2 PARTY FEMALE SUB'
    when 'F' then 'FAMILY MALE SUB'
    when 'G' then 'FAMILY FEMALE SUB'
    end as mbr_contr_type_desc_1
    from member_elig t1
    inner join grp_master t2 on
    t1.grp_id = t2.grp_id

    Perfect!
    Thanks, didn't know that existed. Still learning my way around pl/sql..
    One other (unrelated) question..when i hit the CTRL+LEFT ARROW* button in my SQL window, it will not tab back. This is really annoying! I have looked through PREFERENCES-EDITOR and can't seem to find any setting that will allow this. Do you know of any way to change this so I can tab backwards/fowards through code in the SQL window?
    Thanks for any suggestions!
    *Or CTRL+RIGHT ARROW for that matter..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to calcluate a filed based on two other fields after TABING out.

    Hi,
    I need my third field be calculated based on the previous two fields after tabing out from each field.
    Price Quantity Amount
    12 10 120
    Both price and Quantity is text box and amount is readonly.I want if I change Price from 12 to 15 and tab out then amount should automatically get changed to 150.
    Regards,
    Prakash

    I believe you can use Partial Page Rendering (PPR) to accomplish this. You'd place a 'firePartialAction' event on the input field. This event would fire when you tab out and then you can invoke controlelr logic to set the other two fields appropriately.
    Check out the OA Framework Developer's Guide for examples.

  • Is there a way to calculate a date field based on aother date field in sharepoint list?

    In a SharePoint list, I have a 'Start of Use Date' and need to ensure the 'Review Date' is no more than 14 months after the 'Start of Use Date', but can't figure out the formula.  Can you help?

    You can cast the field values in the SPListItem to DateTime objects and call the AddMonths(int) function to see if the two are more than 14 months apart. For instance:
    DateTime startOfUseDate = (DateTime) item["Start of Use Date"];
    DateTime reviewDate = (DateTime) item["Review Date"];
    if (startOfUseDate.AddMonths(14) >= reviewDate)
    // Review Date IS NOT more than 14 months after Start of Use Date
    else
    // Review Date IS more than 14 months after Start of Use Date
    Danny Jessee
    MCPD - SharePoint Developer 2010
    MCTS - SharePoint 2010, Configuring
    dannyjessee.com/blog

  • Need to compare two fields and populate the other fields.

    Hi All,
    I have scenario like this.
    DATA: text1(150) type C
    VALUE 'Step: SHORT DUMP; Scenario: PRE; Date :09.07.2007. Time :13:08:33.'.
    DATA: text2(150) TYPE C
          VALUE 'Step: &; Scenario: &; &',
    DATA: text_A(150) TYPE C,
              text_B(150) TYPE C,
               text_C(150) TYPE C.
    Now I need to compare text1 and text2 and populate text_A, text_B and text_C as follows.
    text_A = SHORT DUMP
    text_B = PRE
    text_C = Date :09.07.2007. Time :13:08:33.
    Basically I need to fill text_A, text_A and text_A with the values in text1 which are replaced by '&'.
    Can anyone suggest me a code snippet to do it?
    Thanks in advance.
    Regards
    Ankit

    Sorry for slow response - I'm in a different timezone I think... Well it's not a short algorithm, but you could try something like the following (there's probably a sweeter algorithm, but this is what occured to me overnight)... I realise that it's not foolproof as you could have words substituted in for the "&" that also appear in the original message text and that would skew the results...
    Jonathan
    report zlocal_jc_get_msgvars.
    types:
      gty_char150(150)      type c.
    parameters:
      p_text_1              type gty_char150 lower case,
      p_text_2              type gty_char150 lower case.
    initialization.
      perform initialization.
    start-of-selection.
      perform extract_msgv.
    *&      Form  initialization
    form initialization.
    *" Default screen variables
      concatenate
        'Step: SHORT DUMP; Scenario: PRE;'
        'Date :09.07.2007. Time :13:08:33.'
        into p_text_1 separated by space.
      p_text_2 = 'Step: &; Scenario: &; &'.
    endform.                    "initialization
    *&      Form  extract_msgv
    form extract_msgv.
    *" Work out the values that have been substituted
    *" into p_text2 to make p_text1
      data:
        l_text_a            type gty_char150,
        l_text_b            type gty_char150,
        l_text_c            type gty_char150,
        l_text_d            type gty_char150,
        l_tabix_1           type i,
        l_tabix_2           type i,
        l_word_1            type gty_char150,
        lt_word_1           type gty_char150 occurs 10,
        l_word_2            type gty_char150,
        lt_word_2           type gty_char150 occurs 10,
        l_result            type gty_char150,
        l_tabix             type sy-tabix,
        l_tabix_next        type sy-tabix,
        l_tabix_from        type sy-tabix,
        l_tabix_to          type sy-tabix,
        lt_tabix            type sy-tabix occurs 4,
        lt_result           type gty_char150 occurs 10.
    *" Break the strings into words
      split p_text_1 at space into table lt_word_1.
      split p_text_2 at space into table lt_word_2.
      format reset.
      format color col_total.
      write: / p_text_1(80).
      write: / p_text_2(80).
      format reset.
    *" Look at where the words in the shorter string appear in the longer
      loop at lt_word_2 into l_word_2.
        add 1 to l_tabix_2.
        write: / 'P_TEXT_2, Word', l_tabix_2, l_word_2.
        if l_word_2+0(1) = '&'.  "placemarker
          continue.
        endif.
    *" examine the expanded version
        read table lt_word_1 into l_word_1
          with key = l_word_2.
        if not sy-subrc is initial.
          write: /
            'ERROR: Word not found in expanded version' color col_negative.
          continue.
        endif.
        l_tabix_1 = sy-tabix. "Where we found word from short msg
        append l_tabix_1 to lt_tabix.
      endloop.
    *" add pointer to end of list of words too
      describe table lt_word_1 lines l_tabix_1.
      add 1 to l_tabix_1. "because we subtract 1 below...
      append l_tabix_1 to lt_tabix.
      loop at lt_tabix into l_tabix_from.
        l_tabix = sy-tabix.
        write: / l_tabix_from.
    *" get the range of words we want by getting next tabix row
    *" and subtracting 1
        l_tabix_next = l_tabix.
        add 1 to l_tabix_next.
        read table lt_tabix into l_tabix_to index l_tabix_next.
        if not sy-subrc is initial. "no more words...
          exit.
        endif.
        add      1 to   l_tabix_from.
        subtract 1 from l_tabix_to.
        loop at lt_word_1 into l_word_1
          from l_tabix_from to l_tabix_to.
          write: / l_word_1 color col_positive.
    * Push into text_A, text_B, text_C, text_D
          case l_tabix.
            when 1.
              concatenate l_text_A l_word_1 into l_text_a
                separated by space.
            when 2.
              concatenate l_text_b l_word_1 into l_text_b
                separated by space.
            when 3.
              concatenate l_text_c l_word_1 into l_text_c
                separated by space.
            when 4.
              concatenate l_text_d l_word_1 into l_text_d
                separated by space.
          endcase.
        endloop.
      endloop.
      uline.
      format reset.
      format color col_group.
      write: / 'TEXT_A', l_text_a(80).
      write: / 'TEXT_B', l_text_b(80).
      write: / 'TEXT_C', l_text_c(80).
      write: / 'TEXT_D', l_text_d(80).
      format reset.
    endform.                    "extract_msgv

  • Infopackage Abap Routine (Selection based on other fields?)

    Dear Friends,
    I know that Abap routine is used in infopackage to select or restrict using complex data selection.
    My requirement is to restrict Material no field based on 4 other fields. Is that possible?
    Actual condition is  to load Material no only if other 4 fields combination is new.
    Pls help.
    Guru

    Hi,
    Yes you can do this at infoPackage level using the ABAP routine.
    First read the Active Table of the DSO into internal table and do a lookup for the required four fields combination.
    If these four field are new allow the material number.
    Refer the below link for more help.
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/a05ac9fa-f44c-2c10-dbb8-ef54c102707c
    Regards
    Manjula.B

  • Auto population of data to fields based on other input field.

    In overview screen, I have one input field "Business Partner" which contain search help.  As soon as business partner selected from dropdown, the other input fields like Name, Address, City, state should automatically populated without hit of 'ENTER' key.
    I verified with method DO_PREPARE_OUTPUT, but it is triggering only by hitting ENTER key. Is there any event or method which will trigger after business partner selected from dropdown? or any other option to achieve to auto populate the fields.
    Please find attached screen.
    Thanks in advance.

    Hi Narayana,
    You can use the get p method for setting up the values without pressing the enter.
    CASE iv_property.
        WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
          rv_value = cl_bsp_dlc_view_descriptor=>field_type_picklist.
        WHEN if_bsp_wd_model_setter_getter=>fp_server_event.
          rv_value = 'AI_SELECT'.( you can give here the event name)
        WHEN OTHERS.
      ENDCASE.
    Define event with the same name above( AI_SELECT),
    You can set the value of fields based on the first field value within this event.
    Thanks,
    Dharmakasi.

  • Fill DDL based on other field values in offline interactive adobe form

    Hi,
    I have a requirement where in i need to fill the values for a dropdown list  based on 3 other field values in offline adobe interactive forms which uses web service to interact with SAP.
    Note: I read many blogs and posts in SDN , but couldn get much info ab the same, so posting a new thread.
    Thank you.
    Regards,
    Soumya

    Hi Soumya,
    It is possible but a little bit tough and will make your form heavier.
    The solution is advisable only when there is not very much data required for the drop down(May be not more than 500 values as it will create performance issue).
    You can create a hidden table on the form contaning data for all the combinations. Depending on the selection of another 3 fields you can write the code to select only those values from this hidden table which are applicable to that selection. These values you can add to the drop down list removing the previous values.
    Only you have to do is on calculate or vlaidate event of target DDL you have to write your code.
    Pseudocode:
    1. Clear your DDL using deleteItem() method.
    2. Loop at your hidden table.
    3. Inside the loop check for applicable entries depending on selection in other 3 fields.
    4. Select the appropriate vlaues
    5. Add using additem method().
    Refer formCalc or JavaScript help for the appropriate code.
    Hope this will be helpfull.
    Regards,
    Vaibhav

  • After inserting into one field using LOV,  how to populate other fields ?

    Hi,
    I have a BLOCK based on a table (ex:EMP)
    And I have a LOV on the field(item): EMPNO.
    When I select one EMPNO from the LOV (when the field:EMPNO is populated with an emp number), the other fields should be populated
    Can some body let me know, which trigger I need to use and .......
    Thanks

    while creating LOV at empno you can this query
    select empno,ename,deptno from emp
    and define return item for each column.
    You can populate LOV manually at New_instance_item or Key_next_item
    of item empno.

  • End Routine - populating Target Field based on Master Data

    Hi,
    I have an issue with my End Routine in BI 7.0. The scenario is as follows....
    The Target-Fields ZSALES_OFFICE , 0SALES_CHANNEL etc. are being mapped 1:1 from their respective source fields. In addition to these target fields I have a target field 0SALESORG which I need to populate based on the values from 0COMP_CODE which is an attribute of ZSALES_OFFICE. The values of 0COMP_CODE are 9000, 9001, 9002 and 9003 respectively. The end routine condition needs to be implemented as follows...
    For every 0COMP_CODE which has value 9000, 0SALESORG should be populated with the value "EAST". Similarly for every 0COMP_CODE which has value 9001, 0SALESORG should be populated with the value "WEST",  for every 0COMP_CODE which has value 9002, 0SALESORG should be populated with the value "NORTH" and  for every 0COMP_CODE which has value 9003, 0SALESORG should be populated with the value "SOUTH". I tried the following code but it doesnt seem to work. Could you pls help!!
    Thanks,
    SD
    DATA: it_tab4 TYPE TABLE OF /BIC/PZF31SALOFF,
              wa_tab4 TYPE /BIC/PZF31SALOFF.
        SELECT *
          FROM /BIC/PZF31SALOFF
        INTO CORRESPONDING FIELDS OF TABLE it_tab4.
        sort it_tab4 by /BIC/ZF31SALOFF.
        LOOP AT RESULT_PACKAGE
          INTO <result_fields>.
          read table it_tab4
          with key /BIC/ZF31SALOFF = <result_fields>-/BIC/ZF31SALOFF
          into wa_tab4
          binary search.
          if sy-subrc eq 0.
            CASE wa_tab4-comp_code.
              WHEN '9000'.
                <result_fields>-salesorg = 'EAST'.
              WHEN '9100'.
                <result_fields>-salesorg = 'WEST'.
              WHEN '9200'.
                <result_fields>-salesorg = 'NORTH'.
              WHEN '9300'.
                <result_fields>-salesorg = 'SOUTH'.
              MODIFY it_tab4 FROM wa_tab4.
            ENDCASE.
          endif.
        ENDLOOP.

    Replace your select statement ,
    SELECT *
    FROM /BIC/PZF31SALOFF
    INTO CORRESPONDING FIELDS OF TABLE it_tab4.
    instead of selecting all the fields , pick only the fields which are required.(one good performance improvement)
    SELECT    /BIC/PZF31SALOFF  comp_code
    FROM /BIC/PZF31SALOFF
    INTO CORRESPONDING FIELDS OF TABLE it_tab4.
    Remove the line below , this is not required
    MODIFY it_tab4 FROM wa_tab4.

  • Populating other fields in a form based on the selection in a combobox field

    We have done a form(masterdetail) in which we have a combobox field.When we make a selection in the field we require some two other fields to be automatically populated retrieving data from a table(which has the details required) based on the selection made.For eg. Selecting emp id(combobox) should populate empname and salary automatically in the form.Is this possible?If so how can this be done?
    Thanks & Regards,
    Jayanthi.S

    This is what I did following Michael's suggestion and it works fine :-
    1> Created a dynamic LOV named LOV_EMPNO as:-
    select empno,empno from scott.emp
    2> Started creating a form named FORM024_EMP2 on scott.emp.
    3> On reaching the Formatting and Validation section, I chose the EMPNO field in the left frame.
    In the right frame for EMPNO, I changed the item-type to Combobox and selected the lov LOV_EMPNO.
    Then I went to the Javascript handler section for EMPNO, chose the Javascript event onChange and in the
    adjacent Textarea, I wrote:-
    popdetails(this);
    We will create the javascript function popdetails() in the Additional pl/sql section.
    4> Click next and goto the Additional PL/SQL section and I wrote the following code in
    "...after displaying the page" area.
    (You can write this either in
    before displaying the page,
    before displaying the form,
    after displaying the form,
    after displaying the page).
    declare
    type tvcarr is table of varchar2(2000) index by binary_integer;
    l_empno_arr tvcarr;
    l_ename_arr tvcarr;
    l_sal_arr tvcarr;
    begin
    select empno,ename,sal
    bulk collect into
    l_empno_arr,l_ename_arr,l_sal_arr
    from scott.emp;
    htp.p('
    <script>
    var empdets = new Array();
    empdets[0] = new Array("","");
    for i in 1..l_empno_arr.count
    loop
    htp.p('empdets['||l_empno_arr(i)||'] = new Array("'||l_ename_arr(i)||'","'||l_sal_arr(i)||'");');
    end loop;
    htp.p('
    function popdetails(ele)
    var val = new Number();
    var thisform = ele.form;
    val = parseInt(ele.value);
    if (isNaN(val))
    val = 0;
    for (var i = 0; i < thisform.length; i++){
    if (thisform.name == "FORM024_EMP2.DEFAULT.ENAME.01")
    thisform[i].value = empdets[val][0];
    else if(thisform[i].name == "FORM024_EMP2.DEFAULT.SAL.01")
    thisform[i].value = empdets[val][1];
    htp.p('</script>');
    end;

  • How to create a form that can auto-populate all fields based on a specific selection?

    We have created a template for each type of package used in our business.  The template is the same but depending on the package selected, the fields would be populated differently.  How can we create a template to load the fields based on the specific package selected?  We use Adobe Acrobat Pro in creating the templates.

    This forum is for the Adobe FormsCentral (http://formscentral.adobe.com) which is a service that allows you to create, collect and analyze data using an online web form. You should ask Acrobat/PDF related form questions in the Acrobat forums:http://forums.adobe.com/community/acrobat/acrobat_windows
    I'll move your post to that forum so you don't need to retype it. They can help you out...
    Randy

Maybe you are looking for