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

download data from application server

Former Member
0 Likes
1,412

Hi Experts,

How to download data from application server to a flat file and excel file.Please help me with valuable inpute.<<removed_by_moderator>>

Regards,

Sunita.

Edited by: Vijay Babu Dudla on Dec 31, 2008 5:07 AM

Hi Experts,

How to download data from application server to a flat file and excel file.Please help me with valuable inpute.<<removed_by_moderator>>

Regards,

Sunita.

Edited by: Vijay Babu Dudla on Dec 31, 2008 5:07 AM

12 REPLIES 12
Read only

Former Member
0 Likes
1,380

>

> Hi Experts,

> Correct answers will be appriciated with good points.

>

>

> Regards,

> Sunita.

U r not supposed to write that its against the forum rules.please dont repeat that.

for ur query check these links

SAP Library document

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e0901cba-f49e-2910-748c-d7ce4c0c...

wiki code sample

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/to%2bdownload%2bdata%2bfrom%2bapplicatio...

кu03B1ятu03B9к

Edited by: kartik tarla on Dec 31, 2008 9:00 AM

Read only

Former Member
0 Likes
1,380

Download the data by using Open Dataset in program, or else you can use CG3Y transaction

Regards

Sasi

Read only

Former Member
0 Likes
1,380

Please search in SCN and Spend some time at least for yourself out of long 24hrs in a day.

Read only

Former Member
0 Likes
1,380

<<deleted_by_moderator>>

Edited by: Vijay Babu Dudla on Dec 31, 2008 5:06 AM

Read only

Former Member
0 Likes
1,380

Hi watch this thread

[;

reg

Ramya

Read only

Former Member
0 Likes
1,380

Hi,

This is the code to pic data from a file on app server


DATA: A TYPE STRING VALUE '/usr/sap/dev/sys/global/at02.txt'.
DATA: BEGIN OF RECORD OCCURS 0,
       DATA(500),
     END OF RECORD.

OPEN DATASET A FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
 READ DATASET A INTO RECORD.
 IF SY-SUBRC <> 0.
   EXIT.
 ELSE.
   APPEND RECORD.
 ENDIF.
ENDDO.

CLOSE DATASET A.

" where /usr/sap/dev/sys/global/at02.txt is the path of file on the app server provided to u by basis

" people. U will get the data into an internal table. Once u get the data in internal table u can use

" FM GUI_DOWNLOAD to download data into flat file

Read only

0 Likes
1,380

Hi Gang,

Sasi,Santhosh,Ramya,Amit

Please refer =>

Happy New Year to you all,

Have a nice and pleased next year,

Cheers,

Amit.

Read only

Former Member
0 Likes
1,380

Hi..

U can download the file to desktop by using the below function Module.

DATA: loc_fname1 TYPE string.

CONCATENATE p_file '\' INTO p_file.

CONCATENATE p_file p_fname1 INTO loc_fname1.

CONDENSE loc_fname1.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = loc_fname1

filetype = 'ASC'

append = 'X'

write_field_separator = 'X'

TABLES

data_tab = int_mat_unix '' your final internal table

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

OTHERS = 22.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

If we want in unix:

CONSTANTS c_row TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.

CONCATENATE p_unix p_fname1 INTO p_fname1.

CONDENSE p_fname1.

OPEN DATASET p_fname1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc <> 0.

MESSAGE e001(zbhi) WITH text-t17.

EXIT.

ELSE.

LOOP AT int_mat_unix INTO wa_mat_unix. "int_mat_unix is final internal table

CLEAR wf_out_unix.

CONCATENATE wa_mat_unix-matnr

wa_mat_unix-meins

wa_mat_unix-revlv

wa_mat_unix-maktx

wa_mat_unix-tdline

INTO wf_out_unix SEPARATED BY c_row.

CONDENSE wf_out_unix.

TRANSFER wf_out_unix TO p_fname1.

ENDLOOP.

CLOSE DATASET p_fname1.

IF sy-subrc <> 0.

MESSAGE e001(zbhi) WITH text-t18.

ENDIF.

MESSAGE s001(zbhi) WITH text-t19.

ENDIF.

CLEAR wf_tabix.

DESCRIBE TABLE int_mat_unix LINES wf_tabix.

WRITE: 'No of records extracted: ', wf_tabix.

Read only

Former Member
0 Likes
1,380

Hi

Is your question answered?

reg

Ramya

Read only

Former Member
0 Likes
1,380

Hi,

Below is the code to read data from application server.Goto AL11 transaction check file is available and take that path as string varible(dataset)

Open Dataset <Dataset Name> For Input In Text Mode Encoding Default.

If Sy_subrc = 0.

Do

Read Dataset <Dataset Name> Into WA.

If Sy_Subrc <> 0.

Exit.

Endif.

Append WA to IT_TAB.

Enddo.

Close dataset<Dataset Name>.

Regards

Md.MahaboobKhan

Read only

Former Member
0 Likes
1,380

Hi,

Spend some time & understand the code.


   report z_opendataset_input.
DATA: BEGIN OF it_final OCCURS 0,
      matnr(10) TYPE c,
      werks(10) TYPE c,
      usage(10) TYPE c,
      data(08) TYPE c,
      END OF it_final.

DATA wa_it_final LIKE LINE OF it_final.
DATA: v_excel_string(2000) TYPE c,
      v_file LIKE v_excel_string VALUE
      'D:\TEST\TEST1.CSV',
      delimiter TYPE c VALUE ' '.


  OPEN DATASET v_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
  IF sy-subrc NE 0.
write:/ 'error opening file'.
  ELSE.
    WHILE ( sy-subrc EQ 0 ).
      READ DATASET v_file INTO wa_it_final.
      IF NOT wa_it_final IS INITIAL.
        APPEND wa_it_final TO it_final.
      ENDIF.
      CLEAR wa_it_final.
    ENDWHILE.
  ENDIF.
CLOSE DATASET v_file.

LOOP AT IT_FINAL.
WRITE:/ IT_FINAL-MATNR, IT_FINAL-WERKS, IT_FINAL-USAGE,  IT_FINAL-DATA.
ENDLOOP.

Thanks & Regards,

Krishna...

Read only

Former Member
0 Likes
1,380

DATA: S_FILE TYPE STRING VALUE '/tmpl/ztest.txt'.

DATA: BEGIN OF ZTAB OCCURS 0,

DATA(500),

END OF ZTAB.

OPEN DATASET S_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.

DO.

READ DATASET S_FILE INTO ZTAB.

IF SY-SUBRC 0.

EXIT.

ELSE.

APPEND ZTAB.

ENDIF.

ENDDO.

CLOSE DATASET S_FILE.

Once you get the data in ZTAB then use FM GUI_DOWNLOAD to excel file.

Regards,

Joan