How to read specified no of charcters?

Hi
I want to read PO text in internal table.
I want to read only first 60 characters of the address field.
Specifying no of charcters in data field or using 'outputlen' in fieldcat is not giving any results.
Pls. suggest proper method or function for doing this.
Giving code for reference-
TYPES : BEGIN OF ty_final,
        ebeln LIKE ekko-ebeln,   "PUR DOC
        bsart LIKE ekko-bsart,   "DOC TYP
        ernam LIKE ekko-ernam,   "NANE OF THE PERSON WHO CREATED THE DOC
        lifnr LIKE ekko-lifnr,   "VENDOR ACCOUNT
        zterm LIKE ekko-zterm,   "TERMS OF PAYMENT KEY
        ekgrp LIKE ekko-ekgrp,   "PUR GRP
        inco2 LIKE ekko-inco2,   "INCOTERMS
        werks LIKE ekpo-werks,   "PLANT
        menge LIKE ekpo-menge,   "PO QTY
        meins LIKE ekpo-meins,   "UNIT OF QTY
        netpr LIKE ekpo-netpr,   "NET PRICE
        peinh LIKE ekpo-peinh,   "PRICE UNIT
        kzwi1 LIKE ekpo-kzwi1,   "TOTAL LANDED COST
        bedat LIKE ekko-bedat,   "DOC DATE
        name1 LIKE lfa1-name1,   "VENDOR NAME
        lines LIKE tline-tdline,
        text(60) TYPE c,
        END OF ty_final.
DATA: it_text TYPE STANDARD TABLE OF mat_text,
      wa_text TYPE mat_text.
DATA: wa_thead TYPE thead.
DATA: it_lines LIKE TABLE OF tline,
      wa_lines TYPE tline.
DATA : it_final TYPE TABLE OF ty_final,
       wa_final TYPE ty_final.
DATA : it_final1 TYPE TABLE OF ty_final,
       wa_final1 TYPE ty_final.
DATA:  it_fieldcat TYPE TABLE OF slis_fieldcat_alv,
       wa_fieldcat TYPE slis_fieldcat_alv.
--SCREENS--
SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME.
PARAMETER:        p_ekorg LIKE  ekko-ekorg OBLIGATORY,
                  p_ekgrp LIKE  ekko-ekgrp.
SELECT-OPTIONS:   s_bedat FOR ekko-bedat.
SELECTION-SCREEN: END OF BLOCK blk1.
SELECTION-SCREEN: BEGIN OF BLOCK blk2 WITH FRAME TITLE text-001.
PARAMETER: r_grid TYPE c  RADIOBUTTON GROUP grp2.
PARAMETER: r_list TYPE c  RADIOBUTTON GROUP grp2.
SELECTION-SCREEN: END OF BLOCK blk2.
--START OF SELECTION--
START-OF-SELECTION.
  PERFORM getdata.
  PERFORM fill_alv_list.
  PERFORM printdata.
*&      Form  GETDATA
      text
-->  p1        text
<--  p2        text
FORM getdata .
  SELECT * INTO CORRESPONDING FIELDS OF wa_final FROM  ekko AS a INNER JOIN ekpo AS b
  ON  amandt = bmandt
  AND aebeln = bebeln CLIENT SPECIFIED
         WHERE  a~mandt  = sy-mandt
         AND    a~ebeln  LIKE '%'
         AND    a~ekorg  =  p_ekorg
         AND    a~ekgrp  =  p_ekgrp
         AND    a~bedat  IN s_bedat.
    COLLECT wa_final INTO it_final.
    CLEAR wa_final.
  ENDSELECT.
  LOOP AT it_final INTO wa_final.
    SELECT SINGLE name1 INTO wa_final-name1 FROM  lfa1 CLIENT SPECIFIED
           WHERE  mandt  = sy-mandt
           AND    lifnr  = wa_final-lifnr.
    MODIFY it_final FROM wa_final.
    CLEAR wa_final.
  ENDLOOP.
  LOOP AT it_final INTO wa_final.
    wa_thead-tdid     = 'F02'.
    wa_thead-tdspras  = 'EN'.
    wa_thead-tdname   = wa_final-ebeln.
    wa_thead-tdobject = 'EKKO'.
    REFRESH it_lines.
    CALL FUNCTION 'READ_TEXT'                                               "function for getting the PO header text
      EXPORTING
       client                         = sy-mandt
        id                            = wa_thead-tdid
        language                      = wa_thead-tdspras
        name                          = wa_thead-tdname
        object                        = wa_thead-tdobject
  ARCHIVE_HANDLE                = 0
  LOCAL_CAT                     = ' '
IMPORTING
  HEADER                        =
      TABLES
        lines                         = it_lines
  EXCEPTIONS
   id                            = 1
   language                      = 2
   name                          = 3
   not_found                     = 4
   object                        = 5
   reference_check               = 6
   wrong_access_to_archive       = 7
   OTHERS                        = 8
    LOOP AT it_lines INTO wa_lines.  "  WHERE tdline NE ' '.
      wa_text-ebeln  = wa_final-ebeln.
      wa_text-lines  = wa_lines-tdline.
      APPEND wa_text TO it_text.
     CLEAR wa_final.
      CLEAR wa_text.
      CLEAR wa_lines.
    ENDLOOP.
    wa_thead-tdname = ' '.
    CLEAR wa_final.
  ENDLOOP.
  REFRESH it_final1.
  LOOP AT it_text INTO wa_text.
    READ TABLE it_final INTO wa_final WITH KEY ebeln = wa_text-ebeln.
    MOVE-CORRESPONDING wa_final TO wa_final1.
    wa_final1-lines = wa_text-lines.
   wa_final1-text = wa_final1-lines.
   IF ( STRLEN( wa_final1-lines ) > 60 ).
     MOVE wa_final1-lines TO wa_final1-text.
    string
   ENDIF.
    APPEND wa_final1 TO it_final1.
    CLEAR wa_final1.
    CLEAR wa_text.
    CLEAR wa_final.
  ENDLOOP.
ENDFORM.                    " GETDATA
*&      Form  FILL_ALV_LIST
      text
-->  p1        text
<--  p2        text
FORM fill_alv_list .
  PERFORM fill_fieldcat USING 'WERKS' 'WERKS' 'EKPO'  ' ' ' ' ' ' ' '.
  PERFORM fill_fieldcat USING 'EKGRP' 'EKGRP' 'EKKO'  ' ' ' ' ' ' ' '.
  PERFORM fill_fieldcat USING 'BSART' 'BSART' 'EKKO'  ' ' ' ' ' ' ' '.
  PERFORM fill_fieldcat USING 'EBELN' 'EBELN' 'EKKO'  ' ' ' ' ' ' ''.
  PERFORM fill_fieldcat USING 'BEDAT' 'BEDAT' 'EKKO'  ' ' ' ' ' ' ''.
  PERFORM fill_fieldcat USING 'ERNAM' 'ERNAM' 'EKKO'  ' ' ' ' ' ' ''.
  PERFORM fill_fieldcat USING 'NAME1' 'NAME1' 'LFA1'  ' ' ' ' ' ' ''.
  PERFORM fill_fieldcat USING 'KZWI1' ' '     ' '     'Total Value' ' ' ' ' ''.
  PERFORM fill_fieldcat USING 'PEINH' 'PEINH' 'EKPO'  ' ' ' ' ' ' ''.
  PERFORM fill_fieldcat USING 'ZTERM' ' '     ' '     'Terms Of Payment' ' ' ' ' ''.
  PERFORM fill_fieldcat USING 'INCO2' 'INCO2' 'EKPO'  ' '                ' ' ' ' ''.
  PERFORM fill_fieldcat USING 'LIFNR' 'LIFNR' 'EKKO'  ' '                ' ' ' ' ''.
  PERFORM fill_fieldcat USING 'LINES' ' '     ' '     'PO Header'        ' ' ' ' '60'.
PERFORM fill_fieldcat USING 'TEXT'  ' '      ' '    ' TEXT'            ' ' ' ' '60'.
ENDFORM.                    " FILL_ALV_LIST
*&      Form  PRINTDATA
      text
-->  p1        text
<--  p2        text
FORM printdata .
  IF ( r_grid = 'X' ).
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        it_fieldcat   = it_fieldcat
      TABLES
        t_outtab      = it_final1
      EXCEPTIONS
        program_error = 1
        OTHERS        = 2.
  ENDIF.
  IF ( r_list = 'X' ).
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
        it_fieldcat   = it_fieldcat
      TABLES
        t_outtab      = it_final1
      EXCEPTIONS
        program_error = 1
        OTHERS        = 2.
  ENDIF.
ENDFORM.                    " PRINTDATA
*&      Form  fill_fieldcat
      text
     -->P_0204   text
     -->P_0205   text
     -->P_0206   text
     -->P_0207   text
     -->P_0208   text
     -->P_0209   text
FORM fill_fieldcat  USING  p_fieldname
                         p_reffldname
                         p_reftabname
                         p_seltext
                         p_cfieldname
                         p_qfieldname
                         p_outputlen
  CLEAR wa_fieldcat.
  wa_fieldcat-fieldname = p_fieldname.
  wa_fieldcat-ref_fieldname = p_reffldname.
  wa_fieldcat-ref_tabname = p_reftabname.
  wa_fieldcat-seltext_l = p_seltext.
  wa_fieldcat-seltext_s = p_seltext.
  wa_fieldcat-seltext_m = p_seltext.
  wa_fieldcat-outputlen = p_outputlen.
  APPEND wa_fieldcat TO it_fieldcat.
ENDFORM.                    " fill_fieldcat
Regards
Harshada

Hi,
After calling the FM 'READ_TEXT' , read each line of the table it_lines and concatenate the data into some variable v_data and pass v_data to the internal table.
Regards,
Krishna K.

Similar Messages

  • How to read and write data in to a specified range of cells(it include multiple row & columns) in excel

    How to read and write data in to a specified range of cells(it include multiple row & columns) in excel

    CVI Comes with a sample project that explains how to read/write to a Excel file: choose "Explore examples..." in CVI welcome page and navigate to <cviSampleDir>\activex\excel folder where you can load excel2000dem.prj.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • How to read the data in excel sheet

    Dear sir,
    How to read the data in excel sheet when i recieve a data serial communication... ie i have store a data in excel such that
    Cell A       Cell B
       A           Apple 
       B           Ball
       C           Cat
       D           Doll
    when i recieve A from serial communication i have to display Apple, and when i recieve B i have to display Ball and so on.. 

    Hi, 
    I would recommend you to have a look at the VI attached. It makes use of a VI named 'Read from Spreadsheet' to read the row and column data from the tab delimited excel file. The read data is then searched for the Alphabet specified and finally returns you the corresponding string. The test file used to validate the operation of the VI is also attached. 
    Trust this would help you solve the issue. 
    Regards, 
    Sagar G Yadav | Application Engineer | National Instruments
    Attachments:
    read_from_excel.vi ‏10 KB
    Book1.txt ‏1 KB

  • How do I specify an external viewer for animation?

    I occasionally receive PDF files that have accompanying animations (.avi, etc) that Adobe acrobat reader 9.4.1 expects to play using an external viewer.
    On one of my computers (Linux, KDE), it launches xine.  On another (also Linux, KDE), it launches noatun.
    How do I specify which external viewer it should launch?

    This is handled through file associations defined in the OS. Adobe Reader is simply passing the file off to the OS.
    In your file manager/desktop, find a plain AVI file, right click on it to get the contextual menu. You should be able to set your preferred associated program from there.

  • How can we specify the Mailbox for Notes?

    In Mail.app, how can we specify the Mailbox for Notes (where the new notes will be resided)? It is now 'On My Mac'. I wish to change to my IMAP Mailbox so it sync with my iPhone by just checking email (not by syncing on iTunes).
    Thanks in advance.
    Message was edited by: Ekapon

    You could use the DecimalFormat or NumberFormat to do the job.
    double number 1234.567;
    DecimalForamt df = new DecimalFormat("###.##");
    String s = df.format(number);or
    double number 1234.567;
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMaximumFractionDigits(2);
    /* if needed.
       nf.setMaximumIntegerDigits(value);
       nf.setMinimumFractionDigits(value);
       nf.setMinimumIntegerDigits(value); */
    String s = nf.format(number);I didn't test the codes but they should work. For more information, please consult the documentations.

  • Help me...How to read the content if "Transfer-Encoding:chunked" is used?

    I am doing a project for internet control using Java,PHP and MySql.All sites should go through the proxy server only.If the HTTP header contains Content-Length,am getting the content length as below:
    public class HTTPResponseReader extends HTTPMessageReader
        String statusCode;
        public HTTPResponseReader(InputStream istream) throws IOException,                     NoSuchElementException
      BufferedInputStream distream = new BufferedInputStream(istream);
      retrieveHeader(distream);
      StringTokenizer st =  new StringTokenizer(new String(HTTPMessageReader.toArray(header)));
      versionProtocol = st.nextToken();
      statusCode = st.nextToken();
      String s;
      while (st.hasMoreTokens())
            s = st.nextToken();
            if (s.equals("Transfer-Encoding:"))
           transferEncoding = new String(st.nextToken());
         if (s.equals("Content-Length:"))
           contentLength = Integer.parseInt(st.nextToken());
         if (s.equals("Connection:"))
          connection = new String(st.nextToken());
          if (connection.equals("keep-alive")) mustCloseConnection = false;
       retrieveBody(distream);     
    }After getting the Content-Length,i used read method to read the content upto that content length.Then i concatenated the HTTP header and body and the requested site was opened.But some sites dont have Content-Length.Instead of that,Transfer-Encoding is used.I got the HTTP Response header as "Transfer-Encoding:chunked" for some sites.If this encoding is used how to get the length of the message body and how to read the content.
    Can anybody help me.
    Thanks in advance...
    Message was edited by:
    VeeraLakshmi

    Why don't you use HttpUrlConnection class to retrieve data from HTTP server? This class already supports chunked encoding...
    If you want to do anything by yourself then you need to read HTTP RFC and find all required information. Well in two words you may reject advanced encoding by specifying HTTP 1.0 in your request or download chunked answer manually. Read RFC anyway :)

  • How to read the content of a text file (by character)?

    Guys,
    Good day!
    I'm back just need again your help. Is there anyone knows how to read the content of a text file not by line but by character.
    Please help me. Thank you so much in advance.
    Jojo

    http://java.sun.com/javase/6/docs/api/index.html
    package java.io
    InputStream.read(): int
    Reads the next byte of data from the input stream.
    Implementation:
    InputStreamReader
    An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes them into characters using a specified charset. The charset that it uses may be specified by name or may be given explicitly, or the platform's default charset may be accepted.

  • How Can i specify multiple server names in rwservlet.properties  file?

    How Can i specify multiple server names in rwservlet.properties file without clustering?
    I am using oracle 10g Application server. we have 3 servers Repsvr1, RepSvr2 and RepSvr3. Now i need to configure rwservlet.properties file to point to these servers based on any running report. i got 3 keymap files with reports info.
    Sample entry in the key map file is:
    key1: server=Repsvr1 userid=xxx/yyy@dbname report=D:\Web\path1\path2\reports\Report1.rdf destype=cache desformat=PDF %*
    key2: server=Repsvr2 userid=xxx/yyy@dbname report=D:\Web\path1\path3\reports\Report2.rdf destype=cache desformat=PDF %*
    rwservlet.properties file letting me to enter only one servername. Even though i merged all 3 keymap files into 1, still i have the server name issue. If i leave the server to the default name still i am getting the below error.
    REP-51002: Bind to Reports Server Repsvr1 failed. However, i know the default rep_<servername> would be used incase we dont have SERVER=<value> parameter in the rwservlet.properties file.
    If i specify the servername in the rwservlet.properties file then only Repsvr1 reports are working fine and other 2 server reports are giving the same error like
    REP-51002: Bind to Reports Server <<Server Name>> failed.
    how can i configure the info which will work all 3 reports. 2 Port servers are invoking using oracle forms and report server is invoking using ASP pages.
    If i specify Server name & Key map file in rwservlet.properties one at a time, all the reports are working without any error, whenever i am trying to integrate all 3 to workable i am getting binding error. if i exclude the server from rwservlet.properties still i am getting the same error.

    My RELOAD_KEYMAP setting is YES only.As i said If i specify Server name & Key map file in rwservlet.properties one at a time, all the reports are working without any error.
    keymap file entries
    key1: server=Repsvr1 userid=xxx/yyy@dbname report=D:\Web\path1\path2\reports\Report1.rdf destype=cache desformat=PDF %*
    key2: server=Repsvr2 userid=xxx/yyy@dbname report=D:\Web\path1\path3\reports\Report2.rdf destype=cache desformat=PDF %*
    If i use http://server.domain:port/reports/rwservlet? cmdkey = key1 should bring the report from Repsvr1 and http://server.domain:port/reports/rwservlet? cmdkey = key2 should bring the report from Repsvr2, but i am getting an error from Repsvr2 saying that REP-51002: Bind to Reports Server repsvr2 failed.
    Only Servername Repsvr1 is in rwservlet.properties file. Now what is the best option to by pass the server from rwservlet.properties file and should be from keymap file. if i comment server name in rwservlet.properties file still i am getting REP-51002: Bind to Reports Server <<Server Name>> failed error for both keys.

  • How do I specify the JRE i wish to use to Run an Application.

    Hi Everyone;
    Please bear with me if you read this before.
    I have installed java 1.3.1 and java 1.4.1 in that order.
    The JRE used by default is java 1.4.1
    How do I specify the JRE I wish to use to Run an Application from a command prompt.
    Example:
    Java -something org.jboss.Main
    help ??
    Stephen

    I was a lil embarrassed. I told my supervisor that the installation of java overwrites the JRE and that's that.
    My supervisor took 10 minutes and went through it and found java.exe in the System32 file.
    The java.exe file is found in guess where "C:/WINNT/System32/" folder how nice. C:/WINNT/System32/ is in the path. Not only that it's the first entry in the path. So when I execute java it is not using java.exe any one of the java files that I got from the java website.
    So I don't have any control over the version.
    Oh well;
    That's life. That's 1 for my supervisor.
    Stephen

  • How to read a text/html file in java regardless of its encoding?

    Hi All,
    How to read a text/html file in java regardless of its encoding?
    1. Is there any way to identify that a file (read using FileInputStream/or any other means with java.io package) has been saved with which type of encoding i.e. whether the file is using ANSI encoding or Unicode encoding or other?
    2. Is there any standard way to read an encoded file (i.e. files having UTF-16 format for Asian locales character support) and un-encoded file (i.e. files having ordinary ANSI format) correctly without knowing the user input?
    The problem is that while creating an instance of 'InputStreamReader' (ISR) we can pass the encoding type used (otherwise it takes the system's default encoding type), and the ISR expects the file to be in the same encoding format otherwise it reads it as some junk. But we don't know which file the user is going to pass whether it is Unicode (for Asian locales file should be in Unicode) with or ANSI coded (for non-Asian / English locales user generally uses ANSI encoding).
    Regards,
    Sam

    1. There is no reliable way of guessing the encoding of a file without that information. Thats why XML for example has very strict rules wrt. it's encoding (short form: use UTF-8 or UTF-16, if you use anything else, you'll have to specify it)
    2. you might be able to make an educated guess if the possible range of encodings is limited, but it will probably never be 100% certain
    3. The HTML file might have a header entry "<meta http-equiv..." that tells you about it's encoding. You could try to read the start of the file and see if you find that, then if you found it re-read the entire file.
    regards

  • How to read the files in different directories

    how to read the files in different directories here directory names will change dynamically under root node.
    let me say
    rootnode---->subnode1
    >subnode2
    >subnode3
    >subnode n
    how to specify these in file adapter.

    Hi
    look at this thread your problem is solved here
    File Adapter
    Regards
    Abhishek
    Edited by: Abhishek Agrahari on Dec 16, 2008 11:37 AM

  • How To Dynamically specify ArchiveDirectory for SyncRead operation in SOA11g

    Hi All
    I am trying to perform a read operation(SyncRead) and depending on the dynamic input directory location, I need to modify or change the ArchiveDirectory location as well.
    As per the JCA file of the file adapter, I do have the PhysicalArchiveDirectory or LogicalArchiveDirectory, but how can I specify this value from BPEL?
    < adapter-config name="fileRead" adapter="File Adapter" wsdlLocation="fileRead.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
    <adapter-config name="readFile" adapter="File Adapter" wsdlLocation="readFile.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
      <connection-factory location="eis/FileAdapter"/>
      <endpoint-interaction portType="SynchRead_ptt" operation="SynchRead">
        <interaction-spec className="oracle.tip.adapter.file.outbound.FileReadInteractionSpec">
          <property name="DeleteFile" value="true"/>
          <property name="PhysicalDirectory" value="C:\Read"/>
          <property name="FileName" value="AA12666.pdf"/>
          <property name="PhysicalArchiveDirectory" value="C:\Temp"/>
        </interaction-spec>
      </endpoint-interaction>
    </adapter-config>
    I want to specify the value for PhysicalArchiveDirectory from BPEL
    I am able to set physicalDirectiry and filename through jca.file.Directory  and  jca.file.FileName respectively but what about the ArchiveDirectory?
    Please help.
    Thanks in advance
    Abhinav

    You cannot defined the wildcard for the file names. But you can provide the file name dynamically if you are on soa suite 10.1.3.4 minimum. You can get information about that in this link http://download.oracle.com/docs/cd/E12524_01/relnotes.1013/e12523/adapters.htm#CHDBBFBD

  • How can I specify an SFTP directory path that has spaces in it?

    The directory (path) on my SFTP server has spaces in some of the folder names: e.g. /data/Cisco Products/UC Applications/
    How can I specify this path in the directory field of a remote server definition if I want to upload files from my SFTP server to the CUCM?
    I've tried surrounding the whole path in quotes, %, *, backslash space, point, hash...running out of things to try. Must be possible...surely?!#
    Thank-you
    -Rob.

    I haven't tried this but when i hit tab to auto complete on a linux machine i notice a space and backslash between two words. I can see you tried backslash space. Try space backspace - <word><space><backslash><word>

  • How to read a passward protected excel file with the help of database connectivity tool kit

    hi, i was reading an excel file with the help of database connectivity tool kit in labview 8.0
    i made tabels in the excel file nand made odbc connection and specified the workbbok name.
    now my problem is how to read the same file if i specife a pasword to that excel file ?

    Hi,
    Check out this thread about opening a password-protected Excel file using ActiveX. This should take care of it for you!
    Amanda Howard
    Americas Services and Support Recruiting Manager
    National Instruments

  • How do I specify exact corners with the rectangular selection tool?

    Suppose I have an image 2000 pixels wide by 1000 pixels high.  Pixel (0,0) is at the top left as you view the image.  Using the rectangular selection tool, how can I specify an exact area to select?  Say, for example, I want to select the area defined by (0,0), (100,0), (100,100) & (0,100), how would I do this?
    I'm using Photoshop CS6 on a Mac with OSX 10.8.3.
    Any help is appreciated.
    Thanks,
    Kevin H.

    Mylenium,
    33,406 posts!  That's amazing.  Thanks for your technique for specifying an exact selection size.  I tried it out and it works, but is there a way to get the marquee to snap to the guides, as opposed to snapping to pixels.  I can't quite get the marquee to fall exactly where I place the guides, at least not easily.
    Here's a method I've come up with since posting my question.  (I guess I should have tried harder to figure this out before asking the question.)
    Figure out beforehand where you want the corners of the selection marquee to be.
    Activate the rulers: View>Rulers or (Cmd-R.)
    Set rulers to pixels: Photoshop>Preferences>Units&Rulers>Rulers>Pixels
    Select the rectangular selection tool.
    In the menu bar for the selection tool choose Style>Fixed Size.  Then in the dimension boxes to the right of the Style button, type in the width and height you want for your selection, e.g. 200 by 100 pixels.
    Zoom in on where you want the top left pixel of your selection to be.  Zoom in enough to clearly see the pixel.
    With the selection tool active, click-and-release on the pixel you have zoomed in on.
    Go back to normal view (Cmd-0) and you should see your entire selection.
    This answers my own question, and with your method I now have two ways to do this.
    Thanks,
    Kevin H.

Maybe you are looking for