Assigning Values to a Field Depending on Other Field

Hi,
I'm creating a survey that is used to capture data on a yearly basis. We are attempting to make the survey as self-validating as possible to minimize workload. One section of the survey asks for a yearly change in the number of people in a program, asking for both the number of people entering the program and the number leaving the program. We need this section to self validate by checking that the number of people in the program at the beginning of the year, plus the number added to it, minus the number leaving it, equals the number of people in the program at the end of the year.
The validation formula for this is easy. The difficult problem is automatically assigning a value to the beginning of year value. We will know what this value is due to collecting a response from the program the previous year. My plan is for this field to self-fill depending on an earlier response to the selection of the program name.
Suppose there is a question earlier in the survey asking for the program name, I'll call it ProgramName. This is a drop down list that must be selected from a list. I need the export value of the drop down list to be the program name they selected. My plan is that for the field later in the survey to fill like this:
switch(ProgramName.value)
     case "Program1":
          currentfield = "1"
     case "Program2":
          currentfield = "2"
     default:
          currentfield = "0"
Unforunately I am very new to writing JavaScript and don't know the syntext to get this result. Any help would be appreciated!
Thanks

What you're proposing is a custom calucalte script for the beginning of year value field that gets set based on the dropdown selection. I'd suggest setting the field value in the validate event of the drop down instead, in which case the code would look like:
// Set the beginning of year field value based on this field's selection
// initialize variable
var begin_num = 0;
switch (event.value) {
case "Program1":
    begin_num = "1";
    break;
case "Program2":
    begin_num = "2";
    break;
case "Program3":
    begin_num = "3";
    break;
// Set be beginning number field value
getField("begin_num").value = begin_num;
Where "begin_num" is the name of the field that will contain the beginning number.

Similar Messages

  • Assigning values to 2 fields using sql statement

    db11g , apex 4.0 and firefox 24 ,
    hi all ,
    i am trying to follow this tutorial to assign values to 2 items on a page using sql statement ,
    and i am using the same sql statement the tutorial uses
    select d.loc location, count(e.empno) num_employees from dept d, emp e where d.deptno = e.deptno(+) and d.deptno = :P3_DEPTNO group by d.loc -- btw , what does the "+" sign mean?
    after the e.deptno in the where condition .
    but i am facing this error
    1 error has occurred
    Wrong number of columns selected in the SQL query. See Help of attribute for details.
    and it does not work with two columns in the select statement under any conditions , i tried to remove the group function and the group clause ,
    it does not work unless i use only one column in the select statement ??
    thanks

    Pars
    And how exactly is this rewrite of the sql statement resolving the OP's issue.
    You are still using more than 1 column which will still result in the error message:
    Wrong number of columns selected in the SQL query.
    As mentioned in my earlier post APEX 4.0 (the version the OP is using) does not handle a sql statement with multiple columns for the dynamic action Set Value.
    Which means the fastest  and simplest solution is splitting up the dynamic action in multiple Set Value actions.
    Using this plugin or upgrade to a newer apex version would also be a possibility.
    Nicolette

  • One field value will be populated depending on other field's value

    I have two select-options in my selection screen- a)VBAP-VBELN b)VBAP-MATNR.
    My requirement is that if i enter Sales Doc(VBAP-VBELN) in first combo ,Material Number combo(VBAP-MATNR)will be populated with Material numbers for that corresponding Sales Doc only. Not all Material number.
    Please help.

    Hi,
    check this example...
    REPORT  ZTEST_F4HELP                              .
    *---Report with selection screen and to display the list of
    possible entries for field 'B' as per the value in field 'A'.
    parameters: p_vbeln type vbak-vbeln,
                p_posnr type vbap-posnr.
    at selection-screen on value-request for p_posnr.
      data: begin of help_item occurs 0,
              posnr type vbap-posnr,
              matnr type vbap-matnr,
              arktx type vbap-arktx,
            end of help_item.
      data: dynfields type table of dynpread with header line.
      dynfields-fieldname = 'P_VBELN'.
      append dynfields.
      call function 'DYNP_VALUES_READ'
           exporting
                dyname               = sy-cprog
                dynumb               = sy-dynnr
                translate_to_upper   = 'X'
           tables
                dynpfields           = dynfields
           exceptions
                invalid_abapworkarea = 1
                invalid_dynprofield  = 2
                invalid_dynproname   = 3
                invalid_dynpronummer = 4
                invalid_request      = 5
                no_fielddescription  = 6
                invalid_parameter    = 7
                undefind_error       = 8
                double_conversion    = 9
                stepl_not_found      = 10
                others               = 11.
      read table dynfields with key fieldname = 'P_VBELN'.
      p_vbeln = dynfields-fieldvalue.
      call function 'CONVERSION_EXIT_ALPHA_INPUT'
           exporting
                input  = p_vbeln
           importing
                output = p_vbeln.
      select posnr matnr arktx into table help_item
                     from vbap
                          where vbeln = p_vbeln.
      call function 'F4IF_INT_TABLE_VALUE_REQUEST'
           exporting
                retfield    = 'POSNR'
                dynprofield = 'P_POSNR'
                dynpprog    = sy-cprog
                dynpnr      = sy-dynnr
                value_org   = 'S'
           tables
                value_tab   = help_item.
    Cheers,
    SImha.

  • Dump GETWA_NOT_ASSIGNED while assigning value to a field symbol

    LOOP AT <table> INTO <struct>.
        CLEAR l_uom.
        lf_fieldname = '<struct>-UOM'.
        ASSIGN (lf_fieldname) TO <uom>.
        l_uom  = <uom> .
    ENDLOOP.

    I need to put the contents of lf_fieldname into <uom>.......when lf_fieldname is <struct>-UOM.....
    so
    assign lf_fieldname to <uom> is of no use...........and hence v use
    assign (lf_fieldname) to <uom>
    my problem is since i dont knw till the run time if UOM field is present in the table or not, and whn it's not, no mem_area is referenced in the bkgrnd and hence i get an error...........i need to knw if v have a provision to chk if (lf_fieldname) has ne value or not....
    Please help....:)
    Regards,
    Aparna.

  • Assigning value to field in proxy report

    Hello,
    I am writing the abap report for sproxy.
    The link to the field in structure is very long.
    e.g. it-fault_message_mt-request-calldata-requester-gid = 'Z12345'.
    In the structure one field in calldata is ADDITIONAL_ATTRIBUTE which is of table type.
    I want to assign values to the fields of ADDITIONAL_ATTRIBUTE.
    When I click on field ADDITIONAL_ATTRIBUTE we can see line type ZFAULT_MESSAGE_ADDITIONAL_ATTR and this line type is having NAME as on of the field.
    I want to pass value to field NAME.
    Regards,
    Neelambari

    Hi,
    Create a work area as line type. and loop at table type into work area.
    *wa like line type
    *loop at table_type into wa.
    *wa-name = Value.
    *append wa to target table type.
    ****target table type structure should be  same as that of source table type. *****
    Sachin

  • Assigning External content type field column value using Client Object Model

    I have a problem assinging External column value to ListItem object with client object model-based application I'm developing. To be precise, I am able to retrieve data related to external content type by reading external list created from this content type
    but I don't know how to properly use it to assign value to this field. By doing some research on my own I concluded that BDC ID column from external list is the way to go since it uniquely defines selected row from external list but that doesn't
    tell me much since I don't know what to do with it. Currently I ended up with partial solution - to assign plain string value of picker column but that makes this value visible only in "View Properties" option on Sharepoint and not in "Edit Properties"
    which pritty much makes sence since it isn't properly related to rest of the data in specific row. Does someone have a better solution for this?
    Igor S.

    I think I understand your problem.
    In my example I have an external data column "Beneficiary Name", using a Beneficiary external content type (accessing a table of beneficiaries in a SQL table).
    I want to set the "Beneficiary Name" property using the client object model. I know the name of the beneficiary but not the ID value.
    It is a fairly simple solution. You just need to identify the name of the property SharePoint assigns to the ID field, in my case it is called "Beneficiary_ID". Then set the two properties as follows:
    thisItem["Beneficiary_Name"] = "Charitable Trust";
    thisItem["Beneficiary_ID"] = -1;
    thisItem.Update();
    Setting the ID property to -1 causes the server to do an automatic lookup for the ID from the value assigned to the item.

  • How to assigne value in sub record type

    Dear below mention record type database,now i want to assigne value in payr_rec type,in this recrocrd type have one column party_id,but how can assigne value int this field ,
    TYPE group_rec_type IS RECORD(
    group_name VARCHAR2(255),
    group_type VARCHAR2(30),
    created_by_module VARCHAR2(150),
    -- Bug 2467872
    mission_statement VARCHAR2(2000),
    application_id NUMBER,
    party_rec PARTY_REC_TYPE := G_MISS_PARTY_REC
    please guide.

    to get the desired default party_rec attribute value, just assign the "sub-record" attribute defaults as desired; PL/SQL will assign a default (non-null) record as the party_rec value using those attribute defaults:
    create or replace package P_Test_It
    as
         type party_rec_type is record (
              dummy varchar2(1) default 'X'
         type group_rec_type is record (
              group_name VARCHAR2(255),
              group_type VARCHAR2(30),
              created_by_module VARCHAR2(150),
              -- Bug 2467872
              mission_statement VARCHAR2(2000),
              application_id NUMBER,
              party_rec PARTY_REC_TYPE
    end;
    set serveroutput on
    declare
         rec p_test_it.group_rec_type;
    begin
         dbms_output.put_line(rec.party_rec.dummy);
    end;
    X
    PL/SQL procedure successfully completed.Hope it helps.
    Gerard

  • Multiple Value in additional fields using SAP Query

    HI All,
    I have a question related additional field in SAP Query. I tried to create report about PR and PO using SAP Query. Since one PR can be converted to multiple PO, I decided to create additional field
    po_1
    to display the value of PO that related to the PR. But I meet problem when I want to show several PO number in additional field
    po_1
    , I couldn't look the way to solve this problem. Can anybody help me? Just for info, I assign value to additional field
    po_1
    in record processing part.
    Thanks....

    HI,
    IN SQ02, IF table is already in JOIN, just click on the PLUS sign to expand the strcture.
    All the field showing Plus sign in the strcture are selected in your query and with MINUS sing are no selected.
    So you have to just click on the MINUS sign for the field you want to use through table field.
    Generate the query and execute thriugh SQ01.
    If you want to add some other field which is not a part of JOIN,
    then click on EXTRAS Button shown in the MENU option.
    Click on Create button and system will ask abt the additional field.
    Regds,
    Anil

  • To populate values into single field in an internal table

    Hi Friends,
    How we need to populate values into single field in an internal table.
    E.g itab consits of single field ( name)
           i need to assign values to this field name .like
          peter,
          john,
          abrahm,
          daneyal
    Pls tell me i how i need to code for this
    Thanks ,
    Parnith

    Hi,
    Please look at the below code :
    DATA : BEGIN OF itab OCCURS 0 ,
             name(20) TYPE c,
           END OF itab.
    START-OF-SELECTION.
      itab-name = 'Peter'.
      APPEND itab.
      CLEAR itab.
      itab-name = 'John'.
      APPEND itab.
      CLEAR itab.
      itab-name = 'Abrahm'.
      APPEND itab.
      CLEAR itab.
      itab-name = 'Daneyal'.
      APPEND itab.
      CLEAR itab.
      LOOP AT itab.
        WRITE : / itab.
      ENDLOOP.
    Thanks,
    Sriram Ponna.

  • Assigned Value Roll Up

    The assigned value did not roll up to the top WBS element.
    The assigned value showing for 2nd and 3rd level wbs but not rolling up to 1st level.
    The user did CJBW,CJBV,CJEN and CJBN no result.
    PLs Guide

    Dear John,
    As per your requirement,
    first carryout the following checks,
    have you activated and configured the system correctly,
    have you checked that the budgeting carried out is totalled up,if yes then at what levels are there multiple 1st level WBS elements.
    then check the parent WBS element,if the Budgeting is carried out at the 2nd level WBS element or 3rd level WBS element then there is a possibility that your assigned value is not totalled up,it shall be restricted upto level at which budgeting is carried out
    also please go through the post with assigned values
    Assigned value is different in different reports

  • Import screen field value into search help assigned to a different field

    Hi,
    I have created an elementary search help based on a custom DDIC table ZSH_SHHLDR. Dialog Type: Dialog depends on set of values, search help parameters:
    Parameter                       Import     Export   LPos SPos  SDis
    FOLIO                                X                       1       1         X
    CERTN                                             X         2       2
    where FOLIO and CERTN are fields in my table.
    There are two fields in my program defined as like FOLIO and CERTN respectively. These fields are screen fields in a custom dynpro created using Screen Painter. The search help is assigned to the CERTN field. In the screen, I want that the contents of the FOLIO field should be imported into the search help, i.e. on the screen:
    FOLIO: 21353
    CERTN: <F4>
    When I click on F4 help for CERTN, I want that the FOLIO parameter in the search help should contain the value for FOLIO that I entered in the text box on the screen. Is there a way to do this, through an exit for instance? Help is appreciated, thanks.
    Regards

    Hi,
    You need to use the below statement.
    process on value-request.
    field zcom_doa_users-zzjob_role module sub_tes_module.
    Here I declared three fields in the screen fields from structure zcom_doa_users. Try to name the fields with table name-field name. So inside the module in structure zcom_doa_users you will get given value for the other fields also.
    Now you can do your own processing for f4 help.
    Thanks
    Subhankar

  • Assigning a default value to a field

    Hello Everyone,
           Could you please tell me how to assign a default value to a field in a transparent table, so that while creating an entry even if we don't enter the value, a default value will be assigned.
    Thanks,
    Anbu.

    Like this
    DATA: BEGIN OF itab OCCURS 0,
            field1 TYPE c VALUE 'X'
            field2 TYPE c,
          END OF itab.
    append itab.
    append itab.
    You will have by default X set in both rows for field1.
    Regards
    Marcin
    PS: Ooops I just noticed you meant transparent table but I wrote about internal one. As long as you maintain that table using maintenance view you can use event 05 - When Creating a New Entry and set fixed value for a field there. So whenever you create new entry it will receive that value.
    Edited by: Marcin Pciak on Jun 23, 2010 8:57 AM

  • BP Transaction : Assign values to fields upon selection of BP role ?

    Hi All,
    I want to assign values to Grouping and Account Group fields in BP transaction in CRM.
    Is there any BADI or Userexit to achive the same. If possible kindly explain the steps to be implemented to use the BADI.
    Thanks & Regards,
    Navneeth K.

    Hi Navneeth,
    There are 2 ways to approach this :
    1. You can create an application transaction for the standard transaction BP. This will open the transaction in whichever role you require, default a groupng, and allow you to control some other initializaittion parameters. This is very similar the transaction variant mentioned above by Adil.
    You can explore 'Application Transactions' through SPRO->Cross Application>SAP Business Partner-> Business Partner> BAsic Settings>Business Partner Roles>Define Application Transactions.
    2. To default grouping , you can use BADI BUPA_NUMBER_GROUP. THe BADI will receive the list of groupings that will be shown in the dropdown .Write the implementation so as to remove unwanted groupins and keep only the number groupig you wish to default.
    Hope this helps.
    Cheers,
    Rishu.

  • How can i assign value to the certain field in dynmic table ?

    i have created a dynmic table .now i want to assign value to the certain field,how can i do that?
    for eg,
    <dyn_table> contains fields of  name age ,now i want assign 'jack' to this internal talbe's field name ,

    Hi,
    try this:
    FIELD-SYMBOLS: <GT_ITAB>      TYPE TABLE,
                   <GS_ITAB>,
                   <FS>, <FS1>.
    DATA: GT_DATA   TYPE REF TO DATA.
    DATA: GS_DATA   TYPE REF TO DATA.
    START-OF-SELECTION.
      CREATE DATA GT_DATA TYPE TABLE OF PA0002.
      ASSIGN GT_DATA->*   TO <GT_ITAB>.
      CREATE DATA GS_DATA    LIKE LINE OF <GT_ITAB>.
      ASSIGN GS_DATA->*      TO <GS_ITAB>.
      ASSIGN COMPONENT 'NACHN' OF STRUCTURE <GS_ITAB> TO <FS>.
      <FS> = 'Smith'.
      ASSIGN COMPONENT 'VORNA' OF STRUCTURE <GS_ITAB> TO <FS>.
      <FS> = 'Paul'.
      APPEND <GS_ITAB> TO <GT_ITAB>.
      ASSIGN COMPONENT 'NACHN' OF STRUCTURE <GS_ITAB> TO <FS>.
      <FS> = 'Jones'.
      ASSIGN COMPONENT 'VORNA' OF STRUCTURE <GS_ITAB> TO <FS>.
      <FS> = 'Martin'.
      APPEND <GS_ITAB> TO <GT_ITAB>.
      LOOP AT <GT_ITAB> INTO <GS_ITAB>.
        ASSIGN COMPONENT 'NACHN' OF STRUCTURE <GS_ITAB> TO <FS>.
        ASSIGN COMPONENT 'VORNA' OF STRUCTURE <GS_ITAB> TO <FS1>.
        WRITE: / <FS>, <FS1>.
      ENDLOOP.
    Regards, Dieter

  • Assigning a value to a field-symbol (workarea of type any)

    Dear forumers,
    I'm having a bit of difficulty in assigning a value to a field-symbol (it should be treated as a workarea of type any), but I'm given a syntax error instead:-
    The data object "<LFS_WORKAREA>" has no structure and therefore no component called "LFMON".
    What could have gone wrong and how may I resolve this (I must have missed something out)? I will still need <LFS_WORKAREA> to be defined as TYPE ANY.
    Please help. I'd appreciate any inputs at all. Thanks.
    *&      Form  FORMAT_POST_PERIOD
    *       Subroutine to format the posting period data
    *      --> PI_MBEW     Material valuation data (internal table)
    FORM format_post_period  CHANGING    pi_mbew TYPE ANY TABLE.
    " Create local field symbols
      FIELD-SYMBOLS:
      <lfs_workarea> TYPE ANY,
      <lfs_lfmon>    TYPE ckmlcr-poper.
    " Create local variables
      DATA: lv_index TYPE sy-tabix.
      DATA: lv_lfmon TYPE ckmlcr-poper.
    " Format posting periods
      LOOP AT pi_mbew ASSIGNING <lfs_workarea>.
        lv_index = sy-tabix.
        ASSIGN COMPONENT 'LFMON' OF STRUCTURE <lfs_workarea> TO <lfs_lfmon>.
        PERFORM convert_lfmon USING    <lfs_lfmon>
                              CHANGING lv_lfmon.
        MOVE lv_lfmon TO <lfs_workarea>-lfmon.   " the syntax error occurs here  :(
        MODIFY pi_mbew FROM <lfs_workarea>
          INDEX lv_index
          TRANSPORTING lfmon.
        CLEAR: <lfs_workarea>,
               <lfs_lfmon>
               lv_lfmon,
               lv_index.
      ENDLOOP.
    ENDFORM.                    " FORMAT_POST_PERIOD

    Most of us aren't in it for the points in any case...
    For your solution you've redundant code:
    *&      Form  FORMAT_POST_PERIOD
    *       Subroutine to format the posting period data
    *      --> PI_MBEW     Material valuation data (internal table)
    FORM format_post_period  CHANGING    pi_mbew TYPE ANY TABLE.
      FIELD-SYMBOLS:
      <lfs_workarea> TYPE ANY,
      <lfs_lfmon>    TYPE ckmlcr-poper.
      DATA: lv_lfmon TYPE ckmlcr-poper.
    *  DATA: lo_workarea TYPE REF TO data.   "<--Not needed, because the LOOP AT ASSIGNING below does the work
    *  CREATE DATA lo_workarea LIKE LINE OF pi_mbew.
    *  ASSIGN lo_workarea->* TO <lfs_workarea>.
      LOOP AT pi_mbew ASSIGNING <lfs_workarea>.
        ASSIGN COMPONENT 'LFMON' OF STRUCTURE <lfs_workarea> TO <lfs_lfmon>.
        PERFORM convert_lfmon USING    <lfs_lfmon>
                              CHANGING lv_lfmon.
        <lfs_lfmon> = lv_lfmon.
        CLEAR lv_lfmon.
      ENDLOOP.
    ENDFORM.                    " FORMAT_POST_PERIOD
    Here's a couple of more efficient solutions, using LOOP AT INTO.
    FORM format_post_period  CHANGING    pi_mbew TYPE INDEX TABLE. " <-- Table type a little more specific
                                                                   "<--now you can use index operations
      FIELD-SYMBOLS:
      <lfs_workarea> TYPE ANY,
      <lfs_lfmon>    TYPE ckmlcr-poper.
      DATA: lv_lfmon TYPE ckmlcr-poper,
            lv_index TYPE sytabix.
      DATA: lo_workarea TYPE REF TO data.
      CREATE DATA lo_workarea LIKE LINE OF pi_mbew.
      ASSIGN lo_workarea->* TO <lfs_workarea>.
    ASSIGN COMPONENT 'LFMON' OF STRUCTURE <lfs_workarea> TO <lfs_lfmon>.
      LOOP AT pi_mbew INTO <lfs_workarea>.
        lv_index = sy-tabix.    
        PERFORM convert_lfmon USING    <lfs_lfmon>
                              CHANGING lv_lfmon.
        <lfs_lfmon> = lv_lfmon.
        MODIFY pi_mbew FROM <lfs_workarea>
           INDEX lv_index. " <--INDEX TABLE, so this is permitted.
        CLEAR lv_lfmon.
      ENDLOOP.
    ENDFORM.                    " FORMAT_POST_PERIOD

Maybe you are looking for

  • Remote and Testing Server Site Definitions

    I am confused about what information I should put in my remote site definition info and testing server FTC Host directory text boxes. My host placed 3 directories: database, log, and www on my server and Dreamweaver placed two directories, Connection

  • Create a DDic sturcture via ABAP program

    Hello, is it possible to create a DDic structure via a ABAP program? I've got the components and component type of the new structure in a table. I want to create a DDic structure with this information. Is there function module or a method, with this

  • How do I add a clip-based timecode burn in to all my clips?

    Howdy - I'm trying to add a timecode based on each clip to every clip in my project.  If I select all the clips and add a timecode, it's media-based - and I can't figure out how to change that except one-by-one.  Can you change the timecode preferenc

  • Merge two LiveCycle documents.

    I imported a Word Document into LiveCycle.  I was almost finished, when I needed to change the look of a couple of pages.  I edited the Word version, deleteting lines and text and then converted the necessary pages to a LiveCycle document.  I can 'ex

  • Upgrade from Acrobat 4.0

    I have had to replace my pc HD and am back to acrobat 4.0.I only want to read pdf files so want to upgrade to Reader 9.I have vista home premium .Do I just use windows to remove Acrobat 4.0 and then download Reader 9 or can I just leave 4.0 and downl