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: 

Tab Delimiter

g_srivastava
Active Contributor
0 Kudos

Hi All,

I have uploaded a file from presentation server to application server using GUI Upload.The file is tab delimited field seperated by TABs.Now it is uploaded in the application server fine.Now I am downloading it from application server using Al11 List to File choosing unconverted .txt file using menu bar tool of the AL11 TCode.

Here it is giving me a file which is not a tab delimited instead it contains the field length as a seperator.

I want it to be a tab delimited any ideas.

Thanks

Edited by: Srivastava.G on Apr 30, 2009 8:11 AM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Use the following code

REPORT zdemo.

  • Type(s) definition

TYPES: BEGIN OF ty_testfile,

field1 TYPE bukrs,

field2 TYPE anln1,

field3(10) TYPE c,

field4(10) TYPE c,

field5(10) TYPE c,

END OF ty_testfile.

TYPES: BEGIN OF ty_testfile_file,

field1(10) TYPE c,

field2(10) TYPE c,

field3(10) TYPE c,

field4(10) TYPE c,

field5(10) TYPE c,

END OF ty_testfile_file.

  • Work area(s) definition

DATA: wa_file_data TYPE text4096,

wa_testfile TYPE ty_testfile,

wa_testfile_file TYPE ty_testfile_file.

  • Internal table(s) definition

DATA: tb_file_data TYPE TABLE OF text4096,

tb_testfile TYPE TABLE OF ty_testfile,

tb_testfile_file TYPE TABLE OF ty_testfile_file.

  • Class(s) definition

CLASS cl_abap_char_utilities DEFINITION LOAD.

  • EVENT - INITIALIZATION

INITIALIZATION.

  • EVENT - START OF SELECTION

START-OF-SELECTION.

  • Perform to upload data from a file

PERFORM upload_file.

PERFORM data_assign.

*&----


*

  • Form upload_file

*&----


*

  • To upload file data into SAP

*&----


*

FORM upload_file.

  • To read output in specified format from application server

PERFORM upload_app_server.

*To convert raw format to specified format

PERFORM data_convert.

ENDFORM. "upload_file

*&----


*

  • Form upload_app_server

*&----


*

  • To read file from application server

*&----


*

FORM upload_app_server.

DATA: lv_app_server_file TYPE string.

lv_app_server_file = 'pa_filep'.

  • To read file from Application server

OPEN DATASET lv_app_server_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

DO.

READ DATASET lv_app_server_file INTO wa_file_data.

IF sy-subrc = 0.

APPEND wa_file_data TO tb_file_data.

ELSE.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET lv_app_server_file.

ENDFORM. "upload_app_server

*&----


*

  • Form data_convert

*&----


*

  • To convert file to specified format

*&----


*

FORM data_convert.

DATA: lv_file_separator TYPE c.

lv_file_separator = cl_abap_char_utilities=>horizontal_tab.

  • To upload file in other formats(CSV, Tab delimited etc)

CALL FUNCTION 'TEXT_CONVERT_TEX_TO_SAP'

EXPORTING

i_field_seperator = lv_file_separator

i_tab_raw_data = tb_file_data

TABLES

i_tab_converted_data = tb_testfile_file

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.

ENDFORM. "data_convert

*&----


*

  • Form data_assign

*&----


*

  • To assign field value into character format

*&----


*

FORM data_assign.

LOOP AT tb_testfile_file INTO wa_testfile_file.

wa_testfile-field1 = wa_testfile_file-field1.

wa_testfile-field2 = wa_testfile_file-field2.

wa_testfile-field3 = wa_testfile_file-field3.

wa_testfile-field4 = wa_testfile_file-field4.

wa_testfile-field5 = wa_testfile_file-field5.

APPEND wa_testfile TO tb_testfile.

CLEAR wa_testfile.

ENDLOOP.

ENDFORM. "data_assign

Regards,

Manish

11 REPLIES 11

kanishakgupta1
Contributor
0 Kudos

in gui_upload,

give the file extension as ' DAT '.

and download the file from application server through list to file ->unconverted->speadsheet.

This is the best way

regards

kanishak

0 Kudos

Hi Kanishak,

I tried using DAT in GUI_UPLOAD it is still field length between two fields.In the Scenario it has to be txt file on notepad with tab when i download it from Al11 using menu option

List -> Save/send-> File-> unconverted.

Thanks, Have a best day ahead.

0 Kudos

Hi,

Use the Tcode CG3Y to download the file from Application server to Presentation server.

Tcode CG3Z to upload the file from Presentation server to Application server .

0 Kudos

hi,

How u r transferring ur records to Application Server.

What is the syntax for OPEN DATA SET statement u r using.

Use the below statement

OPEN DATASET <Fname> FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    LOOP AT it INTO wa.
      TRANSFER wa TO <fname>.
      IF sy-subrc <> 0.
        EXIT.
      ENDIF.
    ENDLOOP.
    CLOSE DATASET <fname>..

Hope it helps you.

Thanks & Regards

0 Kudos
CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename                      = 'FILEPATHXXXXXXXXXXX.txt'
   FILETYPE                      = 'ASC///DAT tried both'
   HAS_FIELD_SEPARATOR           = 'X'
*   HEADER_LENGTH                 = 0
*   READ_BY_LINE                  = 'X'
*   DAT_MODE                      = ' '
*   CODEPAGE                      = ' '
*   IGNORE_CERR                   = ABAP_TRUE
*   REPLACEMENT                   = '#'
*   CHECK_BOM                     = ' '
*   VIRUS_SCAN_PROFILE            =
*   NO_AUTH_CHECK                 = ' '
* IMPORTING
*   FILELENGTH                    =
*   HEADER                        =
  tables
    data_tab                      = t_tab
 EXCEPTIONS
   FILE_OPEN_ERROR               = 1
   FILE_READ_ERROR               = 2
   NO_BATCH                      = 3
   GUI_REFUSE_FILETRANSFER       = 4
   INVALID_TYPE                  = 5
   NO_AUTHORITY                  = 6
   UNKNOWN_ERROR                 = 7
   BAD_DATA_FORMAT               = 8
   HEADER_NOT_ALLOWED            = 9
   SEPARATOR_NOT_ALLOWED         = 10
   HEADER_TOO_LONG               = 11
   UNKNOWN_DP_ERROR              = 12
   ACCESS_DENIED                 = 13
   DP_OUT_OF_MEMORY              = 14
   DISK_FULL                     = 15
   DP_TIMEOUT                    = 16
          .

OPEN DATASET appl FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT t_tab INTO fs_tab.
  TRANSFER fs_tab TO appl.
ENDLOOP.

I am using this code for the upload program

0 Kudos

hi,

FILETYPE                      = 'ASC' "--->
*   HAS_FIELD_SEPARATOR           = 'X'    "---> comment this thing

Thanks & Regards

Former Member
0 Kudos

Hi,

Download the data in the form of spread sheet .xls.

Now save this excel as tab delimited .txt file.

Thanks,

Sowmya

0 Kudos

Hi Sowmya,

its the same no matter i chooose yes for unicode option or no.

Thanks.

kanishakgupta1
Contributor
0 Kudos

Hi friend,

I tried AL11 and i was also getting the data the way u are getting.

if u want to get the data as tab delimited,

do get it fom the program using open-close datasets and gui_download.

for gui_upload and download

use file extension as ' DAT ' and comment field seperator.

thnks

kanishak

Edited by: Kanishak Gupta on Apr 30, 2009 9:19 AM

Former Member
0 Kudos

Hi,

Use the following code

REPORT zdemo.

  • Type(s) definition

TYPES: BEGIN OF ty_testfile,

field1 TYPE bukrs,

field2 TYPE anln1,

field3(10) TYPE c,

field4(10) TYPE c,

field5(10) TYPE c,

END OF ty_testfile.

TYPES: BEGIN OF ty_testfile_file,

field1(10) TYPE c,

field2(10) TYPE c,

field3(10) TYPE c,

field4(10) TYPE c,

field5(10) TYPE c,

END OF ty_testfile_file.

  • Work area(s) definition

DATA: wa_file_data TYPE text4096,

wa_testfile TYPE ty_testfile,

wa_testfile_file TYPE ty_testfile_file.

  • Internal table(s) definition

DATA: tb_file_data TYPE TABLE OF text4096,

tb_testfile TYPE TABLE OF ty_testfile,

tb_testfile_file TYPE TABLE OF ty_testfile_file.

  • Class(s) definition

CLASS cl_abap_char_utilities DEFINITION LOAD.

  • EVENT - INITIALIZATION

INITIALIZATION.

  • EVENT - START OF SELECTION

START-OF-SELECTION.

  • Perform to upload data from a file

PERFORM upload_file.

PERFORM data_assign.

*&----


*

  • Form upload_file

*&----


*

  • To upload file data into SAP

*&----


*

FORM upload_file.

  • To read output in specified format from application server

PERFORM upload_app_server.

*To convert raw format to specified format

PERFORM data_convert.

ENDFORM. "upload_file

*&----


*

  • Form upload_app_server

*&----


*

  • To read file from application server

*&----


*

FORM upload_app_server.

DATA: lv_app_server_file TYPE string.

lv_app_server_file = 'pa_filep'.

  • To read file from Application server

OPEN DATASET lv_app_server_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

DO.

READ DATASET lv_app_server_file INTO wa_file_data.

IF sy-subrc = 0.

APPEND wa_file_data TO tb_file_data.

ELSE.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET lv_app_server_file.

ENDFORM. "upload_app_server

*&----


*

  • Form data_convert

*&----


*

  • To convert file to specified format

*&----


*

FORM data_convert.

DATA: lv_file_separator TYPE c.

lv_file_separator = cl_abap_char_utilities=>horizontal_tab.

  • To upload file in other formats(CSV, Tab delimited etc)

CALL FUNCTION 'TEXT_CONVERT_TEX_TO_SAP'

EXPORTING

i_field_seperator = lv_file_separator

i_tab_raw_data = tb_file_data

TABLES

i_tab_converted_data = tb_testfile_file

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.

ENDFORM. "data_convert

*&----


*

  • Form data_assign

*&----


*

  • To assign field value into character format

*&----


*

FORM data_assign.

LOOP AT tb_testfile_file INTO wa_testfile_file.

wa_testfile-field1 = wa_testfile_file-field1.

wa_testfile-field2 = wa_testfile_file-field2.

wa_testfile-field3 = wa_testfile_file-field3.

wa_testfile-field4 = wa_testfile_file-field4.

wa_testfile-field5 = wa_testfile_file-field5.

APPEND wa_testfile TO tb_testfile.

CLEAR wa_testfile.

ENDLOOP.

ENDFORM. "data_assign

Regards,

Manish

0 Kudos

HI All,

You all have been a great help.Thanks.

Have a best day ahead.