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

Open dataset concept.

Hi,

I did a program for transfering data from database tables to a .dat or .txt file on my PC using the dataset concept.

the program runs without error but the data is not downloaded into the file. What can be the problem?

Here is the code.

&----


*& Report ZOPDSETOPV

*&

&----


*&

*&

&----


REPORT ZOPDSETOPV.

TABLES : LFA1, EKKO.

PARAMETERS : FILE(200) TYPE c.

DATA : BEGIN OF ITAB OCCURS 0,

LIFNR LIKE LFA1-LIFNR,

NAME1 LIKE LFA1-NAME1,

EBELN LIKE EKKO-EBELN,

BUKRS LIKE EKKO-BUKRS,

EKORG LIKE EKKO-EKORG,

EKGRP LIKE EKKO-EKGRP,

END OF ITAB.

SELECT LFA1NAME1 EKKOEBELN EKKOBUKRS EKKOEKORG EKKO~EKGRP INTO TABLE

ITAB FROM LFA1 INNER JOIN EKKO ON LFA1LIFNR = EKKOLIFNR.

OPEN DATASET FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT ITAB FROM 1 TO 3.

TRANSFER ITAB TO FILE.

ENDLOOP.

CLOSE DATASET FILE.

Thanks...

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 16, 2006 at 06:50 AM

    Hi,

    There is another option to download the data from the Internal table to Local file.

    That is using "GUI_DOWNLOAD" Function moldule.

    Kindly check the following code:

    TABLES : lfa1, ekko.
    
    DATA : BEGIN OF itab OCCURS 0,
             lifnr LIKE lfa1-lifnr,
             name1 LIKE lfa1-name1,
             ebeln LIKE ekko-ebeln,
             bukrs LIKE ekko-bukrs,
             ekorg LIKE ekko-ekorg,
             ekgrp LIKE ekko-ekgrp,
           END OF itab.
    
    PARAMETERS : file(200) TYPE c.
    
    SELECT lfa1~name1 ekko~ebeln ekko~bukrs ekko~ekorg ekko~ekgrp INTO TABLE
    itab FROM lfa1 INNER JOIN ekko ON lfa1~lifnr = ekko~lifnr.
    
    IF sy-subrc EQ 0.
    
      MOVE file TO i_file.
    
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename              = i_file
          filetype              = 'DAT'
          write_field_separator = ' '
        TABLES
          data_tab              = itab.
    
      IF sy-subrc NE 0.
        MESSAGE  'Error writing File' TYPE 'E'.
        EXIT.
      ELSEIF sy-subrc IS INITIAL.
        WRITE : 'File saved in the location' , i_file.
      ENDIF.
    
    ENDIF.

    The contents of the Internal table will be moved to the text file in the specified location.

    hope this helps!

    best regards,

    Thangesh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 16, 2006 at 09:46 AM

    hi friend,

    u have written

    open datase <file> for output in textmode encoding default

    but what is the path that u have given for file

    check that file path in tcode AL11.

    go to AL11 and check whether data has been updated in that specific directory or not. if not just check your program once perfectly(set filepath correctly).

    or there may be another reason by default when you run

    the system stores all the files in /user/temp

    there might be a case of less space.

    try for another file path and run the program

    check in the directory whether file has been uploaded

    or not.

    all the best

    srinivas

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 16, 2006 at 09:51 AM

    reply back to me if u have any queries

    Add a comment
    10|10000 characters needed characters exceeded

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.