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

abap

Former Member
0 Likes
1,225

how we get data from application server?

10 REPLIES 10
Read only

Former Member
0 Likes
1,177

Try pressing F1 before asking basic questions.

Didn't you read the "Rules of Engagement"?

Read only

0 Likes
1,177

use OPEN DATASET,CLOSE DATASET AND READ DATASET/TRANSFER DATASET Statements for posting or reading the data from application server

Read only

Former Member
0 Likes
1,177

Hi,

You can refer to below thread,you will find your solution here.

OR

For App Server:

OPEN DATASET p_file FOR INPUT

IN TEXT MODE

ENCODING DEFAULT.

READ DATASET p_file INTO w_filedata.

CLOSE DATASET l_file.

For Pres Server:

Use FM GUI_DOWNLOAD

<b>Reward if helpful and kindly close the thread if query is resolved</b>

Rgds,

Read only

Former Member
0 Likes
1,177

If you have to get data from the application server to your ABAP program use OPEN DATASET,READ DATASET,CLOSE DATASET.

If you want to get the data from the application server to the PC then execute the transaction CG3Y.Put the application server file address in the source file and the PC file address in the destination file.Press the button'DOWNLOAD'.The data will be transferred from the Application server to the PC file.

Read only

Former Member
0 Likes
1,177

Hi Siva,


DATA:
  con_str(50) TYPE C VALUE '/usr/temp/sample.dat',
  rec_len(80) TYPE C.
 OPEN DATASET con_str
      FOR INPUT IN TEXT MODE ENCODING DEFAULT.
  IF sy-subrc <> 0.
   EXIT.
 ELSE.
   READ DATASET con_str INTO rec_len. 
   WHILE sy-subrc <> 0.
      WRITE / rec_len.
      READ DATASET con_str INTO rec_len.
   ENDWHILE.
 ENDIF.
CLOSE DATASET con_str.

Hope this helps.

Regs,

Venkat Ramanan

Read only

Former Member
0 Likes
1,177

HI

GOOD

GO THROUGH THIS LINK WHICH WILL GIVE YOU THE BRIEF IDEA ABOUT THE APPLICATION SERVER

http://www.sapgenie.com/basis/

THANKS

MRUTYUN

Read only

venkat_o
Active Contributor
0 Likes
1,177

Hi Shiva Reddy,

<b>Method 1</b>.

Use key words OPEN ,READ,TRANSFER key words in the report and press F1 .Read the doucumentation .

<b>Method 2</b>.

Working with Files on the Application Server .

Have a look at this path .

http://help.sap.com/saphelp_46b/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm

I hope that u will go through like that.

<b>Thanks,

Venkat.O</b>

Read only

Former Member
0 Likes
1,177

Hi Siva,

Syntax :

OPEN DATASET <file name> FOR {OUTPUT/INPUT/APPENDING}

IN {TEXT/BINARY} MODE

<b>chk this program..</b>

DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.

OPEN DATASET i_file FOR INPUT IN TEXT MODE.

IF sy-subrc NE 0.

MESSAGE e999(za) WITH 'Error opening file' i_file.

ENDIF.

DO.

  • Reads each line of file individually

READ DATASET i_file INTO wa_datatab.

  • Perform processing here

  • .....

ENDDO.

Downloading files to SAP(Application Server)

  • 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.

Reward points if helpful,

Rgds,

Sumana

Read only

Former Member
0 Likes
1,177

Hi,

following code might help u.

To read data from a file on the application server, use the READ DATASET statement:

Syntax

READ DATASET <dsn> INTO <f> [LENGTH <len>].

This statement reads data from the file <dsn> into the variable <f>. In order to determine into which variable you should read data from a file, you need to know the structure of the file.

You can specify the transfer mode in the OPEN DATASET statement. If you have not already opened the file for reading, the system tries to open it either in binary mode, or using the additions from the last OPEN DATASET statement. However, it is good practice only to open files using the OPEN DATASET statement. For further information about the OPEN DATASET statement and the naming conventions for files, refer to Opening a File.

If the system was able to read data successfully, SY-SUBRC is set to 0. When the end of the file is reached, SY-SUBRC is set to 4. If the file could not be opened, SY-SUBRC is set to 8.

If you are working in binary mode, you can use the LENGTH addition to find out the length of the data transferred to <f>. The system sets the value of the variable <len> to this length.

DATA FNAME(60) VALUE 'myfile'.

DATA: TEXT1(12) VALUE 'abcdefghijkl',

TEXT2(5),

LENG TYPE I.

OPEN DATASET FNAME FOR OUTPUT IN BINARY MODE.

TRANSFER TEXT1 TO FNAME.

CLOSE DATASET FNAME.

OPEN DATASET FNAME FOR INPUT IN BINARY MODE.

DO.

READ DATASET FNAME INTO TEXT2 LENGTH LENG.

WRITE: / SY-SUBRC, TEXT2, LENG.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET FNAME.

The output is:

0 abcde 5

0 fghij 5

4 kl### 2

This example fills the file "myfile" with 12 bytes from the field TEXT1. It is then read into the field TEXT2 in 5-byte portions. Note here that the system fills up the last three bytes of TEXT2 with zeros after the end of the file has been reached. The number of bytes transferred is contained in the field LENG.

If you are working in text mode, you can use the LENGTH addition to find out the length of the current line in the file. The system sets the value of the variable <len> to the length of the line. The system calculates this by counting the number of bytes between the current position and the next end of line marker in the file.

DATA FNAME(60) VALUE 'myfile'.

DATA: TEXT1(4) VALUE '1234 ',

TEXT2(8) VALUE '12345678',

TEXT3(2),

LENG TYPE I.

OPEN DATASET FNAME FOR OUTPUT IN TEXT MODE.

TRANSFER: TEXT1 TO FNAME,

TEXT2 TO FNAME.

CLOSE DATASET FNAME.

OPEN DATASET FNAME FOR INPUT IN TEXT MODE.

DO 2 TIMES.

READ DATASET FNAME INTO TEXT3 LENGTH LENG.

WRITE: / TEXT3, LENG.

ENDDO.

CLOSE DATASET FNAME.

The output appears as follows:

12 4

12 8

This example writes the strings TEXT1 and TEXT2 to the file "myfile" in text mode. They are then read into the string TEXT3 (length 2). The amount of memory occupied by the lines is read into the field LENG.

Read only

Former Member
0 Likes
1,177

Hai Siva Reddy

Go through the following Code

REPORT ZTRAINING_FILE_DOWNLOAD_APPL message-id ZTRAING .

************************************************************************

  • PROGRAM : ZTRAINING_FILE_DOWNLOAD *

  • TITLE : Download customer details *

  • AUTHOR : Kavitha Hari *

************************************************************************

  • Modification Log *

  • Author : *

  • Date of change : *

  • Functional Spec # : *

  • Correction Request # : *

  • Description of Change : *

************************************************************************

----


  • T A B L E S

----


TABLES : KNA1. " Customer Master

----


  • types

----


**-- types for data to be downloaded

types: begin of tp_kna1,

KUNNR type kna1-kunnr, " customer number

LAND1 type kna1-land1, " Country Key

NAME1 type kna1-name1, " customer name

ORT01 type kna1-ort01, " city

PSTLZ type kna1-pstlz, " postal code

REGIO type kna1-regio, " region

end of tp_kna1.

----


  • I n t e r n a l T a b l e s

----


**-- Internal table for data to be downloaded

data: it_kna1 type standard table of tp_kna1 with header line.

----


  • S E L E C T I O N S C R E E N

----


  • Download File

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

select-options: s_kunnr for kna1-kunnr.

PARAMETERS :

P_AFILE LIKE RLGRAP-FILENAME

DEFAULT 'customer.txt'.

selection-screen end of block b1.

----


  • start of selection

----


start-of-selection.

perform get_data.

----


  • end of selection

----


If not it_kna1[] is initial.

perform DOWNLOAD_APP_FILE.

endif.

*&----


*& Form download_app_file

*&----


  • download data to the application server file

*----


FORM DOWNLOAD_APP_FILE.

DATA: L_MSG(100). " error message

OPEN DATASET P_AFILE FOR OUTPUT IN TEXT MODE ENCODING default.

IF SY-SUBRC = 0.

LOOP AT it_kna1.

TRANSFER it_kna1 TO P_AFILE.

ENDLOOP.

CLOSE DATASET P_AFILE.

ENDIF.

ENDFORM. " download_app_file

&----


*& Form get_data

&----


  • get data

----


FORM get_data .

select kunnr

land1

name1

ort01

pstlz

regio

into table it_kna1

from kna1

where kunnr in s_kunnr.

ENDFORM. " get_data

Thansk & regards

Sreenivasulu P