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

OPEN DATASET

Former Member
0 Likes
689

I want to store report output in application sever .For that i followed open dataset.

My problem:

when i used below statements.

1) 1st

+OPEN DATASET PFILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.+_

+TRANSFER WAOUTPUT TO P_FILE.+_

+loop at ioutput into wa_output.+_

+write:/0 waoutput-werks,+_

+10 waoutput-matnr,+_

+25 waoutput-lgort,+_

+35 waoutput-labst.+_

endloop.

+CLOSE DATASET PFILE.+_

i got dump error:

Only character-type data objects are supported at the argument

position "f" for the statement

"TRANSFER f TO ..." .

In this case, the operand "f" has the non-character-type "TYOUTPUT" ._

The current program is flagged as a Unicode program. In the Unicode context ,

type X fields are seen as non-character-type, as are structures that

contain non-character-type components.

2) 2nd type

OPEN DATASET P_FILE FOR OUTPUT IN BINARY MODE.

TRANSFER WA_OUTPUT TO P_FILE.

loop at i_output into wa_output.

write:/0 wa_output-werks,

10 wa_output-matnr,

25 wa_output-lgort,

35 wa_output-labst.

endloop.

CLOSE DATASET P_FILE.

i donot get any error,but in t-code AL11.This file is creates without any data in it.

Kindly help me.

3 REPLIES 3
Read only

venkat_o
Active Contributor
0 Likes
652

Hi Saritha, 1. When you use IN TEXT MODE ENCODING default addition, it supports only character-type variables only. In your case wa_output-labst is a quantity field. check this F1 help on IN TEXT MODE.

... TEXT MODE encoding [linefeed]
. Effect: The addition IN TEXT MODE opens the file as a text file. The addition ENCODING defines how the characters are represented in the text file. When writing to a text file, the content of a data object is converted to the representation entered after ENCODING, and transferred to the file. If the data type is character-type and flat, trailing blanks are cut off. In the data type string, trailing blanks are not cut off. The end-of-line selection of the relevant platform is applied to the transferred data by default. When reading from a text file, the content of the file is read until the next end-of-line selection, converted from the format specified after ENCODING into the current character format, and transferred to a data object. The end-of-line selection used is controlled using the addition linefeed (as of Release 7.0). In Unicode programs, only the content of character-type data objects can be transferred to text files and read from text files. The addition encoding must be specified in Unicode programs, and can only be omitted in non-Unicode programs. Try to use BINARY MODE or create one structure with all Char Variables. Regards, Venkat.O

Read only

Former Member
0 Likes
652

Hi Saritha,

I think you have to make all the fields of the table t_output of type C.

then..try this...

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

loop at t_output into wa_output.

transfer wa_output TO p_file.

endloop.

CLOSE DATASET p_file

Read only

Former Member
0 Likes
652

Hi,

Please refer the code below:



*   Download internal table to Application server file(Unix)
DATA: e_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.

  open dataset e_file for output in text mode.
  lOOP AT it_datatab......
    transfer it_datatab to e_file.
  ENDLOOP.

  close dataset e_file.

Thanks,

Sriram Ponna.