ASCII Code in ABAP

Hi Experts,
We need to enter a unique ASCII character called 'US' or Unit Separator in a text file being generated through a program.
The ASCII code for US is 31. However when we try and do it programmatically the character '#' is getting populated.
The code is as follows:
DATA : lv_sep type c.
field-symbols : <xfs> type x.
assign lv_sep to <xfs> casting.
<xfs> = 0031.
write lv_sep.
Kindly help us out.
Thanks and Regards,
Ravi Bhatnagar

Hi,
This character is special one, so you can't print it out. In SAP all special charcter which can't be printed are replaced with placeholder #.  They are intended to do theri special purpose in flat file, once you open it.
Do the following:
- use fm HR_KR_XSTRING_TO_STRING to convert xstring with value  '1F' (30 decimal value) to string
- write this string to certain place in internal string table (where you want later use it in the file)
- download this table as to file
- special character will do its purpose in text file
This is the same functionality as you would be placing Line Feed (0x0A - 10 dec). It would be shown as # but once you open downlaoded file you don't see hash # anymore, but you see that new line in that place.
Hope this is clear
Regards
Marcin

Similar Messages

  • Getting ASCII code of a character in ABAP. How?

    Hi,
    i need use ascii codes in my program.
    I must get ascii code of a character. How can i get ascii code of a character?
    Thanks.

    Chk these links:
    http://www.sapdb.org/7.4/htmhelp/07/a16384a57411d2a97100a0c9449261/content.htm
    http://sap.ittoolbox.com/groups/technical-functional/sap-dev/function-to-get-ascii-code-234764

  • Convert char to ascii code and vice versa

    HI
    Is there any function module to convert char to ascii code and vice versa.
    Thanks in advance

    Hi,
    be careful if you have unicode running in your system. URL_ASCII_CODE_GET is platform-dependent so it will return the internal HERX representation of the character in your system - which is hopefully and in most cases ASCII.
    Under unicode, we use double-byte characters here. I tried this function and the result CHAR_CODE is '00' regardless what character I specify for TRANS_CHAR. But the coding is so simple I corrected resultig in this sample code:
    [P]
    convert p_form to ASCII (internal) representation
      DATA:
        l_ofs TYPE syfdpos,
        l_len TYPE sy-linsz,
        l_ascii TYPE i.
      FIELD-SYMBOLS:
        <x> TYPE x.
      l_len = STRLEN( p_ascii ).
      DO l_len TIMES.
        l_ofs = sy-index - 1.
        ASSIGN p_ascii+l_ofs(1) TO <x> CASTING.
        l_ascii = <x>.
        WRITE: l_ascii.
      ENDDO.
    [/P]
    Here, for each character of string p_ascii, the internal (ASCII) representation is determined and written to the output list.
    Regards,
    Clemens

  • Optimization of Codes in ABAP

    Hello there,
    Can anyone help me about my problem in optimizing my code in ABAP..
    before i used SDF logical dbf..but simple select in BSIS,BKPF and BSEG tables are much faster than using logical dbf..but my main problem is it took a while also in processing a report while using a select statement..here is my sample code.
    It took 2mins in processing a report...Hope someone can help me
    Please give me some advice.
    Thanks in advance
    aVaDuDz
    SELECT SINGLE *
      FROM skb1
      WHERE bukrs EQ p_bukrs
      AND saknr EQ p_saknr.
      IF sy-subrc EQ 0.
        SELECT blart belnr waers monat budat bukrs hkont buzei
               shkzg dmbtr wrbtr gjahr
        INTO CORRESPONDING FIELDS OF TABLE it_bsis
        FROM bsis
        WHERE bukrs EQ p_bukrs
        AND hkont EQ p_saknr
        AND gjahr IN p_gjahr
        AND monat IN p_monat.
        PERFORM add_record.
      ENDIF.
    FORM add_record .
      LOOP AT it_bsis.
        g_percn = 1.
        CLEAR g_indic.
        g_indic = c_indic.
        REPLACE '&' WITH it_bsis-belnr INTO g_indic.
        REPLACE '%' WITH it_bsis-buzei INTO g_indic.
        CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
          EXPORTING
            percentage = g_percn
            text       = g_indic.
        READ TABLE it_data ASSIGNING <data>
             WITH KEY  belnr = it_bsis-belnr "document #
                       buzei = it_bsis-buzei. "Line Item
        IF sy-subrc <> 0.
          APPEND INITIAL LINE TO it_data ASSIGNING <data>.
          <data>-belnr = it_bsis-belnr. "document #
          <data>-buzei = it_bsis-buzei. "Line Item
        ENDIF.
        <data>-bukrs = it_bsis-bukrs. "Company
        <data>-hkont = it_bsis-hkont. "G/L Acct.
        <data>-gjahr = it_bsis-gjahr.
        <data>-waers = it_bsis-waers.
        <data>-belnr = it_bsis-belnr.
        <data>-monat = it_bsis-monat.
        <data>-budat = it_bsis-budat.
        <data>-blart = it_bsis-blart.
        IF it_bsis-shkzg ='H'.
          <data>-wrbtr = it_bsis-wrbtr * -1.
          <data>-dmbtr = it_bsis-dmbtr * -1.
        ELSE.
          <data>-wrbtr = it_bsis-wrbtr.
          <data>-dmbtr = it_bsis-dmbtr.
        ENDIF.
        SELECT SINGLE lifnr sgtxt
         FROM bseg
         INTO gs_vendor
         WHERE belnr  =  it_bsis-belnr
         AND gjahr IN p_gjahr
         AND lifnr NE ''.
        SELECT SINGLE lifnr name1 stcd1
         FROM lfa1
         INTO gs_lfa1
         WHERE lifnr = gs_vendor-lifnr.
        <data>-lifnr = gs_lfa1-lifnr.
        <data>-sgtxt = gs_vendor-sgtxt.
        <data>-name1 = gs_lfa1-name1.
        <data>-stcd1 = gs_lfa1-stcd1.
        SELECT SINGLE wt_withcd
        FROM with_item
        INTO gs_item
        WHERE belnr = it_bsis-belnr
        AND gjahr IN p_gjahr.
        IF sy-subrc EQ 0.
          <data>-mwskz = gs_item.
        ENDIF.
        SELECT SINGLE ppnam usnam bldat
        FROM bkpf
        INTO gs_bkpf
        WHERE belnr = it_bsis-belnr
        AND gjahr IN p_gjahr.
        <data>-ppnam = gs_bkpf-ppnam.
        <data>-usnam = gs_bkpf-usnam.
        <data>-bldat = gs_bkpf-bldat.
      ENDLOOP.
    ENDFORM.                    " add_record

    Hi,
    Check this code. See the comments where i have mentioned "Add / Remove this".
    For tables like BSEG, BKPF and WITH_ITEM you have to provide complete key to read from table. BUKRS should be the first field in select statement.
    Also, you do not need to check LIFNR  NE '', when you select from BSEG. Just read the first line item. It is vendor / customer line item.
    Also, <b>DO NOT USE SAPGUI_PROGRESS_INDICATOR inside loop</b>. It does affect performance.
    Let me know if you still have performance issue.
    SELECT SINGLE *
                   FROM skb1
                   WHERE bukrs EQ p_bukrs
                   AND saknr EQ p_saknr.
    IF sy-subrc EQ 0.
      SELECT blart belnr waers monat budat bukrs hkont buzei
      shkzg dmbtr wrbtr gjahr
      INTO CORRESPONDING FIELDS OF TABLE it_bsis
      FROM bsis
      WHERE bukrs EQ p_bukrs
      AND hkont EQ p_saknr
      AND gjahr IN p_gjahr
      AND monat IN p_monat.
      PERFORM add_record.
    ENDIF.
    *       FORM add_record                                               *
    FORM add_record .
      LOOP AT it_bsis.
        g_percn = 1.
        CLEAR g_indic.
        g_indic = c_indic.
        REPLACE '&' WITH it_bsis-belnr INTO g_indic.
        REPLACE '%' WITH it_bsis-buzei INTO g_indic.
        CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
             EXPORTING
                  percentage = g_percn
                  text       = g_indic.
        READ TABLE it_data ASSIGNING <data>
        WITH KEY belnr = it_bsis-belnr "document #
        buzei = it_bsis-buzei. "Line Item
        IF sy-subrc <> 0.
          append initial line to it_data assigning <data>.
          <data>-belnr = it_bsis-belnr. "document #
          <data>-buzei = it_bsis-buzei. "Line Item
        ENDIF.
        <data>-bukrs = it_bsis-bukrs. "Company
        <data>-hkont = it_bsis-hkont. "G/L Acct.
        <data>-gjahr = it_bsis-gjahr.
        <data>-waers = it_bsis-waers.
        <data>-belnr = it_bsis-belnr.
        <data>-monat = it_bsis-monat.
        <data>-budat = it_bsis-budat.
        <data>-blart = it_bsis-blart.
        IF it_bsis-shkzg ='H'.
          <data>-wrbtr = it_bsis-wrbtr * -1.
          <data>-dmbtr = it_bsis-dmbtr * -1.
        ELSE.
          <data>-wrbtr = it_bsis-wrbtr.
          <data>-dmbtr = it_bsis-dmbtr.
        ENDIF.
        SELECT SINGLE
                     lifnr
                     sgtxt FROM bseg
                           INTO gs_vendor
                           WHERE bukrs = it_bsis-bukrs " --> Add this
                           AND belnr = it_bsis-belnr
                           AND gjahr IN p_gjahr
                           AND buzei = '001'.    " --> Add this
    *                       AND lifnr NE ''.     " --> Remove this
        SELECT SINGLE lifnr name1 stcd1
        FROM lfa1
        INTO gs_lfa1
        WHERE lifnr = gs_vendor-lifnr.
        <data>-lifnr = gs_lfa1-lifnr.
        <data>-sgtxt = gs_vendor-sgtxt.
        <data>-name1 = gs_lfa1-name1.
        <data>-stcd1 = gs_lfa1-stcd1.
        SELECT SINGLE wt_withcd
        FROM with_item
        INTO gs_item
        WHERE bukrs = it_bsis-bukrs  " --> Add this
        AND belnr = it_bsis-belnr
        AND gjahr IN p_gjahr.
        IF sy-subrc EQ 0.
          <data>-mwskz = gs_item.
        ENDIF.
        SELECT SINGLE ppnam usnam bldat
        FROM bkpf
        INTO gs_bkpf
        WHERE bukrs = it_bsis-bukrs   " --> Add this
        AND belnr = it_bsis-belnr
        AND gjahr IN p_gjahr.
        <data>-ppnam = gs_bkpf-ppnam.
        <data>-usnam = gs_bkpf-usnam.
        <data>-bldat = gs_bkpf-bldat.
      ENDLOOP.
    ENDFORM.
    Regards,
    RS

  • How to send an attached file containing with non-ascii code ?

    Hi,
    I want to send a attaced text file containing with non-ascii code(Traditional Chinese). Is there any way to solve the encoding problem?
    Currently, it transfer into non-meaningful code in receiving side.
    Thanks for the help in advance.

    Here is the code:
    Session _gSession = null;
    MimeMessage message = null;
    Properties props = new Properties();
    props.put("mail.smtp.host", smtpHost);
    _gSession = javax.mail.Session.getInstance(props, null);
    message = new MimeMessage(_gSession);
    message.setFrom(new InternetAddress(emailSender , emailSender));
    InternetAddress ia[] = new InternetAddress[1];
    ia[0] = new InternetAddress(emailReceiver, emailReceiver);
    message.setRecipients(Message.RecipientType.TO, ia);
    message.setSubject("Test Encoding Attached File");
    message.saveChanges();
    BodyPart messageBodyPart = new MimeBodyPart();
    DataSource fds = new FileDataSource("Big5_Code.txt");
    messageBodyPart.setDataHandler(new DataHandler(fds));
    messageBodyPart.addHeader("Content-ID","meme");
    MimeMultipart multipart = new MimeMultipart("related");
    multipart.addBodyPart(messageBodyPart);
    message.setContent(multipart);
    transport.connect();
    transport.send(message);

  • Requied code in abap to display sales order header text

    hi all,
    can anybody help me to send the code in abap to display sales order header text.

    Use FM, Read_text. Pass the necessary parameters like object name, id, language. You can see some of the infos in by clicking the scroll-like button.
    Reward points if useful

  • How can I get the ASCII code instead of Unicode?

    If I use getNumericValue to return the Unicode of a character, I found out "a" = "A". Is there any way I can find out the different code for capital letter and small letter? I'm thinking about ASCII code, any suggestion for which method to return the ASCII code?

    That is not what getNumericValue does. (Try getNumericValue('*'), for example, and you will see it returns -1.) If you want to find the Unicode value of a character, simply cast the character to an int:char letter = 'A';
    int unicodeValue = (int)letter;If the character you chose was in the ASCII character set, you will automatically have its ASCII code, because ASCII is simply the first 128 characters in the Unicode character set.

  • Problem showing Trademark symbol using ascii code in Flex 3

    I am facing problem in displaying trademark symbol (™) using ascii codes(it is showing square symbol). I have ascii code stored in the database for trademark symbol(ascii code "&#153;" ). So I can't use Hexa code instead of ascii code. But using ascii code I am able to show copyright symbol. Following is the sample code :
    <?xml version="1.0"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
        <mx:Script>
            var trademarkSymbol = "\u2122";
            var trademarkSymbol1 = "&#153;";
            var copyrightSymbol = "\u00A9";
            var copyrightSymbol1 = "&#169;";
        </mx:Script>
        <mx:Label text="Macromedia™"/>
        <mx:Label text="Macromedia{trademarkSymbol}"/>
        <mx:Label text="Macromedia{trademarkSymbol1}"/>      \\ problem  code
        <mx:Label text="Macromedia©"/>
        <mx:Label text="Macromedia{copyrightSymbol}"/>
        <mx:Label text="Macromedia{copyrightSymbol1}"/>
    </mx:Application>
    Please suggest some solution.
    Regards
    Rajat Sahni

    You must use Unicode values, not Windows extended ASCII values.
    The Unicode value of a copyright symbol is hex 00A9 or decimal 169. This happens to be the same as where it is in a Windows' extended ASCII character set, but this is irrelevant. The Unicode value of a copyright symbol is hex 2122 or decimal 8482. In Windows' extended ASCII it has a different value, hex 99 or decimal 153, but again this is irrelevant.
    So the reason you think it "works" for the copyright and not for the trademark is that the two character sets agree on the value of the copyright but disagree on the value of the trademark.
    Moral: Find a good Unicode table.
    Gordon Smith
    Adobe Flex SDK Team

  • How do I get labview for linux to send out ascii code to a motion controller?

    I have posted part of this problem but I will now try to clearify things. I have an x-y stage that needs motion control. I have to run the motion controller from within a linux system (RedHat 7.1) due to others in the research area. I have found a motion controller card (PCI) that will run under linux. This card is not National Instruments. I understand that they do not have drivers for their controller cards. This other card comes with the companies own software that uses ASCII codes to move the motors on the stage. I was hoping to create a program that could call those ASCII codes to move the stage. An example would be if a user wanted to have the stage move to the right he would press a b
    utton on the screen instead of typing in whatever ASCII could that move to the right happens to be. How would I go about programming something like this? I have heard of others doing things like this but I am unsure of how to program labview to send out ASCII codes to a PCI card to move motors.

    > would I go about programming something like this? I have heard of
    > others doing things like this but I am unsure of how to program
    > labview to send out ASCII codes to a PCI card to move motors.
    Look in the manual to see get familiar with the sequences of codes you
    need to write, and more importantly, where you write them to. I suspect
    a memory location, but it could be a socket or port.
    Each of these locations will have a slightly different way of accessing
    it. Once you know, search devzone for how to do it on linux, or post
    back here.
    After you can send the codes to the right location, you probably want to
    build a state machine that simplifies the interface and prevents certain
    actions from taking place. Now determine which buttons or
    keys perform
    which actions and use either the event structure or the older polling
    for control changes to affect state changes in the state machine.
    I'm summarizing here assuming that you know what a state machine is and
    why you'd want to use it. If I'm assuming too much, do some research
    and post again with more specific questions. Also be sure to look at
    example VIs as they show how to respond to UI actions.
    Greg McKaskle

  • Unable to print ASCII codes

    Hello,
    I am facing a problem in printing ASCII code between 128 and 159. these codes are displayed as '?'. All the other codes are printed correctly. Please let me know the reason behind this.
    Given below is the code for the same
    class Codes
         public static void main(String args[])
              short i = 165;
              for (i=0; i<=256;i+=5)
                   System.out.println(i+" "+(byte)i+" "+(i+1)+" "+(byte)(i+1)+" "+(i+2)+" "+(byte)(i+2)+" "+(i+3)+" "+(byte)(i+3)+" "+(i+4)+" "+(byte)(i+4));
    Waiting for a quick reply
    rgds,
    Sameer

    1. What are the chars you are talking about? As already mentioned, they are control chars in unicode. What character encoding would you like to use, or in other words, what characters would you like to have for those bytes?
    2. The character encoding of the dos console (Cp850 on the windozes I've used) is different from the system's default encoding (Cp1252, IIRC). This will cause problems if you want to print out text having non-ascii characters. For example System.out.println("&Aring;&Auml;&Ouml;") should print out the last three letters of the finnish alphabet but it prints something else instead. But if you write the text to a file it comes out as it should.
    Another character encoding can be used by wrapping an OutputStreamWriter around System.out:
    OutputStreamWriter osw = new OutputStreamWriter(System.out, "Cp850");
    PrintWriter out = new PrintWriter(osw, true);
    out.println("&Aring;&Auml;&Ouml;");
    Similarly, the input read through the standard inputstream in dos (the keyboard input or redirection using "<") is in another encoding and needs to be converted.

  • ASCII code to print barcode on Lexmark printer

    Hi there
    Can anyone help me on how to arrive at ASCII code to produce EAN 128B barcode on Lexmark T634n laser printer? 
    TJ

    Hi Elini
    Sorry about the delay in getting back to you.
    I want to print the barcode from SAP Script.
    Please let me know if you need more information.
    Regards & Thanks
    Tripura

  • Access code  for abap

    Hi everyone,
    Can you please guys post the access code for abap to mscagin at yahoo com
    thanks
    sri

    What do you mean by access code? Is this the same as a developer key?

  • T.code for ABAP Varaints

    Hi,
    Can anybody tell me the transaction code for ABAP varaints.
    In Se38 , Giving a program name and selecting the radiobutton varaints and click on display.
    We get  varaints screen. I need the transaction code for that screen.
    Regards,
    Sai

    Hi,
    This screen is only called from function module RS_VARIANT_SCREEN (easily found by using 'where-used').  This in turn is called from a number of places (SE38, SA38 etc) but I don't know of a transaction that goes to the variant screen directly.
    After all, the screen is only used if you populate the program name first, like in SE38 for example.
    Regards,
    Nick

  • Program Name which helps to hide the code of abap program

    Hello Experts,
              Could anybody help me in finding the name of the program on running which we can hide the CODE OF Abap program

    Here´s a snippet demonstrating how to hide the ABAP code of a given program
    REPORT z_hide_abap
      NO STANDARD PAGE HEADING.
    DATA: gt_code(72)  TYPE c OCCURS 0,
          gv_code      LIKE LINE OF gt_code,
          gt_code2(72) TYPE c OCCURS 0.
    PARAMETERS: program LIKE sy-repid.
    START-OF-SELECTION.
      READ REPORT program INTO gt_code.
      IF sy-subrc NE 0.
        MESSAGE e398(00) WITH 'Report' program 'not found.'.
    *   ATTENTION:
    *   READ REPORT on a hidden source code return SY-SUBRC=8 !!!
      ENDIF. "IF sy-subrc NE 0
      READ TABLE gt_code INDEX 1 INTO gv_code.
    * append *special* 1st line to hide cource code
      APPEND '*@#@@[SAP]' TO gt_code2.
      LOOP AT gt_code INTO gv_code.
        APPEND gv_code TO gt_code2.
      ENDLOOP.
      INSERT REPORT program FROM gt_code2.
    Reward points if helpful.

  • Can somebody tell me what is g-code in abap language

    hi,
    please help me about  g-code in abap language.
    thank u,
    subhasis,.

    I think,
    g-code means custom code.
    Custom one's will be started with Z, however Z is pronounced as "Zee".
    So, this seems to be relevant to customs.
    You may post this issue in ABAP group to get appropriate answer.
    warm regards
    sairam akundi

Maybe you are looking for

  • Sequence settings for HDV 720p 24 fps

    Okay, now that the French is gone I'm back on track, but still confused. I've captured my HDV 720p @ 24FPS footage using LumiereHD & it's separated & ready to go. What sequence settings/editing timebase should I use? I've noted people here saying DVC

  • Oracle 8i Internet for Red Hat Linux

    Hi all, Can any one help me on this. I have setting up Red Hat Linux 6.2 and JRE 1.1.6v5-glibc also installed on /usr/local/jre directory. But when I try to run "runInstaller" from the oracle cdrom. I have the following error: Initializing Java Virtu

  • Variant for Archiving Program

    Hello Experts, We are doing Upgrade from 4.7 to ECC 6.0 .  We need to generate the Archive Objects for the Tables  S022,S026,S027,S033,S502 etc. My question is after this Archive /Delete  Programs Generation, Will the Variants be available or not . T

  • Error in Creating Inbound delivery

    I'm creating an inbound delivery for General items PO, but when i go to t-code VL31N and select the desired PO and hit enter ..... it show me only three items out of 65 items. when i check the logs here it showing the following error. No item categor

  • Adobe air sony vaio tablet pc delaying problem..

    hi, i am created an app for our agency with adobe air.. app is working fine with pc, mac and etc. but, app isn't working with sony vaio i5 -win8 tablet pc. problem is , delaying. when use application with mouse , no problem. but, if you are using the