Decoding Run Length Encoded String

I have a class that reads data from a server using a BufferedReader. The data is read into a char[]. This data has been Run Length Encoded by a seperate process.
I loop through the char[] looking for a sentinal value. Once this value is found, I look at the next char to find the length and then the next char to find the value that needs to be populated.
In order to correctly determine the length, I & the char with 0xff. This works most of the time. What I am seeing is that in certain circumstances the value is not what I expect. For example, in the following hex representation:
F0 8B 20
FO is my sentinel. 8B tells me to pad for 139. And, 20 tells me the value is a Space. So my class should at this point add 139 spaces.
However, even though I & the char with 0xff it interprets the decimal value as 57.
Here is the Method that does the UnRLE:
public static CharArrayWriter UnRle(char[] InBuffer)
        try {
            CharArrayWriter caWriter = new CharArrayWriter();
            if (IsRle(InBuffer)) {
                int iLoop = 0, iByteRepeat = 0;
                for (int iIdx = RLE_HEADER.length() + RLE_SENTINEL_LEN; iIdx < InBuffer.length; iIdx++) {     // Start after header
                    if (InBuffer[iIdx] == RLE_SENTINEL) {
                        if (InBuffer[iIdx + 1] == RLE_SENTINEL)                           
                            caWriter.write(RLE_SENTINEL);
                        else {                       
                            for (iLoop = 0; iLoop < (int)InBuffer[iIdx + 1] & 0xff; iLoop++)
                                caWriter.write(InBuffer[iIdx + 2]);
                            iIdx += 2;
                    else
                        caWriter.write(InBuffer[iIdx]);
            else
                caWriter.write(InBuffer);
            return caWriter;
        catch (Exception e) {
            System.err.println("UnRle Exception " + e.toString());
            return null;
    }Any ideas?
Thanks,
ABumgardner

Readers and Writers expect to deal with 16-bit characters. You need to be using InputStream and OutputStream.

Similar Messages

  • Re: run length encoding question

    I have this string:
    String s = "########## \r\n# #########\r\n";
    I want to run length encode the results. I am successful at encoding it:
    10#6-|#5-9#| // I am using a delimeter here: "|". I am also using the replace ('-') for whitespace
    I need help with this: how to suppress the trailing whitespace if there is only whitespace before the delimeter. I want my output to be:
    10#|#5-9#|
    thanks for the help

    Yes, I would like to generate code in the encoding phase. I need help in the construct of the conditional "IF" to say something like this in pseudo code: if there is ONLY whitespace between last character and the "|" delimeter, do not print to the console.
    This is the method I am using for the encoding part:
    public class LevelEncodeTrimTest1 {
    public String encode(String input) {
    StringBuffer dest = new StringBuffer();
    for (int i = 0; i < input.length(); i++) {
    int runLength = 1;
    while( i+1 < input.length() && input.charAt(i) == input.charAt(i+1) ) {
    runLength++;
    i++;
    if (runLength == 1) {
    dest.append(input.charAt(i));
    if (runLength == 2){
    //dest.append(runLength);
    dest.append(input.charAt(i));
    dest.append(input.charAt(i));
    if (runLength > 2) {
    dest.append(runLength);
    dest.append(input.charAt(i));
    return dest.toString();
    thanks for the help.
    {noformat}
    {noformat}

  • How to decode encoded string for javascript

    This is encoded HTML code to be used at javascript function
    <div class=\"ProductDetail\"><div style=\"width:780px\">\r\n\t<div class=\"baslik\" style=\"margin: 0px; padding: 5px 10px; border-width: 5px 0px 1px; border-top-style: solid; border-bottom-style: solid; border-top-color: rgb(255, 255, 255); border-bottom-color: rgb(153, 165, 165); vertical-align: baseline; color: rgb(0, 0, 0); clear: both; line-height: 14px; font-family: 'Lucida Grande', sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(219, 223, 226);\"> Di\u011fer \u00d6zellikler<\/div><\/div><\/div>
    When decoded properly it becomes below
    <div class="ProductDetail"><div style="width:780px">
    <div class="baslik" style="margin: 0px; padding: 5px 10px; border-width: 5px 0px 1px; border-top-style: solid; border-bottom-style: solid; border-top-color: rgb(255, 255, 255); border-bottom-color: rgb(153, 165, 165); vertical-align: baseline; color: rgb(0, 0, 0); clear: both; line-height: 14px; font-family: 'Lucida Grande', sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(219, 223, 226);"> Diğer Özellikler</div></div></div>
    This website has both decode and encode features
    http://www.freeformatter.com/javascript-escape.html#ad-output
    I could find HttpUtility.JavaScriptStringEncode at c# however i couldn't find any function class etc to decode encoded string
    So i need help about how to decode like that website does
    .net 4.5 c#
    Browser based Pokemon Style MMORPG Game Developer Used asp.net 4.0 routing at it's
    Monsters

    Hi
    Monster,
    For web questions related to ASP.NET use the
    ASP.NET forum
    You should get more, better and faster answers on the other forum.  Thanks, ahead of time.
    Thanks
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Converting Base64 encoded String to String object

    Hi,
    Description:
    I have a Base64 encoded string and I am using this API for it,
    [ http://ws.apache.org/axis/java/apiDocs/org/apache/axis/encoding/Base64.html]
    I am simply trying to convert it to a String object.
    Problem:
    When I try and write the String, ( which is xml ) as a XMLType to a oracle 9i database I am getting a "Cannot map Unicode to Oracle character." The root problem is because of the conversion of the base64 encoded string to a String object. I noticed that some weird square characters show up at the start of the string after i convert it. It seems like I am not properly converting to a String object. If i change the value of the variable on the fly and delete these little characters at the start, I don't get the uni code error. Just looking for a second thought on this.
    Code: Converting Base64 Encoded String to String object
    public String decodeToString( String base64String )
        byte[] decodedByteArray = Base64.decode( base64String );
        String decodedString = new String( decodedByteArray, "UTF-8");
    }Any suggestions?

    To answer bigdaddy's question and clairfy a bit more:
    Constraints:
    1. Using a integrated 3rd party software that expects a Base64 encoded String and sends back a encoded base64 String.
    2. Using JSF
    3. Oracle 10g database and storing in a XMLType column.
    Steps in process.
    1. I submit my base64 encoded String to this 3rd party software.
    2. The tool takes the encoded string and renders a output that works correctly. The XML can be modified dynamically using this tool.
    3. I have a button that is binded to my jsf backing bean. When that button is clicked, the 3rd party tool sets a backing bean string value with the Base64 String representing the updated XML.
    4. On the backend in my jsf backing bean, i attempt to decode it to string value to store in the oracle database as a XML type. Upon converting the byte[] array to a String, i get this conversion issue.
    Possibly what is happen is that the tool is sending me a different encoding that is not UTF-8. I thought maybe there was a better way of doing the decoding that i wasn't looking at. I will proceed down that path and look at the possibility that the tool is sending back a different encoding then what it should. I was just looking for input on doing the byte[] decoding.
    Thanks for the input though.
    Edited by: haju on Apr 9, 2009 8:41 AM

  • Encoded String

    Hi all
    I'm having problems with decoding an encoded String. The String i have looks like this:
    =?ISO-8859-1?Q?F=E4lt=F6m?=
    The code I use to try and decode the string looks like this:
    fileName = fileName.substring(fileName.indexOf("=?") + 2, fileName.lastIndexOf("?="));
    StringTokenizer st = new StringTokenizer(fileName, "?");
    String encodingType = st.nextToken();
    System.out.println("Encoding type: " + encodingType);
    String type = st.nextToken();
    System.out.println("Type: " + type);
    String name = st.nextToken();
    System.out.println("Name: " + name);
    try {
      String newFileName = new String(name.getBytes(encodingType), encodingType);
      System.out.println("New filename: " + newFileName);
    } catch (Exception ex) {
      ex.printStackTrace();
    }The output is:
    Encoding type: ISO-8859-1
    Type: Q
    Name: F=E4lt=F6m
    New filename: F=E4lt=F6m
    What's wrong with my way of decoding the String?
    Thanks
    Tobias

    This encoding is called "quoted printable". Writing a decoder for it is not hard -- the thing after the = sign is the two character hex code of the actual character -- but there is no built in support for it in J2SE (as there isn't out-of-the-box support for Base64 either).
    There is support for it in the JavaMail-extension package though, by the class javax.mail.internet.MimeUtility. You must be doing something related to email anyway, so I would recommend having a look at it.
    http://java.sun.com/products/javamail/
    Quoted printable is defined at least in section 6.7 of RFC 2045:
    http://faqs.org/rfcs/rfc2045.html

  • BIgMAth from base64 encoded string

    I'm trying to create a BigInteger from a source that is a base64 encoded string. The BigInteger seems to only support radix up to 36. I have a couple of questions.
    1) Why does BigInteger not support higher radix?
    2) Anyone have any advice on how to manually make the BigInteger from a base64 string? Obviously I can change the encoding myself to a lower radix, but I thought someone might have a better idea?
    Thanks,
    Chad

    Base64 is not a Radix in the sense of Decimal or Hex.
    The javadoc for one of the BigInteger constructors -
    BigInteger
    public BigInteger(int signum,
                      byte[] magnitude)
        Translates the sign-magnitude representation of a BigInteger into a BigInteger. The sign is represented as an integer signum value: -1 for negative, 0 for zero, or 1 for positive. The magnitude is a byte array in big-endian byte-order: the most significant byte is in the zeroth element. A zero-length magnitude array is permissible, and will result inin a BigInteger value of 0, whether signum is -1, 0 or 1.
        Parameters:
            signum - signum of the number (-1 for negative, 0 for zero, 1 for positive).
            magnitude - big-endian binary representation of the magnitude of the number.
        Throws:
            NumberFormatException - signum is not one of the three legal values (-1, 0, and 1), or signum is 0 and magnitude contains one or more non-zero bytes.so to force to be positive make the first parameter a 1 .
    Message was edited by:
    sabre150

  • Calculate string CPI (length of string in pixel)

    Word-wrap position is at the moment done in SAP via length of string (count of letters) via function u201CRKD_WORD_WRAPu201D. But this is counting number of char, this give the problem that different font type and size give different word-wrap position ! -> We need to calculate if possible the word-wrap position via the relative length of text u2013 I tried to find some on SDN and Internet, the only thing I can find is some functionality in JAVA u2026
    Can any one help me how to calculate the length of a string using font type and hight of font... as we use truetype font as arial the length of letter "i" is not the same as 'X' ...
    Best regards Jørgen Jensen

    My problem is not to do the wordwrap, my problem is to find the right position as the length of 'i' is not the same length of 'X'
    example:
    iiiiiiiiii (10)
    XXXXXXXXXX(10)
    must be something like this:
    iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii(wordwrap position 35)
    XXXXXXXXXX(Wordwrap position 10)
    I need a way to find the length of a charactor in a given font and size.
    Best regards Jørgen Jensen

  • Unescaping URL Encoded Strings

    Anyone know how to unescape URL encoded strings using XSL? I can use the translate() function to replace the + signs with spaces but the %3F and %3E style characters are causing problems. The escaped characters are in an XML doc.
    Any help would be appreciated.

    Anyone know how to unescape URL encoded strings using XSL? I can use the translate() function to replace the + signs with spaces but the %3F and %3E style characters are causing problems. The escaped characters are in an XML doc.
    Any help would be appreciated.

  • How to convert a base64 encoded string to binary?

    Hi, gurus,
    I want to convert a base64 encoded string (a image  which is read from a xml file)
    into a normal binary string and then upload to archive link.
    could you pls give me some hints on that?
    br.
    jun

    thank you for your quick reply!
    my real requirement is to extract an image(it 's said it's encoded using base64?) from a xml file and upload it sap archive linke,
    following is the xml content, does that mean i need to convert all the chars in the
    <mime_content> pair to your fm, that will be convert to binary string?
    <MIME_CONTENT xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" href="" xfa:contentType="image/jpg"
    >/9j/4AAQSkZJRgABAAEAYABgAAD//gAfTEVBRCBUZWNobm9sb2dpZXMgSW5jLiBWMS4wMQD/2wCE
    AAgFBgcGBQgHBgcJCAgJDBQNDAsLDBgREg4UHRkeHhwZHBsgJC4nICIrIhscKDYoKy8xMzQzHyY4
    PDgyPC4yMzEBCAkJDAoMFw0NFzEhHCExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTEx
    MTExMTExMTExMTExMTExMf/EAaIAAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKCwEAAwEBAQEB
    AQEBAQAAAAAAAAECAwQFBgcICQoLEAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEU
    MoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2Rl
    ZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK
    0tPU1dbX2Nna4eLj5OXm5jp6vHy8/T19vf4foRAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYS
    QVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNU
    VVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5
    usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5jp6vLz9PX29/j5v/AABEIAFQAUwMBEQACEQEDEQH/
    2gAMAwEAAhEDEQA/APf6ACgAoAy/EWsxaLYGZgHmbiKP+8f8BXBjsbHB0ud79EduCwksVU5VourO
    Gg8X64kxdp0kUn7jRjaPy5/Wvk1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qFtBZxoMexEQ/I19NlMZ1aqrVsOo20vd/DqeLXj9inJy8ty
    S18T+H9VaS1s9VsrmQfKYlmALfT1/Cvp6zpV6cqbtK62va/kYyweJoWnODS72M3Urq6ssiK0SzHZ
    gmT/AN9GvgcRisVg3ywoql5pXf8A4E7/AIHoUadOrvLm+f6HMalPLcOWnleRvVmJrznWqVnzVJNv
    zPZowjBWirDvCWoT2OvwRwgslw4jkQdwe/4da9rKK86OIio7S0f9eQswoQq4aTlvHVf15nqNffnx
    QUAFADZESWNo5FDIwIZT0INKUVJWew4txd0eOM7/SvCOtS2cy3Vw5AkjijwoCnplzPQGvj62T0
    4VXzS93ol/mfcYJ18dRU42XRt9/T/gnLXnxL1baU0i3tdLT++ieZL/322f0Arso0aOH/AIUEn33f
    3v8AQ745RSetaTlC5HK6lql/qk3m6jez3UnrNIWx9M9K1lKUt2enSoU6KtTikvIqdKk1N7R/Gf
    iHRlCWWqTSPWMp8yPHptbIrRVJJcu67PU4a2XYavrOCv3Wj+9HQW/xGiuQF1jSEVu81k/ln/vh
    sg/hiuCrgMLV15eVXX/DHE8snT/hT+UtfxWv5np/w0tbC9sf7btWeUSEpEZE2lMcHjJ57V35Vl
    sMO3VbunkfM5xXqxl9XkrW38zta948AKACgAoA8TPWg37a3BrEFvJLZtbrG7oufLZSevoMEc15
    mMhLm5lsfbcO4qmqLot2le/qeU1wH1YUCCgAoAkggluJVit4nlkY4VEUkkwFNKiFKSirydkfS/
    wx0i50PwVYWd9GYrgBpHQ9V3MSAffBFe1h4OFNJn5nm1eGIxc5wd1/kjp63PMCgAoAKAAjIwelAH
    nXxQHVtrOnSXh2kcOpw/MUiUKLgdxgfxeh79Ppx4jDqSvFan0eU5vPDzVOtK8H36f8A8Ijs7mS
    5NtHbytODjylQlsmOteVZ3sfducYx5m1buaF74Y12wtxPeaRewREZ3vAwAvHFW6c4q7Rz08Zhq
    kuWFRNpP4L8MXfinW4rG2VlizmeYDiJO5voPWnSpupKyIx2MhgqLqS36Luz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3h3XrLxaNQ1Xw2jW9
    vocOn5Z0PnSoVy+F9cE8/nQB7BQAUAFABQAUAFABQAUAFABQAUAFAH//2Q==</MIME_CONTENT
    >

  • Getiing length of String in pixels.

    I need to set up legth of combobox depending on length of strings in it. Can I get length of String in pixels?

    You should use the getFontMetrics() method of the Graphics object used by the painting methods of the combo.
    Then the stringWidth(String) method of the given font metrics should give you the needed width.
    Just take care of the fact that the combo must be realized (set visible or packed) for this to work.

  • UIImage to Base64 Encoded String does not matched with PHP Encoded String

    Hi, I have converted an image to base64 string using the following
    UIImage* pic = [UIImage imageNamed:@"closeBtn.png"];
        NSData* pictureData = UIImagePNGRepresentation(pic);
        [Base64 initialize];
        NSString * encodedString = [Base64 encode:pictureData];
    The result obtained by this method and by converting the same image to base64 string in PHP or ASP is different. I am comparing the base64 string (testData) with online generated string from URL http://www.dailycoding.com/Utils/Converter/ImageToBase64.aspx
    Please help ASAP

    Keith:
    I am converting the PNG Image.Actually i want to post a image to PHP server via JSON. for that i am converting the image into base64 string and then sending JSON via HTTP. but when server receives a image data , it cannot convert and save it properl (blank image with 0x0 dimensions). I have compared the Base64 String created from xCode with some online conversion tools. and results are different. I have even tried with JPG images as well.
    How can I get the Same Encoded String as PHP or ASP code can have?

  • Determine length of string without function module

    hai experts,
    i need to know how to determine length of string without function module strlen'
    regards,
    karthik

    Please SEARCH in SCN before posting.

  • There is a question about encode String

    hello
    i find a question when i decode java program at linux(redhat 7.3 Valhalla) and J2SDK 1.4.1_02.
    when i want to encode a String from GB2312 to UTF-16BE, the String used CJK and alpha bet mixed. the String length is error and can not convert success!
    from API documents, the string length when count the CJK character ,2 bytes count to 1,but there is 2! for example ,when i encode a CJK character to a UTF-16BE,when the string length is 1.then in the UTF-16BE should be 1,but there is not 1 but 2!!!:(
    by the way ,when my code run at windows2000,it's right!! no error!
    to everyone:what should i do ? is it a bug in j2sdk1.4.1_02?

    There are multiple 16-bit Unicode encodings, i.e.,
    UTF-16
    UnicodeBigUnmarked
    UnicodeLittleUnmarked
    UnicodeBig
    UnicodeLittle
    with/without BOM (byte order mark).
    Try these at a time, or confirm the unicode encoding used on an OS by the following.
    System.out.println(System.getProperty("sun.io.unicode.encoding"));

  • SaxParser error  parsing xml encoded string

    I'm trying to parse an XML string with Java's SaxParser. The program
    fails at the end of an element or at the beginning of a new element.
    Is my XML string okay?
    <?xml version="1.0" encoding="utf-8"
    ?><DTYPE>OVL</DTYPE><DTYPE>IMG</DTYPE>. . .
    If fails after </DTYPE> and before the next <DTYPE>
    The Sax Parser works fine on files.
    Here is the code I use to send the string to the parser :
    // Parse the input
    SAXParser saxParser = factory.newSAXParser();
    InputStream is = new ByteArrayInputStream(stringToParse.getBytes());
    saxParser.parse( is, handler );
    Here is the error message I get :
    org.xml.sax.SAXParseException: Inadmissible sign at the document end<
    at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376)
    at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3370)
    at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:673)
    at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
    at
    org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:143)
    at EchoSaxParser.parse(EchoSaxParser.java:51)
    at StringParser.parse(StringParser.java:23)
    at Servant.stringparse(Servant.java:30)
    at TEST._TestImplBase._invoke(_TestImplBase.java:43)
    at
    com.sun.corba.se.internal.corba.ServerDelegate.dispatch(ServerDelegate.java�:353)
    at com.sun.corba.se.internal.iiop.ORB.process(ORB.java:280)
    at
    com.sun.corba.se.internal.iiop.RequestProcessor.process(RequestProcessor.ja�va:81)
    at
    com.sun.corba.se.internal.orbutil.ThreadPool$PooledThread.run(ThreadPool.ja�va:106)
    Any help would be greatly appreciated!
    Thank you!

    <?xml version="1.0" encoding="utf-8" ?><DTYPE>IMG</DTYPE><DTYPE>REF</DTYPE>Above is a short XML string that causes the problem.
    It's all one line.
    I also tried adding System.getProperty("line.separator") add the
    end of each tag so I get :
    <?xml version="1.0" encoding="utf-8" ?>
    <DTYPE>IMG</DTYPE>
    <DTYPE>REF</DTYPE>But same error. It still crashes after the first <DTYPE></DTYPE> tag.
    Any help greatly appreciated!

  • Weired problem when encoding String

    Hi guys,
    I need to send an String via HttpConnection (POST), but I get a rather weired error
    Following Code does not work giving me an IOException :
    (Uncaught exception java/lang/RuntimeException: IOException reading reader invalid first byte 11111100)
    String urlmsg = "kind_id=127&beobachter_id=567&kind_vorname=Hansi&kind_nachname=meiser2&kind_geschlecht=w&gruppen_id=4&kind_bew=";
    String bew = "[{'24':'+'},{'12':'~'},{'38':'-'}]";
    String urlbew = URLencode(bew);
    String completeurlmsg = urlmsg+urlbew;
    conn.setRequestProperty("Content-Length", ""+completeurlmsg.getBytes().length);
    OutputStream os = conn.openOutputStream();
    os.write(completeurlmsg.getBytes("utf-8"));
    os.flush();
    os.close();however when I change the "kind_id=" parameter to below(including) 112 (i.e. kind_id=112) the code works. I know the problem is somewhere with the coding, but I got no clue why this exception is occuring. Also note that this problem occurs ONLY with the "kind_id=" parameter, while "beobachter_id=" can be set to any number desired.
    I did use the Search, but all I got was this Post:
    [click here|http://forums.java.net/jive/thread.jspa?threadID=41619&tstart=0] but my code is UTF-8 encoded so this cannot be the solution (Or if it is I need more detailed infos.)
    Any help would be appreciated. Excuse my bad english but i am foreign;)
    PS: Using
    Ubuntu 9.04
    Netbeans 6.5.1 Mobile Edition (WTK included)
    java 1.6.0_13
    if you need more infos just ask, I am not shure what else to post since Netbeans is not giving much output.
    Edited by: kalmuneiu on Jun 16, 2009 9:08 AM

    hi , check this example....
    REPORT  ZVENKATTEST0.
    TABLES:MARA.
    SELECT-OPTIONS:S_TEST1 FOR MARA-MATNR MODIF ID M1 ,
                   S_TEST2 FOR MARA-MEINS MODIF ID M2 .
    PARAMETERS:P_RAD1 RADIOBUTTON  GROUP G1 USER-COMMAND UC1 DEFAULT 'X',
               P_RAD2 RADIOBUTTON GROUP G1 ,
               P_RAD3 RADIOBUTTON GROUP G1 .
    AT SELECTION-SCREEN OUTPUT .
      LOOP AT SCREEN.
        IF P_RAD1 = 'X'.
          IF SCREEN-NAME = 'S_TEST1-LOW' .
            SCREEN-INPUT = '0'.
            MODIFY SCREEN.
          ENDIF.
          IF SCREEN-NAME = 'S_TEST1-HIGH' .
            SCREEN-INPUT = '0'.
            MODIFY SCREEN.
          ENDIF.
          IF SCREEN-NAME = 'S_TEST2-LOW' .
            SCREEN-INPUT = '0'.
            MODIFY SCREEN.
          ENDIF.
          IF SCREEN-NAME = 'S_TEST2-HIGH' .
            SCREEN-INPUT = '0'.
            MODIFY SCREEN.
          ENDIF.
       ENDIF.
          IF P_RAD2 = 'X'.
            IF SCREEN-NAME = 'S_TEST1-LOW' .
              SCREEN-INPUT = '0'.
              MODIFY SCREEN.
            ENDIF.
            IF SCREEN-NAME = 'S_TEST1-HIGH' .
              SCREEN-INPUT = '0'.
              MODIFY SCREEN.
            ENDIF.
          ENDIF.
            IF P_RAD3 = 'X'.
              IF SCREEN-NAME = 'S_TEST2-LOW' .
                SCREEN-INPUT = '0'.
                MODIFY SCREEN.
              ENDIF.
              IF SCREEN-NAME = 'S_TEST2-HIGH' .
                SCREEN-INPUT = '0'.
                MODIFY SCREEN.
              ENDIF.
            ENDIF.
         ENDLOOP.
    regards,
    venkat.

Maybe you are looking for

  • There are two transactions ZJPVCS303 and ZJPVCS303_US for one single Report

    When run as a batch program, (currently this is the case), or withT-Code ZJPVCS303 the selection screen is unchanged (except for additional sales area above) - When run as T-Code ZJPVCS303_UL (UL stands for Upload) the selection screen is changed.  T

  • Memory Upgrade on Compaq Presario V3839TU

    I want to upgrade my laptop Compaq Presario V3839TU memory from 1GB to 2GB.. Is it possible to upgrade memory for this laptop? I don't know how many slots on this laptop, and what kind of memory should I buy if it has available memory slot? Can this

  • All-in-one c6180 Printer ... replacement parts?

    Hi! I have a HP Photosmart All-in-one c6180 printer and it has worked fabulously for me for the past several years! But a few months ago the power adapter cord was caught in the vacuum as I was sweeping and it ripped out the back of the printer break

  • Labels in my Panel

    I'm sorry that I couldn't figure this out from the search. I tried a few things but none seemed to work. I have a panel that contains labels. The labels represent objects alive in my system. The Frame watches these objects and updates every second. I

  • Oracle 9.2.0.1 Standard Edition Silent Installation using Response file

    Does Oracle 9i Standard Edition come in 3 CDs??. I heard problems about providing response files to silent install Oracle 9.2.0.1 server. I am about receive a licensed copy of Oracle 9i and I am looking at creating a response file for silent installa