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: 

Need Help Urgent

Former Member
0 Kudos

1.How to transfer the data from presentation layer to application layer and vice-versa?

3 REPLIES 3

Former Member
0 Kudos

hI

Use transactions CG3Z and CG3Y

David

Former Member
0 Kudos

hi,

Using GUI_UPLOAD , you can take the data into internal table. Read this table and transfer to DATA SET.

Use

OPEN DATA SET

TRANSFER to DATASET

APPEND TO DATASET

CLOSE DATASET

Regards

Sandeep REddy

Former Member
0 Kudos

Hi Kiran,

I am giving some description and code to do so.

Steps:

--> Use function module GUI_UPLOAD to upload the file from presentation server to an internal table.

--> Use OPEN DATASET, TRANSFER and CLOSE DATASET statements to put the internal table to a file on the application server.

Transactions to use:

CG3Z : Presentation (desktop) to Application Server.

CG3Y : Application Server to Presentation Server.

Code Snippets:

    • Retrieve Data file from Application server(Upload from Unix)*

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.

    • Download internal table to presentation server file(PC)*

DATA: ld_filename TYPE string,

  • Pre version 4.7 declaration e_file like rlgrap-filename.

DATA: begin of it_datatab occurs 0,

row(500) type c,

end of it_datatab.

call function 'GUI_DOWNLOAD'

exporting

filename = ld_filename

filetype = 'ASC'

tables

data_tab = it_datatab[]

exceptions

file_open_error = 1

file_write_error = 2

others = 3.

    • Download internal table to presentation server file(PC)*

    • Separating fields/columns by a tab*

DATA: ld_filename TYPE string,

  • Pre version 4.7 declaration e_file like rlgrap-filename.

DATA: begin of it_datatab occurs 0,

col1(50) type c,

col2(50) type c,

col3(50) type c,

  • etc....

end of it_datatab.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = ld_filename

filetype = 'ASC'

  • APPEND = 'X'

write_field_separator = 'X'

  • CONFIRM_OVERWRITE = 'X'

TABLES

data_tab = it_datatab[]

EXCEPTIONS

file_open_error = 1

file_write_error = 2

OTHERS = 3.

    • Retrieve data file from presentation server(Upload from PC)*

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

DATA: begin of it_datatab occurs 0,

row(500) type c,

end of it_datatab.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = i_file

filetype = 'ASC'

TABLES

data_tab = it_datatab "ITBL_IN_RECORD[]

EXCEPTIONS

file_open_error = 1

OTHERS = 2.

Hope this prove to be helpful to you.

Please Reward Points if any of the above points are helpful.

Regards,

Kalyan Chakravarthy