Skip to Content
author's profile photo Former Member
Former Member

Download

Hi Experts,

Can anybody tell me how to download the data from presentationserver to application server.

Thanks in Advance,

Subbu

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Nov 30, 2007 at 11:50 AM

    HI,

    Use CG3Z Tcode

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 11:51 AM

    Hi

    see this program in which EXCEL FILE IN PREASENTATION TO INTERNAL TABLE AND THEN TO APPLICATION SERVER

    REPORT  ZSD_EXCEL_INT_APP.
    
    parameter: file_nm type localfile.
    
    types : begin of it_tab1,
            f1(20),
            f2(40),
            f3(20),
           end of it_tab1.
    
    
    data : it_tab type table of ALSMEX_TABLINE with header line,
           file type rlgrap-filename.
    
    data : it_tab2 type it_tab1 occurs 1,
           wa_tab2 type it_tab1,
           w_message(100)  TYPE c.
    
    
    at selection-screen on value-request for file_nm.
    
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
     EXPORTING
    *   PROGRAM_NAME        = SYST-REPID
    *   DYNPRO_NUMBER       = SYST-DYNNR
    *   FIELD_NAME          = ' '
       STATIC              = 'X'
    *   MASK                = ' '
      CHANGING
       file_name           = file_nm
     EXCEPTIONS
       MASK_TOO_LONG       = 1
       OTHERS              = 2
              .
    IF sy-subrc <> 0.
     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    
    
    start-of-selection.
    
    refresh it_tab2[].clear wa_tab2.
    
    file = file_nm.
    
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = file
        i_begin_col                   = '1'
        i_begin_row                   =  '1'
        i_end_col                     = '10'
        i_end_row                     = '35'
      tables
        intern                        = it_tab
     EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 2
       OTHERS                        = 3
              .
    IF sy-subrc <> 0.
     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    
    loop at it_tab.
    
      case it_tab-col.
    
       when '002'.
    
        wa_tab2-f1 = it_tab-value.
    
       when '004'.
    
        wa_tab2-f2 = it_tab-value.
    
      when '008'.
    
        wa_tab2-f3 = it_tab-value.
    
     endcase.
    
     at end of row.
    
      append wa_tab2 to it_tab2.
     clear wa_tab2.
      endat.
    
    endloop.
    
    data : p_file TYPE  rlgrap-filename value 'TEST3.txt'.
    
    
    OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    *--- Display error messages if any.
      IF sy-subrc NE 0.
        MESSAGE e001(zsd_mes).
        EXIT.
      ELSE.
    
    *---Data is downloaded to the application server file path
        LOOP AT it_tab2 INTO wa_tab2.
          TRANSFER wa_tab2 TO p_file.
        ENDLOOP.
      ENDIF.
    
    *--Close the Application server file (Mandatory).
      CLOSE DATASET p_file.
    
     loop at it_tab2 into wa_tab2.
    
      write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
    
     endloop.

    <b>Rewra di fusefull</b>

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 11:52 AM

    hi,

    to upload from presentation server to application server, first take data into internal table going <b>GUI_upload</b>, after that useing <b>open data set</b> to upload the internal table data to application server

    regards,

    pavan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 11:54 AM

    Hi Reddy,

    I think ur requirement is to download / upload the file from Presentation to Application server and viceversa.

    Try the below code to upload / download / deletefile in the application server.

    Don't forhet to reward me.

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

    types: begin of ty_rawdata,

    LINE(1000) TYPE C,

    end of ty_rawdata.

    types: begin of ty_errors,

    recordnumber type i,

    errormessage(135) type c,

    end of ty_errors.

    data:

    v_record_type(3),

    v_runstatus,

    f_errors(1) type c,

    v_errors type ty_errors,

    v_abort,

    v_rawdata type ty_rawdata,

    cnt_db_inserts type i,

    v_linesread type i,

    v_recordsread type i,

    v_filename like rlgrap-filename,

    v_infile like rlgrap-filename,

    v_outfile like rlgrap-filename.

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

    • INTERNAL TABLES *

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

    data:

    TBL_RAWDATA TYPE TY_RAWDATA OCCURS 0 WITH HEADER LINE,

    TBL_ERRORS TYPE TY_ERRORS OCCURS 0 WITH HEADER LINE.

    parameters:

    p_up radiobutton group r1,

    p_dn radiobutton group r1,

    p_del radiobutton group r1,

    p_pfile like rlgrap-filename,

    p_afile like rlgrap-filename default '/tmp/'.

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

    • INITIALISATION *

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

    INITIALIZATION.

    • authority-check object 'ZINTRASTAT'

    • id 'ACTVT' field '16'.

    • if sy-subrc ne 0.

    • message e408(zf).

    • endif.

    *

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

    • AT SELECTION SCREEN *

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

    at selection-screen on value-request for p_pfile.

    call function 'KD_GET_FILENAME_ON_F4'

    exporting

    mask = ',Text files, *.txt'

    static = 'X'

    changing

    file_name = p_pfile.

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

    • START OF SELECTION *

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

    start-of-selection.

    if p_up = 'X'.

    perform file_upload_presentation_srvr using p_pfile.

    perform file_save using p_afile changing sy-subrc.

    if sy-subrc = 0.

    write / 'file uploaded'.

    endif.

    elseif p_dn = 'X'.

    perform file_upload using p_afile.

    perform file_save_presentation using p_pfile.

    if sy-subrc = 0.

    write / 'file downloaded'.

    endif.

    elseif p_del = 'X'.

    perform file_delete using p_afile.

    if sy-subrc = 0.

    write / 'file deleted'.

    endif.

    endif.

    &----


    *& Form file_upload

    &----


    • Uploads the raw data file from the application server and calculates *

    • the number of lines in that file *

    ----


    • Outputs the global table: gt_rawdata

    • Sets the global variable: gv_linesread

    ----


    • The full filepath is the local parameter passed to the form

    ----


    form file_upload using v_lfilename like v_filename.

    data: v_msg(100).

    • Open the file for upload in text mode, and trap any messages.

    open dataset v_lfilename for input in text mode message v_msg.

    if sy-subrc ne 0.

    • Input file not found!

    • Process the error with an abort

    message E006(ZSEC) with v_lfilename.

    else.

    • The file has opened successfully. Upload every line in the file.

    do.

    • Clear the work area, and read the record from the dataset.

    clear v_rawdata.

    read dataset v_lfilename into v_rawdata.

    if sy-subrc ne 0.

    • The end of the file has been reached, so exit the 'DO' loop.

    exit.

    else.

    v_linesread = v_linesread + 1.

    endif.

    • Append the raw data line to the raw data internal table

    append v_rawdata to tbl_rawdata.

    enddo.

    close dataset v_lfilename.

    endif. "

    endform. " file_upload

    &----


    *& Form file_upload_presentation_srvr

    &----


    • Uploads the raw data file from the presentation server *

    • This should be used for initial testing purposes only. *

    ----


    • Uses data in gt_rawdata

    ----


    • The full filepath is the local parameter passed to the form

    ----


    form file_upload_presentation_srvr using v_lfilename like v_filename.

    call function 'WS_UPLOAD'

    exporting

    • CODEPAGE = ' '

    filename = v_lfilename

    • FILETYPE = 'ASC'

    • HEADLEN = ' '

    • LINE_EXIT = ' '

    • TRUNCLEN = ' '

    • USER_FORM = ' '

    • USER_PROG = ' '

    • DAT_D_FORMAT = ' '

    • IMPORTING

    • FILELENGTH =

    tables

    data_tab = tbl_rawdata

    exceptions

    conversion_error = 1

    file_open_error = 2

    file_read_error = 3

    invalid_type = 4

    no_batch = 5

    unknown_error = 6

    invalid_table_width = 7

    gui_refuse_filetransfer = 8

    customer_error = 9

    others = 10

    .

    if sy-subrc <> 0 or v_lfilename is initial.

    • If no filename given, set the system variables to output message

    if v_filename is initial.

    message E005(ZSEC).

    endif.

    • Input file not found!

    else.

    describe table tbl_rawdata lines v_linesread.

    endif.

    endform. " file_upload_presentation_srvr

    &----


    *& Form file_delete

    &----


    • Deletes the specified file from the application server. *

    ----


    • The full filepath is the local parameter passed into the form

    ----


    form file_delete using v_lfilename like v_filename.

    • Check program is not aborted

    check v_abort is initial.

    delete dataset v_lfilename.

    if sy-subrc ne 0.

    • Append the message output to the error tracing table!

    message E007(ZSEC) with v_lfilename.

    endif.

    endform. " file_delete

    &----


    *& Form file_save

    &----


    • Saves the raw data table to the application server using the full *

    • filepath specified in the input parameters. *

    ----


    • Uses Global internal table: gt_rawdata

    ----


    • The full filepath and the severity of the event in cases of error,

    • are local parameters passed to the form.

    • A returncode is the local parameter passed out of the form

    ----


    form file_save using v_lfilename like v_filename

    changing v_lsubrc.

    data: v_lmsg(100).

    data: v_lsubrc2.

    clear: v_lsubrc, v_lsubrc2.

    • Check program is not aborted

    check v_abort is initial.

    • Open the file

    open dataset v_lfilename for output in text mode message v_lmsg.

    if sy-subrc ne 0.

    • Append the message output to the error tracing table!

    v_lsubrc2 = 4.

    message E006(ZSEC) with v_lfilename.

    else.

    • Loop through the raw data table, transferring the data to the file

    • specified

    clear v_rawdata.

    loop at tbl_rawdata into v_rawdata.

    transfer v_rawdata to v_lfilename.

    if sy-subrc ne 0.

    • Error transferring data!

    v_lsubrc2 = 4.

    message E008(ZSEC) with v_lfilename.

    endif.

    clear v_rawdata.

    endloop.

    • Close the file

    close dataset v_lfilename.

    if sy-subrc ne 0.

    • Error closing the dataset!

    v_lsubrc2 = 4.

    message E009(ZSEC) with v_lfilename.

    endif.

    endif.

    v_lsubrc = v_lsubrc2.

    endform. " file_save

    &----


    *& Form file_save_presentation

    &----


    • text

    ----


    • -->P_P_PFILE text

    ----


    form file_save_presentation using p_dnfile like rlgrap-filename.

    *data: lv_file type string. "4.6c

    *lv_file = p_dnfile.

    CALL FUNCTION 'WS_DOWNLOAD'

    EXPORTING

    • BIN_FILESIZE = ' '

    • CODEPAGE = ' '

    FILENAME = P_DNFILE

    • FILETYPE = ' '

    • MODE = ' '

    • WK1_N_FORMAT = ' '

    • WK1_N_SIZE = ' '

    • WK1_T_FORMAT = ' '

    • WK1_T_SIZE = ' '

    • COL_SELECT = ' '

    • COL_SELECTMASK = ' '

    • NO_AUTH_CHECK = ' '

    • IMPORTING

    • FILELENGTH =

    TABLES

    DATA_TAB = TBL_RAWDATA

    • FIELDNAMES =

    EXCEPTIONS

    FILE_OPEN_ERROR = 1

    FILE_WRITE_ERROR = 2

    INVALID_FILESIZE = 3

    INVALID_TABLE_WIDTH = 4

    INVALID_TYPE = 5

    NO_BATCH = 6

    UNKNOWN_ERROR = 7

    OTHERS = 8.

    • call function 'GUI_DOWNLOAD'

    • exporting

    • BIN_FILESIZE =

  • filename = lv_file

    • FILETYPE = 'ASC'

    • APPEND = ' '

    • WRITE_FIELD_SEPARATOR = ' '

    • HEADER = '00'

    • TRUNC_TRAILING_BLANKS = ' '

    • WRITE_LF = 'X'

    • COL_SELECT = ' '

    • COL_SELECT_MASK = ' '

    • IMPORTING

    • FILELENGTH =

  • tables

  • data_tab = tbl_rawdata

  • 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

  • .

  • endform. " file_save_presentation

Add a comment
10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.