Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

Open dataset, CRLF and blank lines after every record

$
0
0

Hello,

I need help regarding open dataset coding in couple of reports I'm developing for one of our vendors. This is my initial coding:

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

CONCATENATE '/rb-sftp/' sy-sysid '/RB_MENA_KUW_Mezzan_OutletSales_' gv_date '.csv' INTO gv_filename.

 

   IF NOT lt_final[] IS INITIAL.

 

* Openining the Dataset....

     OPEN DATASET gv_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

 

     IF sy-subrc EQ 0.

 

* Moving the data to dataset.

       LOOP AT lt_final INTO wa_final.

 

         CONCATENATE wa_final-kunrg wa_final-slqty wa_final-slval wa_final-frqty wa_final-vrkme wa_final-fkdat

         wa_final-matnr wa_final-rtqty wa_final-dmqty INTO gv_string SEPARATED BY '|'.

         TRANSFER gv_string TO gv_filename.

         CLEAR: gv_string, wa_final.

       ENDLOOP.

 

* Closing the dataset.....

       CLOSE DATASET gv_filename.

       WRITE 'File is uploaded to application server'(003) .

       WRITE /'Path:'(004).

       WRITE gv_filename.

     ELSE.

       WRITE 'File is not uploaded to application server'(005).

     ENDIF.

   ELSE.

     WRITE 'No data found for generation of file'(006).

   ENDIF.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

When I open the resulting file in Notepad, the data looks like a continous line as though Word Wrapped but when I open the file normally, it shows the records one line below the other. Since it was difficult for the vendor to distinguish between records, they asked us to use the Carriage Return/Line feed to separate records. After doing the necessary changes, now in Notepad it displaying as one line below the other but when opened normally, the file has one blank line after each record. Is there any way to remove the blank lines or to prevent it from happening, yet get the records in the proper format? Below is the code I have now:

----------------------------------------------------------------------------------------------------

 

CONCATENATE '/rb-sftp/' sy-sysid '/RB_MENA_KUW_Mezzan_OutletSales_' gv_date '.csv' INTO gv_filename.

 

   l_v_cr_lf = cl_abap_char_utilities=>cr_lf.

 

   IF NOT lt_final[] IS INITIAL.

 

* Openining the Dataset....

     OPEN DATASET gv_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

 

     IF sy-subrc EQ 0.

 

* Moving the data to dataset.

       LOOP AT lt_final INTO wa_final.

 

         CONCATENATE wa_final-kunrg wa_final-slqty wa_final-slval wa_final-frqty wa_final-vrkme wa_final-fkdat

         wa_final-matnr wa_final-rtqty wa_final-dmqty l_v_cr_lf INTO gv_string SEPARATED BY '|'.

         TRANSFER gv_string TO gv_filename.

         CLEAR: gv_string, wa_final.

       ENDLOOP.

 

* Closing the dataset.....

       CLOSE DATASET gv_filename.

       WRITE 'File is uploaded to application server'(003) .

       WRITE /'Path:'(004).

       WRITE gv_filename.

     ELSE.

       WRITE 'File is not uploaded to application server'(005).

     ENDIF.

   ELSE.

     WRITE 'No data found for generation of file'(006).

   ENDIF.


Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>