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

save string data type text in the application server file opened in binary

Madhurivs23
Participant
0 Likes
1,218

Hi All,

My requirement is to save the string "abcd 23432423 asdada" to the text file in the application server.

I have written like this. but its not getting saved properly in the text file. Please help.


  constants X_LINESIZE type I value 128.
  types X_LINETYPE type X length X_LINESIZE.
data: WA_TAB_X type X_LINETYPE.
  data: str1(64) type C.
  data: WA_TAB_X_HDR1 type xstring.

  str1 = 'abcd    23432423   asdada'.
  CONVERT TEXT STR1 INTO SORTABLE CODE WA_TAB_X_HDR1.
  concatenate F_FILENAME1 SY-SYSID F_FILENAME2 '/' TAB_REGUT-TSNAM '.TXT' into F_FILENAME1.
  open dataset F_FILENAME1 for output in binary mode .
  if SY-SUBRC = 0.
    transfer WA_TAB_X_HDR to F_FILENAME1.
    loop at TAB_X into WA_TAB_X.
      transfer WA_TAB_X to F_FILENAME1.
    endloop.
  endif.
  close dataset F_FILENAME1.

Edited by: madhuri sonawane on Jun 2, 2009 4:05 PM

3 REPLIES 3
Read only

Former Member
0 Likes
757

Hi Madhuri,

try with

OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

CLOSE DATASET.

Read only

0 Likes
757

Hi Kishor,

I cannot open the text file in text mode since the other data which contains TAB_X table is in byte mode.

I need to convert that string into byte mode which is not happening I think. Is there any other solution?

Rgds,

Madhuri

Read only

Former Member
0 Likes
757

HI,

constants X_LINESIZE type I value 128.

types X_LINETYPE type X length X_LINESIZE.

data: WA_TAB_X type X_LINETYPE.

data: str1(64) type C.

data: WA_TAB_X_HDR1 type xstring.

data : file (1000) type c.

str1 = 'abcd 23432423 asdada'.

CONVERT TEXT STR1 INTO SORTABLE CODE WA_TAB_X_HDR1.

concatenate F_FILENAME1 SY-SYSID F_FILENAME2 '/' TAB_REGUT-TSNAM '.TXT' into F_FILENAME1.

open dataset file for output in binary mode .

if SY-SUBRC = 0.

transfer WA_TAB_X_HDR to file.

loop at TAB_X into WA_TAB_X.

transfer WA_TAB_X to file

endloop.

endif.

close dataset file.

regards,

Munibabu.k