Application Development 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: 

to save it server

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

former_member189059
Active Contributor
0 Kudos

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.

9 REPLIES 9

Former Member
0 Kudos

Hi Santosh,

Please be descriptive in your query so that we can understand what help exactly you want.

Regards,

Shailesh

0 Kudos

wht i get in output display in abap editor that as to be save it in application server in format of notepad. HOW TO WRITE CODE PLZ GUIDE ME PROPERLY

0 Kudos

Hi,

If you want to transfer after showing the output then you need to do interactive reporting.

How are you displaying your data ? ALV or standard ? If in ALV you need to set pf status and do a user command and then when you click the button on your output screen you need to write the dataset commands in your User command form.

For standard output we need to do the same things but they are not very complex..

Are you planning to change any output a value and then transfer it? If not you can do output display and transfer to server parallelly.

Regards,

Pramod

0 Kudos

This message was moderated.

0 Kudos

plz send me code how to doit

Former Member
0 Kudos

Hi,

When you get your data into the final internal table then please use the dataset commands to write the value into the application server.

Please type 'OPEN DATASET' on your abap screen and press F1 and it will help you write the required code.

Regards,

Pramod

former_member189059
Active Contributor
0 Kudos

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 Kudos

hi,

what get in ouput display that as to be save it in server as text format

0 Kudos

Hi,

For this in your output screen you need to define a new button for export to local server ( using set-pf-status command in your program ) and when you click on this button you need to handle this event using a user command routine.

Regards,

Pramod