cancel
Showing results for 
Search instead for 
Did you mean: 

how to create a CSV file

Former Member
0 Kudos

Hi all,

Is there any functional module exist to create a CSV file.

Regards,

Lisa

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI Lisa ,

try this..

SAP_CONVERT_TO_CSV_FORMAT

a sample of the same..

TYPE-POOLS:TRUXS.
DATA: BEGIN OF ITAB OCCURS 0,
     VBELN
LIKE VBAP-VBELN,
      POSNR LIKE VBAP-POSNR,
      END OF ITAB.
DATA:
ITAB1 TYPE TRUXS_T_TEXT_DATA.
SELECT VBELN         POSNR         UP TO
10 ROWS         FROM VBAP         INTO TABLE ITAB.
CALL FUNCTION
  'SAP_CONVERT_TO_CSV_FORMAT'
  EXPORTING
    I_FIELD_SEPERATOR    = ';'
  TABLES
    I_TAB_SAP_DATA       = ITAB
  CHANGING
    I_TAB_CONVERTED_DATA = ITAB1
  EXCEPTIONS
    CONVERSION_FAILED    = 1
    OTHERS               = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO         WITH SY-MSGV1
SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    FILENAME = 'C:TEMPtest.txt'
  TABLES
    DATA_TAB = ITAB1
  EXCEPTIONS
    OTHERS   = 1.

check this thread

regards

satesh

Answers (5)

Answers (5)

former_member188685
Active Contributor
0 Kudos

Hi Lisa,

the above code which you found in the replies is from the thread

given by me.

just check it ,

Regards

vijay

Former Member
0 Kudos

Hi Vijay,

Yes its your reply and

it was taken from the forum..

i just want to help her with a code that has already solved the problem rather than creating a new code ..

hi lisa you can very well assign points to vijay ..

regards

satesh

former_member188685
Active Contributor
0 Kudos

Hi Sateesh,

Don't take it in wrong way. take it easy.

Regards

vijay

mr_v
Active Contributor
0 Kudos

Hi Vijay,

I tried to execute code, but i'm experiencing an error saying that "The type-pool 'TRUXS' is unknown

Suggestions pls

Thanks

V

former_member188685
Active Contributor
0 Kudos

Because

1. you don't have TRUX in your system. since you are on Older Version.

2. any way check it in SE11 for TRUX in Type Group,just let me know is it there or not.

3. check you have that FM or not.

Regards

vijay

Former Member
0 Kudos

Hi

Go through this link.I hope this will help you to create a CSV files.

http://www.dalestech.com/Media/files/docs/file/Programming_with_file_class_100.pdf

Thanks

Mrutyunjaya Tripathy

former_member188685
Active Contributor
0 Kudos

Hi Lisa,

Check this sample code..

REPORT  ZTESTAA.
 
TYPE-POOLS:TRUXS.
DATA: BEGIN OF ITAB OCCURS 0,
      VBELN LIKE VBAP-VBELN,
      POSNR LIKE VBAP-POSNR,
      END OF ITAB.
DATA:
ITAB1 TYPE TRUXS_T_TEXT_DATA.
SELECT VBELN 
       POSNR   
      UP TO 10 ROWS
      FROM VBAP  
     INTO TABLE ITAB.
CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
  EXPORTING
    I_FIELD_SEPERATOR    = ';'
  TABLES
    I_TAB_SAP_DATA       = ITAB
  CHANGING
    I_TAB_CONVERTED_DATA = ITAB1
  EXCEPTIONS
    CONVERSION_FAILED    = 1
    OTHERS               = 2.
IF SY-SUBRC <> 0.

ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    FILENAME = 'C:TEMPtest.txt'
  TABLES
    DATA_TAB = ITAB1
  EXCEPTIONS
    OTHERS   = 1.

Regards

vijay

Message was edited by: Vijay Babu Dudla

Former Member
0 Kudos

Hi lisa,

1. SAP_CONVERT_TO_CSV_FORMAT

we can use the above FM.

regards,

amit m.

Former Member
0 Kudos

Try FM: SAP_CONVERT_TO_CSV_FORMAT