Skip to Content
author's profile photo Former Member
Former Member

EXTRACTing to TEXT file in Data Warehouse - Simple doubts!

Hi Experts,

Pls. clarify my simple doubts, in data EXTRACTing prog.,(data extract from SAP to text file in Application server, prog. runs in back ground)

For the Dataware house mapping, I hv been asked to make the following changes,

1) Presently, there is NO column headings in Text file, so I need to add the column Headings - How to get it done?

2) presently, its NOT tab deliminated, so, I need to make it to TAB deliminated- How to achieve it?

I am here paste some piece of code, so that U will get understand well.

PERFORM open_dataset_zdata_whouse_04.

DESCRIBE FIELD i_tab LENGTH tfr_length IN BYTE MODE.

LOOP AT i_itab.

TRANSFER i_itab TO transfer_file1 LENGTH tfr_length.

ENDLOOP.

CLOSE DATASET transfer_file1.

ThaNQ.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 03:55 AM

    See the below code :

    parameters: d1 type localfile default

    '/usr/sap/TST/SYS/Test.txt'.

    data: begin of itab occurs 0,

    field1(20) type c,

    field2(20) type c,

    field3(20) type c,

    end of itab.

    data: str type string.

    constants: con_tab type x value '09'.

    • if you have a newer version, then you can use this

    instead.

    *constants:

    • con_tab type c value

    cl_abap_char_utilities=>HORIZONTAL_TAB.

    start-of-selection.

    itab-field1 = 'ABC'.

    itab-field2 = 'DEF'.

    itab-field3 = 'GHI'.

    append itab.

    itab-field1 = '123'.

    itab-field2 = '456'.

    itab-field3 = '789'.

    append itab.

    open dataset d1 for output in text mode.

    loop at itab.

    translate itab using ' # '.

    concatenate itab-field1 itab-field2 itab-field2

    into str

    separated by con_tab.

    translate str using ' # '.

    transfer str to d1.

    endloop.

    close dataset d1.

    above code for tab delimited.

    for heading then you can write simple logic in the loop of internal table

    loop at itab.

    if sy-tabix = 1'

    move heading data to file.

    endif.

    endloop.

    Thanks

    Seshu

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.