Skip to Content
author's profile photo Former Member
Former Member

Reading appln server file

Hi all,

I have a file in appln server with no standard structure(no seperator)

like this

ex:

I20000000 LAGER 0 STATUS BMNR 3 .(first line)

here in this file i need only first field (I20000000) and

last field (3)for batch input.

please help me.

regards,

chandu

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 12, 2005 at 08:00 AM

    Hi Chandu,

    You can get the entire value into an internal table and then read the offset value of the fields you require, for eg,

    I20000000 = field+0(9).

    Sudha

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 12, 2005 at 08:01 AM

    Hi Sai,

    You have to read the whole file and take only information you need.

    DATA: line TYPE string,

    file(20) TYPE C value '/usr/test.dat'.

    OPEN DATASET file IN TEXT MODE ENCODING DEFAULT FOR INPUT.

    DO.

    READ DATASET file INTO line.

    IF sy-subrc <> 0.

    EXIT.

    ENDIF.

    • Now you can use the sub string option and take the relevant value. For example

    firstfield = line+0(9).

    ENDDO.

    Cheers

    Vinod

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 12, 2005 at 08:03 AM

    data: temp(3000) ,

    len type i .

    move:

    'I20000000 LAGER 0 STATUS BMNR 3' to temp .

    varA = temp+0(10) .

    len = strlen( temp ) .

    len = len - 3 .

    varB = temp+len(3) .

    Regards

    Raja

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 12, 2005 at 08:03 AM

    Hi Chandu

    You have to know the position and length of informations you want to find out.

    For ex: I20000000 LAGER 0 STATUS BMNR 3

    OPEN DATASET FILE IN TEXT MODE...

    IF SY-SUBRC = 0.

    DO.

    READ DATASET FILE INTO WA.

    IF SY-SUBRC <> 0. EXIT. ENDIF.

    FIELD1 = WA(9). "-> I20000000

    FIELD2 = WA+30(1). "-> 3

    ENDDO.

    ENDIF.

    Max

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi

      I think you are in the tunnel without exit, if you can't know how the file is, you can't dicide how to find out the informations you need.

      So you have to know where information is in the line and which the line you have to read:

      DO.

      READ DATASET FILE INTO WA.

      IF SY-SUBRC <> 0. EXIT. ENDIF.

      IF SY-INDEX = 1. "it's reading the first line

      ......

      • If you have to read only this line you can exit from

      • cycle.

      exit.

      ENDIF.

      ENDDO.

      Max

      Message was edited by: max bianchi

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.