Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

to save it server

hi all

wht i get in output display in abap editor that as to be save it in application server in format of notepad.

thanks

Tags:
Former Member
Former Member replied

Hello,

There are 2 methods

1. in your current program, use the open dataset statement

wherever you have a write statement, replace it with a transfer statement to transfer the contents to the file instead of writing it to screen

Close your dataset at the end of the program

2. Run the following program

Change p_prog to your original report name

keep the rfc destination as NONE

change p_file to a filepath on your application server where you want your file to the written to

*&---------------------------------------------------------------------*
*& Report  ZKRIS_RUN_VIA_RFC
*&
*&---------------------------------------------------------------------*
*& Author  : Kris Donald
*& Date    : 04-09-2008
*& Purpose : Run a program via rfc (S_TCODE auth is needed for SE38)
*&---------------------------------------------------------------------*
*& Date Changed by Tag Description
*&
*&---------------------------------------------------------------------*

REPORT  zkris_run_via_rfc.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE f1.
PARAMETERS: p_dest LIKE rfcdes-rfcdest DEFAULT 'NONE'.
PARAMETERS: p_prog LIKE trdir-name DEFAULT 'Z'.
PARAMETERS: p_file(512) lower case default 'C:\file.txt'. 
SELECTION-SCREEN END OF BLOCK b1.

INITIALIZATION.
  f1 = 'Paramz'.

START-OF-SELECTION.

  DATA: lv_errormessage LIKE sy-msgv1.
  DATA: it_program      LIKE progtab   OCCURS 0 WITH HEADER LINE.
  DATA: it_writes       LIKE listzeile OCCURS 0 WITH HEADER LINE.

  READ REPORT p_prog INTO it_program.
  IF sy-subrc <> 0.
    WRITE: /'Could not read program ', p_prog.
    EXIT.
  ENDIF.


* Create on target system and retrieve screen output.
  CALL FUNCTION 'RFC_ABAP_INSTALL_AND_RUN'
    DESTINATION p_dest
    IMPORTING
      errormessage = lv_errormessage
    TABLES
      program      = it_program
      writes       = it_writes
    EXCEPTIONS
      OTHERS       = 1.

  open dataset p_file for output in text mode encoding default.

  LOOP AT it_writes.
    transfer it_writes to p_file.
  ENDLOOP.

  close dataset p_file.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question