Application server file length to internal table

i am having a flat file in the appliaction server and it is 350 characters length stored for each line.
i mean like purchase order,matner,material text, kunnr,customer address etc, this all will be 365 chars including spaces.
I have decalred the file path like
file(150) type c.
so in file i store the physical path.
Now i used the statement to read the data into by itab , which has all the fields of applicaion server file .
Do
Read dataset file into waitab.
IF sy-subrc <> 0.
      EXIT.
    ENDIF.
     APPEND waitab TO itab.
    CLEAR waitab.
  ENDDO.
1)My doubt is that
experts
i am simply using Read dataset file into waitab. and i did not mentioned the lenght of the file anywhere in the program? Will the system move all the 365 chars into waitab?
Or do i need to mention the lenght of the file?
2)Suppose my file is like this
1212222  2283838 2839293  383839283 38e439 3u39393 3839839 383993 2837383  38739378  3u873983
Now my itab will be
filed1(10),file2(7),field3(8),field4(7),filed5(8).
so in this case the first 10 chars of the file will be placed in field1,
next 7chars will be placed in field2, is it including spaces?
Here my file lenght is more than the itab, in this case what will happen?Beacuse my need is to have file first line into one record of itab , second line into another record , etc?

Hi,
<li>Try this way. This sample program is used to download TAB delimited file from application server.
REPORT ztest_program.
DATA: BEGIN OF it_t001 OCCURS 0,
        bukrs TYPE t001-bukrs,
        butxt TYPE t001-butxt,
        ort01 TYPE t001-ort01,
        land1 TYPE t001-land1,
        waers TYPE t001-waers,
        spras TYPE t001-spras,
        ktopl TYPE t001-ktopl,
        waabw TYPE t001-waabw,
      END OF it_t001.
DATA: BEGIN OF it_app_file OCCURS 0,
        data TYPE string,
      END OF it_app_file.
CLASS cl_abap_char_utilities DEFINITION LOAD.
CONSTANTS:hor_tab  TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
PARAMETERS : p_file(150) TYPE c.
START-OF-SELECTION.
  "Open file for reading
  OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
  IF sy-subrc EQ 0.
    DO.
      READ DATASET p_file INTO it_app_file-data.
      IF it_app_file IS INITIAL.
        "If file ends or if does not have data
        EXIT.
      ELSE.
        "Splitting TAB delimited data into into internal table
        SPLIT it_app_file-data AT hor_tab INTO it_t001-bukrs
                                               it_t001-butxt
                                               it_t001-ort01
                                               it_t001-land1
                                               it_t001-waers
                                               it_t001-spras
                                               it_t001-ktopl
                                               it_t001-waabw.
        APPEND it_t001.
        CLEAR  it_t001.
      ENDIF.
    ENDDO.
  ENDIF.
  "close file
  CLOSE DATASET p_file.
  LOOP AT it_t001.
    WRITE:/ it_t001-bukrs,
            it_t001-butxt,
            it_t001-ort01,
            it_t001-land1,
            it_t001-waers,
            it_t001-spras,
            it_t001-ktopl,
            it_t001-waabw.
  ENDLOOP.
<li>Let me know if you have any problem in doing.
Thanks
Venkat.O

Similar Messages

  • 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

  • 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

  • Application server file length

    Hi,
    I am doing outbound proxy, where it si executed successfully and the file was placed in the appropriate location, but the file length is more than 255 characters , so i am unable to look into my whole file structure. My source file and target file structre is different some client related header is present in the target file. When i cheked in the sxmb_moni also my target message is not appearing. I have checked under inbound message flag and receiver grouping flag in both payloads it is showing my source structure. in response flag there is no payload folder. So finally iam unable to look at file whole file structure. Can any body suggest me what to do to look at my whole file structure. Even i try to download the file from application server even then also i am getting only till 255 characters of length. Kindly suggest some solution .
    Venkat

    Hi,
    I am doing outbound proxy, where it si executed successfully and the file was placed in the appropriate location, but the file length is more than 255 characters , so i am unable to look into my whole file structure. My source file and target file structre is different some client related header is present in the target file. When i cheked in the sxmb_moni also my target message is not appearing. I have checked under inbound message flag and receiver grouping flag in both payloads it is showing my source structure. in response flag there is no payload folder. So finally iam unable to look at file whole file structure. Can any body suggest me what to do to look at my whole file structure. Even i try to download the file from application server even then also i am getting only till 255 characters of length. Kindly suggest some solution .
    Venkat

  • 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.

  • Wut 118 application server file abc.prn does not exist or is of zero length

    dear members,
    I am printing a character mode report which gives the following error:
    "wut 118 application server file c:\abc.prn does not exist or is of zero length"
    my code on when-button-pressed is here:
              declare
                   repid REPORT_OBJECT;
                   v_rep VARCHAR2(200);
                   rep_status VARCHAR2(50);
                   report_name varchar2(100);
                   v_path varchar2(200);
                   rep_server varchar2(50);
              BEGIN
                   select parameter into rep_server from mis where parameter_type = 'REPORT_SERVER';
                   report_name := 'C:\TEMP\abc.prn';
                   repid := find_report_object('reports');
                   SET_REPORT_OBJECT_PROPERTY(repid,REPORT_FILENAME,:global.report_path||'abc123.rdf');
                   SET_REPORT_OBJECT_PROPERTY(repid,REPORT_EXECUTION_MODE,BATCH);
                   SET_REPORT_OBJECT_PROPERTY(repid,REPORT_COMM_MODE,SYNCHRONOUS);
                   SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESTYPE,FILE);
                   SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESFORMAT,:global.report_path||'dflt.prt');
                   SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESNAME,report_name);
                   SET_REPORT_OBJECT_PROPERTY(repid,REPORT_SERVER,REP_SERVER);
    PF_FGOWGPNO='||:FG_DISPATCH_M.FGOWGPNO||' PF_FISCAL_YEAR='||:FG_DISPATCH_M.XFISCAL_YEAR||:FG_DISPATCH_M.XFISCAL_YEAR||' P_USERNAME='||:DUMMY.USER);
    PF_FGOWGPNO='||:FG_DISPATCH_M.FGOWGPNO||' PF_FISCAL_YEAR='||:FG_DISPATCH_M.XFISCAL_YEAR);
                   SET_REPORT_OBJECT_PROPERTY(repid,REPORT_OTHER,'paramform=no PF_FGOWGPNO='||:FG_WH_INTERCHANGE.FG_TRANSIT_ID||' PF_FISCAL_YEAR='||:FG_WH_INTERCHANGE.XFISCAL_YEAR||' PRINT_IT='||:DUMMY.PRINT_IT);
                   v_rep := RUN_REPORT_OBJECT(repid);
                   rep_status := REPORT_OBJECT_STATUS(v_rep);
                   WHILE rep_status in ('RUNNING','OPENING_REPORT','ENQUEUED') LOOP
                        rep_status := report_object_status(v_rep);
                   END LOOP;
                   IF rep_status = 'FINISHED' THEN
                        --WEB.SHOW_DOCUMENT('/reports/rwservlet/getjobid'||substr(v_rep,instr(v_rep,'_',-1)+1)||'?'||'server=repsrv10g','_blank');
                        NULL;
                   ELSE
                        message('Error when running report');
                   END IF;
                   exception
                        when others then
                        message(sqlerrm);
                        raise form_trigger_failure;
                   END;
                   declare
                        a boolean;
                   begin
                        a := webutil_file_transfer.as_to_client('c:\temp\abc.prn','c:\temp\abc.prn');
                   end;               
                   begin
                        client_host('cmd start /c type c:\temp\abc.prn > prn');
                   exception
                        when others then null;
                   end;Regards:

    Disregard my last. I see what you are doing. You are using file transfer to move the file to the local machine. It was confusing because the paths are the same.
    I would suggest adding a SYNCHRONIZE after the file transfer and before the attempt to print. It might even be a good idea to add some error handling code to verify that the file has been copied and can be found. This will allow you to better deal with situations where the file doesn't get written for some reason. WebUtil offers some functions to check for file existence and size.
    Also, if you are using Java 7U21, this may cause some issues with your CLIENT_HOST call.

  • Length ogf Internal Table

    Hi,
      I am using GUI_UPLOAD to upload the file from presentation server to my internal table. My problem is that the one of the records of testfile is 3000 in length. The internal table is not showing all the data from the testfile. is there any limitation to the record length of an internal table??
    DATA: FILENAME(100) VALUE   'C:\testfile.txt',
          G_FILE TYPE STRING.
    DATA: BEGIN OF T_DATATAB OCCURS 0,
             LINE(3000) type c,
          END OF T_DATATAB.
    G_FILE = FILENAME.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = G_FILE
        FILETYPE                      = 'ASC'
      HAS_FIELD_SEPARATOR           = ' '
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      TABLES
        DATA_TAB                      = T_DATATAB
    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.
    Regards,
    SB

    hi,
    are you imitating lsmw direct input program.
    don't include the all structures. only use the required fields which you are going to populate.,
    thanks
    vijay
    check  the below code..
    *& Report  Z__DIRECT__MAT___CREAT                                      *
    REPORT  Z__DIRECT__MAT___CREAT                  .
    INCLUDE Z_INCLUDE_MAT_CREAT.
    *  SELECTION SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.
    PARAMETERS:P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1 .
    * AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          PROGRAM_NAME  = SYST-CPROG
          DYNPRO_NUMBER = SYST-DYNNR
          FIELD_NAME    = 'P_FILE'
        IMPORTING
          FILE_NAME     = P_FILE.
    *START-OF-SELECTION
    START-OF-SELECTION.
    *Perform to upload the data from Presentation Server
      V_FILE = P_FILE.
      PERFORM UPLOAD_DATA.
    *Transfer the Data to the structure BGR00 BMMH1 BMM00
      PERFORM CONVERT_0000.                                     " BGR00
      PERFORM POPULATE_DATA CHANGING BMM00.
      PERFORM POPULATE_DATA CHANGING BMMH1.
    **Looping the flat file data and updating the structures BMM00 & BMMH1
      LOOP AT MATERIAL_MASTER.
    *Writing the Data to the Application Server in a proper Format
        OPEN DATASET C_ZTEST FOR APPENDING IN  TEXT MODE ENCODING
        DEFAULT.
    *Transfer the Data to the structure BMM00
        PERFORM CONVERT_0002.                                   " BMM00
    *Transfer the Data to the structure BMMh1
        PERFORM CONVERT_0003.                                   " BMMH1
    **Closing the dataset after transfering the data
        CLOSE DATASET  C_ZTEST.
      ENDLOOP.     "Endloop of MATERIAL_MASTER
    *END-OF-SELECTION
    END-OF-SELECTION.
    **Calling the Direct Input Program to Create the material
      SUBMIT RMDATIND WITH %%%_R_P = C_X
                        WITH %%%_PHY = C_ZTEST
                        WITH SPERR = C_N.
    *&  Include           Z_INCLUDE_MAT_CREAT                              *
    **Tables Used To Create the Material
    TABLES:
      BGR00,
      BMM00,
      BMMH1.
    DATA:C_ZTEST(60) type c,
         C_X TYPE C,
         C_N TYPE C,
         V_file type string.
    C_ZTEST = 'Ztest.lsmw.conv'(001).
    C_X = 'X'(003).
    C_N = 'N'(004).
    **FILED SYMBOLS
    FIELD-SYMBOLS: <F> .
    **Structure to Hold the Flat File
    data:
      begin of LSMW_MATERIAL_MASTER,
        MATNR(018) type C,  "Material number
        MTART(004) type C,  "Material type
        MBRSH(001) type C,  "Industry sector
        WERKS(004) type C,  "Plant
        MAKTX(040) type C,  "Material description
        DISMM(002) type C,  "Extra Field Added In the Program as it is required
        MEINS(003) type C,  "Base unit of measure
        MATKL(009) type C,  "Material group
        SPART(002) type C,  "Division
        LABOR(003) type C,  "Lab/office
        PRDHA(018) type C,  "Product hierarchy
        MSTAE(002) type C,  "X-plant matl status
        MTPOS_MARA(004) type C,  "Gen item cat group
        BRGEW(017) type C,  "Gross weight
        GEWEI(003) type C,  "Weight unit
        NTGEW(017) type C,  "Net weight
        GROES(032) type C,  "Size/Dimensions
        MAGRV(004) type C,  "Matl grp pack matls
        BISMT(018) type C,  "Old material number
        WRKST(048) type C,  "Basic material
        PROFL(003) type C,  "DG indicator profile
        KZUMW(001) type C,  "Environmentally rlvt
        BSTME(003) type C,  "Order unit
        VABME(001) type C,
        EKGRP(003) type C,  "Purchasing group
        XCHPF(001) type C,  "Batch management
        EKWSL(004) type C,  "Purchasing key value
        WEBAZ(003) type C,  "GR processing time
        MFRPN(040) type C,  "Manufacturer part number
        MFRNR(010) type C,  "Manufacturer number
        VPRSV(001) type C,  "Price control indicator
        STPRS(015) type C,  "Standard price
        BWPRH(014) type C,  "Commercial price1
      end of LSMW_MATERIAL_MASTER.
    **InternalTable to HOld the Flat File Data
    DATA:
      BEGIN OF MATERIAL_MASTER OCCURS 0.
            INCLUDE STRUCTURE LSMW_MATERIAL_MASTER.
    DATA:
      END OF MATERIAL_MASTER.
    *&      Form  upload_data From Presentation Server
    FORM UPLOAD_DATA.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME                      = V_FILE
         FILETYPE                      = 'ASC'
         HAS_FIELD_SEPARATOR           = 'X'
    *     HEADER_LENGTH                 = 0
    *     READ_BY_LINE                  = 'X'
    *     DAT_MODE                      = ' '
    *     CODEPAGE                      = ' '
    *     IGNORE_CERR                   = ABAP_TRUE
    *     REPLACEMENT                   = '#'
    *   IMPORTING
    *     FILELENGTH                    =
    *     HEADER                        =
        TABLES
          DATA_TAB                      = MATERIAL_MASTER
       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.
        DELETE MATERIAL_MASTER INDEX 1.
      ENDIF.
    ENDFORM.                    "upload_data
    *&    Updating the BGR00 Structure
    FORM CONVERT_0000.                                          " BGR00
    **Opening the Data Set to write the data to Application Server
      OPEN DATASET C_ZTEST FOR OUTPUT IN  TEXT MODE ENCODING DEFAULT
    MOVE: '0' TO BGR00-STYPE,
             'ZTEST' TO BGR00-GROUP,
             SY-MANDT TO BGR00-MANDT,
             SY-UNAME TO BGR00-USNAM,
             'X' TO BGR00-XKEEP,
             '/' TO BGR00-NODATA.
    *Transefering the Data To the Application Server File
      TRANSFER BGR00 TO C_ZTEST.
    *Closing the Dataset after Transfer
      CLOSE DATASET C_ZTEST.
    ENDFORM.                    "convert_0001
    *&     Updating BMM00 Structure
    FORM CONVERT_0002.                                          " BMM00
    * --- BMM00-STYPE
      BMM00-STYPE = '1'.
    * --- BMM00-TCODE
      BMM00-TCODE = 'MM01'.
    * --- BMM00-MATNR
      IF NOT MATERIAL_MASTER-MATNR IS INITIAL.
        BMM00-MATNR = MATERIAL_MASTER-MATNR.
      ELSE.
        BMM00-MATNR = '/'.
      ENDIF.
    * --- BMM00-MBRSH
      IF NOT MATERIAL_MASTER-MBRSH IS INITIAL.
        BMM00-MBRSH = MATERIAL_MASTER-MBRSH.
      ELSE.
        BMM00-MBRSH = '/'.
      ENDIF.
    * --- BMM00-MTART
      IF NOT MATERIAL_MASTER-MTART IS INITIAL.
        BMM00-MTART = MATERIAL_MASTER-MTART.
      ELSE.
        BMM00-MTART = '/'.
      ENDIF.
    * --- BMM00-WERKS
      IF NOT MATERIAL_MASTER-WERKS IS INITIAL.
        BMM00-WERKS = MATERIAL_MASTER-WERKS.
      ELSE.
        BMM00-WERKS = '/'.
      ENDIF.
      BMM00-XEIB1 = 'X'.  " BMM00-xeib1 = '/'.
      BMM00-XEIE1 = 'X'.  " BMM00-xeie1 = '/'.
      BMM00-XEIK1 = 'X'.  " BMM00-xeik1 = '/'.
    **Transfer the data to the Application Server File
      TRANSFER BMM00 TO C_ZTEST.
    ENDFORM.                    "convert_0002
    *&      UPdating BMMH1 Structure
    FORM CONVERT_0003.                                          " BMMH1
    * --- BMMH1-STYPE
      BMMH1-STYPE = '2'.
    * --- BMMH1-MEINS
      IF NOT MATERIAL_MASTER-MEINS IS INITIAL.
        BMMH1-MEINS = MATERIAL_MASTER-MEINS.
      ELSE.
        BMMH1-MEINS = '/'.
      ENDIF.
    * --- BMMH1-MAKTX
      IF NOT MATERIAL_MASTER-MAKTX IS INITIAL.
        BMMH1-MAKTX = MATERIAL_MASTER-MAKTX.
      ELSE.
        BMMH1-MAKTX = '/'.
      ENDIF.
    * --- BMMH1-MATKL
      IF NOT MATERIAL_MASTER-MATKL IS INITIAL.
        BMMH1-MATKL = MATERIAL_MASTER-MATKL.
      ELSE.
        BMMH1-MATKL = '/'.
      ENDIF.
    * --- BMMH1-BISMT
      IF NOT MATERIAL_MASTER-BISMT IS INITIAL.
        BMMH1-BISMT = MATERIAL_MASTER-BISMT.
      ELSE.
        BMMH1-BISMT = '/'.
      ENDIF.
    * --- BMMH1-LABOR
      IF NOT MATERIAL_MASTER-LABOR IS INITIAL.
        BMMH1-LABOR = MATERIAL_MASTER-LABOR.
      ELSE.
        BMMH1-LABOR = '/'.
      ENDIF.
    * --- BMMH1-WRKST
      IF NOT MATERIAL_MASTER-WRKST IS INITIAL.
        BMMH1-WRKST = MATERIAL_MASTER-WRKST.
      ELSE.
        BMMH1-WRKST = '/'.
      ENDIF.
    * --- BMMH1-BRGEW
      IF NOT MATERIAL_MASTER-BRGEW IS INITIAL.
        BMMH1-BRGEW = MATERIAL_MASTER-BRGEW.
      ELSE.
        BMMH1-BRGEW = '/'.
      ENDIF.
    * --- BMMH1-NTGEW
      IF NOT MATERIAL_MASTER-NTGEW IS INITIAL.
        BMMH1-NTGEW = MATERIAL_MASTER-NTGEW.
      ELSE.
        BMMH1-NTGEW = '/'.
      ENDIF.
    * --- BMMH1-GEWEI
      IF NOT MATERIAL_MASTER-GEWEI IS INITIAL.
        BMMH1-GEWEI = MATERIAL_MASTER-GEWEI.
      ELSE.
        BMMH1-GEWEI = '/'.
      ENDIF.
    * --- BMMH1-GROES
      IF NOT MATERIAL_MASTER-GROES IS INITIAL.
        BMMH1-GROES = MATERIAL_MASTER-GROES.
      ELSE.
        BMMH1-GROES = '/'.
      ENDIF.
    * --- BMMH1-SPART
      IF NOT MATERIAL_MASTER-SPART IS INITIAL.
        BMMH1-SPART = MATERIAL_MASTER-SPART.
      ELSE.
        BMMH1-SPART = '/'.
      ENDIF.
    * --- BMMH1-BSTME
      IF NOT MATERIAL_MASTER-BSTME IS INITIAL.
        BMMH1-BSTME = MATERIAL_MASTER-BSTME.
      ELSE.
        BMMH1-BSTME = '/'.
      ENDIF.
    * --- BMMH1-EKWSL
      IF NOT MATERIAL_MASTER-EKWSL IS INITIAL.
        BMMH1-EKWSL = MATERIAL_MASTER-EKWSL.
      ELSE.
        BMMH1-EKWSL = '/'.
      ENDIF.
    * --- BMMH1-EKGRP
      IF NOT MATERIAL_MASTER-EKGRP IS INITIAL.
        BMMH1-EKGRP = MATERIAL_MASTER-EKGRP.
      ELSE.
        BMMH1-EKGRP = '/'.
      ENDIF.
    * --- BMMH1-XCHPF
      IF NOT MATERIAL_MASTER-XCHPF IS INITIAL.
        BMMH1-XCHPF = MATERIAL_MASTER-XCHPF.
      ELSE.
        BMMH1-XCHPF = '/'.
      ENDIF.
    * --- BMMH1-WEBAZ
      IF NOT MATERIAL_MASTER-WEBAZ IS INITIAL.
        BMMH1-WEBAZ = MATERIAL_MASTER-WEBAZ.
      ELSE.
        BMMH1-WEBAZ = '/'.
      ENDIF.
      IF NOT MATERIAL_MASTER-DISMM IS INITIAL.
        BMMH1-DISMM = MATERIAL_MASTER-DISMM.
      ELSE.
        BMMH1-DISMM = '/'.
      ENDIF.
    * --- BMMH1-VPRSV
      IF NOT MATERIAL_MASTER-VPRSV IS INITIAL.
        BMMH1-VPRSV = MATERIAL_MASTER-VPRSV.
      ELSE.
        BMMH1-VPRSV = '/'.
      ENDIF.
      BMMH1-VERPR = '/'.
    * --- BMMH1-STPRS
      IF NOT MATERIAL_MASTER-STPRS IS INITIAL.
        BMMH1-STPRS = MATERIAL_MASTER-STPRS.
      ELSE.
        BMMH1-STPRS = '/'.
      ENDIF.
    * --- BMMH1-BWPRH
      IF NOT MATERIAL_MASTER-BWPRH IS INITIAL.
        BMMH1-BWPRH = MATERIAL_MASTER-BWPRH.
      ELSE.
        BMMH1-BWPRH = '/'.
      ENDIF.
    * --- BMMH1-PRDHA
      IF NOT MATERIAL_MASTER-PRDHA IS INITIAL.
        BMMH1-PRDHA = MATERIAL_MASTER-PRDHA.
      ELSE.
        BMMH1-PRDHA = '/'.
      ENDIF.
    * --- BMMH1-VABME
      IF NOT MATERIAL_MASTER-VABME IS INITIAL.
        BMMH1-VABME = MATERIAL_MASTER-VABME.
      ELSE.
        BMMH1-VABME = '/'.
      ENDIF.
    * --- BMMH1-MAGRV
      IF NOT MATERIAL_MASTER-MAGRV IS INITIAL.
        BMMH1-MAGRV = MATERIAL_MASTER-MAGRV.
      ELSE.
        BMMH1-MAGRV = '/'.
      ENDIF.
    * --- BMMH1-KZUMW
      IF NOT MATERIAL_MASTER-KZUMW IS INITIAL.
        BMMH1-KZUMW = MATERIAL_MASTER-KZUMW.
      ELSE.
        BMMH1-KZUMW = '/'.
      ENDIF.
    * --- BMMH1-MFRNR
      IF NOT MATERIAL_MASTER-MFRNR IS INITIAL.
        BMMH1-MFRNR = MATERIAL_MASTER-MFRNR.
      ELSE.
        BMMH1-MFRNR = '/'.
      ENDIF.
    * --- BMMH1-MFRPN
      IF NOT MATERIAL_MASTER-MFRPN IS INITIAL.
        BMMH1-MFRPN = MATERIAL_MASTER-MFRPN.
      ELSE.
        BMMH1-MFRPN = '/'.
      ENDIF.
      BMMH1-MPROF = '/'.
    * --- BMMH1-MSTAE
      IF NOT MATERIAL_MASTER-MSTAE IS INITIAL.
        BMMH1-MSTAE = MATERIAL_MASTER-MSTAE.
      ELSE.
        BMMH1-MSTAE = '/'.
      ENDIF.
    * --- BMMH1-PROFL
      IF NOT MATERIAL_MASTER-PROFL IS INITIAL.
        BMMH1-PROFL = MATERIAL_MASTER-PROFL.
      ELSE.
        BMMH1-PROFL = '/'.
      ENDIF.
    * --- BMMH1-MTPOS_MARA
      IF NOT MATERIAL_MASTER-MTPOS_MARA IS INITIAL.
        BMMH1-MTPOS_MARA = MATERIAL_MASTER-MTPOS_MARA.
      ELSE.
        BMMH1-MTPOS_MARA = '/'.
      ENDIF.
    **Transfer the Data to Application Server File
    TRANSFER BMMH1 TO C_ZTEST.
    ENDFORM.                    "convert_0003
    *&      Form  POPULATE_DATA
    *       text
    *      <--P_BLF text
    FORM POPULATE_DATA  CHANGING P_BLF.
      DATA: L_NUM TYPE I.
      DO.
        L_NUM = L_NUM + 1.
        ASSIGN COMPONENT L_NUM OF STRUCTURE P_BLF TO <F>.
        IF SY-SUBRC <> 0.
          EXIT.
        ENDIF.
        MOVE BGR00-NODATA TO <F>.
      ENDDO.
    ENDFORM.                    " POPULATE_DATA

  • How to increase the length of internal table dynamically

    How to increase the length of internal table dynamically depending on the number of fields fetched into the internal table ?
    The requirement code :
    types: begin of t_data,
             form          like zscr_data_hdr-form,
             werks         like zscr_data_hdr-werks,
             matnr         like zscr_data_hdr-matnr,
             verid         like zscr_data_hdr-verid,
             lot           like zscr_data_hdr-lot,
             lot_qty       like zscr_data_hdr-lot_qty,
             udate         like zscr_data_hdr-udate,
             utime         like zscr_data_hdr-utime,
             zuser         like zscr_data_hdr-zuser,
             processed     like zscr_data_hdr-processed,
             defect        like zscr_defect_data-defect,
             vornr         like zscr_route_data-vornr,
             fld1          like zscr_defect_data-defect_val,
             fld2          like zscr_defect_data-defect_val,
             fld3          like zscr_defect_data-defect_val,
             fld4          like zscr_defect_data-defect_val,
             fld5          like zscr_defect_data-defect_val,
             fld6          like zscr_defect_data-defect_val,
             fld7          like zscr_defect_data-defect_val,
             fld8          like zscr_defect_data-defect_val,
             fld9          like zscr_defect_data-defect_val,
             fld10         like zscr_defect_data-defect_val,
             fld11         like zscr_defect_data-defect_val,
             fld12         like zscr_defect_data-defect_val,
             fld13         like zscr_defect_data-defect_val,
             fld14         like zscr_defect_data-defect_val,
             fld15         like zscr_defect_data-defect_val,
             fld16         like zscr_defect_data-defect_val,
             fld17         like zscr_defect_data-defect_val,
             fld18         like zscr_defect_data-defect_val,
             fld19         like zscr_defect_data-defect_val,
             fld20         like zscr_defect_data-defect_val,
             fld21         like zscr_defect_data-defect_val,
             fld22         like zscr_defect_data-defect_val,
             fld23         like zscr_defect_data-defect_val,
             fld24         like zscr_defect_data-defect_val,
             fld25         like zscr_defect_data-defect_val,
             fld26         like zscr_defect_data-defect_val,
             fld27         like zscr_defect_data-defect_val,
             fld28         like zscr_defect_data-defect_val,
             fld29         like zscr_defect_data-defect_val,
             fld30         like zscr_defect_data-defect_val,
             fld31         like zscr_defect_data-defect_val,
             fld32         like zscr_defect_data-defect_val,
             fld33         like zscr_defect_data-defect_val,
             fld34         like zscr_defect_data-defect_val,
             fld35         like zscr_defect_data-defect_val,
             fld36         like zscr_defect_data-defect_val,
             fld37         like zscr_defect_data-defect_val,
             fld38         like zscr_defect_data-defect_val,
             fld39         like zscr_defect_data-defect_val,
             fld40         like zscr_defect_data-defect_val,
             fld41         like zscr_defect_data-defect_val,
             fld42         like zscr_defect_data-defect_val,
             fld43         like zscr_defect_data-defect_val,
             fld44         like zscr_defect_data-defect_val,
             fld45         like zscr_defect_data-defect_val,
             fld46         like zscr_defect_data-defect_val,
             fld47         like zscr_defect_data-defect_val,
             fld48         like zscr_defect_data-defect_val,
             fld49         like zscr_defect_data-defect_val,
             fld50         like zscr_defect_data-defect_val,
             fld51         like zscr_defect_data-defect_val,
             fld52         like zscr_defect_data-defect_val,
             fld53         like zscr_defect_data-defect_val,
             fld54         like zscr_defect_data-defect_val,
             fld55         like zscr_defect_data-defect_val,
             fld56         like zscr_defect_data-defect_val,
             fld57         like zscr_defect_data-defect_val,
             fld58         like zscr_defect_data-defect_val,
             fld59         like zscr_defect_data-defect_val,
             fld60         like zscr_defect_data-defect_val,
             fld61         like zscr_defect_data-defect_val,
             fld62         like zscr_defect_data-defect_val,
             fld63         like zscr_defect_data-defect_val,
             fld64         like zscr_defect_data-defect_val,
             fld65         like zscr_defect_data-defect_val,
             fld66         like zscr_defect_data-defect_val,
             fld67         like zscr_defect_data-defect_val,
             fld68         like zscr_defect_data-defect_val,
             fld69         like zscr_defect_data-defect_val,
             fld70         like zscr_defect_data-defect_val,
             fld71         like zscr_defect_data-defect_val,
             fld72         like zscr_defect_data-defect_val,
             fld73         like zscr_defect_data-defect_val,
             fld74         like zscr_defect_data-defect_val,
             fld75         like zscr_defect_data-defect_val,
             fld76         like zscr_defect_data-defect_val,
             fld77         like zscr_defect_data-defect_val,
             fld78         like zscr_defect_data-defect_val,
             fld79         like zscr_defect_data-defect_val,
             fld80         like zscr_defect_data-defect_val,
             fld81         like zscr_defect_data-defect_val,
             fld82         like zscr_defect_data-defect_val,
             fld83         like zscr_defect_data-defect_val,
             fld84         like zscr_defect_data-defect_val,
             fld85         like zscr_defect_data-defect_val,
             fld86         like zscr_defect_data-defect_val,
             fld87         like zscr_defect_data-defect_val,
             fld88         like zscr_defect_data-defect_val,
             fld89         like zscr_defect_data-defect_val,
             fld90         like zscr_defect_data-defect_val,
             fld91         like zscr_defect_data-defect_val,
             fld92         like zscr_defect_data-defect_val,
             fld93         like zscr_defect_data-defect_val,
             fld94         like zscr_defect_data-defect_val,
             fld95         like zscr_defect_data-defect_val,
             fld96         like zscr_defect_data-defect_val,
             fld97         like zscr_defect_data-defect_val,
             fld98         like zscr_defect_data-defect_val,
             fld99         like zscr_defect_data-defect_val,
             fld100         like zscr_defect_data-defect_val,
             fld101         like zscr_defect_data-defect_val,
             fld102         like zscr_defect_data-defect_val,
             fld103         like zscr_defect_data-defect_val,
             fld104         like zscr_defect_data-defect_val,
             fld105         like zscr_defect_data-defect_val,
             fld106         like zscr_defect_data-defect_val,
             fld107         like zscr_defect_data-defect_val,
             fld108         like zscr_defect_data-defect_val,
             fld109         like zscr_defect_data-defect_val,
             fld110         like zscr_defect_data-defect_val,
             fld111         like zscr_defect_data-defect_val,
             fld112         like zscr_defect_data-defect_val,
             fld113         like zscr_defect_data-defect_val,
             fld114         like zscr_defect_data-defect_val,
             fld115         like zscr_defect_data-defect_val,
             fld116         like zscr_defect_data-defect_val,
             fld117         like zscr_defect_data-defect_val,
             fld118         like zscr_defect_data-defect_val,
             fld119         like zscr_defect_data-defect_val,
             fld120         like zscr_defect_data-defect_val,
             fld121         like zscr_defect_data-defect_val,
             fld122         like zscr_defect_data-defect_val,
             fld123         like zscr_defect_data-defect_val,
             fld124         like zscr_defect_data-defect_val,
             fld125         like zscr_defect_data-defect_val,
             fld126         like zscr_defect_data-defect_val,
             fld127         like zscr_defect_data-defect_val,
             fld128         like zscr_defect_data-defect_val,
             fld129         like zscr_defect_data-defect_val,
             fld130         like zscr_defect_data-defect_val,
             fld131         like zscr_defect_data-defect_val,
             fld132         like zscr_defect_data-defect_val,
             fld133         like zscr_defect_data-defect_val,
             fld134         like zscr_defect_data-defect_val,
             fld135         like zscr_defect_data-defect_val,
             dayst         like zscr_data_hdr-dayst,
           end of t_data.
    In this fld1 to fld135 are defined in internal table.
    But if the number of fields are more than 135 then the program is going to short dump.
    Some times fld1 to fid170 or more fields will be there in my internal table.
    Please suggest me how to make my requirement dynamic and display this data fetched into this internal table onto a .XLS file in the presentation server ?

    Hi
    You can try to use the type string:
    form like zscr_data_hdr-form,
    werks like zscr_data_hdr-werks,
    matnr like zscr_data_hdr-matnr,
    verid like zscr_data_hdr-verid,
    lot like zscr_data_hdr-lot,
    lot_qty like zscr_data_hdr-lot_qty,
    udate like zscr_data_hdr-udate,
    utime like zscr_data_hdr-utime,
    zuser like zscr_data_hdr-zuser,
    processed like zscr_data_hdr-processed,
    defect like zscr_defect_data-defect,
    vornr like zscr_route_data-vornr,
    fieldxx type string,
    dayst like zscr_data_hdr-dayst,
    end of t_data.
    So you can save you informations of every fld<n> concatenating their values into fieldxx.
    Max

  • 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.

  • Upload XML file data into internal table

    Hi,
    I need help from you.
    I am uploading XML file from Application server.
    1.In application server under directory it may have several XML files and i need to upload all the XML files  when we gave only directory name. So, what is the function module for that logic . If possible code also.
    2.Once we get the files into some internal table we need to upload data from that files to internal table.
    So what is the logic for that , if possible code also.
    I am giving sample directory:    
    For example in this directory assume 3 xml files are there.
    I need to upload those files and data from that in to internal table.
    Thanks & Regards
    VSR

    Below code will give you an idea.
    TYPE-POOLS: ixml. "iXML Library Types
    *TABLES : rbkp.
    TYPE DECLERATIION
    TYPES: BEGIN OF type_tabpo,
    ebeln TYPE ekko-ebeln, "PO document number
    ebelp TYPE ekpo-ebelp, "PO line item
    END OF type_tabpo.
    TYPES: BEGIN OF type_ekbe,
    belnr TYPE rbkp-belnr, "Invoice document
    gjahr TYPE rbkp-gjahr, "fiscal year
    END OF type_ekbe.
    TYPES: BEGIN OF type_invoice,
    belnr TYPE rbkp-belnr, "PO document number
    gjahr TYPE rbkp-gjahr, "Fiscal Year
    rbstat TYPE rbkp-rbstat, "invoice status
    END OF type_invoice.
    TYPES: BEGIN OF t_xml_line, "Structure for holding XML data
    data(256) TYPE x,
    END OF t_xml_line.
    INTERNAL TABLE DECLERATIION
    DATA: gi_tabpo TYPE STANDARD TABLE OF type_tabpo,
    gi_ekbe TYPE STANDARD TABLE OF type_ekbe,
    gi_invoice TYPE STANDARD TABLE OF type_invoice,
    gi_bapiret2 TYPE STANDARD TABLE OF bapiret2.
    DATA: l_ixml TYPE REF TO if_ixml,
    l_streamfactory TYPE REF TO if_ixml_stream_factory.
    DATA: l_xml_table TYPE TABLE OF t_xml_line, " XML Table of the structure
    l_xml_line TYPE t_xml_line, " Record of structure t_xml_line
    l_xml_table_size TYPE i. " XML table size
    DATA: l_filename TYPE string.
    WORK AREA DECLARATION
    DATA: gw_tabpo TYPE type_tabpo,
    gw_ekbe TYPE type_ekbe,
    gw_invoice TYPE type_invoice,
    gw_bapiret2 TYPE bapiret2.
    BEGIN OF SELECTION SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    PARAMETERS: p_file TYPE pathintern LOWER CASE DEFAULT '/usr/sap/tmp/'.
    Validation of XML file: Only DTD included in XML document is supported
    SELECTION-SCREEN END OF BLOCK blk1.
    SELECTION SCREEN VALIDATION
    AT SELECTION-SCREEN.
    To validate p_file is not initial
    PERFORM sub_validate_file.
    PERFORM sub_validate_path.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    Request for filename for xml file from the application server
    PERFORM sub_get_filename_appl USING p_file.
    START OF SELECTION SCREEN
    START-OF-SELECTION.
    PERFORM sub_fetch_po_details.
    PERFORM sub_get_invoice.
    PERFORM sub_rel_invoice.
    END OF SELECTION SCREEN
    END-OF-SELECTION.
    *& Form sub_validate_file
    To Validate the file
    FORM sub_validate_file .
    IF p_file IS INITIAL.
    MESSAGE e000. "specify the file path
    ENDIF.
    ENDFORM. " sub_validate_file
    *& Form sub_get_filename_appl
    form sub_get_filename_appl USING l_fname TYPE any.
    DATA: l_fname TYPE filename-fileintern. " File name
    *GET THE FILENAME FROM THE APPLICATION SERVER
    CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
    EXPORTING
    directory = l_fname
    filemask = '*'
    IMPORTING
    serverfile = l_fname
    EXCEPTIONS
    canceled_by_user = 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. " sub_get_filename_appl
    *& Form sub_fetch_po_details
    To fetch the PO details from the application server
    Format of file is XML
    FORM sub_fetch_po_details .
    TYPE DECLERATIION
    l_ixml = cl_ixml=>create( ).
    Creating a stream factory
    l_streamfactory = l_ixml->create_stream_factory( ).
    PERFORM get_xml_table.
    LOOP AT gi_tabpo INTO gw_tabpo.
    WRITE:/ gw_tabpo.
    ENDLOOP.
    ENDFORM. " sub_fetch_po_details
    *& Form get_xml_table
    Read from the xml file
    FORM get_xml_table .
    Local variable declarations
    DATA: l_len TYPE i,
    l_len2 TYPE i,
    l_tab TYPE tsfixml,
    l_content TYPE string,
    l_str1 TYPE string,
    c_conv TYPE REF TO cl_abap_conv_in_ce,
    l_itab TYPE TABLE OF string.
    l_filename = p_file.
    code to upload data from application server
    OPEN DATASET l_filename FOR INPUT IN BINARY MODE.
    IF sy-subrc 0.
    WRITE:/ 'invalid file path'.
    ENDIF.
    DO.
    READ DATASET l_filename INTO l_xml_line.
    IF sy-subrc EQ 0.
    APPEND l_xml_line TO l_xml_table.
    ELSE.
    EXIT.
    ENDIF.
    ENDDO.
    CLOSE DATASET l_filename.
    code to find the table size
    DESCRIBE TABLE l_xml_table.
    l_xml_table_size = ( sy-tleng ) * ( sy-tfill ).
    *code to convert hexadecimal to XML
    LOOP AT l_xml_table INTO l_xml_line.
    c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data
    replacement
    = space ).
    c_conv->read( IMPORTING data = l_content len = l_len ).
    CONCATENATE l_str1 l_content INTO l_str1.
    ENDLOOP.
    l_str1 = l_str1+0(l_xml_table_size).
    SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
    LOOP AT l_itab INTO l_str1.
    REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN
    l_str1 WITH space.
    ENDLOOP.
    CALL TRANSFORMATION ('ID') " code to put in internal table
    SOURCE XML l_str1
    RESULT tab = gi_tabpo[].
    ENDFORM. " get_xml_table

  • XML and XSD file to an internal table

    I had read a lot of thread  but i don't understand how to deal with xml/xsd in R3.
    I need someone that have a definite example for this escenary please.
    With OPEN DATASET took from the server XML and XSD file, and put it in two internal tables type string.
    What functions or method have to use, and how to use them, to charge the XML file in an internal table?
    This is an example of XML and XDS:
    XML
    AND CONTINUE
    Best Regards,

    I just tried to interpret your question, it was not obvious what you wanted.
    I guess what you mean is that you have defined (statically) a deep structure, and you want to decode the XML into it. That is called a transformation (transaction STRANS, statement CALL TRANSFORMATION). You have the choice between 2 transformation languages: XSLT and ST. Of course, it depends what release you are running.
    I advise you to play first with the ID transformation, to convert an ABAP deep structured data object into XML, so that you see what XML is generated, this one is called asXML. If you create your own transformation, when you call it, it will first convert automatically the data object to asXML, and the transformation has to do the rest of the job.
    You can do the opposite, i.e. converting from XML to a data object, according to the same principle (intermediate asXML).
    Well, there are lots of things to say, I recommend you to read articles and documentation on XSLT and ST (search on SDN).
    About XSD, it won't help (and I did never see any possibility to use it) to decode the XML, as you must anyway define the target data object statically (and there's no tool to generate the ABAP code of the data object definition from the XSD).
    Note that you may also use iXML libraries to parse the XML.
    Please tell us more.
    BR
    Sandra

  • Collect data from a dynamic XML file into multiple internal tables

    I need to convert the XML file into multiple internal tables. I tried many links and posts in SDN but still was facing difficulty in achieving this. Can some one tell me where I am going wrong.
    My XML file is of the following type.It is very complex and the dynamice.
    The following tags occur more than once in the XML file. The "I" and "L" tags and its child tags can occur ones or more than once for each XML file and it is not constant. i.e in one file they can occur 1 time and in another they can occur 100 times.
    "I" and "L" are child tags of <C>
    <I>
           <J>10</J>
             <K>EN</K>
      </I>
    <L>
             <J>20</J>
              <N>BB</N>
      </L>
    Tags <C> and <F> occur only ones for each XML file. <C> is the child tag of "A" and "F" is the child tag of <C>.
    I need to collect <D>, <E> in one internal table ITAB.
    I need to collect <G>, <H> in one internal table JTAB.
    I need to collect <J>, <K> in one internal table KTAB.
    I need to collect <J>, <N> in one internal table PTAB.
    Below is the complete XML file.
    ?xml version="1.0" encoding="iso-8859-1" ?>
    <A>
        <B/>
        <C>
           <D>RED</D>
           <E>999</E>
        <F>
           <G>TRACK</G>
           <H>PACK</H>
        </F>
        <I>
           <J>10</J>
           <K>EN</K>
        </I>
        <I>
           <J>20</J>
           <K>TN</K>
        </I>
        <I>
           <J>30</J>
           <K>KN</K>
        </I>
        <L>
           <J>10</J>
           <N>AA</N>
        </L>
        <L>
           <J>20</J>
           <N>BB</N>
        </L>
        <L>
           <J>30</J>
           <N>CC</N>
        </L>
        </C>
      </A>
    With the help of SDN I am able to gather the values of <D> <E> in one internal table.
    Now if I need to gather
    <G>, <H> in one internal table JTAB.
    <J>, <K> in one internal table KTAB.
    <J>, <N> in one internal table PTAB.
    I am unable to do. I am following  XSLT transformation method. If some one has some suggestions. Please help.
    Here is my ABAP program
    TYPE-POOLS abap.
    CONSTANTS gs_file TYPE string VALUE 'C:\TEMP\ABCD.xml'.
    * This is the structure for the data from the XML file
    TYPES: BEGIN OF ITAB,
             D(10) TYPE C,
             E(10) TYPE C,
           END OF ITAB.
    * Table for the XML content
    DATA: gt_itab       TYPE STANDARD TABLE OF char2048.
    * Table and work ares for the data from the XML file
    DATA: gt_ITAB     TYPE STANDARD TABLE OF ts_ITAB,
          gs_ITAB     TYPE ts_ITAB.
    * Result table that contains references
    * of the internal tables to be filled
    DATA: gt_result_xml TYPE abap_trans_resbind_tab,
          gs_result_xml TYPE abap_trans_resbind.
    * For error handling
    DATA: gs_rif_ex     TYPE REF TO cx_root,
          gs_var_text   TYPE string.
    * Get the XML file from your client
    CALL METHOD cl_gui_frontend_services=>gui_upload
      EXPORTING
        filename                = gs_file
      CHANGING
        data_tab                = gt_itab1
      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
        not_supported_by_gui    = 17
        error_no_gui            = 18
        OTHERS                  = 19.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    * Fill the result table with a reference to the data table.
    * Within the XSLT stylesheet, the data table can be accessed with
    * "IITAB".
    GET REFERENCE OF gt_shipment INTO gs_result_xml-value.
    gs_result_xml-name = 'IITAB'.
    APPEND gs_result_xml TO gt_result_xml.
    * Perform the XSLT stylesheet
    TRY.
        CALL TRANSFORMATION zxslt
        SOURCE XML gt_itab1
        RESULT (gt_result_xml).
      CATCH cx_root INTO gs_rif_ex.
        gs_var_text = gs_rif_ex->get_text( ).
        MESSAGE gs_var_text TYPE 'E'.
    ENDTRY.
    * Now let's see what we got from the file
    LOOP AT gt_ITAB INTO gs_ITAB.
      WRITE: / 'D:', gs_ITAB-D.
      WRITE: / 'E :', gs_ITAB-E.
    ENDLOOP.
    Transformation
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
      <xsl:strip-space elements="*"/>
      <xsl:template match="/">
        <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
          <asx:values>
            <IITAB>
              <xsl:apply-templates select="//C"/>
            </IITAB>
          </asx:values>
        </asx:abap>
      </xsl:template>
      <item>
          <D>
            <xsl:value-of select="D"/>
          </D>
          <E>
            <xsl:value-of select="E"/>
          </E>
        </item>
      </xsl:template>
    </xsl:transform>
    Now the above pgm and transformation work well and I am able to extract data into the ITAB. Now what changes should I make in transformation and in pgm to collect
    <G>, <H> in one internal table JTAB.
    <J>, <K> in one internal table KTAB.
    <J>, <N> in one internal table PTAB.
    Please help..i am really tring hard to figure this out. I am found lot of threads addressing this issue but not my problem.
    Kindly help.
    Regards,
    VS

    Hi Rammohan,
    Thanks for the effort!
    But I don't need to use GUI upload because my functionality does not require to fetch data from presentation server.
    Moreover, the split command advised by you contains separate fields...f1, f2, f3... and I cannot use it because I have 164 fields.  I will have to split into 164 fields and assign the values back to 164 fields in the work area/header line.
    Moreover I have about 10 such work areas.  so the effort would be ten times the above effort! I want to avoid this! Please help!
    I would be very grateful if you could provide an alternative solution.
    Thanks once again,
    Best Regards,
    Vinod.V

  • Application Server : File writes only 255 characters

    Hi Friends,
    I am trying to writes data to application server file .
    My line size is 1100 charqacters.
    When I use open dataset for output in text mode encoding default
    and transfer contents to file.
    I am only able to write contents upto 255 characters.
    Whatever is beyond that I do not see it in AL11.
    Is there a way to write more than 255 characters.
    I tried CG3Y to view files but it also shows only 255 characters.
    Please help.

    Hi,
    Just find the string length.
    In 4.6C version there is a limit of 1500 characters i. e. U can transfer max of 1500 characters in a single transfer. For that we applied below solution. Check this it may help u.
      l_len = strlen( p_data ).
      DO.
        IF l_len LT 1500.
          TRANSFER p_data+l_offset(l_len) TO p_file.
          MOVE 0 TO l_len.
        ELSE.
          TRANSFER p_data+l_offset(1500) TO p_file.
          SUBTRACT 1500 FROM l_len.
          ADD 1500 TO l_offset.
        ENDIF.
        CHECK l_len EQ 0.
        EXIT.
      ENDDO.
    p_data has the content to be trasfered of around 6000 characters and the length is dynamic.
    Also download the data using CG3Y with BIN to .txt file and see.
    If problem is still there then paste ur code of OPEN DATASET, TRANSFER statements.
    Try to open the file in TEXT MODE.
    eg: OPEN DATASET l_file IN TEXT MODE.
    Thanks,
    Vinod.
    Edited by: Vinod Reddy Vemuru on Jul 25, 2008 12:34 PM

  • Application server file lentgh

    Hi,
    I am trying to read an application server file using open dataset in Binary Mode..
    I want to find the file length of the file read.(number of bytes transferred as in the GUI_Download FM parameter Filelength)
    How can i achieve it.
    Appreciate ur ideas.
    Rgds.
    stck

    Hello,
    Use the FM EPS_GET_FILE_ATTRIBUTES passing the file name and the directory name and get the file_size.
    Vikranth

Maybe you are looking for

  • Export in MS Excel issue

    In a crystal report ver. 10 Detail section, I have a single field which was initially display records vertically like this; aba 123 222 111 REE I used section expert settings (i.e. Format with Multiple Columns) to display these records horizontally l

  • Apps Available For Update Can't Be Updated in iOS 7!

    We have two iPhone 4's, an iPad 2, and an iPad Mini, all with iOS 7.  For weeks now some of our third-party Apps appear under Updates in the App Store app, but Update All is grayed-out and tapping an individual Update button only takes us to the app

  • New Mac Mini sends airplay audio but does not receive it

    I just purchased and set up two new Mac Minis with Mountain Lion. Previous to this, using Lion and even Leopard, I could send Airplay audio to any of my desktop machines. Further, my iOS devices could send audio to my Macs running Snow Leopard and Li

  • Inspection Lot without task list

    Dear experts, I've this problem: I've create an inspection lot without task list. If I try to assing a task list the system give me the message "No inspection plan could be found". But in transaction QP02 I've seen that the inspection plan exists and

  • Email assigned date and time

    HI All, When we forward mails to users in the interaction center Webclient agent inbox, the mails are shown in assigned status to the users.what is the table which store email assigned date and time. Regards KRK