Application Development and Automation 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: 
Read only

Tab Delimited File format

Former Member
0 Likes
2,810

Hello,

I have a requirement where i have to write a file in tab de-limited format into an application server. Request you to share your inputs for the same. The challenge is to write it in the Tab Delimited format.

Thanks,

Rahul.

Hello,

I have a requirement where i have to write a file in tab de-limited format into an application server. Request you to share your inputs for the same. The challenge is to write it in the Tab Delimited format.

Thanks,

Rahul.

9 REPLIES 9
Read only

Former Member
0 Likes
1,691

Hi,

Save the file as .txt file.

use gui_upload to upload file from presentation server to internal table and then use open dataset to transfer contents to app server.

Refer below code

&----


*& Report Z_CLFO_APP

*&

&----


*&

*&

&----


REPORT Z_CLFO_APP.

DATA:BEGIN OF I_TAB OCCURS 0,

CUST_ID TYPE BU_ID_NUMBER, "Customer ID

IDNUMBER TYPE BU_ID_NUMBER, "Investor ID

LOB(3) TYPE C, "Line of business

BP TYPE BU_PARTNER, "Business partner number

RECNO(5) TYPE C, "Record Number

MSG TYPE BAPI_MSG, "Error Message

END OF I_TAB.

data:l_file type string,

L_FILE1 TYPE STRING VALUE 'CLFO_1.TXT'.

insert

parameters:p_file like rlgrap-filename DEFAULT 'E:/CLFO'.

CLASS cl_abap_char_utilities DEFINITION LOAD.

CONSTANTS: con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.

start-of-selection.

move p_file to l_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = l_file

FILETYPE = 'ASC'

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 = I_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

  • OTHERS = 17

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

clear l_file.

OPEN DATASET L_FILE1 FOR OUTPUT in TEXT MODE ENCODING DEFAULT.

if sy-subrc = 0.

loop at i_tab.

concatenate i_tab-cust_id i_tab-idnumber i_tab-lob

into l_file separated by con_tab.

transfer l_file to l_file1.

clear l_file.

endloop.

close dataset l_file1.

endif.

Message was edited by:

Raghu Devagiri

Message was edited by:

Raghu Devagiri

Read only

JozsefSzikszai
Active Contributor
0 Likes
1,691

hi Vasanta,

FM: GUI_DOWNLOAD

there is a parameter : WRITE_FIELD_SEPARATOR ==> should be 'X' when you call the FM

hope this helps

ec

Read only

0 Likes
1,691

Hello Eric,

Thanks for your suggestion. But I need this format to be written in an Application Server, not in a Presentation Server.

Thanks,

Vasanth

Read only

0 Likes
1,691

Hi,

try this.

l_file1 is the file that will be created in app server.

CLASS cl_abap_char_utilities DEFINITION LOAD.

CONSTANTS: con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.

data:l_file type string.

OPEN DATASET L_FILE1 FOR OUTPUT in TEXT MODE ENCODING DEFAULT.

if sy-subrc = 0.

loop at i_tab.

concatenate i_tab-cust_id i_tab-idnumber i_tab-lob

into l_file separated by con_tab.

transfer l_file to l_file1.

clear l_file.

endloop.

close dataset l_file1.

Message was edited by:

Raghu Devagiri

Read only

0 Likes
1,691

Hello Rahul,

You can use the hexadecimal character '09' for horizontal tab.

Concatenate the fields separated by '09' and then transfer the data to the application server.

Regards,

Abhishek Jolly

Read only

JozsefSzikszai
Active Contributor
0 Likes
1,691

hi Vasanta,

FM: GUI_DOWNLOAD there is a parameter: WRITE_FIELD_SEPARATOR ==> should be 'X' when you call the FM

hope this helps

ec

Read only

Former Member
0 Likes
1,691

Vasanta Kumar,

None of the above options will work as you are trying to download unto the application server. GUI_DOWNLOAD is used to download onto the presentation server. You have to use <b>open dataset</b> and <b>close data</b> set to achieve your requirement.

Regards

Aneesh.

Read only

Former Member
0 Likes
1,691

Hi kumar,

Please fallow the below procedure it will help you out.

Open one word document.

Press the tab button there.

Copy that tab space.(Ctrl + C )

Come to your program and declare the constants

paste the copied value in below spave. ' '.

Constants : c_tab type c value ‘ ’. (ctrl + v)

Here paste your tab space which you have copied form word document.

concatenate 'rama' 'krishna' into v_value separated by c_tab.

Then transfer the file to application server.

If you are still facing the problem please let me know I will give you one data element.

Regards,

Rewards points…

Read only

Former Member
0 Likes
1,691

ok