Create generic HTTPService class

I am trying to create a generic HTTPService class. I am using
this code as my starting point:
import mx.controls.Alert;
import mx.rpc.http.HTTPService;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
private var service:HTTPService
public function useHttpService(parameters:Object):void {
service = new HTTPService();
service.destination = "sampleDestination";
service.method = "POST";
service.addEventListener("result", httpResult);
service.addEventListener("fault", httpFault);
service.send(parameters);
public function httpResult(event:ResultEvent):void {
var result:Object = event.result;
//Do something with the result.
?? How to run my function here if I dont know a name of it
public function httpFault(event:FaultEvent):void {
var faultstring:String = event.fault.faultString;
Alert.show(faultstring);
httpResult should be able to fire different functions that a
service requester will provide. How can I send a function name or
something else for the httpResult to fire when data has arrived?
Thanks

There are several options. First look into the AsyncToken. It
allows you to associate a dynamic "token" object with a given
request and result. properties of this object can be almos anyting,
including strings, if you want to use a switch statement to direct
the results to the desited handler, and even functions, if you want
to specify a callback function.
Additionally, bracket notation will resolve a function name
expressed as a string, and let you call that. So if you pass in a
reference to the scope of the handler, say "caller", and the
calling component has a public function processResult(), and you
pass the name of that function in via a var, say "handlerFunc",
then from wiithin your HTTP component you can do:
caller[handlerFunc](whatever)
Tracy

Similar Messages

  • Generic Repository class to download BSP into Ms-excel

    Hi,
    we have developed the download utility for BSP-MVC application, we have many BSP-MVC applications so i have to  develop a generic Repository class to download BSP into ms-excel, which is usable for all, the data selection will be done from model at run time by using techniques (field symbols and data references)wolud you please suggest how to achive this.
    Thanks in advance !
    best regards
    ravi

    I have written a generic download utility as a custom BSP Extension Element.  Perhaps it will give you some ideas:
    <a href="/people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table a BSP Extension for Downloading a Table</a>
    <a href="/people/thomas.jung3/blog/2005/07/18/bsp-extension-for-downloading-a-table-applying-an-iterator Extension for Downloading a Table: Applying an Iterator</a>

  • Could not create WMI locator class (80040154) - Win7 x64 OSD

    Hello All,
    I'm attempting to deploy a Win7 x64 OS to a Dell Optiplex 3010 through SCCM 2012 via PXE, a process I've done many times in the last few months. All of a sudden, on this one machine, I can't get it to work.
    The first strange thing that happened is, after the initial check for a PXE server I am told to "Press F12 for network service boot". I've never seen that before on any other system. Secondly, after supplying the password to begin the OSD process
    I'm met with error message 80040154. An excerpt from my log file is below:
    spLocator.createInstance( ((bUseAdminLocator == true) ? CLSID_WbemAdministrativeLocator : CLSID_WbemLocator ) ), HRESULT=80040154 (e:\nts_sccm_release\sms\framework\core\ccmcore\wminamespace.cpp,264)    TSPxe    1/8/2015 10:00:45
    AM    268 (0x010C)
    Could not create WMI locator class (80040154)    TSPxe    1/8/2015 10:00:45 AM    268 (0x010C)
    spNamespace.Open(c_szCIMv2Namespace), HRESULT=80040154 (e:\qfe\nts\sms\framework\tscore\tspolicy.cpp,604)    TSPxe    1/8/2015 10:00:45 AM    268 (0x010C)
    Failed to connect to WMI namespace \\.\ROOT\CIMV2 (Code 0x80040154)    TSPxe    1/8/2015 10:00:45 AM    268 (0x010C)
    TS::Policy::GetClientIdentity (&m_oHttpTransport, m_sSiteCode, sMediaGuid.c_str(), m_sClientGUID, m_sNetbiosName, bUnknown, sServerNames, sImportedClientIdentity), HRESULT=80040154 (e:\qfe\nts\sms\framework\tscore\tspolicy.cpp,867)    TSPxe  
     1/8/2015 10:00:45 AM    268 (0x010C)
    I see this error happening for people attempting a Win 8.1 OSD without the proper WMI file. But that's not what I'm trying to do. This exact process has worked on many other Optiplex 3010's and 3020's since May when I started using it. Any suggestions?

    Ok, here's what was happening. Boy do I feel stupid.
    When I went to enter this latest batch of computers into SCCM, I went into the BIOS, copied the MAC, and used it as I should to import the system into SCCM. I assigned it to my OSD collection, then deployed my OSD TS to that collection. This is when I started
    having major issues. Reason being: I transposed two of the digits in the MAC I entered. As a result, the computer booted as part of the “Unknown Systems” collection and was assigned a generic OSD TS that didn’t contain the necessary drivers to complete. I
    never assigned a TS to that collection, and I'm the only one that's been using SCCM for OSD. I can only assume someone else was playing around with it trying to learn and did this themselves.
    When I removed the outdated boot image the Unknown Computers TS was supposed to use, I began being unable to even PXE boot (of course). After trying many and varied solutions (including double-checking the MAC I had written down
    incorrectly), thinking it was a PXE or boot image issue I began looking at the PXE boot logs on my DP. I noticed it kept saying that there were no advertisements to this system, which made no sense. I had deployed an OSD TS to it 5 minutes ago! I finally
    noticed the MAC address was incorrect and fixed it. Guess what? It’s imaging as I type.
    Thanks for all the help guys - lesson learned.

  • Can anybody explain me creating Generic Datasource using Function module?

    Hi,
    can anybody explain me creating Generic Datasource using Function module?
    Thax in advance,
    Ravi.

    Generic Extraction via Function Module
    /people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module
    1. Create s structure with the fields that you need from the 4 tables . Activate.
    2. Goto SE 80 Select The Function Group , Copy , Select the Function module
    " RSAX_BIW_GET_DATA_SIMPLE " and Give a New name starting With
    Y or Z .
    3. SE37 ->Your Function module name -> Change , In table tab give your structure
    name by deleting the associated type given in " E_T_DATA " .
    4. Now select source code and Do the coding . Give Data source name in Coding .
    In your case you have to take data from more that 1 table .
    5. Activate the Function Group .
    6. In RSO2 Create the Data source , Give the Function Module Name , And Save.
    7. RSA3 -> Give data source name and Check for the Records .
    Creation of custom datasource. (Using function module)
    <b>is an example</b>
    1.Create a function group .
    2. Structure ZTEST123
    ZMATNR MATNR CHAR 18 0 Material Number
    ZMTART MTART CHAR 4 0 Material type
    ZMBRSH MBRSH CHAR 1 0 Industry sector
    ZMATKL MATKL CHAR 9 0 Material group
    ZBISMT BISMT CHAR 18 0 Old material number
    ZMAKTX MAKTX CHAR 40 0 Material description
    3. Create function module (i.e. ZTEST….) .
    FM - YMARA_DATA_TRNS
    FUNCTION YMARA_DATA_TRNS.
    ""Local Interface:
    *" IMPORTING
    *" VALUE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR
    *" VALUE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL
    *" VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE OPTIONAL
    *" VALUE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL
    *" VALUE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL
    *" TABLES
    *" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL
    *" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL
    *" E_T_DATA STRUCTURE ZTEST123 OPTIONAL
    *" EXCEPTIONS
    *" NO_MORE_DATA
    *" ERROR_PASSED_TO_MESS_HANDLER
    data : ZTEST123 type ZTEST123 occurs 0 with header line.
    Maximum number of lines for DB table
    STATICS: S_S_IF TYPE SRSC_S_IF_SIMPLE,
    S_COUNTER_DATAPAKID LIKE SY-TABIX.
    DATA: begin of t_mara occurs 0,
    ZMATNR type MATNR,
    ZMTART type MTART,
    ZMBRSH type MBRSH,
    ZMATKL type MATKL,
    ZBISMT type BISMT,
    end of t_mara.
    DATA: begin of t_makt occurs 0,
    ZMATNR type MATNR,
    ZMAKTX type MAKTX,
    end of t_makt.
    Initialization mode (first call by SAPI) or data transfer mode
    (following calls) ?
    IF I_INITFLAG = SBIWA_C_FLAG_ON.
    Check DataSource validity
    CASE I_DSOURCE.
    WHEN 'ZZMARA_DATA'.
    WHEN OTHERS.
    IF 1 = 2. MESSAGE E009(R3). ENDIF.
    this is a typical log call. Please write every error message like this
    LOG_WRITE 'E' "message type
    'R3' "message class
    '009' "message number
    I_DSOURCE "message variable 1
    ' '. "message variable 2
    RAISE ERROR_PASSED_TO_MESS_HANDLER.
    ENDCASE.
    Fill parameter buffer for data extraction calls
    S_S_IF-REQUNR = I_REQUNR.
    S_S_IF-DSOURCE = I_DSOURCE.
    S_S_IF-MAXSIZE = I_MAXSIZE.
    ELSE. "Initialization mode or data extraction ?
    Data transfer: First Call OPEN CURSOR + FETCH
    Following Calls FETCH only
    First data package -> OPEN CURSOR
    IF S_COUNTER_DATAPAKID = 0.
    Determine number of database records to be read per FETCH statement
    from input parameter I_MAXSIZE. If there is a one to one relation
    between DataSource table lines and database entries, this is trivial.
    In other cases, it may be impossible and some estimated value has to
    be determined.
    select MATNR
    MTART
    MBRSH
    MATKL
    BISMT
    from mara up to 10 rows
    into table t_mara.
    if not t_mara[] is initial.
    select MATNR
    maktx
    from makt
    into table t_makt
    for all entries in t_mara
    where matnr = t_mara-zmatnr.
    endif.
    loop at t_mara.
    read table t_makt with key zmatnr = t_mara-zmatnr.
    ZTEST123-zmatnr = t_mara-zmatnr.
    ZTEST123-ZMTART = t_mara-ZMTART.
    ZTEST123-ZBISMT = t_mara-ZBISMT.
    ZTEST123-ZMBRSH = t_mara-ZMBRSH.
    ZTEST123-ZMATKL = t_mara-ZMATKL.
    ZTEST123-zmaktx = t_makt-zmaktx.
    append ZTEST123.
    clear ZTEST123.
    endloop.
    clear E_T_DATA.
    refresh E_T_DATA.
    E_T_DATA[] = ZTEST123[].
    ENDIF.
    S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.
    ENDIF. "Initialization mode or data extractio
    ENDFUNCTION.
    3. Create the data source using transaction (RSO2).
    4. If structure exists for the table parameter of your function module then ok else create a structure for the table parameter ‘E_T_DATA’.
    5. Test the datasource in R/3 using transaction RSA3.
    6. Transfer the data source to BW –System and replicate it in the BW-System.

  • Generics/Abstract class question

    I'm not sure exactly what my problem is here. I am creating an abstract class for a number of other data types that I am creating. The purpose of this class is to track changes so that the GUI can prompt the user to save changes if they try to exit without saving. I want to do this by storing a reference of the original object and then making changes on a new object. I am running into problems though. Right now I am trying to define the clone method in that class and am getting an error.
    public abstract class ChangeableDataType<T extends ChangeableDataType>{
        protected T old;
        public Object clone(){
            T t = new T(); // Error occurs here
            //Stuff
        }The error I get is unexpected type on the line where I try to call a new T(). Is this not something that I can do? I have tried to put any code in that I thought might have the problem.

    No, that isn't something you can do. I'm sure it's discussed in more (and better) detail in [the Generics FAQ|http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html] though.

  • Basic/Generic Loader class (iView, JSP)

    Hello all,
    i wanna create a very basic custom iView. For this i do not wanna build a JSPDynPage, but just wanna use a standard loader class.
    So is there somekinda generic loader class available which i can simply add to the portalapp.xml of my custom iview?
    regards,
    Markus

    You can use JSTL.
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <h2>Hello World!</h2>
            <c:import url="http://www.yahoo.com"/>
        </body>
    </html>

  • Error during creating a new class diagram

    Hi everbody,
    I'm using JDeveloper 10.1.3.3.0 with ADF Faces and Toplink. I'm exposing to an error message in JDeveloper while creating a new class diagram. The error message is shown in dialog and saying "The name of the element can not be set to 'package name' as another element has got the same name in the package". I have controlled the name of the new class diagram. The name is unique in the package. Also I'm creating this new file in the package "tr.com.bilisim.class_diagram" and details part of this error message in dialog also says
    "BME-02002 : The name of the element can not be set to 'class_diagram' as another element has got the same name in the package"
    "BME-02002 : The name of the element can not be set to 'bilisim as another element has got the same name in the package"
    "BME-02002 : The name of the element can not be set to 'com' as another element has got the same name in the package"
    "BME-02002 : The name of the element can not be set to 'tr' as another element has got the same name in the package"
    As I understand from the error message, during creating a new class diagram from 'new file dialog' also tries to create the directories in relevant package (tr.com.bilisim.class_diagram).
    How can I solve this problem? Please urgent help!
    best regards...
    --baris                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    -repost
    please urgent
    --barisk                                                                                                                                                                                                                           

  • Problem with creating my own class...

    Hi all,
    Purpose with this program:
    I want to create my own class StringThing which take a string parameter and transform the content toUpperCase().
    I have created a simple class StringThing which look like this:
    class StringThing {
    public String upperize (String u) {
    u.toUpperCase();
    return u;
    }And my class where I use the StringThing looks like this:
    import java.io.*;
    class UseStringThing{
    public static void main (String arg[]) throws Exception {
    BufferedReader keyboard = new BufferedReader(
    new InputStreamReader(System.in));
    String s,p;
    System.out.prinln("write a sentence!");
    s=keyboard.readLine();
    StringThing thing = new StringThing();
    p=thing.upperize(s);
    System.out.println(p);
    }Am I not supposed to transform my string parameter in my class by using for instance toUpperCase()? Or is there some fundamental rule or piece of code which I forgot?
    Thanks in advance,
    /Beginner-T-who-ripps-his-hear-over-this-small-problem

    Strings cannot be modified. What this line does:
    u.toUpperCase();
    is to create a new String object. toUpperCase() returns the newly created string and you are ignoring the returned value. What you want to do is:
    return u.toUpperCase();
    or
    u = u.toUpperCase();

  • Class override, how to create the child class and then the base class

    I started to write a program for a smart DMM, the problem is every version of the DMM the company change the communication commend.
    My idea is to write a child class for every DMM version and every SubVI of the child will override the base class SubVI.
    My problem is, i want first to create one child class and after i will see every thing is work,  start to create the base class. that way i will see if am thinking the right way.
    My question is
    How can i create a child class and then create the base class and configure the SubVi of the child class to be Override of the base class?
    I tried to search in the property of the class but i didn't see nothing.
    Thanks
    Solved!
    Go to Solution.

    This can be done and I've done it on occasion.
    You simply create the base class with the dynamic dispatch methods you require (connector panes need to be identical to thos of the child class).
    Then set the inheritance of the class to inherit from this base class.  If your method is defined as a dynamic dispatch method in the parent, you'll most likely now have some errors (unless your child method was already DD in which case you might just be OK already).
    To change the inheritance of a class, right-click the properties of the class in your project and select properties.  I believe the ineritance tree is at the lower end of the properties.  Click on the "change inheritance" (or something similar) to choose the class from which you now wish to inherit.
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

  • Need to create a driver class for a program i have made...

    hey guys im new to these forums and someone told me that i could get help on here if i get in a bind...my problem is that i need help creating a driver class for a program that i have created and i dont know what to do. i need to know how to do this is because my professor told us after i was 2/3 done my project that we need at least 2 class files for our project, so i need at least 2 class files for it to run... my program is as follows:
    p.s might be kinda messy, might need to put it into a text editor
    Cipher.java
    This program encodes and decodes text strings using a cipher that
    can be specified by the user.
    import java.io.*;
    public class Cipher
    public static void printID()
    // output program ID
    System.out.println ("*********************");
    System.out.println ("* Cipher *");
    System.out.println ("* *");
    System.out.println ("* *");
    System.out.println ("* *");
    System.out.println ("* CS 181-03 *");
    System.out.println ("*********************");
    public static void printMenu()
    // output menu
    System.out.println("\n\n****************************" +
    "\n* 1. Set cipher code. *" +
    "\n* 2. Encode text. *" +
    "\n* 3. Decode coded text. *" +
    "\n* 4. Exit the program *" +
    "\n****************************");
    public static String getText(BufferedReader input, String prompt)
    throws IOException
    // prompt the user and get their response
    System.out.print(prompt);
    return input.readLine();
    public static int getInteger(BufferedReader input, String prompt)
    throws IOException
    // prompt and get response from user
    String text = getText(input, prompt);
    // convert it to an integer
    return (new Integer(text).intValue());
    public static String encode(String original, int offset)
    // declare constants
    final int ALPHABET_SIZE = 26; // used to wrap around A-Z
    String encoded = ""; // base for string to return
    char letter; // letter being processed
    // convert message to upper case
    original = original.toUpperCase();
    // process each character of the message
    for (int index = 0; index < original.length(); index++)
    // get the letter and determine whether or not to
    // add the cipher value
    letter = original.charAt(index);
    if (letter >='A' && letter <= 'Z')
    // is A-Z, so add offset
    // determine whether result will be out of A-Z range
    if ((letter + offset) > 'Z') // need to wrap around to 'A'
    letter = (char)(letter - ALPHABET_SIZE + offset);
    else
    if ((letter + offset) < 'A') // need to wrap around to 'Z'
    letter = (char)(letter + ALPHABET_SIZE + offset);
    else
    letter = (char) (letter + offset);
    // build encoded message string
    encoded = encoded + letter;
    return encoded;
    public static String decode(String original, int offset)
    // declare constants
    final int ALPHABET_SIZE = 26; // used to wrap around A-Z
    String decoded = ""; // base for string to return
    char letter; // letter being processed
    // make original message upper case
    original = original.toUpperCase();
    // process each letter of message
    for (int index = 0; index < original.length(); index++)
    // get letter and determine whether to subtract cipher value
    letter = original.charAt(index);
    if (letter >= 'A' && letter <= 'Z')
    // is A-Z, so subtract cipher value
    // determine whether result will be out of A-Z range
    if ((letter - offset) < 'A') // wrap around to 'Z'
    letter = (char)(letter + ALPHABET_SIZE - offset);
    else
    if ((letter - offset) > 'Z') // wrap around to 'A'
    letter = (char)(letter - ALPHABET_SIZE - offset);
    else
    letter = (char) (letter - offset);
    // build decoded message
    decoded = decoded + letter;
    return decoded;
    // main controls flow throughout the program, presenting a
    // menu of options the user.
    public static void main (String[] args) throws IOException
    // declare constants
    final String PROMPT_CHOICE = "Enter your choice: ";
    final String PROMPT_VALID = "\nYou must enter a number between 1" +
    " and 4 to indicate your selection.\n";
    final String PROMPT_CIPHER = "\nEnter the offset value for a caesar " +
    "cipher: ";
    final String PROMPT_ENCODE = "\nEnter the text to encode: ";
    final String PROMPT_DECODE = "\nEnter the text to decode: ";
    final String SET_STR = "1"; // selection of 1 at main menu
    final String ENCODE_STR = "2"; // selection of 2 at main menu
    final String DECODE_STR = "3"; // selection of 3 at main menu
    final String EXIT_STR = "4"; // selection of 4 at main menu
    final int SET = 1; // menu choice 1
    final int ENCODE = 2; // menu choice 2
    final int DECODE =3; // menu choice 4
    final int EXIT = 4; // menu choice 3
    final int ALPHABET_SIZE = 26; // number of elements in alphabet
    // declare variables
    boolean finished = false; // whether or not to exit program
    String text; // input string read from keyboard
    int choice; // menu choice selected
    int offset = 0; // caesar cipher offset
    // declare and instantiate input objects
    InputStreamReader reader = new InputStreamReader(System.in);
    BufferedReader input = new BufferedReader(reader);
    // Display program identification
    printID();
    // until the user selects the exit option, display the menu
    // and respond to the choice
    do
    // Display menu of options
    printMenu();
    // Prompt user for an option and read input
    text = getText(input, PROMPT_CHOICE);
    // While selection is not valid, prompt for correct info
    while (!text.equals(SET_STR) && !text.equals(ENCODE_STR) &&
    !text.equals(EXIT_STR) && !text.equals(DECODE_STR))
    text = getText(input, PROMPT_VALID + PROMPT_CHOICE);
    // convert choice to an integer
    choice = new Integer(text).intValue();
    // respond to the choice selected
    switch(choice)
    case SET:
         // get the cipher value from the user and constrain to
    // -25..0..25
    offset = getInteger(input, PROMPT_CIPHER);
    offset %= ALPHABET_SIZE;
    break;
    case ENCODE:
    // get message to encode from user, and encode it using
    // the current cipher value
    text = getText(input, PROMPT_ENCODE);
    text = encode(text, offset);
    System.out.println("Encoded text is: " + text);
    break;
    case DECODE:
    // get message to decode from user, and decode it using
    // the current cipher value
    text = getText(input, PROMPT_DECODE);
    text = decode(text, offset);
    System.out.println("Decoded text is: " + text);
    break;
    case EXIT:
    // set exit flag to true
    finished = true ;
    break;
    } // end of switch on choice
    } while (!finished); // end of outer do loop
    // Thank user
    System.out.println("Thank you for using Cipher for all your" +
    " code breaking and code making needs.");
    }

    My source in code format...sorry guys :)
       Cipher.java
       This program encodes and decodes text strings using a cipher that
       can be specified by the user.
    import java.io.*;
    public class Cipher
       public static void printID()
          // output program ID
          System.out.println ("*********************");
          System.out.println ("*       Cipher      *");
          System.out.println ("*                   *");
          System.out.println ("*                          *");
          System.out.println ("*                   *");
          System.out.println ("*     CS 181-03     *");
          System.out.println ("*********************");
       public static void printMenu()
          // output menu
          System.out.println("\n\n****************************" +
                               "\n*   1. Set cipher code.    *" +
                               "\n*   2. Encode text.        *" +
                               "\n*   3. Decode coded text.  *" +
                               "\n*   4. Exit the program    *" +
                               "\n****************************");
       public static String getText(BufferedReader input, String prompt)
                                           throws IOException
          // prompt the user and get their response
          System.out.print(prompt);
          return input.readLine();
       public static int getInteger(BufferedReader input, String prompt)
                                           throws IOException
          // prompt and get response from user
          String text = getText(input, prompt);
          // convert it to an integer
          return (new Integer(text).intValue());
       public static String encode(String original, int offset)
          // declare constants
          final int ALPHABET_SIZE = 26;  // used to wrap around A-Z
          String encoded = "";           // base for string to return
          char letter;                   // letter being processed
          // convert message to upper case
          original = original.toUpperCase();
          // process each character of the message
          for (int index = 0; index < original.length(); index++)
             // get the letter and determine whether or not to
             // add the cipher value
             letter = original.charAt(index);
             if (letter >='A' && letter <= 'Z')          
                // is A-Z, so add offset
                // determine whether result will be out of A-Z range
                if ((letter + offset) > 'Z') // need to wrap around to 'A'
                   letter = (char)(letter - ALPHABET_SIZE + offset);
                else
                   if ((letter + offset) < 'A') // need to wrap around to 'Z'
                      letter = (char)(letter + ALPHABET_SIZE + offset);
                   else
                      letter = (char) (letter + offset);
             // build encoded message string
             encoded = encoded + letter;
          return encoded;
       public static String decode(String original, int offset)
          // declare constants
          final int ALPHABET_SIZE = 26;  // used to wrap around A-Z
          String decoded = "";           // base for string to return
          char letter;                   // letter being processed
          // make original message upper case
          original = original.toUpperCase();
          // process each letter of message
          for (int index = 0; index < original.length(); index++)
             // get letter and determine whether to subtract cipher value
             letter = original.charAt(index);
             if (letter >= 'A' && letter <= 'Z')          
                // is A-Z, so subtract cipher value
                // determine whether result will be out of A-Z range
                if ((letter - offset) < 'A')  // wrap around to 'Z'
                   letter = (char)(letter + ALPHABET_SIZE - offset);
                else
                   if ((letter - offset) > 'Z') // wrap around to 'A'
                      letter = (char)(letter - ALPHABET_SIZE - offset);
                   else
                      letter = (char) (letter - offset);
             // build decoded message
             decoded = decoded + letter;
          return decoded;
       // main controls flow throughout the program, presenting a
       // menu of options the user.
       public static void main (String[] args) throws IOException
         // declare constants
          final String PROMPT_CHOICE = "Enter your choice:  ";
          final String PROMPT_VALID = "\nYou must enter a number between 1" +
                                      " and 4 to indicate your selection.\n";
          final String PROMPT_CIPHER = "\nEnter the offset value for a caesar " +
                                       "cipher: ";
          final String PROMPT_ENCODE = "\nEnter the text to encode: ";
          final String PROMPT_DECODE = "\nEnter the text to decode: ";
          final String SET_STR = "1";  // selection of 1 at main menu
          final String ENCODE_STR = "2"; // selection of 2 at main menu
          final String DECODE_STR = "3"; // selection of 3 at main menu
          final String EXIT_STR = "4";  // selection of 4 at main menu
          final int SET = 1;            // menu choice 1
          final int ENCODE = 2;         // menu choice 2
          final int DECODE =3;          // menu choice 4
          final int EXIT = 4;           // menu choice 3
          final int ALPHABET_SIZE = 26; // number of elements in alphabet
          // declare variables
          boolean finished = false; // whether or not to exit program
          String text;              // input string read from keyboard
          int choice;               // menu choice selected
          int offset = 0;           // caesar cipher offset
          // declare and instantiate input objects
          InputStreamReader reader = new InputStreamReader(System.in);
          BufferedReader input = new BufferedReader(reader);
          // Display program identification
          printID();
          // until the user selects the exit option, display the menu
          // and respond to the choice
          do
             // Display menu of options
             printMenu(); 
             // Prompt user for an option and read input
             text = getText(input, PROMPT_CHOICE);
             // While selection is not valid, prompt for correct info
             while (!text.equals(SET_STR) && !text.equals(ENCODE_STR) &&
                     !text.equals(EXIT_STR) && !text.equals(DECODE_STR))       
                text = getText(input, PROMPT_VALID + PROMPT_CHOICE);
             // convert choice to an integer
             choice = new Integer(text).intValue();
             // respond to the choice selected
             switch(choice)
                case SET:
                // get the cipher value from the user and constrain to
                   // -25..0..25
                   offset = getInteger(input, PROMPT_CIPHER);
                   offset %= ALPHABET_SIZE;
                   break;
                case ENCODE:
                   // get message to encode from user, and encode it using
                   // the current cipher value
                   text = getText(input, PROMPT_ENCODE);
                   text = encode(text, offset);
                   System.out.println("Encoded text is: " + text);
                   break;
                case DECODE:
                   // get message to decode from user, and decode it using
                   // the current cipher value
                   text = getText(input, PROMPT_DECODE);
                   text = decode(text, offset);
                   System.out.println("Decoded text is: " + text);
                   break;
                case EXIT:
                   // set exit flag to true
                   finished = true ;
                   break;
             } // end of switch on choice
          } while (!finished); // end of outer do loop
          // Thank user
          System.out.println("Thank you for using Cipher for all your" +
                             " code breaking and code making needs.");
    }

  • Problem in creating a Persistent Class

    Hi All,
    I am working on Persistent Classes for the first time. I have tried to gain some info by going through some related threads and of course Thomas' Blog on Persistent Classes.
    My Problem:
    I have been trying to create a Persistent Class that takes fields from multiple database tables (KNA1 and KNVV).
    I wasn't able to generate mapping successfully.
    So, the solution was to create 2 Persistent Classes and create a data model class for these two (It was mentioned in one of the threads)
    I have been trying to create a Persistent Class for the fields from table KNA1 (I need only some 11 fields)
    When I activate, I again get a warning 'No mapping exists for the fields' as a result of which the main class is not activated.
    I read somewhere that all fields from a table needs to be included in the 'Inclusion area', otherwise, the class doesn't activate.
    So I tried creating a view, but I get another warning message saying 'Database operations with view are not allowed' and the main class remains unactivated.
    Please suggest.
    Also, if there are any related materials on how to deal with multiple tables, I would be more than glad.
    Thanks for all your time.

    If you are creating a persistent class for SAP tables, then effectively you are attempting to update the tables directly.  And that is a really bad idea.
    See [here|regarding updation of database table...; and [here |Important points to be cautios of when updating a standard table; for more discussion on that topic.
    Only create persistent classes for database operations on your own tables.
    I guess your classes are failing because you haven't done the mapping.  Did you click on the button marked "persistence" on the SE24 view of your ZCL class?
    matt
    One more thing - it's against the forum rules to ask for material and links...

  • Create a new class in pe51 form layout

    Hi experts,
                   I want to create a new form  layout in pe51 for payroll register. In standard form class maximum columns is 132 but i want
    more than 300 columns for payroll register. so its possible to to create new zform class in pe51. If its possible pls guide me.
    Thanks in advance.
    Thanks & Regards
    G.Vendhan

    Hi, I am working on the same thing and created a form in PE51 using Form class CKT0 which gives me 255 columns.  I am however having problems with finding some of the fields I need.
    Thanks.
    N

  • ?Is it possible to create a javafx class without extending Application class ? If yes, how

    Is it possible to create a javafx class without extending Application class ? If yes, how ?

      There is no  such thing as a javafx  class.  It is a regular  java class.  The Aapplication class is  the entry
    point  for JavaFX application.  You have to extend the Application class to create Javafx  application .

  • How to create a Calendar Class in Universe.

    I want to create a Calendar class which will further contain Year,Quarter,Month,Day,Week Objects which can be used at report level.
    In our database we have different dates in " DD/MM/YYYY:hh:min:ss " format.
    I would like to know if this can be used to create a new Calendar Object or do I need a different table in DB like Calendar look up table provided in sample efashion universe?
    Help appreciated.

    Hi,
    Sorry for the delay in coming back - I had no access yesterday.
    I am not sure what you mean. If you have a lookup table, then you create views/aliases of this table for each of the dates you want to use it for.
    So f your transaction record contains original date and paid_date
    you would create a
    original_date_view as select * from calendar_lookup
    paid_date_view as select * from calendar_lookup
    these views could then be joined to the orginal_date and paid_date fields in your transaction table.
    In the universe you would then expose 2 classes, which contained the same objects.
    Original_date
    Date,
    Day,
    Month,
    Year
    etc
    Paid_date
    Date,
    Day,
    Month,
    Year
    etc
    If you are not using the lookup then you would have to code each date object based on the transaction date field
    So Day in orignal_date would be to_char(txn.original_date, "dd")
    while Day in Paid_date would be to_char(txn.paid_date, "dd")
    Hope this helps
    Alan

  • BI : Error while creating generic datasource

    Hi Experts,
    While creating the generic DS , It is giving the me the below error:
    :Invalid extract structure template ZFI_AGED_TR_BAL of DataSource ZFI_AGED_BALANCE". Kindly advise.
    thanks & regards,
    M.S

    Hi ,
    I am creating Generic DS on Extract stucutre ZFI_AGED_TR_BAL.
    It is containing the below fields as currency fields which is referrering to table T001.Kindly advise how should i include the currency field.
    Field,Data Element,Datatype,Ref table,ref field , description
    BUCK2,DMBTR,CURR,T001,WAERS,Amount in Local Currency
    Thanks & regards,
    M.S

Maybe you are looking for

  • Which version of an object is included in a transport request

    Hi experts, I have one doubt regarding the transport requests and the object versions included in it. We've found in one development that there are differences between the development system and the productive system and all the transport requests, w

  • Using Imac as hub?

    Hi folks! I was wondering if it's possible to use my iMac as a hub to connect to my xbox360 on internet Thanks Aeterna

  • Export PDF Graphic

    I need to Extract a PDF graphic, crop and save as a new PDF. Not sure how to do this. Can anyone help me out with this?

  • SYBASE ZFD 3 OBDC USER NAME AND PASSWORD

    I am trying to get an OBDC hook for a Access front end and I keep gettin Invalid User ID or Password. I installed the Sybase Driver with a NAL, I even had the OBDC send to a text file so I could look at it. It finds a database and links but it cannot

  • Understanding Throughput Numbers on ASA5585-X series

    I'm in the evalation process to upgrade from an ASA5580, which at peak is handling 5 Gbps download and 2 Gbps upload I want to be sure I'm understanding the numbers on the ASA5585-X data sheet correctly. Looking at the ASA5585-S40 for example, these