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

write data in internal table to application server

Former Member
0 Likes
2,911

can anyone please tell me how to put all the data in the internal table m_itab into the application server with the path specified as "/export/SAPtf/aiainc".

thanks in advance......

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,297

You need to use Open dataset command.

data : v_file(128) type c value '/export/SAPtf/aiainc'.

open dataset v_file for output in text mode .

loop at itab.

transfer itab data to v_file.

endloop.

close dataset v-file.

Reward Points if it is helpful

Thanks

Seshu

3 REPLIES 3
Read only

Former Member
0 Likes
1,297

check this sample coding

REPORT test.

*--Internal table & Work area Declaration

DATA : t_data TYPE STANDARD TABLE OF t000,

wa_data TYPE t000.

DATA : w_message(100) TYPE c.

*--Application Server File path from user

PARAMETERS : p_file TYPE rlgrap-filename.

START-OF-SELECTION.

*--Get data into the Internal table t_data

SELECT * FROM t000 INTO TABLE t_data .

*--- Create the application server file path

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT MESSAGE w_message.

*--- Display error messages if any.

IF sy-subrc NE 0.

MESSAGE w_message TYPE 'E'.

EXIT.

ELSE.

*---Data is downloaded to the application server file path

LOOP AT t_data INTO wa_data.

TRANSFER wa_data TO p_file.

ENDLOOP.

ENDIF.

*--Close the Application server file (Mandatory).

CLOSE DATASET p_file.

IF sy-subrc NE 0.

MESSAGE 'Error closing the File' TYPE 'E'.

EXIT.

ELSEIF sy-subrc IS INITIAL.

WRITE : 'File saved in the location' , p_file.

ENDIF.

Read only

Former Member
0 Likes
1,298

You need to use Open dataset command.

data : v_file(128) type c value '/export/SAPtf/aiainc'.

open dataset v_file for output in text mode .

loop at itab.

transfer itab data to v_file.

endloop.

close dataset v-file.

Reward Points if it is helpful

Thanks

Seshu

Read only

Former Member
0 Likes
1,297

dsn = '/export/SAPtf/aiainc'

OPEN DATASET dsn IN TEXT MODE.

LOOP AT M_ITAB.

TRANSFER M_ITAB TO dsn.

ENDLOOP.

CLOSE DATASET.