Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Dataset writing in .dat (multiple lines)

Former Member
0 Kudos

Hi,

I write in .dat file with my dataset.

The problem is : I can't make a new line for each transfer.

Have someone an idea ?

My code :


OPEN DATASET filename_ventes FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

select  *
from    CE13910
where   PERIO = '2008002'
and     ALTPERIO = '2008006'.

MOVE CE13910-VV800 TO c_converted2.
MOVE CE13910-VV000 TO c_converted3.

  CONCATENATE CE13910-PERIO CE13910-ALTPERIO CE13910-ARTNR 
CE13910-PAPH2 CE13910-PAPH3 c_converted2 c_converted3
  INTO resultString SEPARATED BY separatedString .

  transfer resultString to filename_ventes.

ENDSELECT.

CLOSE DATASET filename_ventes.

Thanks for your help.

Nico

1 ACCEPTED SOLUTION

former_member156446
Active Contributor
0 Kudos

try this way:

data: co_line_feed TYPE c VALUE cl_abap_char_utilities=>cr_lf.

concatenate resultString co_line_feed into resultString. " and then transfer

  transfer resultString to filename_ventes.

3 REPLIES 3

former_member376453
Contributor
0 Kudos

Why don't you first finish your selection, then loop into table and download the data into application server line by line. Refer to below code:


 LOOP AT itab_header INTO wa_header.
*---Make all the header data into line data
    CONCATENATE wa_header-combi
                wa_header-descr
                wa_header-werks
                wa_header-blank1
                wa_header-blank2
                wa_header-blank3
                wa_header-blank4
    INTO  wa_string1                        " Header String Data
    SEPARATED BY c_tab.

"---Transfer the data to Application Server
    TRANSFER wa_string1 TO v_fpath1.
    IF sy-subrc EQ 0.
      v_counter1 = v_counter1 + 1.
    ENDIF.

    CLEAR: wa_string1.

  ENDLOOP.

former_member156446
Active Contributor
0 Kudos

try this way:

data: co_line_feed TYPE c VALUE cl_abap_char_utilities=>cr_lf.

concatenate resultString co_line_feed into resultString. " and then transfer

  transfer resultString to filename_ventes.

Former Member
0 Kudos

HI,

The better way is to put your code as per the Kuntal Nandi specifed. Fetch the data first and later loop the table and uploaad to application server.

data: cr_lf TYPE c VALUE cl_abap_char_utilities=>CR_LF.

OPEN DATASET filename_ventes FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
 
select  *
from    CE13910
where   PERIO = '2008002'
and     ALTPERIO = '2008006'.
 
MOVE CE13910-VV800 TO c_converted2.
MOVE CE13910-VV000 TO c_converted3.
 
CONCATENATE CE13910-PERIO  CE13910-ALTPERIO CE13910-ARTNR 
                         CE13910-PAPH2 CE13910-PAPH3       c_converted2 
                         c_converted3 cr_lf         --------------> Add Cr_lf    for new line    
                 INTO resultString 
    SEPARATED BY separatedString .
 
  transfer resultString to filename_ventes.
 
ENDSELECT.
 
CLOSE DATASET filename_ventes.

Edited by: Avinash Kodarapu on Mar 10, 2009 10:35 PM