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

Need to save a file on Application server, receiving error.

Former Member
0 Likes
1,799

Hello,

I want to save a file on Application server.

I have data in the final output table gt_out_chng.

I want to write a file in the application server and this is the

code that written,

data : MY_NEW_FILE type file.

MY_NEW_FILE = '/tmp/test.txt'.

data: gv_output(255) type c,

P_FILE TYPE rlgrap-filename.

p_file = 'F:\USR\SAP\PUT'.

CONCATENATE p_file '\' sy-datum sy-uzeit '.txt'

INTO p_file.

OPEN DATASET 'P_FILE' IN TEXT MODE FOR OUTPUT

ENCODING DEFAULT.

IF SY-SUBRC = 0.

LOOP AT GT_OUT_CHNG INTO WA_OUTPUT_TAB.

TRANSFER WA_OUTPUT_TAB TO 'P_FILE'.

CLEAR WA_OUTPUT_TAB.

ENDLOOP.

ENDIF.

CLOSE DATASET 'P_FILE'.

i am receiving an error message as follows :

"WA_OUTPUT_TAB" cannot be a table, a reference,

a string, or contain any of these objects.

Please correct the code if found any errors..

Any suggestions will be apprecaited!

Regards,

Kittu

Edited by: Kittu on May 15, 2009 10:27 AM

1 ACCEPTED SOLUTION
Read only

kanishakgupta1
Contributor
0 Likes
1,458

Hi Kittu,

The only mistake i suppose u have done is u have taken the P_FILE in qoutes.

Please remove the quetes everywhere.

regards

kanishak

Hello,

I want to save a file on Application server.

I have data in the final output table gt_out_chng.

I want to write a file in the application server and this is the

code that written,

data : MY_NEW_FILE type file.

MY_NEW_FILE = '/tmp/test.txt'.

data: gv_output(255) type c,

P_FILE TYPE rlgrap-filename.

p_file = 'F:\USR\SAP\PUT'.

CONCATENATE p_file '\' sy-datum sy-uzeit '.txt'

INTO p_file.

OPEN DATASET 'P_FILE' IN TEXT MODE FOR OUTPUT

ENCODING DEFAULT.

IF SY-SUBRC = 0.

LOOP AT GT_OUT_CHNG INTO WA_OUTPUT_TAB.

TRANSFER WA_OUTPUT_TAB TO 'P_FILE'.

CLEAR WA_OUTPUT_TAB.

ENDLOOP.

ENDIF.

CLOSE DATASET 'P_FILE'.

i am receiving an error message as follows :

"WA_OUTPUT_TAB" cannot be a table, a reference,

a string, or contain any of these objects.

Please correct the code if found any errors..

Any suggestions will be apprecaited!

Regards,

Kittu

Edited by: Kittu on May 15, 2009 10:27 AM

8 REPLIES 8
Read only

Former Member
0 Likes
1,458

Hi!

Tell us, please how did you declare the WA_OUTPUT_TAB variable?

It should not contain any of the objects, that the error message mentioned.

Regards

Tamá

Read only

karol_seman
Active Participant
0 Likes
1,458

Hi,

you are using wrong variable name. P_FILE holds the path for local file, not in application server, therefor you have an error during opening the dataset. So use correct variable and also don't use apostrophes for variable name because then it is not the variable value but the path is you variable!!


OPEN DATASET MY_NEW_FILE IN TEXT MODE FOR OUTPUT
ENCODING DEFAULT.

Regards,

Karol

Edited by: Karol Seman on May 15, 2009 10:33 AM

Read only

Former Member
0 Likes
1,458

Hi

TRANSFER WA_OUTPUT_TAB TO 'P_FILE'.

dont put P_FILE under single colen

rite one- TRANSFER WA_OUTPUT_TAB TO P_FILE.

Read only

former_member189059
Active Contributor
0 Likes
1,458

Hello,

Instead of using the following,

OPEN DATASET 'P_FILE' IN TEXT MODE FOR OUTPUT ENCODING DEFAULT.

use this,

OPEN DATASET P_FILE IN TEXT MODE FOR OUTPUT ENCODING DEFAULT.

P_FILE is your variable, do not put it in quotes

Edit: The same thing applies for your transfer and close statements

Edited by: Kris Donald on May 15, 2009 2:05 PM

Read only

matt
Active Contributor
0 Likes
1,458

TRANSFER line TO filename.

line MUST be a flat structure. Though you've not given the definition, it sounds like WA_OUTPUT_TAB is a table. Either that or it contains tables, references or string. Just like the error message says.

matt

Read only

Former Member
0 Likes
1,458

Data : P_FILE TYPE rlgrap-filename.

Here need to specify the length, DATA : P_FILE(128) TYPE RLGRAP-FILENAME.

Read only

kanishakgupta1
Contributor
0 Likes
1,459

Hi Kittu,

The only mistake i suppose u have done is u have taken the P_FILE in qoutes.

Please remove the quetes everywhere.

regards

kanishak

Read only

Former Member
0 Likes
1,458

Hello,

Thank you for your quick response!

My issue is fixed!

The only mistake was I had kept the file name in qoutes. When removed from the quotes it was working fine.

I apprecaite the help/suggestions!

Regards,

Kittu