Create XML file on application server (unix directory) from internal table

Hallo everybody,
I have got the following problem:
I am working with <u><b>release 4.6C</b></u> and have got to create XML files from HR master data and organizational data respectively.
This takes place in 3 steps:
1.     Collect the data in an internal table
2.     Convert the data to XML format using the function module 'SAP_CONVERT_TO_XML_FORMAT'
3.     Download the data
If I download the converted data, which are in an internal table, to the presentation server via the function module ‘WS_DOWNLOAD’ and open it with the Internet Explorer, everything is ok.
If I download the converted data to the application server, i.e. into a unix directory via
‘open dataset’, ‘loop at internal table, ‘transfer working area to file’, ‘close dataset’
and then try to open it, this is not possible, because after the last tag some unreadable characters, e.g. a square, appear that aren’t supposed to be there. That’s what my colleagues told me, for I haven’t got access to the server.
I have no idea where these characters come from and how I can get rid of them. I guess that either I have to modify (how?) the table with the converted data before the download or I have to use another way to convert the data. For the second way I would probably have to work with an XML class or an XML interface. Unfortunately I’I am not an expert in working with classes so sample coding would have to be rather detailed.
Here’s some more information about how I work with the conversion function module:
  call function 'SAP_CONVERT_TO_XML_FORMAT'
       exporting
            i_field_seperator    = lv_field_seperator
           i_line_header        = lv_line_header
           i_filename           = lv_xml_file
           i_appl_keep          = ' '
            i_xml_doc_name       = lv_xml_doc_name
       importing
            pe_bin_filesize      = lv_result
       tables
            i_tab_sap_data       = gt_data
       changing
            i_tab_converted_data = lt_tab_converted_data
       exceptions
            conversion_failed    = 1
            others               = 2.
lv_field_seperator = ‘X’.
lv_xml_doc_name = ‘Personalstammdaten Publikation’
lv_result: type i
gt_data: fields: PERNR, PERSG, PERSK etc.
  types:
  begin of truxs_xml_line,
    data(256) type x,
  end of truxs_xml_line.
  types:
  truxs_xml_table type table of truxs_xml_line.
data:
lv_tab_converted_data type truxs_xml_line,
lt_tab_converted_data type truxs_xml_table
open dataset lv_xml_file for output in binary mode.
loop at lt_tab_converted_data into lv_tab_converted_data.
  transfer lv_tab_converted_data to lv_xml_file.
endloop.
close dataset lv_xml_file
lv_xml_file: /usr/users/.../.../Personendaten_2004-11-02.xml
Hope the information is detailed enough! Otherwise let me know. Thank you in advance.
Message was edited by: Johannes Schwehm

Hi Raja,
tried the "TEXT" mode, but that didn't help.
There are still characters after the last tag, that are not supposed to be there including a date that is not
the creation date of the file.
Thank you for your help.
Regards
Johannes

Similar Messages

  • XML data into Oracle Tables. XML file on Application Server.Oracle Apps R12

    Hi All,
    My Database version : 11.2.0.2.0
    I have an XML file which needs to be loaded into the Database Tables. How ever i do not want to use the XMLTYPE as given below
    insert into test1 (
    SELECT PrcDate, PmtType, PmtStatus, PmtTypeCount, PmtTypeAmt
    FROM XMLTABLE(
    '/WFPaymentAck/RejectedDom1ACH'
    PASSING XMLTYPE( BFILENAME('ECX_UTL_LOG_DIR_OBJ','wf_test_xml.XML'), NLS_CHARSET_ID('UTF8') )
    COLUMNS
    PrcDate VARCHAR2(2000) PATH '@PrcDate' ,
    PmtType VARCHAR2(2000) PATH '@PmtType' ,
    PmtStatus VARCHAR2(100) PATH '@PmtStatus' ,
    PmtTypeCount VARCHAR2(100) PATH 'PmtTypeCount' ,
    PmtTypeAmt VARCHAR2(100) PATH 'PmtTypeAmt'
    Because this way the XML file needs to reside on the DB server.
    I am looking into other option of loading the XML file into a CLOB column of a table and reading it from that column.
    I did a couple of tests and feel that this way also the XML file has to reside on the Database Server itself. I am not sure if this is correct or if there is any problem with our TEST instance.
    ++Can anyone let me know if i need to have the XML file on the DB server instead of the Application server to load into a CLOB column of table ??++
    ++Or++
    ++Is there any other workaround for me to load XML into Oracle Tables, while having the XML file on Application Server.++
    Your immediate help is appreciated. I need to get past this ASAP.
    Thanks in Advance.
    VJ

    1) Are you asking me to create a folder on Database directory which points to a folder on the Apps server ?I suggest creating an Oracle directory object (a database object) pointing to a real location (folder) on Application server.
    we DONOT want a hand shake between the DB Server and the APPS server.I don't see where the problem is.
    I'm not familiar with Apps R12 but there's no doubt the two servers are already communicating, at least App server should be able to access the DB for the whole thing to run.
    As I said :
    One way or another, the data has to make its way to the database, there's no workaround to that.How do you imagine the data will end up in a database table if it doesn't come to the DB server?
    There's no magical method out there, both servers have to communicate at some point.
    About client-server approaches (client being here the App server), you can read about accessing the XML DB repository in the XML DB Developer's Guide : http://download.oracle.com/docs/cd/E11882_01/appdev.112/e23094/toc.htm
    Other option : SQL*Loader can load a CLOB, or an XMLType column too
    Edited by: odie_63 on 19 déc. 2011 20:22

  • Unable to create a file in Application Server using OPEN DATASET stattement.

    I am unable to create a file in Application Server using the following statement.
    OPEN DATASET filename FOR OUTPUT
    IN TEXT MODE ENCODING DEFAULT
    MESSAGE msg.
    The message I'm getting is "Permission Denied". I have checked authorisation using SU53 which says "The last authorization check was successful". Please help.

    You can use following code to capture the error.
    TRY.
          OPEN DATASET filename FOR OUTPUT IN BINARY MODE MESSAGE V_MSG.
          CATCH CX_ROOT
          INTO EXCEPTION.
          CALL METHOD O_EXCEPTION ->IF_MESSAGE~GET_TEXT
            RECEIVING
            RESULT = V_MSG.
          MESSAGE v_msg
          TYPE 'E'.
    ENDTRY.
    You can capture error in v_msg.
    Following are the exceptions for the same:
    Exceptions
    Catchable Exceptions
    CX_SY_FILE_OPEN
    Cause: The file is already open.
    Runtime Error: DATASET_REOPEN
      CX_SY_CODEPAGE_CONVERTER_INIT   
    Cause: The desired conversion is not supported. (Due to specification of invalid code page or of language not supported in the conversion, with SET LOCALE LANGUAGE.)
    Runtime Error: CONVT_CODEPAGE_INIT
    CX_SY_CONVERSION_CODEPAGE
    Cause: Internal error in the conversion.
    Runtime Error: CONVT_CODEPAGE
    CX_SY_FILE_AUTHORITY
    Cause: No authorization for access to file
    Runtime Error: OPEN_DATASET_NO_AUTHORITY
    Cause: Authorization for access to this file is missing in OPEN DATASET with addition FILTER.
    Runtime Error: OPEN_PIPE_NO_AUTHORITY
      CX_SY_PIPES_NOT_SUPPORTED   
    Cause: The operating system does not support pipes.
    Runtime Error: DATASET_NO_PIPE
    CX_SY_TOO_MANY_FILES
    Cause: Maximum number of open files exceeded.
    Runtime Error: DATASET_TOO_MANY_FILES   Non-Catchable Exceptions   
    Cause: An attempt was made to open a pipe that is already open.
    Runtime Error: DATASET_PIPE_POSITION
    Hope that will help you.
    Please reward if useful.

  • Xml file in application server

    Experts,
    I'm using a a simple tranformation and "open dataset" statement in order to write a xml file in application server: This is working fine.
    i notice that when i preview the file in transaction "AL11" , it shows like " <tag> <tag> <tag> <tag> ......
    The encoding of this file is 'utf-8'.
    I did another test that was writing, trouht transaction CG3Z, a xml file in encoding 'ISO-8859-15'. When a preview the file in AL11 is shows like :
    <tag>
    <tag>
    <tag>
    <tag>
    The change in the preview is due to the codification ? Or is regarding that way we write the file to the server ?
    Best regards,
    MR.

    Hello,
    Change is because of the encoding style changed from utf-8 to 'ISO-8859-15'.
    May be you can try changing this manualy in XML file and see the output result.
    Thanks,
    Augustin.

  • Create Excel file in application server but the field value is incorrect

    Hi Experts,
    i am facing a problem when create excel file in application server using OPEN DATASET command.
    the internal table have 4 field and one of those field contains 19 digit number --> ICCID.
    the code running well, successfully create EXCELfile in application server but the problem is SAP only copy exactly first 15 digit numeric only and the rest became zero 0
    Example :
    the field value in internal table is 8962118800000447654 but when i opened in the excel file the value became 8962118800000440000.
    and if i add alphabet like a8962118800000447654 then it is correct.
    is there is anything wrong with my code?
    here is my code
    CONSTANTS: c_tab TYPE abap_char1 VALUE cl_abap_char_utilities=>horizontal_tab. "Tab Char
    Data : begin of lt_zdsdmmdt00005 occurs 0,
             SERNR (18) type c,
             MSISDNl(20) type c,
             BOX1 (20) type c,
             ICCID(30) type c,
           end of lt_zdsdmmdt00005.
    data : ld_temp(100) type c.
    i_file = '/usr/sap/DM/test_excel.xls'.
    open dataset i_file for output in legacy text mode.
      loop at lt_zdsdmmdt00005.
        move lt_zdsdmmdt00005-ICCID to ld_iccid .
        concatenate lt_zdsdmmdt00005-sernr  lt_zdsdmmdt00005-MSISDN  lt_zdsdmmdt00005-BOX1 ld_iccid
        into ld_temp separated by c_tab.
        transfer ld_temp to i_file.
      endloop.
      close dataset i_file.
    Best Regard,
    Akbar.

    Hi Naveen,
    thanks for your reply,
    i already tried and the result still the same. any idea?
    Best Regard,
    Akbar.

  • Problem in creating a file on Application Server

    Hi,
    I am facing an issue while creating a file on the application server.
    I am creating a file with sales data from SAP and saving it on the application server.
    At the end of this operation, I am calling a Unix script to push this file from SAP to an external system.
    The issue I am facing is - at every month end, when I run a job for creating the file (its a custom program which is scheduled to run periodically), I get a strange scenario where a BLANK FILE gets created on the application server even though the data tables are not blank.
    Also the user id gets changed to UID = 1400 when I run this job for the first time when a BLANK FILE gets created.
    When I delete this file and run the job again, though, the file gets created WITH DATA.
    The user name remains DEVADM (Dev Admin), as it should be for the scheduled jobs.
    What could be the possible reasons for this?
    Please help me in this direction.
    Thank you.
    Regards,
    Keerthi

    Hi,
    You are using OPEN DATASET ? And what is the sy-subrc ?
    Can you post some lines of your code?
    Best regards,
    Leandro Mengue

  • Creating a file on application server that exceeds 10 Million charecters

    Hello All,
    We have custom IDocs which carry Strings of 1062 characters in each of their segments.
    Now the requirement is to create a single string file out of these idocs data.
    It is expected that each of these IDocs can go up to having more than 70,000 segments.
    So, now when this is concatenated into one single string it can go upto 7 Million charecters.
    My questions are:
    1. Can we create a text file with so many charecters in a single line or is there any limitation for this ?
    2. I have found a datatype CHAR30000, using which i'm currently concatnating around 30 segment data and then writing onto the file. Now once I wrote a single line, how can I set the pointer to End of line ?
    3. Is there any limitation in ABAP to create such a long string text file using method mentioned above ?
    Thanks for responding back!!
    -Sri

    No, It should be something like below.. for writing the file onto application server , which aint working though...
    *Writing output data into the file.
      lw_endofline = 30000.
      OPEN DATASET p_fileop FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
      LOOP AT int_output INTO wa_output.
        TRANSFER wa_output-sdata TO p_fileop.
        "SET DATASET p_fileop POSITION lw_endofline.
        SET DATASET p_fileop POSITION lw_endofline.
        lw_endofline = lw_endofline + 30000.
      ENDLOOP.
      CLOSE  DATASET p_fileop.

  • OPEN DATASET create .txt file in application server

    Hi,
    I'm trying to create a .txt into application server. Code as follows:-
    OPEN DATASET gv_filestatus FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc <> 0.
        WRITE: 'File cannot be opened.'.
      ENDIF.
      LOOP AT gt_pdfstatus INTO gw_pdfstatus.
        TRANSFER gw_pdfstatus TO gv_filestatus.
      ENDLOOP.
      CLEAR gw_pdfstatus.
    CLOSE DATASET gv_filestatus.
    But I got the error "GW_PDFSTATUS" cannot be a table, a reference, a string, or contain any of these objects. GW_PDFSTATUS is a work area with 5 fields of different type. I know that I can transfer table type of TLINE but I'm not sure how to convert my internal table gt_pdfstatus as TLINE.
    Please advise. Thanks.

    When transfering data to a file, you should convert the data to type char and then transfer it to the file.
    So, you would need to declare a structure with 5 fields of type c with the corresponding length of the original structure.
    Then move the corresponding fields of work are gw_pdfstatus to the character type structure. And then transfer the new structure to the file (gv_filestatus in your case).
    "for example if all the fields in the gw_pdfstatus  are of lenght 10, then declare a structure as follows
    data : begin of file_wa,
    f1(10) type c,
    f2(10)  type c,
    f3(10) type c,
    f4(10) type c,
    f5(10) type c,
    end of file_wa.
    OPEN DATASET gv_filestatus FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc  0.
        WRITE: 'File cannot be opened.'.
      ENDIF.
      LOOP AT gt_pdfstatus INTO gw_pdfstatus.
        move-corresponding gw_pdfstatus to file_wa.  " Add this
        TRANSFER file_wa TO gv_filestatus.   " Change this line
      ENDLOOP.
      CLEAR gw_pdfstatus.
    CLOSE DATASET gv_filestatus.
    Hope this helps.
    KR,
    Advait

  • Creating a File in Application Server

    Hi i have some data in the internal table itab. which contains few fields. Some of the fields are blanks and some contains data. Now i am transfering this internal table to file which is in Application Server. When i trnasfer itab to file, blank fields are concatenated by  next field.
    Explanation:
    itab contains fallwoing data:
    field1  field2  field3  field4  field5
    uu       kk                nn      ii
    when i transer this to file it is coming as fallows
    field1  field2  field3  field4  field5
    uu       kk       nn      ii
    how can i solve this problem
    Thanx in Advance
    Subhani.

    Hi Subhani,
    This probelm can be fixed very easily.  All you need to do is to use Offsets while writing to the file from internal table.  This is done as follows:
    DATA: gv_string(217) TYPE c,                     " Holds text to display
    Loop at <itab> into <wa>.
       gv_string+0(5) = <wa>-<fieldname>
       gv_string+10(5) = <wa>-<fieldname>
    do this for all the fileds.
    Endloop.
    Note: In the above code snipet, 0(5) represents 'Starting for the 0th position, reserve 5 characters and print it there.  Use this for all the fields of your internal table.  Based on the size of the field(s) of the itab, allocate the space accordingly.
    <b>PLZ REWARD POINTS IF HELPFUL</b>

  • Create an XML File in Application server

    Hello,
    I have a requirement to create an XML File as Local File and as server File. For the local File it works fine and i got a Local XML File.
    My problem is for the Server File.I found a solution in internet to convert in binary.But i don't get in the server File created the XML structure.
    Here is My code for the unix server File
    DATA ex_tab TYPE TABLE OF x255.
      data: wa_tab type x255.
      data: lv_line(255) type c.
    **-- carica tabella gt_file
       PERFORM CARICA_TAB_FILE.
       LOOP AT GT_FILE.
         MOVE-CORRESPONDING GT_FILE TO WA_SOURCE.
         APPEND WA_SOURCE TO GT_SOURCE.
         CLEAR WA_SOURCE.
       ENDLOOP.
    * Perform the XSLT stylesheet
       TRY.
           CALL TRANSFORMATION ZMESMO052_XML
              SOURCE MATERIAL_DATA = GT_SOURCE[]
              RESULT XML XML_RESULT .
         CATCH CX_ROOT INTO GS_RIF_EX.
           GS_VAR_TEXT = GS_RIF_EX->GET_TEXT( ).
           MESSAGE GS_VAR_TEXT TYPE 'E'.
       ENDTRY.
      CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
         EXPORTING
             buffer     = XML_RESULT
           TABLES
             binary_tab = ex_tab.
       CONCATENATE P_FILE '.xml' INTO P_FILE.
       CONDENSE P_FILE.
       TRANSLATE P_FILE TO LOWER CASE.
       OPEN DATASET P_FILE FOR OUTPUT IN BINARY MODE.
       IF SY-SUBRC NE 0.
         MESSAGE E000(ZF) WITH ' Error opening File' P_FILE.
       ENDIF.
       loop at ex_tab  into wa_tab.
         move wa_tab to lv_line.
         transfer lv_line to p_file.
       endloop.
       close dataset p_file.
    And i Got a file like this
    Any solution please

    I Found the solution,
    DATA EX_TAB TYPE TABLE OF X255.
       DATA: WA_TAB TYPE X255.
       DATA: LV_LINE(255) TYPE C.
       DATA: L_CONVIN TYPE REF TO CL_ABAP_CONV_IN_CE.
       DATA: L_HTML TYPE STRING.
       DATA: L_VALUE TYPE STRING.
       DATA: L_MSGSTR TYPE STRING.
       DATA: FILENAME TYPE STRING.
    **-- carica tabella gt_file
       PERFORM CARICA_TAB_FILE.
       LOOP AT GT_FILE.
         MOVE-CORRESPONDING GT_FILE TO WA_SOURCE.
         APPEND WA_SOURCE TO GT_SOURCE.
         CLEAR WA_SOURCE.
       ENDLOOP.
    * Perform the XSLT stylesheet
       TRY.
           CALL TRANSFORMATION ZMESMO052_XML
              SOURCE MATERIAL_DATA = GT_SOURCE[]
              RESULT XML XML_RESULT .
         CATCH CX_ROOT INTO GS_RIF_EX.
           GS_VAR_TEXT = GS_RIF_EX->GET_TEXT( ).
           MESSAGE GS_VAR_TEXT TYPE 'E'.
       ENDTRY.
       TRY.
           CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
             EXPORTING
               ENCODING = 'UTF-8'
               INPUT    = XML_RESULT
             RECEIVING
               CONV     = L_CONVIN.
           CALL METHOD L_CONVIN->READ
             IMPORTING
               DATA = L_HTML.
         CATCH CX_ROOT.
           L_MSGSTR = 'Conversion error'.
       ENDTRY.
       SEARCH L_HTML FOR '><'.
       CLEAR L_VALUE.
       L_VALUE = CL_ABAP_CHAR_UTILITIES=>NEWLINE.
       CONCATENATE '>' L_VALUE '<' INTO L_VALUE.
       IF SY-SUBRC = 0.
         REPLACE ALL OCCURRENCES OF '><' IN L_HTML WITH L_VALUE IN
    CHARACTER MODE.
       ENDIF.
       CONCATENATE P_FILE '.xml' INTO P_FILE.
       CONDENSE P_FILE.
       TRANSLATE P_FILE TO LOWER CASE.
       FILENAME = P_FILE.
       OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE
    WITH UNIX LINEFEED.
       TRANSFER L_HTML TO FILENAME.
       CLOSE DATASET FILENAME.

  • Reading XML file from application server and  put into internal table-4.6C

    Dear All,
    Is there any way of reading XML file from application server to SAP? I am using 4.6C. Function module SCMS_STRING_TO_XSTRING function module is not available. Please suggest.
    Thanks and regards,
    Atanu

    Hi Atanu!
    Simply use the XSLT transformation 'ID'.
    FIELD-SYMBOLS <ls_result> TYPE ANY.
    CREATE DATA lref_data TYPE (your_structure).
    ASSIGN lref_data->* TO <ls_result>.
    CALL TRANSFORMATION id
                        SOURCE XML xmlstr
                        RESULT result = <ls_result>.
    "xmlstr" contains your XML file. Just read it into it via standard I/O operations. "<ls_result>" will contain your DDIC formatted content.
    Best regards
    Torsten

  • Create excel file on application server

    Hi experts,
    Is it possiblel to create an excel file on the application server in a background process ?
    We have an windows nt application server.
    I tried with open dataset ..but i didn't work 100% good.
    has anybody any sample ?
    Thanks.

    I m using an csv file as tabdelimited .
    data: htab(1) type c.
    htab = cl_abap_char_utilities=>horizontal_tab.
    the file is downloaded as excel , but if i open the file i see the content of a row always in the first column.
    Types : begin of ty_test,
                    name1 type char10,
                    name2 type char10,
                end of ty_test.
    Data : it_test type table of ty_test,
              wa_test type ty_test,
              wa_row type string.
    data: htab(1) type c.
    htab = cl_abap_char_utilities=>horizontal_tab.
    wa_test-name1 = 'name1'.
    wa_test-name2 = 'name2'.
    append wa_test to it_test.
    clear wa_test.
    open dataset <filename> for output in text mode
              encoding default.
       loop at it_test into wa_test.
         conatenate wa_test-nam1 wa_test-name2  into wa_row  separated by htab.
         transfer wa_row to <filename>.
      endloop.
    close dataset.
    Edited by: Moo Yac on Jul 2, 2009 11:48 AM

  • Write XML file in application server

    Experts,
    I'm using a transformation to generate a xml file:
      CALL TRANSFORMATION zdatafechomes
      SOURCE ficheiroexecucao = gt_source[]
      RESULT XML  xml_result.
    It's working fine. But i'm having problems in putting the "xml_result" (it's a type xtring) into the application server.
    Anyone knows how to do it ? Transaction cg3z it's different because the file comes from C:
    Best Regards,
    Mário.

    Hello Mario
    I do not see why the following logic should not work:
    *& Report  ZUS_SDN_XML_XSTRING_APPLSERVER
    REPORT  ZUS_SDN_XML_XSTRING_APPLSERVER.
    DATA:
      gd_dsn            type string,
      gd_xstring        type xstring,
      gt_kna1           type STANDARD TABLE OF kna1.
    start-of-selection.
      select * from kna1 into table gt_kna1 up to 10 rows.
      BREAK-POINT.
      call TRANSFORMATION id
        source itab = gt_kna1
        result xml = gd_xstring.
        gd_dsn = '/tmp/xml_as_xstring.file'.
        open DATASET gd_dsn for OUTPUT in BINARY MODE.
        check ( syst-subrc = 0 ).
        TRANSFER gd_xstring to gd_dsn.
        CLOSE DATASET gd_dsn.
    end-of-SELECTION.
    Regards
      Uwe

  • Authorization for the user to write/read/create a file in application serve

    Hi experts.
    I am uploading some data to a file in a folder in application server, created in AL11 tcode.
    In my program i need to restrict the unauthorized users to create/write/read a file in app server.
    I dont know how to do this.
    Kindly give me the code, please it wil be helpfull for you all.
    I dont know how to use the auth object or function module, to do this.
    Is the basis/security people need to do something.
    Kindly revert me back ASAP.
    KK

    Or use AUTHORITY_CHECK_DATASET function module before the open data set
    This function module allow you to check the user's authorization to access files (with the key words OPEN DATASET, READ DATASET, TRANSFER and DELETE DATASET). A check should be performed before opening a file.
    The authorization check is performed uwing the authorization object S_DATASET.
    Description of function parameters:
    PROGRAM: Name of the ABAP/4 program that contains the file access. If no program name is specified, the system assumes the current program.
    ACTIVITY: Access type. The possible values are:
    READ: Read file
    WRITE: Change file
    READ_WITH_FILTER: Read file with filter function
    WRITE_WITH_FILTER: Change file with filter function
    DELETE: Delete file
    FILENAME: Name of accessed file
    Example
    Notes
    The values to be passed as the ACTIVITY are defined as constants in the TYPE-POOL SABC.

  • Creating a new file in application server

    hai,
      please rectify this, how to create a file in application server ?
       can any one forward a sample code for creating a file in application server.
                           hazam

    Hi Hazam,
      Please check the below code.
    Data :   P_UFILE(60)                   " Unix File name
             TYPE C
             value '/emn_R3/hr/ben_age25_dep'.
        CLEAR GD_SUBRC.
        <b>OPEN DATASET</b> GD_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
        IF SY-SUBRC <> 0.
          GD_SUBRC = SY-SUBRC.
          gs_error-pernr = gs_0021-pernr.
          gs_error-ename = gd_ename.
          gs_error-mess
               = 'Can not open File:'(017) + gd_file.
          append gs_error to gt_error.
          clear gs_error.
    *      CLEAR GD_MSG1.
    *      CONCATENATE 'Can not open File:'(017)
    *                   GD_FILE
    *        INTO GD_MSG1.
    *      WRITE : / GD_MSG1.
        ELSE.
          LOOP AT GT_BODY INTO GS_BODY.
            <b>TRANSFER</b> GS_BODY TO GD_FILE.
          ENDLOOP.
          <b>CLOSE DATASET</b> GD_FILE.
        ENDIF.
    Hope this will help you.
    Thanks&Regards,
    Siri.
    Message was edited by: Srilatha T

Maybe you are looking for