BIN to ASCII

Hi Gurus,
I would like to clarify. I understand that if I am attaching a file to the email that will be sent by SAP, it in ASCII format. Am I correct?
Or the format is not relevant if the email is attachment or not?
I am having a problem, when I used the CONTENT_TXT which is the text in the email (not attachment), the message is correct.
Example.
I should get the following data with 3 lines because it is 3 records.
A
B
C
But when I used the attachment type, I am getting
A                                        B                                        C
Which I believe that it is in BIN format.
Is there a possibility that I can change the format to ASCII and send it with ATTACHMENT?
Here is my code:
REPORT  ZGLTEST.
DATA: objpack LIKE sopcklsti1 OCCURS  2 WITH HEADER LINE.
DATA: objhead LIKE solisti1   OCCURS  1 WITH HEADER LINE.
DATA: objbin  LIKE solisti1   OCCURS 10 WITH HEADER LINE.
*DATA: objtxt  LIKE solisti1   OCCURS 10 WITH HEADER LINE.
DATA: reclist LIKE somlreci1  OCCURS  5 WITH HEADER LINE.
DATA: doc_chng LIKE sodocchgi1.
DATA: tab_lines LIKE sy-tabix.
Creating the document to be sent
*doc_chng-obj_name = 'OFFER'.
doc_chng-obj_descr = 'Description'.
Creating the document attachment
(Assume the data in OBJBIN are given in BMP format)
objbin = 'ACT'.
APPEND objbin.
objbin = ' | '.
APPEND objbin.
objbin = '/ \'.
APPEND objbin.
DESCRIBE TABLE objbin LINES tab_lines.
objhead = '2007_016_FR10_HFM_SFeRE.txt'.
APPEND objhead.
Creating the entry for the compressed attachment
objpack-transf_bin = 'X'.
*clear objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num   = 1.  "1.
objpack-body_start = 1.
objpack-body_num   = tab_lines.
objpack-doc_type   = 'RAW'.
*objpack-doc_type   = 'TXT'.
*objpack-doc_type   = 'CSV'.
objpack-obj_name   = 'ATTACHMENT'.
objpack-obj_descr = 'Reproduction object 138'.
objpack-doc_size   = 240. "tab_lines * 255.
APPEND objpack.
Entering names in the distribution list
reclist-receiver = 'E-mail address'.
reclist-rec_type = 'U'.
APPEND reclist.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
  EXPORTING
    document_data              = doc_chng
    put_in_outbox              = 'X'
    commit_work                = 'X'
  TABLES
    packing_list             = objpack
    object_header          = objhead
    CONTENTS_BIN      = objbin
    receivers                 = reclist
  EXCEPTIONS
    too_many_receivers         = 1
    document_not_sent          = 2
    operation_no_authorization = 4
    OTHERS                     = 99.
CASE sy-subrc.
  WHEN 0.
    WRITE: / 'Result of the send process:'.
    LOOP AT reclist.
      WRITE: / reclist-receiver(48), ':'.
      IF reclist-retrn_code = 0.
        WRITE 'sent successfully'.
      ELSE.
        WRITE 'not sent'.
      ENDIF.
    ENDLOOP.
  WHEN 1.
    WRITE: / 'no authorization to send to the specified number of', 'recipients!'.
  WHEN 2.
    WRITE: / 'document could not be sent to any of the recipients!'.
  WHEN 4.
    WRITE: / 'no authorization to send !'.
  WHEN OTHERS.
    WRITE: / 'error occurred during sending !'.
ENDCASE.
Is the <b>objpack-transf_bin</b> tells the SAP that it will be an attachment?
Thanks in advance.
Benedict

Also, is there a FM to convert the BIN format to ASCII format?
Or, is there an a way that I can input an "ENTER" character to separate the records that will be inputed in the attachment?
Thanks.
Benedict

Similar Messages

  • How to upload in ASCII format

    I need to learn how to upload a .pl to the cgi-bin in ASCII
    format. Is there a way to get Dreamweaver8 to do this
    automatically?
    Thanks
    chartoonz

    > I need to learn how to upload a .pl to the cgi-bin in
    ASCII format. Is there
    > a way to get Dreamweaver8 to do this automatically?
    It should happen automatically. Have you tried?
    What was the result?
    If the Perl file doesn't work when uploaded- what exactly are
    the error
    messages? Much more likely to be a problem is saving a Perl
    file with
    windows linebreaks and uploading it to a Linux server.
    Alan
    Adobe Community Expert, dreamweaver
    http://www.adobe.com/communities/experts/

  • Trying to Arch-Chroot after messing up an update, can't run /bin/bash

    Hey guys,
    I made so absolutely dumb errors recently I just haven't been sound in mind.
    So I'm updating my system after months and I'm doing what is described here https://www.archlinux.org/news/binaries … ervention/
    My first mistake is when I forgot to do pacman -S bash and pacman -Su  after doing pacman -Syu --ignore filesystem,bash in the last section. So I had to chroot into my system to do the last 2 updates.
    I chrooted in and succesfully updated bash. But then I forgot to do pacman -Su! So my filesystem is still not updated haha...
    Well I tried to chroot in again to do the last update, and now I get this error.
    chroot: failed to run command (block ascii)/bin/(block ascii)sh(block ascii): No such file or directory.
    Which probably actually reads as /bin/bash: no such file or directory.
    I'm not sure how to fix this issue with bash. As I said I updated bash without updating the filesystem when I chrooted...hoping someone knows what I can do.
    Thanks!

    Either point it to /usr/bin/bash (arch-chroot /mnt /usr/bin/bash) or just update from outside the chroot (pacman --root /mnt -Su)
    Last edited by Scimmia (2013-08-26 03:22:11)

  • How to remove the ^M character?

    I'm porting applications from Windows to Solaris. My cpp programs failed to compile in some cases because of the ^M characters at the end of each line. Does anyone know how to remove them systematically? The applicaiton has hundreds of files. It's pratically impossible to use text editor to chop it off.

    Here is a useful little script I wrote. It needs to be in your $PATH because it is mildly recursive...
    #!/bin/sh
    if [ "$1" = "" -o "$1" = "-h" ]; then
    cat 1>&2 << END_OF_HELP_TEXT
    USAGE: crlf [-h] <file | directory> [...]
    OPTIONS: -h Display this help text
    DESCRIPTION: The specified files are converted from
    DOS to UNIX format, regardless of file
    type, as described in the notes section.
    The specified directories are descended
    recursively, but only the following
    file types are converted by default:
    Makefile, makefile, \*.mk, \*.gmk,
    \*.h, \*.c, \*.cpp
    NOTES: The DOS to UNIX file conversion implies
    at least the following changes:
    1. Make the file writable (chmod u+w)
    2. Strip carriage returns (0x0d)
    3. Terminate with a line feed (0x0a)
    END_OF_HELP_TEXT
    exit 1
    fi
    while [ "$1" != "" ]
    do
    if [ -f "$1" ]; then
    # Get permissions
    permissions="u+w"
    if [ -x "$1" ]; then
    permissions="$permissions"x
    fi
    # Convert the specified file
    /usr/bin/echo "$1"
    /usr/bin/chmod u+w "$1"
    /usr/bin/dos2unix -ascii "$1" "$1" 2>/dev/null
    offset=`ls -l "$1" 2>/dev/null | awk '{ print $5 }' 2>/dev/null`
    offset=`expr "$offset" - 1 2>/dev/null`
    if [ "$offset" -ge "0" ]; then
    terminator=`od -x -j "$offset" "$1" 2>/dev/null | head -1 2>/dev/null`
    if [ "$terminator" != "0000000 0a00" -a "$terminator" != "" ]; then
    echo "" 1>>"$1" 2>/dev/null
    fi
    fi
    # Set permissions
    /usr/bin/chmod "$permissions" "$1" 2>/dev/null
    else
    # Convert all source files in the specified directory
    /usr/bin/find "$1" -follow -a -type f -a \
    \( -name "[M,m]akefile" -o -name "*.mk" -o -name "*.gmk" \
    -o -name "*.h" -o -name "*.c" -o -name "*.cpp" \) \
    -exec crlf {} \;
    fi
    shift
    done
    exit 0

  • What is the diffrence between ASCII and BIN mode

    Hello All,
    What is the diffrence between ASCII and BIN mode
    Regards,
    Lisa.

    'ASC' :
    ASCII format. The table is transferred as text. The conversion exits are
    carried out. The output format additionally depends on the parameters
    CODEPAGE, TRUNC_TRAILING_BLANKS, and TRUNC_TRAILING_BLANKS_EOL.
    'IBM' :
    ASCII format with IBM codepage conversion (DOS). This format correspond
    to the 'ASC' format when using target codepage 1103. This codepage is
    often used for data exchange by disc.
    'DAT' :
    Column-by-column transfer. With this format, the data is transferred as
    with ASC text. However, no conversion exists are carried out and the
    columns are separated by tab characters. This format creates files that
    can be uploaded again with gui_upload or ws_upload.
    'DBF' :
    The data is downloaded in dBase format. Because in this format the file
    types of the individual columns are included, import problems, for
    example, into Microsoft Excel can be avoided, especially when
    interpreting numeric values.
    'WK1' :
    The data is downloaded in Lotus 1-2-3 format.
    'BIN' :
    Binary format. The data is transferred in binary format. There is no
    formatting and no codepage conversion. The data is interpreted row by
    row and not formatted in columns. Specify the length of the data in
    parameter BIN_FILESIZE. The table should consist of a column of type X,
    because especially in Unicode systems the conversion of structured data
    into binary data leads to errors.

  • Converting bin files from LV 2 (on a Mac) to ASCII

    I inherited a large number of data files that were collected on an Apple Quadra 950 using LV 2, and I need to convert them to an ASCII format.  We've tried the Read Binary Files.vi that comes with LV, and found out that (in 1993), LV was in Big Endian format, but even with that, we don't get the data we expect.  I don't have the .vi or the lab notebook this was collected on.  We have installed LV 8 on a Mac running pre-OS X.
    Thanx!
    Dawn R

    All is big endian. This is nice a simple!
    You have:
    21 byte text header (DATA:ADAMS 1.10\r****\r in this case)
    2x I32, designating the 2D dimension of the data (13x12000 in this case)
    I32 data starting at position 29. This needs to be reshaped to 2D according to (point 2).
    (There are only 13 plots, so disregard the legend size )
    Message Edited by altenbach on 11-20-2007 09:42 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    LV2binary.png ‏52 KB

  • Text to binary (.txt to .bin)

    Hello,
    I'm developing an application on J2ME that needs to read from files.
    I want to use binary files instead text files, because I think that in this way I have two benefits:
    1. reducing the jar size
    2. speeding up the reading process.
    that's the starting point...and I hope this approach is right.
    I've developed a small class in J2SE just as an utility to convert .txt files in .bin files and...GULP!!!...a txt file of 22KB becomes 44KB converted in .bin...there is something wrong, but I don't know.
    here is the code I wrote:
    package texttobin;
    import java.io.*;
    public class Main {
        public static void main(String[] args) {
            File inFile  = null;    //the file to read
            File outFile = null;    //the file to write
            //read the path from commandline
            if (args.length > 0)
                inFile = new File(args[0]);
                outFile = new File(args[1]);
            //some checkings
            if (inFile == null) return;
            if (outFile == null) return;
            try {
                //setup the streams
                FileOutputStream outputStream = new FileOutputStream (outFile);
                DataOutputStream dataOutputStream = new DataOutputStream (outputStream);
                FileInputStream sourceStream = new FileInputStream(inFile);
                byte readingByte[] = new byte[1];
                while(true) {
                    if (sourceStream.read(readingByte)!=-1) {
                        //to be sure: I convert the readed input byte in a string
                        //and pass the char inside to the writeChar method...
                        dataOutputStream.writeChar(new String(readingByte).charAt(0));
                        //the same result is achieved with:
                        //dataOutputStream.writeChars(new String(readingByte));
                    else break;
                dataOutputStream.close();
                outputStream.close();
                sourceStream.close();
            catch(FileNotFoundException fnfe)
                System.out.println (fnfe);
                return;
            catch(IOException ioe)
                System.out.println (ioe);
                return;
    }WHAT'S WRONG?!
    THANKS A LOT!!!
    daniele

    ZIP it or use a 7-bit encoding scheme (which isn't
    easy). As for faster reading: you need to see that
    the decoding of your file format doesn't take more
    time than the reading of an unencoded format would
    take.Yes, you're right, but I thought that the bottleneck is the reading process, not the decoding algorhytm (hopefully!!!)
    I found an article that say:
    An ASCII file is a binary file that stores ASCII codes. Recall that an ASCII code is a 7-bit code stored in a byte. To be more specific, there are 128 different ASCII codes, which means that only 7 bits are needed to represent an ASCII character.
    However, since the minimum workable size is 1 byte, those 7 bits are the low 7 bits of any byte. The most significant bit is 0. That means, in any ASCII file, you're wasting 1/8 of the bits. In particular, the most significant bit of each byte is not being used.
    http://www.cs.umd.edu/class/spring2003/cmsc311/Notes/BitOp/asciiBin.html
    (and sorry for the mistake: 7-bit not 7 bytes!!!)
    another intrested thing I've found is here:
    http://www2.sys-con.com/ITSG/virtualcd/Java/archives/0607/heaton/index.html
    there is some ways to store strings in bin files (like fstream in C++), but I didn't tested yet if in this way I can reduce the size of the bin.
    The files are stored in the jar file, then zipping maybe can reduce more the size of the jar, but I think that when the stream opens it takes the real bytes of the contained text (well...I'm not sure...may you confirm it?)
    thank you.

  • No Bin directory in ORACLE_HOME\CTX.

    Hi,
    I've installed Oracle 8i EE on Redhat 6, and in
    oracle_home\CTX\ directory, the bin directory is missing. I need
    the executable file ctxhx which is in the bin directory.
    I 've installed all interMedia options in my Oracle8i
    installation.
    Can someone help me ??
    Thanks
    Bart
    null

    Bart (guest) wrote:
    : Hi,
    : I've installed Oracle 8i EE on Redhat 6, and in
    : oracle_home\CTX\ directory, the bin directory is missing. I
    need
    : the executable file ctxhx which is in the bin directory.
    Oracle Intermedia Text
    This looks like a part of INSO filters which are provided
    with context/intermedia on some other platfoms. If this is so,
    then from 8.1.5 (linux) release notes:
    The third party filters to extract pertinent ASCII information
    from documents being indexed are not provided by Oracle
    Intermedia Text for the Intel-Linux platform.Maybe there are licensing issues with those, maybe INSO doesn't
    have a linux version - I don't know.
    Andre
    null

  • Upgrading from asa711-k8.bin to asa 721-k8.bin error

    when i am trying to upgrade to the new image i get this error
    test(config)# boot config disk0:/asa721-k8.bin
    ERROR: Unable to set this url, file has non-ASCII characters

    Hi,
    I believe this error message is occurred because the command is not put in the right order.
    I've tested a few times in GNS3 and I believe the right sequences are as follows:
    enable config t copy run disk0:/.private/startup-config boot config disk0:/.private/startup-config wr mem
    I hope this helps.
    Btw, I've also documented it here.
    http://firewallengineer.wordpress.com/2012/05/06/solved-error-unable-to-set-this-url-file-has-non-ascii-characters/

  • ASCII Mode Connection & FTP LIST command

    Hi All,
    I want to realize a simple Java FTP Client. At the beginning I tought to write a dir/file listing method, but I have no less difficulties to do it.
    As RFC says LIST is the appropriate command to be implemented.
    As I read RFC I should to open an ASCII Mode Connection but I don't know How.
    Connecting some ftp Server and sending it a "LIST" command I receive these replyes:
    331 User name okay, need password.
    230 User logged in, proceed.
    150 Opening ASCII mode data connection for /bin/ls.
    426 Data connection closed, transfer aborted.
    So, after 150 I should receive directory content, but it doesn't work. On the other side, if I want to send "HELP" command, using readLine() method I can display all reply from server.
    How can I make directory listing for my FTP Client?
    Thanks a lot...

    I prefer fireftp, but yea thats what I use to do any sort of ftp with the crio. At the time I was testing it I was able to log onto the ftp server of the crio, list directory and do get and put operations. Good to hear its working fine for you though.
    Looks like the device is having problems now (has become completely unresponsive) and is deployed 350 miles from here so we have some new problems to deal with. Maybe it was the device, I am not sure but I guess this is on hold until the device is back up.
    [will work for kudos]

  • How to store binary files into ascii files

    I need to record Data with sampling rate of 100kHz and for that reason I saved this data as a .bin. In principle this file should consist of two rows, the time and the data (voltage) domain with an ?resolution? of 16 bit. For my analysis I need this files as an ASCII file. I´m an absolute rookie in Programming (and LabView as well) and so far unable to slove this problem...can anyone help me?

    Hola,
    I´m still waiting for the computer I have ordered for my setup, but anyway I have borrowed one...2 GB Ram and a 3.00 GHz Pentium 4, not the worst I guess.
     To acquire the data I´m using the PCIe 6251M Series DaqCard and a BNC 2120 Connector Block.
    Corresponding the example “Graph Acquired Binary Data”. Yes it is possible to display the saved data from the .bin file, but this does not help me to convert it into an txt (ascii) file.
    So far I´m unable to use the “array to spreadsheet string” function in a proper, working way...I think I have to lern more about the way it has to be programmed....
    Tituriel

  • DIY ASCII animation splash screen!

    I don't startx automatically, but I like flashing colours and ASCII art. Hence, I decided to make some ascii animations to spruce up my tty at logon.
    Obligatory video link (watch in HD, the frames flash by too fast to look good at 360p)
    Here's how I did it, there are probably better ways, but I'm here to learn as well.  Please share with me your ineffable wisdom with me.  Limitations: requires a directory full of .jpegs, only works from sysinit_end to shutdown_start unless you hard-code the art into the function file a la 2.b (due to parsing of the jpeg files in a mounted dir).
    0. Install jp2a from the AUR.
    1. Use ffmpeg to extract .jpeg frames from a small portion of the video
    ffmpeg -i foo.avi -t 40 -ss 00:00:00.00 foo-%d.jpeg
    Where -t is the duration to be extracted in seconds, and -ss is the point at which to start recording (hh:mm:ss.ms).  Doesn't have to be .avi!
    2a. the easy way
    For startup / shutdown splashes, create a file in functions.d:  /etc/rc.d/functions.d/animation
    Modify this here to include your directory with the pictures and the maximum number of lines your tty can display without distorting the output.
    add_hook sysinit_end evasplash1
    add_hook shutdown_start evasplash2
    evasplash1() {
    for f in /home/eqyiel/scripts/evasplash1/*.jpeg
    do
    jp2a --colors --height=55 $f
    echo -ne '\033[55F'
    sleep 0.01
    done
    echo -ne '\033[55E'
    evasplash2() {
    for f in /home/eqyiel/scripts/evasplash2/*.jpeg
    do
    jp2a --colors --height=55 $f
    echo -ne '\033[55F'
    sleep 0.0001
    done
    echo -ne '\033[55E'
    Pay special attention to --height and the two escape codes, \033[55F and \033[55E.
    --height is the maximum height in lines of your tty
    '\033[55F' means "position the cursor 55 lines above where it is right now or at the top of the screen if there are <55 lines to the top"
    '\033[55E' means "position the cursor 55 lines below where it is right now or at the bottom of the screen if there are <55 lines to the bottom"
    The escape codes must be expressed in literals and echo needs the -e switch to enable interpretation of backslash escapes.
    You may want to test this out in a shell script before rebooting your computer, a la:
    #!/bin/bash
    while [ 1 ]
    do
    for f in /home/eqyiel/scripts/evasplash1/*.jpeg
    do jp2a --colors --height=55 $f
    echo -ne '\033[55F'
    sleep 0.01
    done
    echo -ne '\033[55E'
    done
    For a login splash, just add the code to the end of your /etc/profile:
    for f in /home/eqyiel/scripts/dbsplash/*.jpeg
    do jp2a --colors --height=55 $f
    echo -ne '\033[55F'
    sleep 0.0001
    done
    echo -ne '\033[55E'
    2b. the hard way (for the truly masochistic)
    Use jp2a to extract raw ANSI data from the .jpeg frames you have created:
    for f in *.jpeg; do jp2a -v --colors --height=55 $f > $f.txt; done
    This will create a whole bunch of files full of ANSI escape sequences.  Now, open up your preferred editor and import the files one by one, stitching them together in this fashion:
    #!/bin/bash
    while [ 1 ]
    do
    sleep=.1
    echo -ne '╔═══╗
    ║* ║
    ║ ║
    ║ ║
    ╚═══╝
    sleep $sleep
    echo -ne '\033[5F╔═══╗
    ║ * ║
    ║ ║
    ║ ║
    ╚═══╝
    sleep $sleep
    echo -ne '\033[5F╔═══╗
    ║ *║
    ║ ║
    ║ ║
    ╚═══╝
    sleep $sleep
    echo -ne '\033[5F╔═══╗
    ║ ║
    ║* ║
    ║ ║
    ╚═══╝
    sleep $sleep
    echo -ne '\033[5F╔═══╗
    ║ ║
    ║ * ║
    ║ ║
    ╚═══╝
    sleep $sleep
    echo -ne '\033[5F╔═══╗
    ║ ║
    ║ *║
    ║ ║
    ╚═══╝
    sleep $sleep
    echo -ne '\033[5F╔═══╗
    ║ ║
    ║ ║
    ║* ║
    ╚═══╝
    sleep $sleep
    echo -ne '\033[5F╔═══╗
    ║ ║
    ║ ║
    ║ * ║
    ╚═══╝
    sleep $sleep
    echo -ne '\033[5F╔═══╗
    ║ ║
    ║ ║
    ║ *║
    ╚═══╝
    echo -ne '\033[5F'
    sleep=.1
    done
    You'll need to transpose it to the notation in functions.d, with the functions() {listed like this}. I'm thinking there's an easier way to do this with the directory full of .txt files, like a clever `cat`, please tell me how if you know.
    Note:
    The "archlinux" /etc/issue prompt was made by Ali Gündüz or "gnufs" as he is known on this board.
    I played no part in the creation of Dragon Ball or Evangelion, I only extracted a few frames from each to test this idea.
    See:
    http://aligunduz.org/
    https://bbs.archlinux.org/search.php?ac … r_id=26003
    Inspired by:
    https://bbs.archlinux.org/viewtopic.php?id=50845
    http://www.youtube.com/watch?v=cfuVLYysY2Q
    http://www.youtube.com/watch?v=3shEw8UWETA

    Wow, that looks really cool, even if it needs a bit work. Now I just need a nice video to play

  • /usr/bin/diff problem

    Hi,
    we just migrated one of our apps from Solaris 8 to Solaris 10.
    One issue we noticed is the following:
    Once a day an RCS-controlled ASCII text configuration database is being updated. This file has a size of about 260 MB.
    As per normal RCS procedure, before the new file is checked in, it's being compared to the old version using /usr/bin/diff.
    On the old Server (Netra T4, Solaris 8) the diff was running for about 15 Minutes.
    On the new Server (V245, Solaris 10) the diff now takes 2 1/2 hours !!
    I haven't found an obvious cause for this, so I was thinking about using dtrace to find out why the diff on the new server is taking that long.
    On the other side, I don't have much experience with dtrace yet....
    I would very much appreciate any help you could offer to help me find the problem.
    thanks
    --Marc                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    In the future, you might consider asking Unix and Terminal oriented questions in the Mac OS X Technologies > Unix Forum
    <http://discussions.apple.com/forum.jspa?forumID=735>

  • Help with binary to decimal, binary to hex, and hex to ascii or ascii to hex program

    I decided to do a program that will do binary to decimal, binary to hex, and hex to ascii for a project related to a java programming course, which only needs to perform features from chapters 1-6 and 8 of Tony Gaddis's book. The functions work fine as their own main programs out side of this combined effort, so can anyone help me determine why I get the following 41 errrors saying: class, interface, or enum expected as well as any other errors that may show up afterwards because I'm stumped. My flowcharts, which have to be revised after discovering that my previous function were logically incorrect after running them in their own main are attached below as the spec sheet.
    My code is as follows and I hope you don't mind the commented lines of unused code because I'm not sure where I want things and what I want at the moment:
    import java.util.Scanner;
    import java.io.*;
    import java.lang.*;
    public class BintoDectoHextoAscii
       public static void main(String[] args)throws IOException
          Scanner input = new Scanner(System.in);
          System.out.println("Enter a binary number: ");
          String binary = input.nextLine(); // store input from user
         if (binary == input.nextLine())
          //int i= Integer.parseInt(hex,2);
          //String hexString = Integer.toHexString(i);
          //System.out.println("Hexa decimal: " + hexString);
          //int finaldecimalvalue = binaryToDecimal(hexString);
          int finaldecimalvalue = binaryToDecimal(hexString);
         if (binary != input.nextLine())
          String hexInput; // The variable Bin Input declared as the datatype int to store the Binary value  
          // Create a Scanner object for keyboard input.
          //Scanner keyboard = new Scanner(System.in);
          // Get the number of binary files.
          System.out.print("Enter the Hex value: ");
          hexInput = keyboard.nextLine();
          System.out.println("Original String: "+ hexInput);
          //String hexEquivalent = asciiToHex(demoString);
          String hexEquivalent = asciiToHex(hexInput);
          //Hex value of original String
          System.out.println("Hex String: "+ hexEquivalent);
          String asciiEquivalent = hexToASCII(hexEquivalent);
          //ASCII value obtained from Hex value
          System.out.println("Ascii String: "+ asciiEquivalent);String finalhexOutput = HextoAsciiConverter(hexEquivalent);
         if (binary != input.nextLine() && hexInput != keyboard.nextLine())
             BufferedReader binInput = new BufferedReader(new InputStreamReader(System.in));
             System.out.println("Enter the Binary number:");
             String hex = binInput.readLine();
             //String finaldecimalvalue = binaryToDecimal(decimal);
             //long finalhexvalue = BinaryToHexadecimal(num);
             long finalhexvalue = BinaryToHexadecimal();
       public static String BinaryToHexadecimal(String hex)
          //public static void main(String[] args)throws IOException
             //BufferedReader bf= new BufferedReader(new InputStreamReader(System.in));
             //System.out.println("Enter the Binary number:");
             //String hex = binInput.readLine();
             long num = Long.parseLong(hex);
             long rem;
             while(num > 0)
             rem = num % 10;
             num = num / 10;
             if(rem != 0 && rem != 1)
             System.out.println("This is not a binary number.");
             System.out.println("Please try once again.");
             System.exit(0);
             int i= Integer.parseInt(hex,2);
             String hexString = Integer.toHexString(i);
             System.out.println("Hexa decimal: " + hexString);
          return num.tolong();
      //int i= Integer.parseInt(hex,2);
      //String hexString = Integer.toHexString(i);
      //System.out.println("Hexa decimal: " + hexString);
    //} // end BintoDectoHextoAsciil
       //public static String HexAsciiConverter(String hextInput)
          // Get the number of binary files.
          //System.out.print("Enter the Hex value: ");
          //hexInput = keyboard.nextLine();
          //System.out.println("Original String: "+ hexInput);
          //String hexEquivalent = asciiToHex(demoString);
          //String hexEquivalent = asciiToHex(hexInput);
          //Hex value of original String
          //System.out.println("Hex String: "+ hexEquivalent);
          //String asciiEquivalent = hexToASCII(hexEquivalent);
          //ASCII value obtained from Hex value
          //System.out.println("Ascii String: "+ asciiEquivalent);
       //} // End function  
       private static String asciiToHex(String asciiValue)
          char[] chars = asciiValue.toCharArray();
          StringBuffer hex = new StringBuffer();
          for (int i = 0; i < chars.length; i++)
             hex.append(Integer.toHexString((int) chars[i]));
          return hex.toString();
       private static String hexToASCII(String hexValue)
          StringBuilder output = new StringBuilder("");
          for (int i = 0; i < hexValue.length(); i += 2)
             String str = hexValue.substring(i, i + 2);
             output.append((char) Integer.parseInt(str, 16));
          return output.toString();
       public static String binaryToDecimal(String binary)
            //Scanner input = new Scanner(System.in);
            //System.out.println("Enter a binary number: ");
            //String binary = input.nextLine(); // store input from user
            int[] powers = new int[16]; // contains powers of 2
            int powersIndex = 0; // keep track of the index
            int decimal = 0; // will contain decimals
            boolean isCorrect = true; // flag if incorrect input
           // populate the powers array with powers of 2
            for(int i = 0; i < powers.length; i++)
                powers[i] = (int) Math.pow(2, i);
            for(int i = binary.length() - 1; i >= 0; i--)
                // if 1 add to decimal to calculate
                if(binary.charAt(i) == '1')
                    decimal = decimal + powers[powersIndex]; // calc the decimal
                else if(binary.charAt(i) != '0' & binary.charAt(i) != '1')
                    isCorrect = false; // flag the wrong input
                    break; // break from loop due to wrong input
                } // end else if
                // keeps track of which power we are on
                powersIndex++; // counts from zero up to combat the loop counting down to zero
            } // end for
            if(isCorrect) // print decimal output
                System.out.println(binary + " converted to base 10 is: " + decimal);
            else // print incorrect input message
                System.out.println("Wrong input! It is binary... 0 and 1's like.....!");
            return decimal.toint();
       } // end function
    The errors are as follows:
    ----jGRASP exec: javac BintoDectoHextoAscii.java
    BintoDectoHextoAscii.java:65: error: class, interface, or enum expected
       public static String BinaryToHexadecimal(String hex)
                     ^
    BintoDectoHextoAscii.java:73: error: class, interface, or enum expected
             long rem;
             ^
    BintoDectoHextoAscii.java:74: error: class, interface, or enum expected
             while(num > 0)
             ^
    BintoDectoHextoAscii.java:77: error: class, interface, or enum expected
             num = num / 10;
             ^
    BintoDectoHextoAscii.java:78: error: class, interface, or enum expected
             if(rem != 0 && rem != 1)
             ^
    BintoDectoHextoAscii.java:81: error: class, interface, or enum expected
             System.out.println("Please try once again.");
             ^
    BintoDectoHextoAscii.java:83: error: class, interface, or enum expected
             System.exit(0);
             ^
    BintoDectoHextoAscii.java:84: error: class, interface, or enum expected
             ^
    BintoDectoHextoAscii.java:87: error: class, interface, or enum expected
             String hexString = Integer.toHexString(i);
             ^
    BintoDectoHextoAscii.java:88: error: class, interface, or enum expected
             System.out.println("Hexa decimal: " + hexString);
             ^
    BintoDectoHextoAscii.java:90: error: class, interface, or enum expected
          return num.tolong();
          ^
    BintoDectoHextoAscii.java:91: error: class, interface, or enum expected
       ^
    BintoDectoHextoAscii.java:124: error: class, interface, or enum expected
          StringBuffer hex = new StringBuffer();
          ^
    BintoDectoHextoAscii.java:125: error: class, interface, or enum expected
          for (int i = 0; i < chars.length; i++)
          ^
    BintoDectoHextoAscii.java:125: error: class, interface, or enum expected
          for (int i = 0; i < chars.length; i++)
                          ^
    BintoDectoHextoAscii.java:125: error: class, interface, or enum expected
          for (int i = 0; i < chars.length; i++)
                                            ^
    BintoDectoHextoAscii.java:128: error: class, interface, or enum expected
          ^
    BintoDectoHextoAscii.java:130: error: class, interface, or enum expected
       ^
    BintoDectoHextoAscii.java:135: error: class, interface, or enum expected
          for (int i = 0; i < hexValue.length(); i += 2)
          ^
    BintoDectoHextoAscii.java:135: error: class, interface, or enum expected
          for (int i = 0; i < hexValue.length(); i += 2)
                          ^
    BintoDectoHextoAscii.java:135: error: class, interface, or enum expected
          for (int i = 0; i < hexValue.length(); i += 2)
                                                 ^
    BintoDectoHextoAscii.java:138: error: class, interface, or enum expected
             output.append((char) Integer.parseInt(str, 16));
             ^
    BintoDectoHextoAscii.java:139: error: class, interface, or enum expected
          ^
    BintoDectoHextoAscii.java:141: error: class, interface, or enum expected
       ^
    BintoDectoHextoAscii.java:144: error: class, interface, or enum expected
       public static String binaryToDecimal(String binary)
                     ^
    BintoDectoHextoAscii.java:150: error: class, interface, or enum expected
            int powersIndex = 0; // keep track of the index
            ^
    BintoDectoHextoAscii.java:151: error: class, interface, or enum expected
            int decimal = 0; // will contain decimals
            ^
    BintoDectoHextoAscii.java:152: error: class, interface, or enum expected
            boolean isCorrect = true; // flag if incorrect input
            ^
    BintoDectoHextoAscii.java:155: error: class, interface, or enum expected
            for(int i = 0; i < powers.length; i++)
            ^
    BintoDectoHextoAscii.java:155: error: class, interface, or enum expected
            for(int i = 0; i < powers.length; i++)
                           ^
    BintoDectoHextoAscii.java:155: error: class, interface, or enum expected
            for(int i = 0; i < powers.length; i++)
                                              ^
    BintoDectoHextoAscii.java:159: error: class, interface, or enum expected
            for(int i = binary.length() - 1; i >= 0; i--)
            ^
    BintoDectoHextoAscii.java:159: error: class, interface, or enum expected
            for(int i = binary.length() - 1; i >= 0; i--)
                                             ^
    BintoDectoHextoAscii.java:159: error: class, interface, or enum expected
            for(int i = binary.length() - 1; i >= 0; i--)
                                                     ^
    BintoDectoHextoAscii.java:166: error: class, interface, or enum expected
                else if(binary.charAt(i) != '0' & binary.charAt(i) != '1')
                ^
    BintoDectoHextoAscii.java:169: error: class, interface, or enum expected
                    break; // break from loop due to wrong input
                    ^
    BintoDectoHextoAscii.java:170: error: class, interface, or enum expected
                } // end else if
                ^
    BintoDectoHextoAscii.java:174: error: class, interface, or enum expected
            } // end for
            ^
    BintoDectoHextoAscii.java:180: error: class, interface, or enum expected
            else // print incorrect input message
            ^
    BintoDectoHextoAscii.java:185: error: class, interface, or enum expected
            return decimal.toint();
            ^
    BintoDectoHextoAscii.java:186: error: class, interface, or enum expected
       } // end function
       ^
    41 errors
    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.

    so can anyone help me determine why I get the following 41 errrors saying: class, interface, or enum expected as well as any other errors that may show up afterwards because I'm stumped.
    Yes - YOU CAN!
    My code is as follows and I hope you don't mind the commented lines of unused code because I'm not sure where I want things and what I want at the moment:
    Excellent! Commenting out code is EXACTLY how you troubleshoot problems like yours.
    Comment out sections of code until the problem goes away. Then start adding back ONE SECTION of code at a time until the problem occurs. When it does you have just FOUND the problem.
    If you do that you wind up with code that looks like this:
    import java.util.Scanner;
    import java.io.*;
    import java.lang.*;
    public class BintoDectoHextoAscii  {
          public static void main(String[] args)throws IOException      {
             Scanner input = new Scanner(System.in);
             System.out.println("Enter a binary number: ");
             String binary = input.nextLine(); // store input from user
                  public static String BinaryToHexadecimal(String hex)     {     } // end function        
    Notice ANYTHING UNUSUAL?
    You have a complete CLASS definition followed by a method definition.
    Methods have to be INSIDE the class - you can NOT define methods on their own.
    Write modular code.
    Write EMPTY methods - just the method signature and maybe a RETURN NULL if you need to return something.
    Then add calls to those empty methods.
    When everything compiles and runs find you can start adding code to the methods ONE METHOD AT A TIME.
    Test compile and run after you add the code for each method.

  • Can we change the default file format 'BIN' of system to 'ASC' using table

    can we change the default file format u2018BINu2019 of system to u2018ASCu2019 using table TSOPE
    if possible:will it affect any system performance

    Hello Vincent,
    BIN(Binary) is default selection.and so we have to select ascii.to make myself more clear my queries is like:
    first for setting ascii what we need to enter in text box that is against ASCII.and
    secondly if we select ASCII will it affect system performance in anyways.

Maybe you are looking for

  • ITunes stopped after upgrade to 10.2 in Windows 7

    I use iTunes for 5 years now and never had a problem. Today I upgraded to the latest 10.2 version and I can't get iTunes started. No issues with my other apps. I tried recovery but that didn't help me either. Please help. I hope Apple makes a patch f

  • Viewing .psd on different computer problem????

    Ok I have to bring a project from photoshop to school to present. Problems - you can NOT nstall fonts, brushes, etc. on the school computers - I have used custom brushes and fonts that do not come with photoshop - project need to be a .psd So what wo

  • Page that scales down

    Even though I haven't yet uploaded these pages I'm working on, when I preview (in Firefox, for instance) my index page scales down in comparison to the others and yet they are all copies of each other to which I have still to change the content...I h

  • Strange circle scratches appearing on MacBook Pro screen

    Hey guys I need some help! My brand new Macbook Pro came last week and I am absolutely in love with it! Apart from one thing, over the past day (literally) I've had these weird circular scratches appearing on my screen and no matter how hard I try I

  • How can I export or save custom tuning scales (project settings)

    Dealing with arab scales (maqamat) in Logic I started using the tuning scales in project prefs. I found some ("lucy-...") tuning scale presets on the internet an sucessfully imported them to my presets list. Now I would really appreciate being able t