Application Server file to internal table

Hi,
  How can i read the application server file into the internal table??  Which FM should i use??
Regards,
Kit

Hi,
Open Dataset is used to read or write on to application server ... other than that i am not sure that there exists any way to do the same ... here is a short description for that
FILE HANDLING IN SAP
Introduction
• Files on application server are sequential files.
• Files on presentation server / workstation are local files.
• A sequential file is also called a dataset.
Handling of Sequential file
Three steps are involved in sequential file handling
• OPEN
• PROCESS
• CLOSE
Here processing of file can be READING a file or WRITING on to a file.
OPEN FILE
Before data can be processed, a file needs to be opened.
After processing file is closed.
Syntax:
OPEN DATASET <file name> FOR {OUTPUT/INPUT/APPENDING}
IN {TEXT/BINARY} MODE
This statement returns SY_SUBRC as 0 for successful opening of file or 8, if unsuccessful.
OUTPUT: Opens the file for writing. If the dataset already exists, this will place the cursor at the start of the dataset, the old contents get deleted at the end of the program or when the CLOSE DATASET is encountered.
INPUT: Opens a file for READ and places the cursor at the beginning of the file.
FOR APPENDING: Opens the file for writing and places the cursor at the end of file. If the file does not exist, it is generated.
BINARY MODE: The READ or TRANSFER will be character wise. Each time ‘n’’ characters are READ or transferred. The next READ or TRANSFER will start from the next character position and not on the next line.
IN TEXT MODE: The READ or TRANSFER will start at the beginning of a new line each time. If for READ, the destination is shorter than the source, it gets truncated. If destination is longer, then it is padded with spaces.
Defaults: If nothing is mentioned, then defaults are FOR INPUT and in BINARY MODE.
PROCESS FILE:
Processing a file involves READing the file or Writing on to file TRANSFER.
TRANSFER Statement
Syntax:
TRANSFER <field> TO <file name>.
<Field> can also be a field string / work area / DDIC structure.
Each transfer statement writes a statement to the dataset. In binary mode, it writes the length of the field to the dataset. In text mode, it writes one line to the dataset.
If the file is not already open, TRANSFER tries to OPEN file FOR OUTPUT (IN BINARY MODE) or using the last OPEN DATASET statement for this file.
IF FILE HANDLING, TRANSFER IS THE ONLY STATEMENT WHICH DOES NOT RETURN SY-SUBRC
READ Statement
Syntax:
READ DATASET <file name> INTO <field>.
<Field> can also be a field string / work area / DDIC structure.
Each READ will get one record from the dataset. In binary mode it reads the length of the field and in text mode it reads each line.
CLOSE FILE:
The program will close all sequential files, which are open at the end of the program. However, it is a good programming practice to explicitly close all the datasets that were opened.
Syntax:
CLOSE DATASET <file name>.
SY-SUBRC will be set to 0 or 8 depending on whether the CLOSE is successful or not.
DELETE FILE:
A dataset can be deleted.
Syntax:
DELETE DATASET <file name>.
SY-SUBRC will be set to 0 or 8 depending on whether the DELETE is successful or not.
Pseudo logic for processing the sequential files:
For reading:
Open dataset for input in a particular mode.
Start DO loop.
Read dataset into a field.
If READ is not successful.
Exit the loop.
Endif.
Do relevant processing for that record.
End the do loop.
Close the dataset.
For writing:
Open dataset for output / Appending in a particular mode.
Populate the field that is to be transferred.
TRANSFER the filed to a dataset.
Close the dataset.
chk a sampel
parameters: p_file like rlgrap-filename obligatory
default '/usr/sap/upload.xls'.
types: begin of t_data,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
matnr like vbap-matnr,
werks like vbap-werks,
megne like vbap-zmeng,
end of t_data.
data: it_data type standard table of t_data,
wa_data type t_data.
open dataset p_file for output in text mode encoding default.
if sy-subrc ne 0.
write:/ 'Unable to open file:', p_file.
else.
do.
read dataset p_file into wa_data.
if sy-subrc ne 0.
exit.
else.
append wa_data to it_data.
endif.
enddo.
close dataset p_file.
endif.
And if you want to write on the file.
*--- open UNIX file
open dataset unixfile for output in text mode message w_msg.
if sy-subrc ne 0.
write: / 'Cannot open for writing:', unixfile, w_msg.
exit.
endif.
*--- write UNIX file
loop at it_file.
transfer it_file to unixfile.
endloop.
*--- close UNIX file
close dataset unixfile.

Similar Messages

  • Comparing Application server file and internal table

    hi all
    Iam new to the world of ABAP. I have a requirement wherein i need to compare data in a internal table and that of the file. I need to extract the delta records( ie the record is found in the internal table but not in the file and vice versa ) and put it in another internal table. Which is the best way to do it?
    Awaiting quick reply. Thanks
    Nirmal.

    Hello Nimal
    First read the file into your itab. For comparison you can use the same logic as change documents are prepared. Assuming both of your itabs are of structure struc_a. Then define the following type:
    TYPES: BEGIN OF ty_s_itab_di. 
    INCLUDE TYPE struc_a.
    TYPES: CHIND  TYPE bu_chind.
    TYPES: END OF ty_s_itab_di.
    TYPES: ty_t_itab_di  TYPE STANDARD TABLE OF ty_s_itab_di
                         WITH DEFAULT KEY.
    DATA: 
      gt_itab_old  TYPE ty_t_itab_di,
      gt_itab_new  TYPE ty_t_itab_di.
    Fill itabs gt_Itab_old with the corresponding data of itab1 and gt_itab_new with the corresponding data of itab2.
    Very important: sort you itabs either by all key fields or by all fields.
    Call function CHANGEDOCUMENT_PREPARE_TABLES with the following parameters:
    - CHECK_INDICATOR = ' '
    - TABLE_NEW = gt_Itab_new
    - TABLE_OLD = gt_itab_old
    The function module will remove identical lines from both itabs. New entries in gt_itab_New will have CHIND = 'I' and deleted entries in gt_itab_old will have CHIND = 'D'.
    Read the documentation of the function module and play around with it. You will see that this a quite easy yet powerful approach for comparing itabs.
    Regards
    Uwe

  • How to Down load Data in Application server into the Internal Table

    hi freinds,
    iam having a file in the application server.
    now i need to send the data in the file to the internal table.
    is there any Function Module?
    i need with out using the OPEN DATA SET and CLOSE DATA SET Keywords.
    is there any possible?
    Regard's,
    Ranjith.

    Hi,
    There is no other option for uploading the data from the application server to the internal table without using OPEN DATASET and CLOSE DATASET. Even if you find the FM internal logic in FM uses these keywords to read the data from Application server.

  • How to upload a file in application server to an internal table

    Hi,
          I am asked to upload a file from application server to internal table. Can you please suggest me the ways to do it or the function module which helps to browse the application server file names.
      I have done a program. But its giving problem in searching the files from application server. I am pasting my code for ur review. Please tell me which part i have to correct or suggest me some other ways to do it.
    *& Report  ZUPLOAD1
    REPORT  ZUPLOAD1.
    type-pools: truxs.
    parameters: p_upl_ps radiobutton group g1 default 'X', "upload from pres. server
                 p_path type rlgrap-filename, 
                 p_upl_as radiobutton group g1,   "upload from appln server
                 <b>p_dir LIKE filepath-pathintern DEFAULT 'Y_ABAP', 
                 p_file LIKE filepath-pathintern lower case,</b>      
                 p_test as checkbox.
    constants: c_x value 'X',
               c_tab type c value cl_abap_char_utilities=>horizontal_tab.
    types: ty_data(1000) type c.    "structure to hold legacy data
    data: i_data type standard table of ty_data. "internal table of ty_data
    types: begin of stritab,
          land1 type v_t604-land1,  "structure of legacy file.
          stawn type v_t604-stawn,
          bemeh type v_t604-bemeh,
          impma type v_t604-impma,
          minol type v_t604-minol,
          end of stritab.
    data: gi_itab type standard table of stritab, "internal table of legacy file
          gw_itab type stritab.  "work area
    data: i_raw type truxs_t_text_data,
          v_fullpath type string.
    at selection-screen on value-request for p_path.
    if p_upl_ps = c_x. "if presentation server is selected
    perform get_file.
    else.            "if application server is selected
    perform set_file_path.      
    perform upload_from_server.
    perform split_data.
    endif.
    form get_file.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      PROGRAM_NAME        = SYST-CPROG
      DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = ' '
    IMPORTING
       FILE_NAME           = p_path.     "getting the file name of pres server
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
      EXPORTING
      I_FIELD_SEPERATOR          =
        I_LINE_HEADER              = 'X'              "converting excel to sap and filling in
        I_TAB_RAW_DATA             = i_raw      "internal table
        I_FILENAME                 = p_path
      TABLES
        I_TAB_CONVERTED_DATA       = gi_itab
    EXCEPTIONS
       CONVERSION_FAILED          = 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.
    endform.
    form set_file_path.                 "Getting the file path of application server
    data: lv_file type p_file.
          lv_file = p_file.
          CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
            EXPORTING
            CLIENT                           = SY-MANDT
              LOGICAL_PATH                     = p_dir
            OPERATING_SYSTEM                 = SY-OPSYS
            PARAMETER_1                      = ' '
            PARAMETER_2                      = ' '
            PARAMETER_3                      = ' '
            USE_BUFFER                       = ' '
              FILE_NAME                        = lv_file
            USE_PRESENTATION_SERVER          = ' '
            ELEMINATE_BLANKS                 = 'X'
           IMPORTING
             FILE_NAME_WITH_PATH              = v_fullpath
           EXCEPTIONS
             PATH_NOT_FOUND                   = 1
             MISSING_PARAMETER                = 2
             OPERATING_SYSTEM_NOT_FOUND       = 3
             FILE_SYSTEM_NOT_FOUND            = 4
             OTHERS                           = 5
          IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
    endform.
    form upload_from_server.
    data: lv_msg type string,
          lw_data type ty_data.
    open dataset v_fullpath for input message lv_msg in text mode encoding default.
    if sy-subrc <> 0.
    message lv_msg type 'i'.
    stop.
    endif.
    do.
    read dataset v_fullpath into lw_data.
    if sy-subrc <> 0.
    write:/5 'Error in processign data set'.
    exit.
    endif.
    append lw_data to i_data.
    enddo.
    close dataset v_fullpath.
    if sy-subrc <> 0.
    write: /5 'Error closing dataset'.
    endif.
    endform.
    form split_data.
    data: lw_data type ty_data.
    data: lw_itab type stritab.
    data: begin of ty_itab,
          land1 type v_t604-land1,
          stawn type v_t604-stawn,
          bemeh type v_t604-bemeh,
          impma type v_t604-impma,
          minol type v_t604-minol,
          end of ty_itab.
    loop at i_data into lw_data.
    split lw_data at c_tab into
          ty_itab-land1
          ty_itab-stawn
          ty_itab-bemeh
          ty_itab-impma
          ty_itab-minol.
    lw_itab-land1 = ty_itab-land1.
    lw_itab-stawn = ty_itab-stawn.
    lw_itab-bemeh = ty_itab-bemeh.
    lw_itab-impma = ty_itab-impma.
    lw_itab-minol = ty_itab-minol.
    append lw_itab to gi_itab.
    endloop.
    endform.
    start-of-selection.
    loop at gi_itab into gw_itab.
    write: /5 'COUNTRY', 'IMPORT CODE', 'SUP UNIT', 'FIRST UOM', 'SECOND UOM',
           /5 gw_itab-land1, gw_itab-stawn,gw_itab-bemeh,gw_itab-impma,gw_itab-minol.
    endloop.
    end-of-selection.
    I hope problem must be in p_dir and p_file which are in bold.. Kindly help me out. Thanks in advance.

    see the following ex:
    *&      Form  SUB_GET_FILEPATH
          text
    -->  p1        text
    <--  p2        text
    FORM SUB_GET_FILEPATH .
        GFILE = 'D:\SAP_INT\INBOUND\INBOX'.  "Path
    ENDFORM.                    " SUB_GET_FILEPATH
    *&      Form  SUB_GET_FILE
          text
    -->  p1        text
    <--  p2        text
    FORM SUB_GET_FILE .
      DATA: P_FDIR(200) TYPE C.
      DATA: IT_FILEDIR1 TYPE STANDARD TABLE OF TY_FILEDIR WITH HEADER LINE.
      P_FDIR = GFILE.
      CALL FUNCTION 'RZL_READ_DIR_LOCAL'
        EXPORTING
          NAME     = P_FDIR
        TABLES
          FILE_TBL = IT_FILEDIR.
      REFRESH : IT_FILEDIR1.
      LOOP AT IT_FILEDIR.
        IF IT_FILEDIR-NAME(4) = 'ZINC' OR IT_FILEDIR-NAME(4) = 'zinc'.
          MOVE IT_FILEDIR-NAME TO IT_FILEDIR1-NAME.
          APPEND IT_FILEDIR1.
        ENDIF.
      ENDLOOP.
      IF IT_FILEDIR1[] IS INITIAL.
        STOP.
      ENDIF.
      LOOP AT IT_FILEDIR1.
        REFRESH: I_TAB.
        CLEAR: I_TAB.
        NAME = IT_FILEDIR1-NAME.
        CONCATENATE: GFILE '\' NAME INTO G_FILE.
        OPEN DATASET G_FILE FOR INPUT IN TEXT MODE
                                         ENCODING DEFAULT
                                         IGNORING CONVERSION ERRORS.
        IF SY-SUBRC EQ 0.
          CONCATENATE 'FILENAME  : ' G_FILE INTO I_MSG1.
          APPEND I_MSG1.
          DO.
            READ DATASET G_FILE INTO RECORD.
            IF SY-SUBRC = 0.
              SPLIT RECORD AT ',' INTO I_TAB-BUKRS  I_TAB-EBELN
                  I_TAB-BLDAT  I_TAB-XBLNR I_TAB-LIFNR I_TAB-AMOUNT
                  I_TAB-CURR  I_TAB-BUSAREA
                  I_TAB-BKTXT I_TAB-DMBTR I_TAB-MENGE I_TAB-SRNO.
              MOVE-CORRESPONDING I_TAB TO I_TAB1.
            ELSE.
              EXIT.
            ENDIF.
            APPEND I_TAB1.
            CLEAR: I_TAB, I_TAB1.
          ENDDO.
        ENDIF.
        CLOSE DATASET G_FILE.

  • Upload tab-delimited file from the application server to an internal table

    Hello SAPients.
    I'm using OPEN DATASET..., READ DATASET..., CLOSE DATASET to upload a file from the application server (SunOS). I'm working with SAP 4.6C. I'm trying to upload a tab-delimited file to an internal table but when I try load it the fields are not correctly separated, in fact, they are all misplaced and the table shows '#' where supposedly there was a tab.
    I tried to SPLIT the line using as separator a variable with reference to CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB but for some reason that class doesn't exist in my system.
    Do you know what I'm doing wrong? or Do you know a better method to upload a tab-delimited file into an internal table?
    Thank you in advance for your help.

    Try:
    REPORT ztest MESSAGE-ID 00.
    PARAMETER: p_file LIKE rlgrap-filename   OBLIGATORY.
    DATA: BEGIN OF data_tab OCCURS 0,
          data(4096),
          END   OF data_tab.
    DATA: BEGIN OF vendor_file_x OCCURS 0.
    * LFA1 Data
    DATA: mandt  LIKE bgr00-mandt,
          lifnr  LIKE blf00-lifnr,
          anred  LIKE blfa1-anred,
          bahns  LIKE blfa1-bahns,
          bbbnr  LIKE blfa1-bbbnr,
          bbsnr  LIKE blfa1-bbsnr,
          begru  LIKE blfa1-begru,
          brsch  LIKE blfa1-brsch,
          bubkz  LIKE blfa1-bubkz,
          datlt  LIKE blfa1-datlt,
          dtams  LIKE blfa1-dtams,
          dtaws  LIKE blfa1-dtaws,
          erdat  LIKE  lfa1-erdat,
          ernam  LIKE  lfa1-ernam,
          esrnr  LIKE blfa1-esrnr,
          konzs  LIKE blfa1-konzs,
          ktokk  LIKE  lfa1-ktokk,
          kunnr  LIKE blfa1-kunnr,
          land1  LIKE blfa1-land1,
          lnrza  LIKE blfa1-lnrza,
          loevm  LIKE blfa1-loevm,
          name1  LIKE blfa1-name1,
          name2  LIKE blfa1-name2,
          name3  LIKE blfa1-name3,
          name4  LIKE blfa1-name4,
          ort01  LIKE blfa1-ort01,
          ort02  LIKE blfa1-ort02,
          pfach  LIKE blfa1-pfach,
          pstl2  LIKE blfa1-pstl2,
          pstlz  LIKE blfa1-pstlz,
          regio  LIKE blfa1-regio,
          sortl  LIKE blfa1-sortl,
          sperr  LIKE blfa1-sperr,
          sperm  LIKE blfa1-sperm,
          spras  LIKE blfa1-spras,
          stcd1  LIKE blfa1-stcd1,
          stcd2  LIKE blfa1-stcd2,
          stkza  LIKE blfa1-stkza,
          stkzu  LIKE blfa1-stkzu,
          stras  LIKE blfa1-stras,
          telbx  LIKE blfa1-telbx,
          telf1  LIKE blfa1-telf1,
          telf2  LIKE blfa1-telf2,
          telfx  LIKE blfa1-telfx,
          teltx  LIKE blfa1-teltx,
          telx1  LIKE blfa1-telx1,
          xcpdk  LIKE  lfa1-xcpdk,
          xzemp  LIKE blfa1-xzemp,
          vbund  LIKE blfa1-vbund,
          fiskn  LIKE blfa1-fiskn,
          stceg  LIKE blfa1-stceg,
          stkzn  LIKE blfa1-stkzn,
          sperq  LIKE blfa1-sperq,
          adrnr  LIKE  lfa1-adrnr,
          mcod1  LIKE  lfa1-mcod1,
          mcod2  LIKE  lfa1-mcod2,
          mcod3  LIKE  lfa1-mcod3,
          gbort  LIKE blfa1-gbort,
          gbdat  LIKE blfa1-gbdat,
          sexkz  LIKE blfa1-sexkz,
          kraus  LIKE blfa1-kraus,
          revdb  LIKE blfa1-revdb,
          qssys  LIKE blfa1-qssys,
          ktock  LIKE blfa1-ktock,
          pfort  LIKE blfa1-pfort,
          werks  LIKE blfa1-werks,
          ltsna  LIKE blfa1-ltsna,
          werkr  LIKE blfa1-werkr,
          plkal  LIKE  lfa1-plkal,
          duefl  LIKE  lfa1-duefl,
          txjcd  LIKE blfa1-txjcd,
          sperz  LIKE  lfa1-sperz,
          scacd  LIKE blfa1-scacd,
          sfrgr  LIKE blfa1-sfrgr,
          lzone  LIKE blfa1-lzone,
          xlfza  LIKE  lfa1-xlfza,
          dlgrp  LIKE blfa1-dlgrp,
          fityp  LIKE blfa1-fityp,
          stcdt  LIKE blfa1-stcdt,
          regss  LIKE blfa1-regss,
          actss  LIKE blfa1-actss,
          stcd3  LIKE blfa1-stcd3,
          stcd4  LIKE blfa1-stcd4,
          ipisp  LIKE blfa1-ipisp,
          taxbs  LIKE blfa1-taxbs,
          profs  LIKE blfa1-profs,
          stgdl  LIKE blfa1-stgdl,
          emnfr  LIKE blfa1-emnfr,
          lfurl  LIKE blfa1-lfurl,
          j_1kfrepre  LIKE blfa1-j_1kfrepre,
          j_1kftbus   LIKE blfa1-j_1kftbus,
          j_1kftind   LIKE blfa1-j_1kftind,
          confs  LIKE  lfa1-confs,
          updat  LIKE  lfa1-updat,
          uptim  LIKE  lfa1-uptim,
          nodel  LIKE blfa1-nodel.
    DATA: END   OF vendor_file_x.
    FIELD-SYMBOLS:  <field>,
                    <field_1>.
    DATA: delim          TYPE x        VALUE '09'.
    DATA: fld_chk(4096),
          last_char,
          quote_1     TYPE i,
          quote_2     TYPE i,
          fld_lth     TYPE i,
          columns     TYPE i,
          field_end   TYPE i,
          outp_rec    TYPE i,
          extras(3)   TYPE c        VALUE '.,"',
          mixed_no(14) TYPE c        VALUE '1234567890-.,"'.
    OPEN DATASET p_file FOR INPUT.
    DO.
      READ DATASET p_file INTO data_tab-data.
      IF sy-subrc = 0.
        APPEND data_tab.
      ELSE.
        EXIT.
      ENDIF.
    ENDDO.
    * count columns in output structure
    DO.
      ASSIGN COMPONENT sy-index OF STRUCTURE vendor_file_x TO <field>.
      IF sy-subrc <> 0.
        EXIT.
      ENDIF.
      columns = sy-index.
    ENDDO.
    * Assign elements of input file to internal table
    CLEAR vendor_file_x.
    IF columns > 0.
      LOOP AT data_tab.
        DO columns TIMES.
          ASSIGN space TO <field>.
          ASSIGN space TO <field_1>.
          ASSIGN COMPONENT sy-index OF STRUCTURE vendor_file_x TO <field>.
          SEARCH data_tab-data FOR delim.
          IF sy-fdpos > 0.
            field_end = sy-fdpos + 1.
            ASSIGN data_tab-data(sy-fdpos) TO <field_1>.
    * Check that numeric fields don't contain any embedded " or ,
            IF <field_1> CO mixed_no AND
               <field_1> CA extras.
              TRANSLATE <field_1> USING '" , '.
              CONDENSE <field_1> NO-GAPS.
            ENDIF.
    * If first and last characters are '"', remove both.
            fld_chk = <field_1>.
            IF NOT fld_chk IS INITIAL.
              fld_lth = strlen( fld_chk ) - 1.
              MOVE fld_chk+fld_lth(1) TO last_char.
              IF fld_chk(1) = '"' AND
                 last_char = '"'.
                MOVE space TO fld_chk+fld_lth(1).
                SHIFT fld_chk.
                MOVE fld_chk TO <field_1>.
              ENDIF.       " for if fld_chk(1)=" & last_char="
            ENDIF.         " for if not fld_chk is initial
    * Replace "" with "
            DO.
              IF fld_chk CS '""'.
                quote_1 = sy-fdpos.
                quote_2 = sy-fdpos + 1.
                MOVE fld_chk+quote_2 TO fld_chk+quote_1.
              ELSE.
                MOVE fld_chk TO <field_1>.
                EXIT.
              ENDIF.
            ENDDO.
            <field> = <field_1>.
          ELSE.
            field_end = 1.
          ENDIF.
          SHIFT data_tab-data LEFT BY field_end PLACES.
        ENDDO.
        APPEND vendor_file_x.
        CLEAR vendor_file_x.
      ENDLOOP.
    ENDIF.
    CLEAR   data_tab.
    REFRESH data_tab.
    FREE    data_tab.
    Rob

  • Is it possible  upload local file to internal table in background mode?

    Hi, all,
    Is it possbile to  upload local file(not server file) to internal table in background mode.
    If possbile ,please tell me detail . Thanks in advance.
    Regards,
    Lily

    Hello,
    This is possible.
    If you report has to be executed in background using schedule Job. Then the file path should be constant and it can be hard coded in the report itself while populationg the internal table.
    Then create a variant for your report and use that variant in the job.
    This will solve your problem I guess.
    Regards
    Arindam

  • Problem in uploading the file of internal table into appliaction server

    i want to send the data of internal table to application server through selection screen and in selection screen and in selection screen parameter it should show the path of application server and through that path internal table data should go to application server , if possible give the code

    Hi,
    form download_file_appl_server.
      open dataset p_dlf2 for output
              in text mode encoding default .
      if sy-subrc ne 0.
        message:i005 with text-415 text-407.
      endif.
      loop at i_final into wa_final.
        transfer wa_final to p_dlf2.
      endloop.
      close dataset p_dlf2.
    endform.                    " OPENDATA_CLOSE
    where p_dlf2 is the seelction screen parameter which give the application server file path
    You can use this code for ur purpose.
    Reward if useful.
    Regards
    Shibin

  • FM????? Text file to Internal table in Background

    Hi,
    I need to execute my prog in background and as per my req i need to dwnload a file from prsentation server to internal table for processing. I'm not sure whch FM to use to dwnload from text file to internal table. I cannot use GUI_UPLOAD FM for background runs.....pls help
    Thanks in advance

    Chesat,
    You can not work for this requirement.You will have an idea on it.
    Introduction
    The use of FTP from ABAP seems to have been a hot topic on the ABAP Forums of late. I thought I might sit down and document whatever I could find on this subject and share it as a weblog.
    Over the years I have seen lots of different solutions for moving files on and off of a SAP system. I have seen external FTP scripts written in OS shell languages. I have seen full blown custom applications that are made to interface to the SAP system. However I think you will find that most of the technology you need to perform a simple FTP from ABAP is already contained in the standard system. All of my examples and screen shots will be coming from a 46C system.
    SAP's Solution
    If you have ever taken a look at the kernel directory of your SAP system, you might have noticed an interesting little executable: sapftp.exe (the name of the file on Windows SAP Kernels). It is this part of the Kernel that exposes FTP functionality to the ABAP Programming language.
    So you have a suspicion that there is FTP functionality in ABAP, but you’re not quite sure how to use it. Where do you start? I always turn to the Service Marketplace first. A quick search on SAPFTP reveals there is an entire component (BC-SRV-COM-FTP) on the subject. The most general note and our starting place is OSS Note 93042. This note starts off with a nice description of what SAPFTP is: A client RFC application that is accessed via RFC from ABAP. But we also find out that in addition to SAPFTP being part of the kernel, it is also part of the SAPGui. That means that we can perform FTP commands originating from our R/3 Server or from a Client Workstation.
    Well if this solution is accessed via RFC, then we must have to setup some RFC destinations. In fact we have two that we need; SAPFTP for Front-end FTP and SAPFTPA for access on the application server. Luckily we don't even have to mess with setting these RFC destinations up in SM59. SAP has supplied a program, RSFTP005, to generate the destinations for us.
    Now before we go off and start written code on our own to hit these FTP functions, why don't we make sure everything is setup and working. Once again SAP has helped us out by providing us with a test program, RSFTP002. (In case you are wondering the FTP functionality and many other test programs are all contained in SAP Development Class SFTP). When we run this test, we get a set input parameters for the server, username password, etc. We want to start out simple and just make sure we are getting a connection. Therefore we will just execute the pwd command (Print Working Directory).
    Your answer back should look something like this:
    If you are wanting to see a list of FTP commands, try using the command HELP in place of PWD:
    If something did go wrong during the test, I suggest that you active the trace option in SM59 for the FTP Destination. You can then use program RSFTP001 to display the current trace file.
    Programming the FTP
    Not only does the RSFTP002 program give us a test environment, but it also provides us with a programming example. We can see that the FTP functionality is really provided by a set of function modules all within the SFTP Function Group. We have the basic commands such as FTP_CONNECT, FTP_COMMAND, and FTP_DISCONNECT that can be strung together to create a complete file operation action. The FTP_COMMAND Function allows you to issue arbitrary FTP commands as long as the SAPFTP function, the Host, and the Destination server all support the command. Then you have the specialized functions such as FTP_R3_TO_SERVER, FTP_R3_TO_CLIENT, and FTP_CLIENT_TO_R3. This lets you take some data in memory and transfer it someplace else. This has the advantage of not having to write the data to the file system first and not to have to issue any FTP commands. However these functions are also limited to the scope described.
    If you are already familiar with FTP in general, working with these function modules should not seem to difficult. The Connect, Command, Disconnect actions would seem somewhat self explanatory. So instead of looking at the entire program in detail let's focus on two things that may be unfamiliar. First the program starts off with an ABAP Kernel System call to AB_RFC_X_SCRAMBLE_STRING. Well we don't want to pass a potentially sensitive password openly. Therefore the FTP_CONNECT function module requires that the password be encrypted before it receives it. It is this System call that performs that one-way encryption. Now I checked a 620 SP42 system and in this example, SAP has replace the AB_RFC_X_SCRAMBLE_STRING with a function call to HTTP_SCRAMBLE. Unfortunately HTTP_SCRAMBLE doesn't even exist in my 46C system. The only other thing that I wanted to point out about these function calls is the exporting parameter on the FTP_CONNECT. It passes back a parameter called handle. This handle then becomes an importing parameter to all subsequent calls: FTP_COMMAND and FTP_CLOSE. This handle is the pointer to the instance of FTP that we started with the FTP_CONNECT. This assures that we get reconnected to the same FTP session with each command we issue.
    FTP Development
    I thought I would share a few of the things that can be built using this FTP functionality. First off I didn't want a bunch of ABAP programs directly working with the SAP FTP Function modules. As you can see there is already a difference in the examples for encrypting the password between 46C and 620. Therefore I thought it would be best to encapsulate all the FTP function in one custom ABAP OO Class. Not only did I get the opportunity to hid the inner SAP functionality and make it easy to switch out during upgrades, but I also get consistent error handling as well. I accept the User Name, Password, Host, and RFC Destination in during the Constructor of the class. I then store these values away in Protected Attributes. Each function module is then implemented as a Instance Method. The Password encryption functionality is then all tucked away nicely in the class. Also the calling program doesn't have to worry about keeping track of the FTP handle either since it is an instance attribute as well.
    Next I got really carried away. I wanted a way to record entire FTP scripts that could be filled with values at runtime and ran as a step in a background job. My company used to have many interfaces that ran frequently sending files all over the place. We needed a mechanism to monitor and support these file moves. This was really the root of this tool, but it also gives you an idea of how powerful these functions can be.
    Closing
    I hope that anyone interested in FTP from ABAP will find this resource useful. If anyone has any other resources that should be included here, feel free to post them.
    Thomas Jung is an Application Developer for Kimball Electronics Group (www.kegroup.com) and a huge fan of ABAP.
    Comment on this weblog
    Showing messages 1 through 7 of 7.
    Titles Only
    Main Topics
    Oldest First
         New to SAP/ABAP-4
    2005-02-24 13:03:06 Thomas Godfrey Business Card [Reply]
    I've been in IT for over 30 years as a mainframe contract programmer/analyst. Recently a company hired me for my legacy knowledge of there business to become a developer on SAP for these same systems.
    My first task is to develop a generalized ftp application to send data to the mainframe and then on to financial institutions. I have created an ABAP/4 test program with literals for the dest/host etc. And it works fine. I need more detail/guidance in creating the Class/Method/Function you have described to make this parameter driven and callable by other programs. I know this is a lot to ask, any help in pointing me in the right direction would be greatly appreciated. When I mention class creation to the existing staff they all say "Oh, we don't use or know anything about that object oriented stuff, we just right programs."
    Thanks,
    Tom
         New to SAP/ABAP-4
    2005-02-24 13:13:33 Thomas Jung Business Card [Reply]
    "we don't use or know anything about that object oriented stuff" That's something I might have expected to hear 4 years ago. That's kind of like saying that you only want to use half of the programming lanuage (the old half at that).
    However it is true that you have to learn to walk before you run. There are some fundamentals to ABAP that are usefull to have down before you start in with ABAP OO. But I wouldn't let that hold you back for long.
    I'm afraid that I wouldn't be able to teach you everything you would need to know to create a function module or a class in this posting. There was a nice weblog that was just posted the other day that had the steps to create your first simple class. I suggest you start there.
    As far as my FTP class goes, I don't mind sending you the code for the class. My email address is already all over SDN (and spammers' lists) so just send me the address that you want the details sent to. My email is [email protected].
         New to SAP/ABAP-4
    2005-02-24 13:05:42 Thomas Godfrey Business Card [Reply]
    I just read what I typed, I meant "write programs" not "right programs" ... duh
         Good suggestions - now...
    2004-11-24 09:15:27 Jacques Claassen Business Card [Reply]
    ...any chance you've used FTP via an HTTP proxy?
    Any help using the HTTP* functions in the ZFTP function group will be greatly appreciated. Any one?
    Thx
         Good suggestions - now...
    2004-11-24 09:59:11 Thomas Jung Business Card [Reply]
    I'm afraid I haven't done either. However I have used the HTTP client functionality in the WebAS 620 (if_http_client) along with an HTTP proxy. I have an example of this in another weblog.
         Pretty insightful
    2004-11-15 19:27:26 Subramanian Venkateswaran Business Card [Reply]
    Thanks for this weblog, and I can be pretty sure there are some(many) more weblogs in the waiting.
    Regards,
    Subramanian V.
         I have been using a local include ...
    2004-11-15 16:29:39 Swapan Sarkar Business Card [Reply]
    On the other hand I have been using a local include of ZCL_FTP_BASE in my programs for some time. Here's the signature:
    <quote>
    *& Include ZHR9_FTP_CLASSES
    *& Utility class ZCL_FTP_BASE having all the
    functions to upload and download files from an
    FTP server.
    CLASS zcl_ftp_base DEFINITION.
    PUBLIC SECTION.
    Output file type
    TYPES: BEGIN OF t_scratch,
    data(1024) TYPE c,
    END OF t_scratch,
    t_str_tab TYPE STANDARD TABLE OF t_scratch.
    CONSTANTS: co_crlf(2) TYPE x VALUE '0D0A'.
    DATA: status TYPE c VALUE space.
    METHODS: constructor IMPORTING im_user TYPE string im_pwd TYPE string
    im_server TYPE string,
    send_table_data IMPORTING im_file TYPE string
    im_table TYPE t_str_tab,
    get_table_data IMPORTING im_file TYPE string
    EXPORTING ex_table TYPE t_str_tab,
    send_string_data IMPORTING im_file TYPE string
    im_string TYPE string,
    get_string_data IMPORTING im_file TYPE string
    EXPORTING ex_string TYPE string,
    disconnect.
    PRIVATE SECTION.
    DATA: v_user(64) TYPE c,
    v_pwd_clear(30) TYPE c,
    v_pwd(64) TYPE c,
    v_server(30) TYPE c,
    v_filename TYPE rlgrap-filename,
    v_handle TYPE i.
    METHODS: pwd_scramble IMPORTING im_pwd TYPE c.
    ENDCLASS. "ZCL_FTP_BASE DEFINITION
    </quote>
    Showing messages 1 through 7 of 7.
    Pls. mark if this doc. is useful

  • Question about reading csv file into internal table

    Some one (thanks those nice guys!) in this forum have suggested me to use FM KCD_CSV_FILE_TO_INTERN_CONVERT to read csv file into internal table. However, it can be used to read a local file only.
    I would like to ask how can I read a CSV file into internal table from files in application server?
    I can't simply use SPLIT as there may be comma in the content. e.g.
    "abc","aaa,ab",10,"bbc"
    My expected output:
    abc
    aaa,ab
    10
    bbb
    Thanks again for your help.

    Hi Gundam,
    Try this code. I have made a custom parser to read the details in the record and split them accordingly. I have also tested them with your provided test cases and it work fine.
    OPEN DATASET dsn FOR input IN TEXT MODE ENCODING DEFAULT.
    DO.
    READ DATASET dsn INTO record.
      PERFORM parser USING record.
    ENDDO.
    *DATA str(32) VALUE '"abc",10,"aaa,ab","bbc"'.
    *DATA str(32) VALUE '"abc","aaa,ab",10,"bbc"'.
    *DATA str(32) VALUE '"a,bc","aaaab",10,"bbc"'.
    *DATA str(32) VALUE '"abc","aaa,ab",10,"b,bc"'.
    *DATA str(32) VALUE '"abc","aaaab",10,"bbc"'.
    FORM parser USING str.
    DATA field(12).
    DATA field1(12).
    DATA field2(12).
    DATA field3(12).
    DATA field4(12).
    DATA cnt TYPE i.
    DATA len TYPE i.
    DATA temp TYPE i.
    DATA start TYPE i.
    DATA quote TYPE i.
    DATA rec_cnt TYPE i.
    len = strlen( str ).
    cnt = 0.
    temp = 0.
    rec_cnt = 0.
    DO.
    *  Start at the beginning
      IF start EQ 0.
        "string just ENDED start new one.
        start = 1.
        quote = 0.
        CLEAR field.
      ENDIF.
      IF str+cnt(1) EQ '"'.  "Check for qoutes
        "CHECK IF quotes is already set
        IF quote = 1.
          "Already quotes set
          "Start new field
          start = 0.
          quote = 0.
          CONCATENATE field '"' INTO field.
          IF field IS NOT INITIAL.
            rec_cnt = rec_cnt + 1.
            CONDENSE field.
            IF rec_cnt EQ 1.
              field1 = field.
            ELSEIF rec_cnt EQ 2.
              field2 = field.
            ELSEIF rec_cnt EQ 3.
              field3 = field.
            ELSEIF rec_cnt EQ 4.
              field4 = field.
            ENDIF.
          ENDIF.
    *      WRITE field.
        ELSE.
          "This is the start of quotes
          quote = 1.
        ENDIF.
      ENDIF.
      IF str+cnt(1) EQ ','. "Check end of field
        IF quote EQ 0. "This is not inside quote end of field
          start = 0.
          quote = 0.
          CONDENSE field.
    *      WRITE field.
          IF field IS NOT INITIAL.
            rec_cnt = rec_cnt + 1.
            IF rec_cnt EQ 1.
              field1 = field.
            ELSEIF rec_cnt EQ 2.
              field2 = field.
            ELSEIF rec_cnt EQ 3.
              field3 = field.
            ELSEIF rec_cnt EQ 4.
              field4 = field.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
      CONCATENATE field str+cnt(1) INTO field.
      cnt = cnt + 1.
      IF cnt GE len.
        EXIT.
      ENDIF.
    ENDDO.
    WRITE: field1, field2, field3, field4.
    ENDFORM.
    Regards,
    Wenceslaus.

  • Erroneous row-lines in application server file

    Hello,
    There are some erroneous row-lines in application server file. Some part of data is repeating on a single line. I could not able to figure out if this is new record or part of same line. I have checked the code. Internal table is correctly written on application server using TRANSFER statement.
    This problem is occurring only in Production environment as per description. So, I am not able to simulate the case in development environment.
    When I downloaded file into notepad I get following text on single line:-
    7411NC00101 GASNW 49223004 ESSENT NETWERK NOORD (GAS) GASNW 49223004 ESSENT NETWERK NOORD (GAS)  871694840014102760
    Correct record should be:-
    7411NC00101 GASNW 49223004 ESSENT NETWERK NOORD (GAS) 871694840014102760
    Can anyone please suggest me possible causes of the problem?
    Thanks in advance,
    Minal

    Hi,
    Just check the code in debugging  where the "GASNW 49223004 ESSENT NETWERK NOORD (GAS)" portion is generated and written to text area. This is happening because of the loop or not refreshing the variables.
    With regards,
    Sunil

  • Blank line in Application server file

    Hi,
    I am uploading datas from 2 internal tables to Application server file(same file).
    I want a blank like after i finish uploading the first internal table.
    Need a blank line between two internal table datas.
    Kindly help me in solving this issue.
    Regards
    Sowmmya VB

    hi Sowmya...
    Do this way.. Sample code....
    Data : Blank(100).
    OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    LOOP AT ITAB1.
      TRANSFER ITAB1 TO P_FILE.
    ENDLOOP.
      TRANSFER BLANK TO P_FILE.  "this will transfer a Blank record.
    LOOP AT ITAB2.
      TRANSFER ITAB2 TO P_FILE.
    ENDLOOP.
    CLOSE DATASET P_FILE.

  • GUI_UPLOAD to upload flat file to internal table

    Hi Experts,
    I have to upload a flat file which has multiple records ,from a local server.The fields in records are ~ saperated.
    Presently i am only looking into uploading the flat file into internal table.
    I have done the following coding;
    TYPES: BEGIN OF gt_frmgt ,
           tablety  type c length 10 ,
           tablenm  type c length 30,
           numin  type  c length 2,
           END OF gt_frmgt.
    TYPES: begin of gt_frmgto,
             rec(1000) type c,
            end of gt_frmgto.
    DATA: Itgt_frmgt type table of gt_frmgt with header line.
    DATA: itgt_frmgto type table of gt_frmgto with header line.
    DATA: lfile_path type string.
    PARAMETERS: f_path type localfile.
    at selection-screen on value-request for f_path.
      call function 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          static    = 'X'
        CHANGING
          file_name = f_path.
    start-of-selection.
      lfile_path = f_path.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME                      = lfile_path
          FILETYPE                      = 'ASC'
         HAS_FIELD_SEPARATOR           = 'X'
        HEADER_LENGTH                 = 0
        READ_BY_LINE                  = 'X'
        DAT_MODE                      = ' '
        CODEPAGE                      = ' '
        IGNORE_CERR                   = ABAP_TRUE
        REPLACEMENT                   = '#'
        CHECK_BOM                     = ' '
        VIRUS_SCAN_PROFILE            =
        NO_AUTH_CHECK                 = ' '
      IMPORTING
        FILELENGTH                    =
        HEADER                        =
        TABLES
          DATA_TAB                      =  itgt_frmgto
      EXCEPTIONS
        FILE_OPEN_ERROR               = 1
        FILE_READ_ERROR               = 2
        NO_BATCH                      = 3
        GUI_REFUSE_FILETRANSFER       = 4
        INVALID_TYPE                  = 5
        NO_AUTHORITY                  = 6
        UNKNOWN_ERROR                 = 7
        BAD_DATA_FORMAT               = 8
        HEADER_NOT_ALLOWED            = 9
        SEPARATOR_NOT_ALLOWED         = 10
        HEADER_TOO_LONG               = 11
        UNKNOWN_DP_ERROR              = 12
        ACCESS_DENIED                 = 13
        DP_OUT_OF_MEMORY              = 14
        DISK_FULL                     = 15
        DP_TIMEOUT                    = 16
        OTHERS                        = 17
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      delete itgt_frmgto index 1.
      loop at itgt_frmgto.
        clear Itgt_frmgt.
        split itgt_frmgto-rec at cl_abap_char_utilities=>vertical_tab
        into Itgt_frmgt-tablety
        Itgt_frmgt-tablenm
        Itgt_frmgt-numin.
        append Itgt_frmgt.
      endloop.
      loop at Itgt_frmgt.
        write:/ Itgt_frmgt-tablety, Itgt_frmgt-tablenm, Itgt_frmgt-numin.
    The input file in Local path is ;
    XXXXXXX~~Export the invoice
    2~19980501~19980531
    // The first invoice:
    0~00130698114000010004119980512059611000276233.350.1711076.66????321000789010005???????????????????130601000000000??????????18? 3352051????532611-3357211???~~~
    0~????????176233.350.1711076.6676233.350~1510
    // The second invoice:
    0~00130698114000010007219980512059611000440482.000.175882.00????110108078901007?????????61? 68744479?????????????462088-07?????130601000000000??????????18? 3352051????532611-3357211???????????~~~
    0~????????139780.000.175780.0039780.000~1510
    0~????3.5"10702.000.17102.0070.20~1510
    and the output is :
    XXXXXXX~~
    2~~1998050
    // The fir
    0~00~1
    0~????~?
    // The sec
    0~00~1
    0~????~?
    0~????
    I am unable to understand why this split is happening .According to me the first 3 fields should be displayed without field saperater.
    It would be very much appreciated if any body has little idea about this.
    Thankx,
    Priya
    Message was edited by:
            Priya Parmeshwar Shiggaon
    Message was edited by:
            Priya Parmeshwar Shiggaon

    if it is one time upload then u can use transaction CG3Z n upload file on application server.
    u can tno use Gui_upload in background.
    Program to upload file via gui_upload in foreground  -(open fiel in Excel format and then make changes and save it as text tab file and upload tht file) -
    REPORT  Z_AMIT_BAPI
    no standard page heading line-size 255.
    parameters: p_file like rlgrap-filename default 'C:\temp\emp.txt'.
    data :begin of itab occurs 0,
             pernr(8),
             bdate(10),
             edate(10),
             mail(30) ,
            end of itab.
    Start-of-selection.
    Perform read_file.
    *&      Form  read_file
          text
    -->  p1        text
    <--  p2        text
    FORM read_file .
    DATA: full_file_name    TYPE string.
    full_file_name = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = full_file_name
        FILETYPE                      = 'ASC'
        HAS_FIELD_SEPARATOR           = ','
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
      NO_AUTH_CHECK                 = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      TABLES
        DATA_TAB                      = itab
    EXCEPTIONS
       FILE_OPEN_ERROR               = 1
       FILE_READ_ERROR               = 2
       NO_BATCH                      = 3
       GUI_REFUSE_FILETRANSFER       = 4
       INVALID_TYPE                  = 5
       NO_AUTHORITY                  = 6
       UNKNOWN_ERROR                 = 7
       BAD_DATA_FORMAT               = 8
       HEADER_NOT_ALLOWED            = 9
       SEPARATOR_NOT_ALLOWED         = 10
       HEADER_TOO_LONG               = 11
       UNKNOWN_DP_ERROR              = 12
       ACCESS_DENIED                 = 13
       DP_OUT_OF_MEMORY              = 14
       DISK_FULL                     = 15
       DP_TIMEOUT                    = 16
       OTHERS                        = 17
    IF SY-SUBRC <> 0.
      MESSAGE e000(000) WITH 'Upload-Error; RC:' sy-subrc.
    ENDIF.
    ENDFORM.                    " read_file
    reward points if helpfull
    amit

  • FM to upload the Excel file to internal table

    Hi
    Is any FM available to upload the Excel file to internal table.
    Thanks
    Anbu

    Hi
    se this code
    EXCEL to INTERNAL TABLE and then to APPLICATION SERVER
    *& Report  ZSD_EXCEL_INT_APP
    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.

  • How to convert xml file into internal table in ABAP Mapping.

    Hi All,
    I am trying with ABAP mapping. I have one scenario in which I'm using below xml file as a sender from my FTP server.
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MTO_ABAP_MAPPING xmlns:ns0="http://Capgemini/Mumbai/sarsingh">
      <BookingCode>2KY34R</BookingCode>
    - <Passenger>
      <Name>SARVESH</Name>
      <Address>THANE</Address>
      </Passenger>
    - <Passenger>
      <Name>RAJESH</Name>
      <Address>POWAI</Address>
      </Passenger>
    - <Passenger>
      <Name>CARRON</Name>
      <Address>JUHU</Address>
      </Passenger>
    - <Flight>
      <Date>03/03/07</Date>
      <AirlineID>UA</AirlineID>
      <FlightNumber>125</FlightNumber>
      <From>LAS</From>
      <To>SFO</To>
      </Flight>
      </ns0:MTO_ABAP_MAPPING>
    AT the receiver side I wnat to concatenate the NAME & ADDRESS.
    I tried Robert Eijpe's weblog (/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach)
    but couldnt succeed to convert the xml file into internal table perfectly.
    Can anybody help on this. 
    Thanks in advance!!
    Sarvesh

    Hi Sarvesh,
    The pdf has details of ABAP mapping. The example given almost matches the xml file you want to be converted.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/3.0/how to use abap-mapping in xi 3.0.pdf
    Just in case you have not seen this
    regards
    Vijaya

  • Application server file formats.

    Hi,
    I have one query regarding the application server file formats, when we are creating a file we give some extension (.txt, .dat),what is the use of different extensions.
    When we are downloading the file from appl server using CG3Y we have two options(ASC and BIN ) what is the use of these options.
    Thanks in advance.

    Hi,
    A text file is a kind of computer file that is structured as a sequence of lines.
    A .dat  file is a computer file which stores data for use by a computer application or system.
    A character encoding consists of a code that pairs a sequence of characters from a given character set (sometimes referred to as code page) with something else, such as a sequence of natural numbers, octets or electrical pulses, in order to facilitate the storage of text in computers and the transmission of text through telecommunication networks.
    ASCII and BINARY codes are used for internal representation of data.
    The major difference between ASCII and BINARY is that when ASCII mode is used then the READ DATASET stmt starts at new line each time and in case of BINARY it reads character by character ( or some characters).
    Thanks and regards.

Maybe you are looking for