Function EXCEL_OLE_STANDARD_DAT Dump CX_SY_CONVERSION_NO_NUMBER

Hi everybody,
We are migrating R/3 from 4.6 to 5.0, when executing Z's programs using function 'EXCEL_OLE_STANDARD_DAT' in the new version it ends in a short dump CX_SY_CONVERSION_NO_NUMBER, that's because de field of the data table for the column in excel is an integer, and de the header for this column is text, can anybody help with this problem.
Thanks in advance,
Julio Cesar

Please refer to Note 721793 - Problems with MS_EXCEL_OLE_STANDARD_DAT.
- Guru
Reward points for helpful answers

Similar Messages

  • Function short dump - A dynamically specified column name is unknown.

    Hello,
    I've created BRF fuction according to the  Note 1466868 - Dunning by collection strategy with BRFplus. I get short dump during simulation of function with following exception:
    "A dynamically specified column name is unknown. "
    Runtime Errors         SAPSQL_INVALID_FIELDNAME
    Exception              CX_SY_DYNAMIC_OSQL_SEMANTICS
    No.   Ty.          Program                             Include                             Line
          Name
       19 METHOD       CL_FDT_ELEMENT================CP    CL_FDT_ELEMENT================CM012   129
          CL_FDT_ELEMENT=>GET_VALUES_DDIC
       18 METHOD       CL_FDT_ELEMENT================CP    CL_FDT_ELEMENT================CM011   124
          CL_FDT_ELEMENT=>GET_VALUES
       17 METHOD       CL_FDT_WD_RENDER_VALUE_INPUT==CP    CL_FDT_WD_RENDER_VALUE_INPUT==CM00G   139
          CL_FDT_WD_RENDER_VALUE_INPUT=>VALIDATE_VALUES
    In my opinion there is uncorrect query.
    Current version:
    .  SELECT FIKRS AS VALUE NAME AS TEXT FROM FMBS_BS_T
        INTO CORRESPONDING FIELDS OF TABLE lt_value
        WHERE LANGU EQ 'E'.
    instead of:
    .  SELECT FM_AREA AS VALUE NAME AS TEXT FROM FMBS_BS_T
        INTO CORRESPONDING FIELDS OF TABLE lt_value
        WHERE LANGU EQ 'E'.
    My sap version:
    EHP4 FOR SAP ERP 6.0 / NW7.01
      SAP_BASIS     701     0003     SAPKB70103
    Do you know any note or solution  to resolve this problem.
    Best regards,
    Jacek Witczak

    Hi, I came back to working on "Dunning by collection strategy with BRFplus". According to your sugestions, I raised the level of components:
    SAP_BASIS Level 09
    SAP_ABA level 09
    PI_BASIS level 09
    SAP_BW level 09
    But still I have the same short dump.
    Shoudl we raise any other components? Maybe you know note, which resolve this problem?

  • RFC function Short dump - Function code SPBT_INITIALIZE

    Hi ALL,
        We are trying to change the Sales orders using the RFC function with Paraller processing. When the function is doing the paraller processing we are getting the runtime error when it tries to initialize using the function module SPBT_INITIALIZE. How can we fix this error.
    Here is the description of the error:
    Short text of error message:                                             
    Init. group IBM_IDOC_CHG not possible as another group IBM_IDOC_ADD is a 
    lready init.                                                                               
    Technical information about the message:                                 
    Diagnosis                                                               
         The system tried to initialize the environment for processing       
         parallel RFCs using the function code SPBT_INITIALIZE. Here it was  
         established that the environment was already initialized for other  
         PBT groups.                                                         
         This is a programming error in an application program that uses     
         parallel RFCs. You can find the name of the program in the ABAP     
         call stack.                                                         
    Appreciate your help in this,
    Thanks,
    Satya

    Hi,
    you need a wrapper RFC to do achive result.
    Go tru the thread below you problem should be resolved,
    RFC to FILE
    You need to map the multi structured file to new RFC structure.
    Hope this helps.
    Prasad Babu.
    Message was edited by:
            PrasadBabu Koribilli

  • Invalid code in the column and DUMP function

    Hi all,
    My DB is 11.1 and Character set is UTF8.
    After ETL, I find some invalid characters appear in my tables, one of which is '�'. Since they are history data, I can't find the source data for them.
    The only choice for me now seems to remove all of them for downstream systems. After issuing select dump(column,10) from mytable, I find that '�' is represented by
    239,191,189.
    So I guess whether I can dump the data, remove the bad string and then umdump the contents to get the good string. In a word, is there an inverse function for dump function?
    Can anybody give me some advices, please? Thank you very much.
    Best regards,
    Leon

    Hi Leon
    Its working for me
    Not that the Datatype of variable "a" is "*NVARCHAR2*"
    SQL>SELECT *
      2    FROM t_13;
    INSERT_SORCE                   NAME                                     DUMP_NAME
    TOAD                           Arun¿Gupta                               Typ=96 Len=12: 65,114,117,110,239,191,189,71,117,112,116,97
    TOAD_To_Textpad_To_TOAD        Arun?Gupta                               Typ=96 Len=10: 65,114,117,110,63,71,117,112,116,97
    TOAD_To_SQLPlus                Arun?Gupta                               Typ=96 Len=10: 65,114,117,110,63,71,117,112,116,97
    SQL>DECLARE
      2      a       NVARCHAR2(100) := CHR(191);
      3      b       VARCHAR2(100);   
      4      c       VARCHAR2(100);  
      5      b_dump  VARCHAR2(200);  
      6      c_dump  VARCHAR2(200);  
      7  BEGIN
      8    SELECT name
      9          ,REPLACE (name,a,'')
    10      INTO b
    11          ,c
    12      FROM t_13
    13     WHERE insert_sorce = 'TOAD';
    14    
    15 
    16    SELECT DUMP(b)
    17          ,DUMP(c)
    18      INTO b_dump
    19          ,c_dump
    20      FROM DUAL;
    21  
    22 
    23    DBMS_OUTPUT.PUT_LINE ('Value of b      = '||b); 
    24    DBMS_OUTPUT.PUT_LINE ('Dump Value of b = '||b_dump);   
    25    DBMS_OUTPUT.PUT_LINE ('Value of c      = '||c); 
    26    DBMS_OUTPUT.PUT_LINE ('Dump Value of c = '||c_dump);   
    27  END;
    28  /
    Value of b      = Arun¿Gupta
    Dump Value of b = Typ=1 Len=12: 65,114,117,110,239,191,189,71,117,112,116,97
    Value of c      = ArunGupta
    Dump Value of c = Typ=1 Len=9: 65,114,117,110,71,117,112,116,97
    PL/SQL procedure successfully completed.My DB
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    PL/SQL Release 10.2.0.5.0 - Production
    CORE 10.2.0.5.0 Production
    TNS for Linux: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - Production
    Regards
    Arun
    Edited by: Arun Kumar Gupta on Jun 15, 2011 2:44 PM

  • Can any one help me to configure the mysql table to enable user expiration to function, I have tryed most things, but not dates are being passed back to the data base from the form

    Im trying to build  user expiration into my registration form, but I cant get the form to send back the date registering.
    in my data base i have tried every thing from timestamp to datetime. I can get a timestamp but it is not functioning with the expiration?

    just have a look at my tutorial Login tables: installation & configuration where the required column attributes are explained and where you can obtain a fully functional SQL dump for a typical ADDT "login" and (optionally) "login_stats" table.
    BTW, "expiration" will have to be an "int" column.
    Cheers,
    Günter

  • Write to excel using Range function - Excel_write_range.vi

    I am using the write using range Excel function to dump some data into Excel.
    My data is an array consisting of decimal numbers (data type double) but I have to use "Number To Fractional String" before I can dump this array into Excel. And then when I open the output excel file, you have all these warnings for each cell saying, "number displayed as string". Is there a way to instead dump numbers (in format double) into the Excel. That way each cell in the excel output file will already be formatted as a number instead of string.
    Thanks in advance.

    I'm assuming you're actually using ActiveX to write out Excel files. I say this because a lot of people say "Excel files" when they're really talking about spreadsheet-formatted files, generated using the Write to Spreadsheet File VI. That said, the "Value" ("Value 2" in newer versions of Excel) is a variant, so you can wire any datatype to it. Just wire the numeric value directly.

  • CRM_ORDER_MAINTAIN Save Function problem

    Hi
    We are trying to create Grantor applications in SAPM CRM 6.0 using Function Module CRM_ORDER_MAINTAIN.      
    From an ABAP program we are passing the parameters in order to recreate the same scenario that is used in the Standard SAP CRM Web to create this type of applications.
    When the CRM_ORDER_MAINTAIN function is called the returned code is 0 (zero), we think that is no problem. Then, the CRM_ORDER_SAVE function needs to be call passing the u201CGUID of a CRM Order Objectu201D as parameter that is generated with the last order. But in this case the returned code is 1 which means u201Cdocument_not_saveu201D.
    We also tried calling the CRM_ORDER_MAINTAIN function passing as parameters only the u201Cct_orderadm_hu201D table with the value u201CGAPu201D in the field u201Cprocess_typeu201D, and the table u201Cct_input_fieldsu201D with the value u201Corderadm_hu201D in the field u201Cobjectnameu201D; all this in order to create the u201CGUID of a CRM Order Objectu201D. And then use that GUID again in the CRM_ORDER_MAINTAIN function.
    When calling the CRM_ORDER_MAINTAIN function a DUMP is generated because of the data contained in the table CT_DOC_FLOW. This dump has the type of message u201CCRM_DOC_FLOW No. 010u201D u201CDocument flow record could not be generatedu201D. The table result is:
    4ABA4D7B372E0194E1008000AC137072 (Grantor ID in which the application will remain)
    BUS2100010 (Business Transaction Type of Grantor application)
    4AEA377815A301E6E1008000AC137072 (ID generated for the application)
    BUS2000270 (Business Transaction Type)
    If the ID is not sent, no error message is generated but also the record is not created.
    We also test the CRM_TEST_ORDER_MAINTAIN function with the standard program passing the operation type u201CGAPu201D as parameter. But the execution of the program generates a DUMP. If the function is test with another type of operation as parameter, the program executes correctly generating the corresponding records.
    If the u201CGUID of a CRM Order Objectu201D is generated calling the GUID_CREATE function, when calling the CRM_ORDER_SAVE function a DUMP is generated with type message X of class CRM_ORDER Nol 009  u201CIncorrect values in interface parametersu201D.
    Please any idea to solve it.
    Thanks in advanced,
    Osmany

    Hi,
    concerning first part of your post - "document_not_save" is usually posted if some validations were not passed by new document.
    it could be for example implementation of badi order_save.
    You should debug function module crm_order_save and look for message with reason for not saving.
    Regards
    Radek

  • Passing a query with a variable to a function

    I have a procedure that builds a query and passes it to a function to dump the results to a csv file. I now need to add a parameter to the procedure to allow the number of days in the past to be passed in and used as a variable in the query (it was previously hardcoded to "sysdate-7" and worked fine). So I have added the parameter "p_days_back", but as soon as I put "sysdate - p_days_back" in the query, it fails with "Invalid Query". I'm hoping there's someway to format this parameter to be acceptable to this quoted query string. Procedure snippet below:
    CREATE OR REPLACE PROCEDURE EXTRACT_PS_EMPS
    (p_days_back IN NUMBER DEFAULT 7)
    AS
    v_query VARCHAR2(4000);
    v_separator VARCHAR2(1) := ',';
    v_dir VARCHAR2(500) := '/export/home/oracle';
    v_filename VARCHAR2(100) := 'emp_data.csv';
    l_rows NUMBER(4) := 0;
    BEGIN
    v_query :=
    'SELECT user_access_id,
    jobcode,
    orig_hire_dt,
    empl_status,
    company
    FROM ps_empl_view
    WHERE company in (''TP'',''SS'',''UE'',''UG'')
    AND orig_hire_dt <= sysdate
         AND (empl_status in (''P'',''A'',''L'',''S'')
    or (empl_status NOT in (''P'',''A'',''L'',''S'') AND effdt >= sysdate - p_days_back))
    ORDER BY user_access_id';
    l_rows := uns_pf_dump_csv(v_query, v_separator, v_dir, v_filename);
    dbms_output.put_line('Rows created: ' || l_rows);
    IF l_rows < 0 THEN
    IF l_rows = -1 THEN
    dbms_output.put_line('File Open Error');
    v_text := 'Error from EXTRACT_PS_EMPS: ' || l_rows || ' = ' || 'File Open Error';
    ELSIF l_rows = -2 THEN
    dbms_output.put_line('Query Error');
    v_text := 'Error from EXTRACT_PS_EMPS: ' || l_rows || ' = ' || 'Query Error';
    ELSIF l_rows = -3 THEN
    dbms_output.put_line('Invalid Path');
    v_text := 'Error from EXTRACT_PS_EMPS: ' || l_rows || ' = ' || 'Invalid Path';
    ELSIF l_rows = -4 THEN
    dbms_output.put_line('Invalid Mode');
    v_text := 'Error from EXTRACT_PS_EMPS: ' || l_rows || ' = ' || 'Invalid Mode';
    ELSIF l_rows = -5 THEN
    dbms_output.put_line('Invalid Filehandle');
    v_text := 'Error from EXTRACT_PS_EMPS: ' || l_rows || ' = ' || 'Invalid Filehandle';
    ELSIF l_rows = -6 THEN
    dbms_output.put_line('Invalid Operation');
    v_text := 'Error from EXTRACT_PS_EMPS: ' || l_rows || ' = ' || 'Invalid Operation';
    ELSIF l_rows = -7 THEN
    dbms_output.put_line('Write Error');
    v_text := 'Error from EXTRACT_PS_EMPS: ' || l_rows || ' = ' || 'Write Error';
    ELSIF l_rows = -8 THEN
    dbms_output.put_line('Internal Error');
    v_text := 'Error from EXTRACT_PS_EMPS: ' || l_rows || ' = ' || 'Internal Error';
    ELSIF l_rows = -9 THEN
    dbms_output.put_line('Other Error');
    v_text := 'Error from EXTRACT_PS_EMPS: ' || l_rows || ' = ' || 'Other Error';
    END IF;
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line('Proc Error from EXTRACT_PS_EMPS: ' || SQLERRM);
    END;
    Thanks in advance for your help.

    In the future please post the following:
    1. Oracle version (example: 10.2.0.4)
    2. Post any code in fixed format using \ tags.
    One question, do you have the ability to modify your function that dumps data to CSV?                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Error in task -Downloading a file from report

    Hi all,
    This is my code to download the content of report to Excel,Problem i am getting when trying to put heading for numerical fields .Its getting '0' in the heading .For remaining  Fields which are non-numberic its displaying nicely.Could any one solve this for me.
    report zt11.
      data :  itab type mard occurs 0 .
    select  * from mard into table itab .
    data: it_t001   type t001  occurs 0,
          it_fields type dfies occurs 0  with header line,
          begin of it_fnames occurs 0,
            reptext like dfies-reptext,
          end of it_fnames.
          CALL FUNCTION 'GET_FIELDTAB'
      EXPORTING
      LANGU                     = SY-LANGU
      ONLY                      = ' '
        TABNAME                   = 'MARD'
      WITHTEXT                  = 'X'
    IMPORTING
      HEADER                    =
      RC                        =
      TABLES
        FIELDTAB                  = it_fields
      EXCEPTIONS
        INTERNAL_ERROR            = 1
        NO_TEXTS_FOUND            = 2
        TABLE_HAS_NO_FIELDS       = 3
        TABLE_NOT_ACTIV           = 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.
    loop at it_fields.
      it_fnames-reptext = it_fields-reptext.
      append it_fnames.
    endloop.
    CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
      EXPORTING
        FILE_NAME                       = 'C:\T001'
      CREATE_PIVOT                    = 0
        DATA_SHEET_NAME                 = 'Companies'
      PIVOT_SHEET_NAME                = ' '
      PASSWORD                        = ' '
      PASSWORD_OPTION                 = 0
      TABLES
      PIVOT_FIELD_TAB                 =
        DATA_TAB                        = itab
       FIELDNAMES                      = it_fnames
      EXCEPTIONS
        FILE_NOT_EXIST                  = 1
        FILENAME_EXPECTED               = 2
        COMMUNICATION_ERROR             = 3
        OLE_OBJECT_METHOD_ERROR         = 4
        OLE_OBJECT_PROPERTY_ERROR       = 5
        INVALID_FILENAME                = 6
        INVALID_PIVOT_FIELDS            = 7
        DOWNLOAD_PROBLEM                = 8
        OTHERS                          = 9
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    short dump :  unable to interpret the "..... " as number.

    Hi,
    You are not formatting the internal table for field labels correctly.
    See the attached code and do accordingly.
    This will help you.
    Reward for useful answers.
    report zesdr001
           line-size 215
           line-count 65
           no standard page heading
           message-id zv.
                          Tables Declaration
    tables:vbrk,       " Sales Document: Billing Header Data
           mara,       " Material Master Data
           mbew,       " Material Valuation data
           mbewh,      " Material Valuation: History Data
           t001,       " Company Codes
           t001w,      " Plants/Branches
           konv,       " Pricing Conditions Data
           t179t,      " Materials: Product hierarchies: Texts
           tcurx,      " Currency Conversion Table
           vbuk,       " Sales Document: Header Status data
           tvko,       " Organizational Unit: Sales Organizations
           tvtw,       " Organizational Unit: Dist.Channels
           tspa,       " Organizational Unit: Divisions
           tvfk,       " Billing Document Types
           kna1.       " Customer Master Data
                 Declaration of Data and Internal Tables
    Internal table to store the Billing Details data.(VBRK,VBRP)
    data: begin of itab_bill occurs 0,
            vbeln like vbrk-vbeln,            " Billing Document Number
            fktyp like vbrk-fktyp,            " Billing Category
            vbtyp like vbrk-vbtyp,            " Sales Doc Category
            fkdat like vbrk-fkdat,            " Billing doc date
            fkart like vbrk-fkart,            " Billing Doc type
            bukrs like vbrk-bukrs,            " Company Code
            kurrf like vbrk-kurrf,            " Exchange type
            knumv like vbrk-knumv,            " Condition Number
            waerk like vbrk-waerk,            " Currency
            kunag like vbrk-kunag,            " Sold to Party
            vrkme like vbrp-vrkme,            " sales Unit
            posnr like vbrp-posnr,            " Item Number
            charg like vbrp-charg,            " Batch Number
            fkimg like vbrp-fkimg,            " Billed quantity
            werks like vbrp-werks,            " Plant
            matnr like vbrp-matnr,            " Material Number
            netwr like vbrp-netwr,            " Net Value of the doc
            wavwr like vbrp-wavwr,            " Cost in Doc Currency
            kdmat like vbap-kdmat,            " Customer Material
          end of itab_bill.
    Internal table to write the report output when Customer Mode
    Radiobutton is selected
    data: begin of itab_out occurs 0,
            kunag like vbrk-kunag,            " Customer No
            vbeln like vbrk-vbeln,            " Billing Document Number
            fkart like vbrk-fkart,            " Billing Doc type
            fktyp like vbrk-fktyp,            " Billing Category
            vbtyp like vbrk-vbtyp,            " Sales Doc Category
            fkdat like vbrk-fkdat,            " Billing doc date
            kunnr like kna1-kunnr,            " Customer
            bukrs like vbrk-bukrs,            " Company Code
            kurrf like vbrk-kurrf,            " Exchange Rate
            waerk like vbrk-waerk,            " Currency
            vrkme like vbrp-vrkme,            " Sales Unit
            posnr like vbrp-posnr,            " Item Number
            charg like vbrp-charg,            " Batch Number
            fkimg like vbrp-fkimg,            " Billed quantity
            werks like vbrp-werks,            " Plant
            matnr like vbrp-matnr,            " Material NUmber
            kdmat like vbap-kdmat,            " Customer Material
            bil_amt(16) type p decimals 2,    " Bill Amount
            mode(10),                         " Mode
            density(10),                      " Density
            sel_prc(16) type p decimals 2,    " Selling Price
            mvg_prs like mbew-verpr,          " Moving Price
            gp_mvp_amt like vbrp-netwr,       " GrossProfit Amount(MVP)
            gp_mvp_pr(6)  type p decimals 2,  "   ,, percentage
          end of itab_out.
    Internal table to write the report output when Mode
    Radiobutton is selected
    data: begin of itab_out2 occurs 0,
            mode(10),
            vbeln like vbrk-vbeln,             " Billing Document Number
            fktyp like vbrk-fktyp,             " Billing Category
            vbtyp like vbrk-vbtyp,             " Sales Doc Category
            fkdat like vbrk-fkdat,             " Billing doc date
            kunag like vbrk-kunag,             " Sold to party
            kunnr like kna1-kunnr,             " Customer
            bukrs like vbrk-bukrs,             " Company Code
            kurrf like vbrk-kurrf,             " Exchange Rate
            waerk like vbrk-waerk,             " Currency
            vrkme like vbrp-vrkme,             " Sales UNit
            posnr like vbrp-posnr,             " Item No
            charg like vbrp-charg,             " Batch Number
            fkimg like vbrp-fkimg,             " Billed quantity
            werks like vbrp-werks,             " Plant
            matnr like vbrp-matnr,             " Material Number
            kdmat like vbap-kdmat,             " Customer Material No
            bil_amt(16)   type p decimals 2,   " Billing Amount
            density(10),                       " density
            sel_prc(16) type p decimals 4,     " Selling Price
            mvg_prs like mbew-verpr,           " Moving Price
            gp_mvp_amt like vbrp-netwr,        " GrossProfit Amount(MVP)
            gp_mvp_pr(6)  type p decimals 2,   "   ,, percentage
          end of itab_out2.
    Internal table to write the report output when Density
    Radiobutton is selected
    data: begin of itab_out3 occurs 0,
            mode(10),
            density(10),
            vbeln like vbrk-vbeln,            " Billing Document Number
            fktyp like vbrk-fktyp,            " Billing Category
            vbtyp like vbrk-vbtyp,            " Sales Doc Category
            fkdat like vbrk-fkdat,            " Billing doc date
            kunag like vbrk-kunag,            " Sold to Party
            kunnr like kna1-kunnr,            " Customer
            bukrs like vbrk-bukrs,            " Company Code
            kurrf like vbrk-kurrf,            " Exchange Rate
            waerk like vbrk-waerk,            " Currency
            vrkme like vbrp-vrkme,            " Sales Unit
            posnr like vbrp-posnr,            " Item Number
            charg like vbrp-charg,            " Batch Number
            fkimg like vbrp-fkimg,            " Billed quantity
            werks like vbrp-werks,            " Plant
            matnr like vbrp-matnr,            " Material Number
            kdmat like vbap-kdmat,            " Customer Material
            bil_amt(16)   type p decimals 2,  " Bill Amount
            sel_prc(16) type p decimals 4,    " Selling Price
            mvg_prs like mbew-verpr,          " Moving Price
            gp_mvp_amt like vbrp-netwr,       " GrossProfit Amount(MVP)
            gp_mvp_pr(6)  type p decimals 2,  "   ,, percentage
          end of itab_out3.
    *-Internal Table to Hold data to be downloaded to file
    data: begin of itab_out1 occurs 0,
            kunag(10),                       " Customer
            vbeln(10),                       " Billing Doc No
            fkdat(10),                       " Bill Date
            posnr(6),                        " Item No
            mode(6),                         " Mode
            density(6),                      " Density
            matnr(18),                       " Material
            charg(10),                       " Batch Number
            fkimg like vbrp-fkimg,           " Billed quantity
            vrkme(4),                        " Sales Unit
            sel_prc(14),                     " Selling Price
            bil_amt(15)  type p decimals 2,  " Billing Amount
            waerk(4),                        " Currency
            mvg_prs(15),                     " Moving Price
            gp_mvp_amt like vbrp-netwr,      " Gross profit Amount(MVP)
            gp_mvp_pr(15),                   "    ,,  percentage
            kdmat(35),                       " Customer Material
          end of itab_out1.
    *Internal Table
    data: begin of fieldnames occurs 0,
            title(25) type c,
            table(5)  type c,
            field(5)  type c,
            type(1)   type c,
          end of fieldnames.
    Declaration Of Variables
    data: w_period like bapi0002_4-fiscal_period,
          w_year   like bapi0002_4-fiscal_year,
          w_date   like bsad-budat,
          w_lin type i.       "No.of lines in Internal Table
    data: t_fkimg             like vbrp-fkimg,
          t_bil_amt(8)        type p decimals 2,
          t_gp_mvp_amt(8)     type p decimals 2,
          t_gr_fkimg          like vbrp-fkimg,
          t_gr_bil_amt(8)     type p decimals 2,
          t_gr_gp_mvp_amt(8)  type p decimals 2,
          t_efkimg            like vbrp-fkimg,
          t_ebil_amt(8)       type p decimals 2,
          t_egp_mvp_amt(8)    type p decimals 2.
    data:f_flg .
                       Select-Options
    selection-screen: begin of block b with frame.
    selection-screen : begin of block b1 with frame title text-001.
    select-options:s_bukrs for t001-bukrs no intervals no-extension
                                                         obligatory,
                   s_vkorg for tvko-vkorg no intervals no-extension,
                   s_vtweg for tvtw-vtweg no intervals no-extension,
                   s_spart for tspa-spart no intervals no-extension,
                   s_werks for t001w-werks no intervals no-extension,
                   s_kunag for kna1-kunnr,
                   s_vbeln for vbuk-vbeln,
                   s_fkart for tvfk-fkart,
                   s_fkdat for vbrk-fkdat obligatory.
    selection-screen begin of line.
    selection-screen comment 1(20) text-008.
    selection-screen end   of line.
    selection-screen begin of line.
    parameters p_cust type c radiobutton group cust.
    selection-screen comment 3(20) text-004 for field p_cust.
    selection-screen end of line.
    selection-screen begin of line.
    parameters p_mode type c radiobutton group cust.
    selection-screen comment 3(20) text-006 for field p_mode.
    selection-screen end of line.
    selection-screen begin of line.
    parameters p_dens type c radiobutton group cust.
    selection-screen comment 3(20) text-007 for field p_dens.
    selection-screen end of line.
    selection-screen: end of block b1.
    selection-screen : begin of block b2 with frame title text-002.
    parameters:  p_dwnlod as checkbox,
                 p_file like rlgrap-filename. " default 'C:\zesdr001'.
    selection-screen: end of block b2.
    selection-screen: end of block b.
    *******At Selection Screen********************************************
    at selection-screen.
    At Selection Screen on Value Request
    at selection-screen on value-request for p_file.
      perform f4_help.
    Checking for the input values of selection screen.
      perform screen_check.
    Top Of Page***************************************************
    top-of-page.
      perform rep_headers.
    *******Start of Selection*********************************************
    start-of-selection.
    Selecting data from the database tables
      perform invoice_selection.
      describe table itab_bill lines w_lin.
      if w_lin = 0.
        message i008.   " No Data Found for the Given Selection Criteria
      else.
    Moving the data records into output internal table
        perform bill_details.
    When Customer Radio button is selected
        if p_cust eq 'X'.
          perform invoice_output_cust.
    When Mode Radio button is selected
        elseif p_mode eq 'X'.
          perform invoice_output_mode.
    When density Radio button is selected
        elseif p_dens eq 'X'.
          perform invoice_output_dens.
        endif.
      endif.
    *******End of Selection***********************************************
    end-of-selection.
      perform init_fieldnames.
      if p_dwnlod = 'X'.
        perform read_data_for_dowlload.
      perform down_load_to_file using p_file.
        perform download_excel using p_file.
      endif.
    *&      Form  screen_check
       Ckecking for Selection Screen fields Validation
    form screen_check.
    Validation of Sales Organization
      clear tvko.
      if not s_vkorg-low is initial.
        select vkorg from tvko up to 1 rows
               into tvko-vkorg
               where vkorg in s_vkorg.
        endselect.
        if sy-subrc ne 0.
          message e009.  " Invalid Sales Organization
        endif.
      endif.
    Validation of Distribution Channel
      clear tvtw.
      if not s_vtweg-low is initial.
        select vtweg from tvtw up to 1 rows
               into tvtw-vtweg
               where vtweg in s_vtweg.
        endselect.
        if sy-subrc ne 0.
          message e010.  " Invalid Distribution Channel
        endif.
      endif.
    Validation of Division
      clear tspa.
      if not s_spart-low is initial.
        select spart from tspa up to 1 rows
               into tspa-spart
               where spart in s_spart.
        endselect.
        if sy-subrc ne 0.
          message e011.  " Invalid Division
        endif.
      endif.
    Validation for company code
      clear t001.
      if not s_bukrs-low is initial.
        select single bukrs from t001
             into t001-bukrs
             where bukrs in s_bukrs.
        if sy-subrc <> 0.
          message e007.   " Enter valid Company Code
        endif.
      endif.
    Validation of billing Document Type
      clear tvfk.
      if not s_fkart is initial.
        select fkart from tvfk up to 1 rows
               into tvfk-fkart
               where fkart in s_fkart.
        endselect.
        if sy-subrc ne 0.
          message e012.  " Invalid Billing Document Type
        endif.
      endif.
    Validation of Billing Document Number
      clear vbuk.
      if not s_vbeln is initial.
        select vbeln from vbuk up to 1 rows
               into vbuk-vbeln
               where vbeln in s_vbeln and
                     vbtyp = 'M'.
        endselect.
        if sy-subrc ne 0.
          message e013.   " Invalid Billing Doc Number
        endif.
      endif.
    Validation of Customer
      clear kna1.
      if not s_kunag is initial.
        select kunnr from kna1 up to 1 rows
               into kna1-kunnr
               where kunnr in s_kunag.
        endselect.
        if sy-subrc ne 0.
          message e014.    " Invalid Customer Number
        endif.
      endif.
    Validation of Plant
      clear t001w.
      if not s_werks is initial.
        select werks from t001w up to 1 rows
               into t001w-werks
               where werks in s_werks.
        endselect.
        if sy-subrc ne 0.
          message e004.    " Invalid Plant Number
        endif.
      endif.
    Validation for File path to download
      if p_dwnlod = 'X'.
        if p_file is initial.
          message e006.  " Enter the Valid file path to Download
        endif.
      endif.
    endform.             "screen_check
          FORM invoice_selection                                        *
    Selecting data from the database tables
    form invoice_selection.
      select
            a~vbeln                   " Billing Doc Number
            a~fktyp                   " Billing Category
            a~vbtyp                   " Sales Doc category
            a~fkdat                   " Billing doc date
            a~fkart                   " Billing doc type
            a~bukrs                   " Company code
            a~kurrf                   " Exchange rate
            a~knumv                   " Condition record Number
            a~waerk                   " Currency
            a~kunag                   " Sold to Party
            b~vrkme                   " Sales Unit
            b~posnr                   " Item Number
            b~charg                   " Batch Number
            b~fkimg                   " Billed quantity
            b~werks                   " Plant
            b~matnr                   " Material Number
            b~netwr                   " Net Value of Bill Doc
            b~wavwr                   " Cost in Doc Currency
            c~kdmat                   " Customer Material
                     into table itab_bill
                     from vbrk as a join vbrp as b
                            on bvbeln = avbeln
                            join vbap as c
                            on baubel = cvbeln and
                               baupos = cposnr
                      where a~vbeln in s_vbeln and
                            a~fkdat in s_fkdat and
                            a~bukrs in s_bukrs and
                            a~vtweg in s_vtweg and
                            a~vkorg in s_vkorg and
                            a~spart in s_spart and
                            a~fkart in s_fkart and
                            b~werks in s_werks and
                            a~kunag in s_kunag and
                            a~sfakn eq ' ' and
                            a~fksto eq ' ' .
    endform .
          FORM bill_details                                             *
    appending data into itab_out internal table
    form bill_details.
      sort itab_bill by vbeln.
      select single waers from t001 into t001-waers
                              where bukrs in s_bukrs.
      data:f_txt1(10),f_txt2(10),f_txt3(10).
      loop at itab_bill.
        itab_out-vbeln   = itab_bill-vbeln.
        itab_out-fktyp   = itab_bill-fktyp.
        itab_out-vbtyp   = itab_bill-vbtyp.
        itab_out-fkdat   = itab_bill-fkdat.
        itab_out-fkart   = itab_bill-fkart.
        itab_out-bukrs   = itab_bill-bukrs.
        itab_out-kurrf   = itab_bill-kurrf.
        itab_out-waerk   = itab_bill-waerk.
        itab_out-kunag   = itab_bill-kunag.
        itab_out-vrkme   = itab_bill-vrkme.
        itab_out-posnr   = itab_bill-posnr.
        itab_out-charg   = itab_bill-charg.
        itab_out-fkimg   = itab_bill-fkimg.
        itab_out-werks   = itab_bill-werks.
        itab_out-matnr   = itab_bill-matnr.
        itab_out-kdmat   = itab_bill-kdmat.
       select single currdec from tcurx into tcurx-currdec
              where currkey eq itab_out-waerk.
        if sy-subrc eq '0' .
          if tcurx-currdec eq '0'.
            itab_bill-netwr = itab_bill-netwr * 100.
            itab_bill-wavwr = itab_bill-wavwr * 100.
          endif.
        endif.
        itab_out-bil_amt = itab_bill-netwr.
        clear : konv.
    Pricing data from KONV table
        select single kbetr kwert kpein from konv into
                                      (konv-kbetr,konv-kwert,konv-kpein)
                                       where knumv = itab_bill-knumv and
                                             kposn = itab_bill-posnr and
                                             kschl eq 'ZSP1' and
                                             krech eq 'C' and
                                             kinak eq ' '.
    Currency conversion
        select single currdec from tcurx into tcurx-currdec
                           where currkey eq itab_out-waerk.
        if sy-subrc eq '0' .
          if tcurx-currdec eq '0'.
            konv-kbetr = konv-kbetr * 100.
          endif.
        endif.
    Unit Price
        itab_out-sel_prc = konv-kbetr.
    Unit Price Calculation
        if not konv-kpein is initial.
          itab_out-sel_prc = itab_out-sel_prc / konv-kpein .
        endif.
    Call Function to get the Period for the given Billing date
    and Company Code
        perform get_period.
    Selecting Material Valuation Data
        clear:mbew.
        if itab_out-fktyp eq 'L'.
          select single
              lfmon lfgja verpr stprs vmver vmstp
                 from mbew
                 into (mbew-lfmon,mbew-lfgja,mbew-verpr,
                       mbew-stprs,mbew-vmver,mbew-vmstp)
                          where matnr = itab_out-matnr
                          and   bwkey = itab_out-werks.
          if mbew-lfmon = w_period and mbew-lfgja = w_year.
            select single currdec from tcurx into tcurx-currdec
                  where currkey eq t001-waers.
            if sy-subrc eq '0' .
              if tcurx-currdec eq '0'.
                mbew-stprs = mbew-stprs * 100.
                mbew-verpr = mbew-verpr * 100.
              endif.
            endif.
            if itab_out-waerk eq t001-waers.
              itab_out-mvg_prs = mbew-verpr  ."/ itab_out-kurrf.
            else.
              itab_out-mvg_prs = mbew-verpr  / itab_out-kurrf.
            endif.
          else.
            clear:mbewh.
            select single
             lfmon lfgja verpr stprs
                from mbewh
                into (mbewh-lfmon,mbewh-lfgja,mbewh-verpr,
                      mbewh-stprs)
                         where matnr = itab_out-matnr
                         and   bwkey = itab_out-werks
                         and   lfmon = w_period
                         and   lfgja = w_year.
            select single currdec from tcurx into tcurx-currdec
                    where currkey eq t001-waers.
            if sy-subrc eq '0' .
              if tcurx-currdec eq '0'.
                mbewh-verpr = mbewh-verpr * 100.
              endif.
            endif.
            if itab_out-waerk eq t001-waers.
              itab_out-mvg_prs = mbewh-verpr ."/ itab_out-kurrf.
            else.
              itab_out-mvg_prs = mbewh-verpr  / itab_out-kurrf.
            endif.
            if itab_out-mvg_prs is initial.
              select single
                      lfmon lfgja verpr stprs vmver vmstp
                         from mbew
                         into (mbew-lfmon,mbew-lfgja,mbew-verpr,
                               mbew-stprs,mbew-vmver,mbew-vmstp)
                                  where matnr = itab_out-matnr
                                  and   bwkey = itab_out-werks.
              select single currdec from tcurx
                 into tcurx-currdec
                 where currkey eq t001-waers.
              if sy-subrc eq '0' .
                if tcurx-currdec eq '0'.
                  mbew-verpr = mbew-verpr * 100.
                endif.
              endif.
              if itab_out-waerk eq t001-waers.
                itab_out-mvg_prs = mbew-verpr  ."/ itab_out-kurrf.
              else.
                itab_out-mvg_prs = mbew-verpr  / itab_out-kurrf.
              endif.
            endif.
          endif.
        endif.
    To find Density and Mode from MARA and T179T tables
        clear :mara,t179t.
        select single prdha from mara
              into mara-prdha
              where matnr = itab_out-matnr.
        select single vtext from t179t
               into t179t-vtext
               where spras = 'EN' and
               prodh = mara-prdha(4).
        split t179t-vtext at ' ' into f_txt1 f_txt2 f_txt3.
        itab_out-mode = f_txt2.
        itab_out-density = f_txt3.
        if not itab_out-mvg_prs is initial.
          if itab_out-fktyp eq 'L'.
            itab_out-gp_mvp_amt = itab_out-bil_amt - itab_out-mvg_prs *
                                                       itab_out-fkimg.
          else.
            itab_out-gp_mvp_amt = '0'.
          endif.
        endif.
        if not itab_out-mvg_prs is initial
           and not itab_out-sel_prc is initial.
          itab_out-gp_mvp_pr = ( itab_out-sel_prc - itab_out-mvg_prs )
                                         / itab_out-sel_prc * 100.
        endif.
        append itab_out.
        clear itab_out.
      endloop.
      loop at itab_out.
        if itab_out-vbtyp eq 'N' or itab_out-vbtyp eq 'O'.
          itab_out-fkimg   = itab_out-fkimg * -1.
          itab_out-sel_prc = itab_out-sel_prc * -1.
          itab_out-bil_amt = itab_out-bil_amt * -1.
          itab_out-mvg_prs = itab_out-mvg_prs * -1.
          itab_out-gp_mvp_amt = itab_out-gp_mvp_amt * -1.
          itab_out-gp_mvp_pr = itab_out-gp_mvp_pr * -1.
    If the bill amount is 0 then the quantity should also be 0.
          if itab_out-bil_amt = 0.
            itab_out-fkimg = 0.
          endif.
    Check if the Bill amount is Credit memo amount, then the gross profit
    should also be the same bill amount irrespecitve of +ve or -ve.
          if itab_out-gp_mvp_amt = 0.
            move: itab_out-bil_amt to itab_out-gp_mvp_amt.
          endif.
          modify itab_out.
          clear itab_out.
        endif.
      endloop.
    endform.
    *&      Form  get_period
    Getting Document Period
    form get_period.
      clear :w_period,w_year,w_date.
      concatenate itab_out-fkdat(4)
                   itab_out-fkdat+4(2)
                   itab_out-fkdat+6(2)
                   into w_date.
      call function 'BAPI_COMPANYCODE_GET_PERIOD'
           exporting
                companycodeid = itab_out-bukrs
                posting_date  = w_date
           importing
                fiscal_year   = w_year
                fiscal_period = w_period.
    endform.                    " get_period
    *&      Form  invoice_output_cust
          Report Output when customer is selected
    form invoice_output_cust.
      write at /1(214) sy-uline.
      sort itab_out  by kunag vbeln fkart posnr fkdat.
      loop at itab_out.
        if f_flg = 'X'.
          format color col_normal intensified off.
          f_flg = ' '.
        else.
          format color col_normal intensified on.
          f_flg = 'X'.
        endif.
        at new kunag.
          read table itab_out index sy-tabix.
        endat.
        write:  /01 sy-vline,  2(10) itab_out-kunag,
                 12 sy-vline, 13(10) itab_out-vbeln,
                 23 sy-vline, 24(6)  itab_out-posnr,
                 30 sy-vline, 31(10) itab_out-fkdat,
                 41 sy-vline, 42(6)  itab_out-mode,
                 48 sy-vline, 49(7)  itab_out-density,
                 56 sy-vline, 57(18) itab_out-matnr,
                 75 sy-vline, 76(10) itab_out-charg,
                 86 sy-vline,
                 87(13) itab_out-fkimg unit itab_out-vrkme no-sign,
                 102(3) itab_out-vrkme,
                105 sy-vline,
                106(14) itab_out-sel_prc currency konv-waers no-sign,
                120 sy-vline,
                121(15) itab_out-bil_amt currency vbrk-waerk no-sign,
                138(3) itab_out-waerk,
                141 sy-vline,
                142(15) itab_out-mvg_prs currency vbrk-waerk no-sign,
                157 sy-vline,
                158(15) itab_out-gp_mvp_amt currency vbrk-waerk no-sign,
                173 sy-vline,174(6)  itab_out-gp_mvp_pr no-sign ,
                180 sy-vline,181(33) itab_out-kdmat,
                214 sy-vline.
        t_fkimg = t_fkimg + itab_out-fkimg.
        t_bil_amt = t_bil_amt + itab_out-bil_amt.
        t_gp_mvp_amt = t_gp_mvp_amt + itab_out-gp_mvp_amt.
        t_gr_fkimg      = t_gr_fkimg         + itab_out-fkimg.
        t_gr_bil_amt    = t_gr_bil_amt       + itab_out-bil_amt.
        t_gr_gp_mvp_amt = t_gr_gp_mvp_amt    + itab_out-gp_mvp_amt.
        at end of kunag.
          format reset.
          format color col_total intensified off.
          write:/1(214) sy-uline.
          write:/01 sy-vline,
                 02 'Sub Total of Customer:'(035), itab_out-kunag,
                 87(13) t_fkimg unit itab_out-vrkme no-sign,
                121(15) t_bil_amt no-sign,
                158(15) t_gp_mvp_amt no-sign,
                214 ' ',
                /1(214)  sy-uline.
          clear: t_fkimg, t_bil_amt, t_gp_mvp_amt.
        endat.
        at last.
          write:/01 sy-vline,
                 02 'Grand Total :'(032),
                 87(13) t_gr_fkimg unit itab_out-vrkme no-sign,
                121(15) t_gr_bil_amt no-sign,
                158(15) t_gr_gp_mvp_amt no-sign,
                214 ' '.
        endat.
        format color off.
      endloop.
      write at /1(214) sy-uline.
    endform.    "invoice_output_cust
    *&      Form  invoice_output_mode
          Report Output
    form invoice_output_mode.
      loop at itab_out.
        move-corresponding itab_out to itab_out2.
        append itab_out2.
        clear: itab_out2.
      endloop.
      write at /1(214) sy-uline.
      sort itab_out2  by mode vbeln posnr fkdat.
      loop at itab_out2.
        if f_flg = 'X'.
          format color col_normal intensified off.
          f_flg = ' '.
        else.
          format color col_normal intensified on.
          f_flg = 'X'.
        endif.
        at new mode.
          read table itab_out2 index sy-tabix.
        endat.
        write: /01 sy-vline,  2(10) itab_out2-kunag,
                12 sy-vline, 13(10) itab_out2-vbeln,
                23 sy-vline, 24(6)  itab_out2-posnr,
                30 sy-vline, 31(10) itab_out2-fkdat,
                41 sy-vline, 42(6)  itab_out2-mode,
                48 sy-vline, 49(7)  itab_out2-density,
                56 sy-vline, 57(18) itab_out2-matnr,
                75 sy-vline, 76(10) itab_out2-charg,
                86 sy-vline,
                87(13) itab_out2-fkimg unit itab_out2-vrkme no-sign,
                102(3) itab_out2-vrkme,
                105 sy-vline,
                106(14) itab_out2-sel_prc currency vbrk-waerk no-sign,
                120 sy-vline,
                121(15) itab_out2-bil_amt currency vbrk-waerk no-sign,
                             138(3)  itab_out2-waerk,
                141 sy-vline,
                142(15) itab_out2-mvg_prs currency vbrk-waerk no-sign,
                157 sy-vline,
                158(15) itab_out2-gp_mvp_amt currency vbrk-waerk no-sign,
                173 sy-vline,174(6)  itab_out2-gp_mvp_pr no-sign,
                180 sy-vline,181(33) itab_out2-kdmat,
                214 sy-vline.
        t_fkimg = t_fkimg + itab_out2-fkimg.
        t_bil_amt = t_bil_amt + itab_out2-bil_amt.
        t_gp_mvp_amt = t_gp_mvp_amt + itab_out2-gp_mvp_amt.
        t_gr_fkimg      = t_gr_fkimg         + itab_out2-fkimg.
        t_gr_bil_amt    = t_gr_bil_amt       + itab_out2-bil_amt.
        t_gr_gp_mvp_amt = t_gr_gp_mvp_amt    + itab_out2-gp_mvp_amt.
        at end of mode.
          format reset.
          format color col_total intensified off.
          write:/1(214) sy-uline.
          write:/01 sy-vline,
                 02 'Sub Total of Mode :'(033), itab_out2-mode,
                 87(13) t_fkimg unit itab_out-vrkme no-sign,
                121(15) t_bil_amt no-sign,
                158(15) t_gp_mvp_amt no-sign,
                214 ' ',
                /1(214)  sy-uline.
          clear: t_fkimg, t_bil_amt, t_gp_mvp_amt.
        endat.
        at last.
          write:/01 sy-vline,
                 02 'Grand Total :'(032),
                 87(13) t_gr_fkimg unit itab_out-vrkme no-sign,
                121(15) t_gr_bil_amt no-sign,
                158(15) t_gr_gp_mvp_amt no-sign,
                214 ' '.
        endat.
        format color off.
      endloop.
      write at /1(214) sy-uline.
    endform.    "invoice_output_mode
    *&      Form  invoice_output_dens
          Report Output
    form invoice_output_dens.
      loop at itab_out.
        move-corresponding itab_out to itab_out3.
        append itab_out3.
        clear: itab_out3.
      endloop.
      write at /1(214) sy-uline.
      sort itab_out3  by mode density vbeln posnr fkdat.
      loop at itab_out3.
        if f_flg = 'X'.
          format color col_normal intensified off.
          f_flg = ' '.
        else.
          format color col_normal intensified on.
          f_flg = 'X'.
        endif.
        at new mode.
        endat.
        at new density.
          read table itab_out3 index sy-tabix.
        endat.
        write:  /01 sy-vline,  2(10) itab_out3-kunag,
                 12 sy-vline, 13(10) itab_out3-vbeln,
                 23 sy-vline, 24(6)  itab_out3-posnr,
                 30 sy-vline, 31(10) itab_out3-fkdat,
                 41 sy-vline, 42(6)  itab_out3-mode,
                 48 sy-vline, 49(7)  itab_out3-density,
                 56 sy-vline, 57(18) itab_out3-matnr,
                 75 sy-vline, 76(10) itab_out3-charg,
                 86 sy-vline,
                 87(13) itab_out3-fkimg unit itab_out3-vrkme no-sign,
                 102(3) itab_out3-vrkme,
                 105 sy-vline,106(14) itab_out3-sel_prc no-sign,
                 120 sy-vline,
                 121(15) itab_out3-bil_amt currency vbrk-waerk no-sign,
                              138(3)  itab_out3-waerk,
                 141 sy-vline,142(15) itab_out3-mvg_prs no-sign
                                      currency vbrk-waerk,
                 157 sy-vline,158(15) itab_out3-gp_mvp_amt no-sign
                                      currency vbrk-waerk,
                 173 sy-vline,174(6)  itab_out3-gp_mvp_pr no-sign,
                 180 sy-vline,181(33) itab_out3-kdmat,
                 214 sy-vline.
        t_efkimg      = t_efkimg      + itab_out3-fkimg.
        t_ebil_amt    = t_ebil_amt    + itab_out3-bil_amt.
        t_egp_mvp_amt = t_egp_mvp_amt + itab_out3-gp_mvp_amt.
        t_fkimg = t_fkimg + itab_out3-fkimg.
        t_bil_amt = t_bil_amt + itab_out3-bil_amt.
        t_gp_mvp_amt = t_gp_mvp_amt + itab_out3-gp_mvp_amt.
        t_gr_fkimg      = t_gr_fkimg         + itab_out3-fkimg.
        t_gr_bil_amt    = t_gr_bil_amt       + itab_out3-bil_amt.
        t_gr_gp_mvp_amt = t_gr_gp_mvp_amt    + itab_out3-gp_mvp_amt.
        at end of density.
          format reset.
          format color col_total intensified off.
          write:/1(214) sy-uline.
          write:/01 sy-vline,
                 02 'Sub Total of Density :'(034), itab_out3-density,
                87(13) t_efkimg unit itab_out-vrkme no-sign,
               121(15) t_ebil_amt currency vbrk-waerk no-sign,
               158(15) t_egp_mvp_amt currency vbrk-waerk no-sign,
               214 ' ',
                /1(214) sy-uline.
          clear: t_efkimg, t_ebil_amt,t_egp_mvp_amt.
        endat.
        at end of mode.
          format reset.
          format color col_total intensified off.
          write:/01 sy-vline,
                 02 'Sub Total of Mode :'(033), itab_out3-mode,
                 87(13) t_fkimg unit itab_out-vrkme no-sign,
                121(15) t_bil_amt no-sign,
                158(15) t_gp_mvp_amt no-sign,
                214 ' ',
                /1(214) sy-uline.
          clear: t_fkimg, t_bil_amt, t_gp_mvp_amt.
        endat.
        at last.
          write:/01 sy-vline,
                 02 'Grand Total :'(032),
                87(13) t_gr_fkimg unit itab_out-vrkme no-sign,
               121(15) t_gr_bil_amt no-sign,
               158(15) t_gr_gp_mvp_amt no-sign,
               214 ' '.
        endat.
        format color off.
      endloop.
      write at /1(214) sy-uline.
    endform.    "invoice_output_dens
    *&      Form  f4_help
          To Get F4 Help to Select File Name
    form f4_help.
      call function 'F4_FILENAME'
           exporting
                program_name  = sy-cprog
                dynpro_number = syst-dynnr
                field_name    = 'P_FILE'
           importing
                file_name     = p_file.
    endform.                                                    " f4_help
    *&      Form  rep_headers
          Report Header
    form rep_headers.
      format color col_heading on.
      format color col_heading on.
      select single butxt from t001 into t001-butxt
                                    where bukrs = s_bukrs-low.
      skip 2.
      write: /2 t001-butxt, 92 'BILLING ANALYSIS'(003),
             190 'Date :'(010),sy-datum.
      write :/2 'Company Code :'(011), s_bukrs-low ,
            85 'Billing Date :'(012) , s_fkdat-low , '-' ,s_fkdat-high ,
            190 'Page :'(013), sy-pagno,
            214 ' '.
      write at /1(214) sy-uline.
      write: /1 sy-vline,  2(10) 'Customer'(004) centered,
             12 sy-vline, 13(10) 'Billing'(009) centered,
             23 sy-vline, 24(6)  'Billing'(009) centered,
             30 sy-vline, 31(10) 'Billing'(009) centered,
             41 sy-vline, 42(6)  'Mode'(006) centered,
             48 sy-vline, 49(7)  'Density'(014) centered,
             56 sy-vline, 57(18) 'Material'(015) centered,
             75 sy-vline, 76(10) 'Batch'(016) centered,
             86 sy-vline, 87(13) 'Quantity'(017) centered,102(3) 'UOM'(027),
             105 sy-vline, 106(14) 'Selling'(018) centered ,
             120 sy-vline, 121(15) 'Billing'(009) centered,
                           138(3) 'Cur'(028),
             141 sy-vline, 142(15) 'Mvg.Avg.Price'(020) centered,
             157 sy-vline, 158(22) 'Gross Profit(MVP)'(022) centered,
             180 sy-vline, 181(33) 'Customer Material'(023) centered,
             214 sy-vline.
      write: /1 sy-vline,  2(10) 'Code'(024) centered,
             12 sy-vline, 13(10) 'Document'(025) centered,
             23 sy-vline, 24(6)  'Item'(026) centered,
             30 sy-vline, 31(10) 'Date'(036) centered,
             41 sy-vline,
             48 sy-vline,
             56 sy-vline,
             75 sy-vline,
             86 sy-vline,
            105 sy-vline, 106(14) 'Price'(030) centered ,
            120 sy-vline, 121(15) 'Amount'(031) centered,
            141 sy-vline, 142(15) '(per Unit)'(019) centered,
            157 sy-vline, 158(15) 'Amount'(031) centered,
            173 sy-vline, 174(6) ' % '(029) centered,
            180 sy-vline,
            214 sy-vline.
      format color off.
    endform.                    " rep_headers
    *&      Form  init_fieldnames
    Initialise all the fields to download in Excel Data File
    form init_fieldnames.
      perform append_fieldname using text-004 'itab_out1'
                                     'KUNAG'    'X'.
      perform append_fieldname using text-037 'itab_out1'
                                     'VBELN'   'X'.
      perform append_fieldname using text-036 'itab_out1'
                                     'FKDAT'  'X'.
      perform append_fieldname using text-038 'itab_out1'
                                     'POSNR'    'X'.
      perform append_fieldname using text-006 'itab_out1'
                                     'MODE' 'X'.
      perform append_fieldname using text-014 'itab_out1'
                                     'DENSITY' 'X'.
      perform append_fieldname using text-015 'itab_out1'
                                     'MATNR'    'X'.
      perform append_fieldname using text-016 'itab_out1'
                                     'CHARG' 'X'.
      perform append_fieldname using text-017 'itab_out1'
                                     'FKIMG'    'X'.
      perform append_fieldname using text-039 'itab_out1'
                                     'VRKME' 'X'.
      perform append_fieldname using text-040 'itab_out1'
                                     'SEL_PRC' 'X'.
      perform append_fieldname using text-041 'itab_out1'
                                     'BIL_AMT' 'X'.
      perform append_fieldname using text-028 'itab_out1'
                                     'WAERK' 'X'.
      perform append_fieldname using text-020 'itab_out1'
                                     'MVG_PRS' 'X'.
      perform append_fieldname using text-044 'itab_out1'
                                     'GP_MVP_AMT' 'X'.
      perform append_fieldname using text-045 'itab_out1'
                                     'GP_MVP_PR' 'X'.
      perform append_fieldname using text-023 'itab_out1'
                                     'KDMAT'         'X'.
    endform.
    *&      Form  append_fieldname
    Appending field Names
    form append_fieldname using p_title p_table p_field p_type.
      clear: fieldnames.
      fieldnames-title = p_title.
      fieldnames-ta

  • Download files in excel format

    Hi,
    Can anyone help me for downloading file in excel format? I have scheduled a job repeated everyday at a particular time, but it dumps a text file, NOT in excel format. My programme is an ALV.
    Code snippet would be verymuch helpfull.
    Thank,
    Thushara.

    Hello Thushara,
    here is a code i am giving you . It will take the data from a database , and download it into the excel format..
    You just can customize this program to download the data from an ALV ....
    Here is the sample code...
    REPORT  ZKUN_FILE4                              .
    TABLES: USR03,DD02L.
    DATA: ZX030L LIKE X030L.
    DATA BEGIN OF ZDFIES OCCURS 0.
         INCLUDE STRUCTURE DFIES.
    DATA END OF ZDFIES.
    DATA: BEGIN OF FLDITAB OCCURS 0,
          FLDNAME(11) TYPE C,
          END OF FLDITAB.
    DATA ITABUSR03 LIKE USR03 OCCURS 0 WITH HEADER LINE.
    DATA TNAME LIKE DD02L-TABNAME.
    SELECT * FROM USR03 INTO TABLE ITABUSR03.
    TNAME = 'USR03'.
    PERFORM GETFIELEDS.
    PERFORM SHOW123.
    FORM GETFIELEDS.
         CALL FUNCTION 'GET_FIELDTAB'
          EXPORTING
              LANGU              = SY-LANGU
              ONLY               = SPACE
              TABNAME            = TNAME
              WITHTEXT           = 'X'
          IMPORTING
              HEADER             = ZX030L
          TABLES
              FIELDTAB           = ZDFIES
          EXCEPTIONS
              INTERNAL_ERROR      = 01
              NO_TEXTS_FOUND      = 02
              TABLE_HAS_NO_FIELDS = 03
              TABLE_NOT_ACTIV     = 04.
         CASE SY-SUBRC.
            WHEN 0.
              LOOP AT ZDFIES.
                   FLDITAB-FLDNAME = ZDFIES-FIELDNAME.
                   APPEND FLDITAB.
              ENDLOOP.
            WHEN OTHERS.
                 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  with  SY-SUBRC.
          ENDCASE.
    ENDFORM.
    FORM SHOW123.
    CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
         EXPORTING
              FILE_NAME                 = 'C:\USR03.XLS'
              DATA_SHEET_NAME           = 'USER LIST'
        TABLES
             DATA_TAB                  =  ITABUSR03
             FIELDNAMES                =  FLDITAB
        EXCEPTIONS
             FILE_NOT_EXIST            = 1
             FILENAME_EXPECTED         = 2
             COMMUNICATION_ERROR       = 3
             OLE_OBJECT_METHOD_ERROR   = 4
             OLE_OBJECT_PROPERTY_ERROR = 5
             INVALID_FILENAME          = 6
             INVALID_PIVOT_FIELDS      = 7
             DOWNLOAD_PROBLEM          = 8
             OTHERS                    = 9.
    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.
    Hope this solves your problem.
    Regards,
    Kunal.
    Note : Reward points if found useful.

  • Download to a particular sheet  in MS- Excel

    Hi Experts,
    I need to download data from my internal table into a particular worksheet(say sheet1, sheet2..etc ) in MS-Excel.
    Can any one guide me how to do this?
    Thanks
    Dany

    Use FM : EXCEL_OLE_STANDARD_DAT,
    mention sheet name for every internal table and see the example code :
    Tables
    tables : zsdcarton,
             ztruck,
             ztruckstatus.
    Constants
    constants: c_werks(4) type c value '1000'.
    Internal table for Ztruck
    data : begin of i_ztruck occurs 0,
           werks  like ztruck-werks," Plant
           vdatu like ztruck-vdatu, " Delivery date
           ZZTRKNO like ztruck-ZZTRKNO, " Route #
           ZZSHIPTIME like ztruck-ZZSHIPTIME, " Dispatch time
           ZCLTIME like ztruck-ZCLTIME, " Truck close time
           end of i_ztruck.
    Internal table for ZSDCARTON
    data : begin of i_zsdcarton occurs 0,
           lateflag like zsdcarton-lateflag,
           zzslot like zsdcarton-zzslot,
           status like zsdcarton-status,
           end of i_zsdcarton.
    Internal table for Final output
    data : begin of i_final occurs 0,
           vdatu like ztruck-vdatu, " Delivery Date
           ZZTRKNO like ztruck-ZZTRKNO, " Route #
           ZZSHIPTIME like ztruck-ZZSHIPTIME, " Dispatch time
           ZCLTIME like ztruck-ZCLTIME, " Truck close time
           load_compl_c(5)     type n , " Load Complted Time
           status_s_total(5) type n,  " No Scan/Load
           status_l_total(5) type n,  " Late Scan
           end of i_final.
    Internal Table XLS File Header
    DATA: BEGIN OF i_head OCCURS 0,
          field(30) TYPE c,
          END OF i_head.
    Variables
      status couter
    data: status_total(5)   type n,
      no scan / no load
          status_s(3)       type n,
          status_s_total(5) type n,
      good
          status_g(3)       type n,
          status_g_total(5) type n,
      late
          status_l(3)       type n,
          status_l_total(5) type n,
      manual
          status_m(3)       type n,
          status_m_total(5) type n,
      alternative
          status_a(3)       type n,
          status_a_total(5) type n.
    S E L E C T I O N    -   S C R E E N *************************
    selection-screen : begin of block blk with frame title text-001.
    select-options : p_vdatu for zsdcarton-vdatu obligatory
                    default sy-datum.
    selection-screen : end of block blk .
    S T A R T  -  O F  - S E L E C T I O N  ******************
    start-of-selection.
    Get the data from ZTRUCK and
      perform get_data_tables.
    Down load the data into XLS file
      perform get_download.
    S T A R T  -  O F  - S E L E C T I O N  ******************
    end-of-selection.
    *&      Form  get_data_tables
    FORM get_data_tables.
      data : lv_time like sy-uzeit.
      select werks
             vdatu
             zztrkno
             zzshiptime
             zcltime from ztruck into table i_ztruck
                                 where werks = c_werks
                                 and   vdatu in p_vdatu.
      if sy-subrc ne 0.
        message e000(zwave) with 'No data found for given current date'.
      endif.
      loop at i_ztruck.
        refresh : i_zsdcarton.
        clear :   i_zsdcarton,
                  lv_time.
    Get the Scan Status for Every route
        select lateflag zzslot status from zsdcarton into table i_zsdcarton
                               where werks =  i_ztruck-werks
                               and   vdatu = i_ztruck-vdatu
                               and   zztrkno = i_ztruck-zztrkno.
        if sy-subrc eq 0.
          loop at i_zsdcarton.
            case  i_zsdcarton-lateflag.
    late cartons
              when  'X'.
    late and never loaded
                if i_zsdcarton-zzslot = space.
                  add 1 to status_s.
                else.
                  add 1 to status_l.
                endif.
    all other exceptions
              when  space.
    check if scanned
                case i_zsdcarton-zzslot.
    good scan
                  when 'S'.
                    add 1 to status_g.
    never scanned
                  when space.
                    if i_zsdcarton-status = space.
    no scan
                      add 1 to status_s.
                    else.
    no load -> no scan
                      add 1 to status_s.
                    endif.
    manual scanned
                  when 'M'.
                    if i_zsdcarton-status = 'M'.
                      add 1 to status_g.
                    elseif i_zsdcarton-status = 'E'.
    exceprtion -> manual
                      add 1 to status_g.
                    endif.
                endcase.
            endcase.
    add totals
            add status_g   to  status_g_total.
          Late Scan
            add status_l   to  status_l_total.
            add status_a   to  status_a_total.
          No Scan and Load
            add status_s   to  status_s_total.
            clear : status_g,
                    status_l,
                    status_a,
                    status_s.
          endloop.
        else.
          continue.
        endif.
    Get the Load Complete Time
        select single uzeit from ztruckstatus into lv_time
                                       where   werks = i_ztruck-werks
                                       and     lgnum = '100'
                                       and     vdatu = i_ztruck-vdatu
                                       and     zztrkno = i_ztruck-zztrkno
                                       and     tstat = 'L'.
        if sy-subrc eq 0.
          write: lv_time(5)
                  to i_final-load_compl_c     using edit mask '__:__'.
        endif.
    Delivery Date
        i_final-vdatu = i_ztruck-vdatu.
    Route #
        i_final-zztrkno = i_ztruck-zztrkno.
    Dispach time
        i_final-zzshiptime = i_ztruck-zzshiptime.
    Truck Close Time
        i_final-zcltime = i_ztruck-zcltime.
    No Scan/ Load
        i_final-status_s_total = status_s_total .
    Late Scan
        i_final-status_l_total = status_l_total.
        append i_final.
        clear : status_g_total,
                status_l_total,
                status_a_total,
                status_s_total,
                lv_time,
                i_final.
      endloop.
    ENDFORM.                    " get_data_tables
    *&      Form  get_download
          Download the data
    FORM get_download.
      data : lv_file like rlgrap-filename,
             lv_date(8) type c.
      lv_date = sy-datum.
      concatenate 'C:/Truckload'  lv_date into lv_file.
    Fill the Header Values
    Delivery Date
      i_head-field = 'Delivery Date'.
      append i_head.
    Route #
      i_head-field = 'Route'.
      APPEND i_head.
    Dispatch Time
      i_head-field = 'Dispatch Time'.
      append i_head.
    Closing Time
      i_head-field = 'Closing Time'.
      append i_head.
    Load Completed Time
      i_head-field = 'Load Completed Time'.
      append i_head.
    No Scan/Load
      i_head-field = 'No Scan/Load'.
      append i_head.
    Late Scan
      i_head-field = 'Late Scan'.
      append i_head.
      CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
        EXPORTING
          FILE_NAME                       = lv_file
      CREATE_PIVOT                    = 0
          DATA_SHEET_NAME                 = 'TruckLoad'
      PIVOT_SHEET_NAME                = ' '
      PASSWORD                        = ' '
      PASSWORD_OPTION                 = 0
       TABLES
      PIVOT_FIELD_TAB                 =
          DATA_TAB                        = i_final
          FIELDNAMES                      = i_head
       EXCEPTIONS
         FILE_NOT_EXIST                  = 1
         FILENAME_EXPECTED               = 2
         COMMUNICATION_ERROR             = 3
         OLE_OBJECT_METHOD_ERROR         = 4
         OLE_OBJECT_PROPERTY_ERROR       = 5
         INVALID_FILENAME                = 6
         INVALID_PIVOT_FIELDS            = 7
         DOWNLOAD_PROBLEM                = 8
         OTHERS                          = 9
      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.                    " get_download
    Thanks
    Seshu

  • How to export the data to a  Excel file

    Hi all,
    How to use the  'EXCEL_OLE_STANDARD_DAT'
    to export the data from itab to EXCEL file.
    REPORT  ZT11.
    data : begin of itab occurs 0,
          t1(3)  type c  value 'sag',
          t2(3)  type c value 'ntc',
          end of itab.
          append itab.
          write : itab-t1,itab-t2.
          CALL FUNCTION 'GET_FIELDTAB'
          EXPORTING
            LANGU                     = SY-LANGU
            ONLY                      = ' '
            TABNAME                   = ' '
            WITHTEXT                  = 'X'
          IMPORTING
            HEADER                    =
            RC                        =
            TABLES
              FIELDTAB                  =
          EXCEPTIONS
            INTERNAL_ERROR            = 1
            NO_TEXTS_FOUND            = 2
            TABLE_HAS_NO_FIELDS       = 3
            TABLE_NOT_ACTIV           = 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.
          CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
            EXPORTING
              FILE_NAME                       =
            CREATE_PIVOT                    = 0
            DATA_SHEET_NAME                 = ' '
            PIVOT_SHEET_NAME                = ' '
            PASSWORD                        = ' '
            PASSWORD_OPTION                 = 0
          TABLES
            PIVOT_FIELD_TAB                 =
            DATA_TAB                        =
            FIELDNAMES                      =
          EXCEPTIONS
            FILE_NOT_EXIST                  = 1
            FILENAME_EXPECTED               = 2
            COMMUNICATION_ERROR             = 3
            OLE_OBJECT_METHOD_ERROR         = 4
            OLE_OBJECT_PROPERTY_ERROR       = 5
            INVALID_PIVOT_FIELDS            = 6
            DOWNLOAD_PROBLEM                = 7
            OTHERS                          = 8
          IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.

    Hi, you can even use control technology. There are several example programs how to export data to excel. Please go to transaction SE80. Choose enviroment->examples -> control examples.  Take a look at office integration.
    /Ernesto

  • Reg: Field Names in GUI_DOWNLOAD

    Hi Sapers,
    I want to keep the Field Headings in XLS file.Here I am using the FM GUI_DOWNLOAD, and passing the Tables parameter(i.e, fieldnames) .But my heading is truncated to 10 char.
    as the way the FM does.
    How can I satisfy my client.Plz help me out.
    regards,
    sri...

    yah, sure.
    here is my code, from type-pools....
    *---- TYPE-POOLS DECLARATION -*
    TYPE-POOLS:truxs.
    *---- SELECTION SCREEN BLOCK -*
    SELECTION-SCREEN BEGIN OF BLOCK sri. " WITH FRAME TITLE INPUT'.
    PARAMETERS   p_bukrs TYPE t001-bukrs OBLIGATORY VALUE CHECK.
    PARAMETERS : pperiod(2) TYPE c,
                 pyear(4)   TYPE c,
                 p_file TYPE rlgrap-filename OBLIGATORY default 'C:\Documents and Settings\srikanth\Desktop\rep1.xls'.
    PARAMETERS : csvfile  RADIOBUTTON GROUP rg1,     "factfile RADIOBUTTON GROUP rg1,
                 excel    RADIOBUTTON GROUP rg1 default 'X',
                 text     RADIOBUTTON GROUP rg1.
    SELECTION-SCREEN END OF BLOCK sri.
    *---- TYPES DECLARATION -*
    TYPES : BEGIN OF ty_faglflext,
              tslvt TYPE faglflext-tslvt,
              tsl01 TYPE faglflext-tsl01,
              tsl02 TYPE faglflext-tsl02,
              tsl03 TYPE faglflext-tsl03,
              tsl04 TYPE faglflext-tsl04,
              tsl05 TYPE faglflext-tsl05,
              tsl06 TYPE faglflext-tsl06,
              tsl07 TYPE faglflext-tsl07,
              tsl08 TYPE faglflext-tsl08,
              tsl09 TYPE faglflext-tsl09,
              tsl10 TYPE faglflext-tsl10,
              tsl11 TYPE faglflext-tsl11,
              tsl12 TYPE faglflext-tsl12,
              zzetbrnum TYPE zetbrmap-zzetbrnum,
            END OF ty_faglflext.
    TYPES :BEGIN OF ty_bukrs,
              bukrs TYPE bukrs,
           END OF ty_bukrs.
    TYPES :BEGIN OF ty_etbrtot,
              zzetbrnum TYPE zetbrmap-zzetbrnum,
              totamt TYPE tslxx12,
           END OF ty_etbrtot.
    TYPES :BEGIN OF ty_currtostr,
             dfld(1) type c,
              zzetbrnum LIKE zetbrmap-zzetbrnum,
              totamt(26) TYPE c,
           END OF ty_currtostr.
    TYPES : BEGIN OF ty_csv,
              comma(80) TYPE c,
            END OF ty_csv.
    TYPES : BEGIN OF ty_txt,
              hfld(1) TYPE c,
              dfld(1) TYPE c,
              zzetbrnum LIKE zetbrmap-zzetbrnum,
              totamt(26) TYPE c,
              tfld(1) TYPE c,
            END OF ty_txt.
    TYPES : BEGIN OF header_record,
              hfld(1) TYPE c,
              filler1(13) TYPE c,
              loc(5) TYPE c,
              filler2(10) TYPE c,
              ppyy(4) TYPE c,
              filler3(47) TYPE c,
            END OF header_record.
    TYPES : BEGIN OF detail_record,
              dfld(1) TYPE c,
              gl(4) TYPE c,
              subbacc(5) TYPE c,
              bal(18) TYPE n,
              sign(1) TYPE c,
              filler(4) TYPE c,
              code(2) TYPE c,
              filler1(45) TYPE c,
            END OF detail_record.
    TYPES : BEGIN OF trailer_record,
              tfld(1) TYPE c,
              filler(79) TYPE c,
            END OF trailer_record.
    *---- DATA DECLARATION -*
    *---- Work Area Declaration -*
    DATA : wa_infaglflext TYPE ty_faglflext,
           wa_inetbrtot TYPE ty_etbrtot,
           wa_currtostr TYPE ty_currtostr,
           wa_csv TYPE ty_csv,
           wa_txt TYPE ty_txt,
           wa_header_record TYPE header_record,
           wa_detail_record TYPE detail_record,
           wa_trailer_record TYPE trailer_record.
          wa_xls type ty_xls.
    *---- Internal Tables Declaration -*
    DATA : infaglflext TYPE STANDARD TABLE OF ty_faglflext,
           inetbrtot TYPE STANDARD TABLE OF ty_etbrtot,
           i_currtostr TYPE TABLE OF ty_currtostr,
           i_csv TYPE STANDARD TABLE OF ty_csv,
           i_txt TYPE STANDARD TABLE OF ty_txt.
          i_xls type table of ty_xls.
    DATA: BEGIN OF dlpivot OCCURS 1.
              INCLUDE STRUCTURE excelpivot.
    DATA: END OF dlpivot.
    DATA : t_bukrs TYPE STANDARD TABLE OF ty_bukrs WITH HEADER LINE.
    DATA : BEGIN OF infieldnames OCCURS 1,   " Internal Table to Hold Headings in file.
            text(50),
           END OF infieldnames.
    *---- Variables -*
    DATA : v_temp TYPE tslxx12,
           v_amt TYPE tslxx12.
    DATA : v_mon(2) TYPE c,
           v_year(4) TYPE c,
           v_yr(4) TYPE c.
    DATA : v_pfile TYPE string.
          p_filetyp type string.
    DATA : v_len TYPE i,
           v_ext(4),
           v_exts(4),
           v_fpath TYPE string.
    *---- INITIALIZING PARAMETERS -*
    INITIALIZATION.
      v_mon   = sy-datum+4(2).
      v_year  = sy-datum+0(4).
      pperiod = v_mon.
      pyear   = v_year.
    *---- VALIDATIONS -*
    *---- COMPANY CODE VALIDATION -*
    AT SELECTION-SCREEN ON p_bukrs.
      SELECT bukrs FROM t001 INTO TABLE t_bukrs WHERE bukrs = p_bukrs. " COMP CODE
      IF sy-subrc NE 0.
        MESSAGE 'enter valid company code' TYPE 'E'.
      ENDIF.
    *---- MONTH VALIDATION -*
    AT SELECTION-SCREEN ON pperiod.
      IF ( pperiod LT 1 OR pperiod GT 12 ).
        MESSAGE 'Enter valid month ' TYPE 'E'.
      ENDIF.
    *---- YEAR VALIDATION -*
    AT SELECTION-SCREEN ON pyear.
      v_yr = v_year - 2.
      IF ( pyear GT v_year OR pyear LT  v_yr ).
        MESSAGE 'Enter valid Year(Not less than current minus 2 or Greater than current) ' TYPE 'E'.
      ENDIF.
    *---- File Extension Validation -*
    AT SELECTION-SCREEN.
      PERFORM get_ext.
      IF ( ( NOT ( excel EQ 'X' AND v_ext EQ '.xls' ) ) and
      ( NOT ( csvfile EQ 'X' AND v_ext EQ '.csv' ) ) and
      ( NOT ( text EQ 'X' AND v_ext EQ '.txt' ) ) ).
        MESSAGE e001(zgmam_msg).   "'choose the correct file format' TYPE 'E'.
      ENDIF.
    *---- F4 FUNCTIONALITY FOR FILE PATH -*
    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.
      SELECT a~tslvt
             a~tsl01
             a~tsl02
             a~tsl03
             a~tsl04
             a~tsl05
             a~tsl06
             a~tsl07
             a~tsl08
             a~tsl09
             a~tsl10
             a~tsl11
             a~tsl12
             b~zzetbrnum
         INTO TABLE infaglflext
         FROM faglflext AS a
           INNER JOIN zetbrmap AS b
             ON arbukrs = bbukrs  AND
                aracct  = bhkont
         WHERE a~ryear   = pyear.
      IF sy-subrc EQ 0.
        LOOP AT infaglflext INTO wa_infaglflext.
         CLEAR v_amt.
          v_amt = v_amt + wa_infaglflext-tslvt.
          DO pperiod TIMES
            VARYING v_temp
            FROM   wa_infaglflext-tsl01
              NEXT wa_infaglflext-tsl02.
            v_amt = v_amt + v_temp.
          ENDDO.
          wa_inetbrtot-zzetbrnum = wa_infaglflext-zzetbrnum.
          wa_inetbrtot-totamt    = v_amt .
          APPEND wa_inetbrtot TO inetbrtot.
          CLEAR : wa_inetbrtot,
                  wa_infaglflext,
                  v_amt.
        ENDLOOP.
        PERFORM header.
        IF ( excel EQ 'X' AND v_ext EQ '.xls' ).
          PERFORM download_to_xls.
        ELSE.
          IF ( csvfile EQ 'X' AND v_ext EQ '.csv' ).
            PERFORM download_to_csv.
          ELSE.
            IF ( text EQ 'X' AND v_ext EQ '.txt' ).
              PERFORM download_to_text.
            ENDIF.
          ENDIF.
        ENDIF.
      ELSE.
        WRITE :/ 'NO RECORDS FOUND'.
      ENDIF.
    -------------------SUBROUTINES----------------------------------**
    *&      Form  download_to_xls
          text
    FORM download_to_xls.
    *wa_xls-head1 = 'GENERAL LEDGER'.
    *wa_xls-head2 = 'AMOUNT'.
    *APPEND WA_XLS TO I_CSV.
    *CLEAR WA_XLS.
    *loop at inetbrtot into wa_inetbrtot.
    wa_xls-zzetbrnum = wa_inetbrtot-zzetbrnum.
    wa_xls-totamt    = wa_inetbrtot-totamt.
    append wa_xls to i_CSV.
    clear wa_xls.
    *endloop.
    CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
      EXPORTING
        file_name                       = p_file
      CREATE_PIVOT                    = 0
       DATA_SHEET_NAME                 = 'EXCEL'
      PIVOT_SHEET_NAME                = ' '
      PASSWORD                        = ' '
      PASSWORD_OPTION                 = 0
    TABLES
       PIVOT_FIELD_TAB                 = dlpivot
       DATA_TAB                        = inetbrtot
       FIELDNAMES                      = infieldnames
    EXCEPTIONS
       FILE_NOT_EXIST                  = 1
       FILENAME_EXPECTED               = 2
       COMMUNICATION_ERROR             = 3
       OLE_OBJECT_METHOD_ERROR         = 4
       OLE_OBJECT_PROPERTY_ERROR       = 5
       INVALID_PIVOT_FIELDS            = 6
       DOWNLOAD_PROBLEM                = 7
       OTHERS                          = 8
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'GUI_DOWNLOAD'
       EXPORTING
         filename                      = v_pfile
         filetype                      = 'DBF'
         WK1_N_SIZE                    = 15
         WK1_T_SIZE                    = 15
         append                       = 'X'
      CONFIRM_OVERWRITE               = 'X'
       TABLES
         data_tab                      = inetbrtot
         fieldnames                    = infieldnames.
    ENDFORM.                    "download_to_xls
    *&      Form  download_to_csv
          text
    FORM download_to_csv.
      DATA : v_data TYPE string.
      CLEAR wa_inetbrtot.
      LOOP AT inetbrtot INTO wa_inetbrtot.
        v_data = wa_inetbrtot-totamt.
        CONDENSE  v_data NO-GAPS.
        CALL FUNCTION 'HRCM_AMOUNT_TO_STRING_CONVERT'
          EXPORTING
            betrg                         = v_data
        WAERS                         = ' '
        NEW_DECIMAL_SEPARATOR         =
        NEW_THOUSANDS_SEPARATOR       =
         IMPORTING
           string                        = wa_currtostr-totamt
        wa_currtostr-zzetbrnum = wa_inetbrtot.
        APPEND wa_currtostr TO i_currtostr.
        CLEAR wa_currtostr.
      ENDLOOP.
      LOOP AT i_currtostr INTO wa_currtostr.
        CONCATENATE wa_currtostr-zzetbrnum
                    wa_currtostr-totamt
                    INTO wa_csv-comma
                    SEPARATED BY ','.
        APPEND wa_csv TO i_csv.
        CLEAR wa_csv.
      ENDLOOP.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                      = v_pfile
       filetype                         = 'ASC'
      WRITE_FIELD_SEPARATOR           = 'X'
        TABLES
          data_tab                      = i_csv
         fieldnames                   = infieldnames.
    ENDFORM.                    "download_to_csv
    *&      Form  DOWNLOAD_TO_TEXT
          text
    -->  p1        text
    <--  p2        text
    FORM download_to_text. " using p_filetyp type string.
      DATA : BEGIN OF head OCCURS 1,                             " Internal Table to Hold Headings in file.
              text(1) VALUE 'H',
             END OF head.
      DATA : v_data TYPE string.
      CLEAR wa_inetbrtot.
      CLEAR wa_header_record.
      wa_header_record = space.
      wa_header_record-hfld = 'H'.
    wa_txt-hfld = 'H'.
      wa_header_record-ppyy+0(2) = pperiod.
      wa_header_record-ppyy2(2) = pyear2(2).
      APPEND wa_header_record TO i_csv.
      APPEND wa_txt TO i_txt.
      CLEAR wa_txt.
      LOOP AT inetbrtot INTO wa_inetbrtot.
        CLEAR wa_detail_record.
        wa_detail_record = space.
        wa_detail_record-dfld = 'D'.
       wa_txt-dfld         = 'D'.
       wa_txt-zzetbrnum    = wa_inetbrtot-zzetbrnum.
        wa_detail_record-bal = '0000000000000000000000'.
       wa_detail_record-bal = wa_
        v_data              = wa_inetbrtot-totamt.
        wa_detail_record-gl = wa_inetbrtot-zzetbrnum.
        CONDENSE  v_data NO-GAPS.
        CALL FUNCTION 'HRCM_AMOUNT_TO_STRING_CONVERT'           "CONVERT ITAB-DATA TO STRING, AS THE ITAB CONTAINS A CURRENCY FIELD.
          EXPORTING
            betrg                         = v_data
        WAERS                           = ' '
        NEW_DECIMAL_SEPARATOR           =
        NEW_THOUSANDS_SEPARATOR         =
         IMPORTING
           string                         = wa_txt-totamt
        wa_detail_record-bal = wa_txt-totamt.
        IF ( wa_inetbrtot-totamt LT 0 ).
          wa_detail_record-sign = '-'.
        ELSE.
          wa_detail_record-sign = ' '.
        ENDIF.
        APPEND wa_detail_record TO i_csv.
        APPEND wa_txt TO i_txt.
        CLEAR wa_txt.
      ENDLOOP.
      wa_trailer_record-tfld = 'T'.
      APPEND wa_trailer_record TO i_csv.
      CLEAR wa_txt.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
      BIN_FILESIZE                      =
         filename                         = v_pfile
         filetype                         = 'DAT'
        append                          = 'X'
         header                         = 'abcd'
         replacement                    = '#'
      WRITE_FIELD_SEPARATOR             = ','
      CONFIRM_OVERWRITE                 = 'X'
        TABLES
          data_tab                        = i_csv
        fieldnames                      = HEAD.
    ENDFORM.                    " DOWNLOAD_TO_FILE
    *&      Form  header
          text
    -->  p1        text
    <--  p2        text
    FORM header .
      infieldnames-text = 'GeneralLedger Account'.
      APPEND infieldnames.
      CLEAR infieldnames.
      infieldnames-text = 'Amount'.
      APPEND infieldnames.
      CLEAR infieldnames.
    ENDFORM.                    "header
    *&      Form  get_ext
          text
    FORM get_ext.
      v_pfile = p_file.
      v_len   = STRLEN( v_pfile ).
      v_len   = v_len - 4.
      v_ext   = v_pfile+v_len(4).
    ENDFORM.                    "get_ext
    Message was edited by:
            srikanth vadlamani

  • Can't create a temporary document from an XmlInputStream

    Attempts to create an XmlDocument fail when reading it from an XmlInputStream
    MainXmlInput.java
    package com.kitfox.dbtest;
    import com.sleepycat.db.DatabaseException;
    import com.sleepycat.db.Environment;
    import com.sleepycat.db.EnvironmentConfig;
    import com.sleepycat.dbxml.XmlContainer;
    import com.sleepycat.dbxml.XmlDocument;
    import com.sleepycat.dbxml.XmlException;
    import com.sleepycat.dbxml.XmlInputStream;
    import com.sleepycat.dbxml.XmlManager;
    import com.sleepycat.dbxml.XmlManagerConfig;
    import com.sleepycat.dbxml.XmlQueryContext;
    import com.sleepycat.dbxml.XmlResolver;
    import com.sleepycat.dbxml.XmlResults;
    import com.sleepycat.dbxml.XmlTransaction;
    import com.sleepycat.dbxml.XmlValue;
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.PrintStream;
    import java.net.URL;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    class DatabaseResolver extends XmlResolver {
        public boolean resolveDocument(XmlTransaction txn, XmlManager mgr,
                String uri, XmlValue val)
                throws XmlException {
            System.err.println("<--->");
            throw new UnsupportedOperationException("Not supported yet.");
        public boolean resolveCollection(XmlTransaction txn, XmlManager mgr,
                String uri, XmlResults res)
                throws XmlException {
            System.err.println("<--->");
            throw new UnsupportedOperationException("Not supported yet.");
        public XmlInputStream resolveSchema(XmlTransaction txn, XmlManager mgr,
                String location, String nameSpace)
                throws XmlException {
            InputStream in = DatabaseResolver.class.getResourceAsStream(location);
            return in == null ? null : mgr.createInputStream(in);
        public XmlInputStream resolveEntity(XmlTransaction txn, XmlManager mgr,
                String systemId, String publicId)
                throws XmlException {
            System.err.println("<--->");
            throw new UnsupportedOperationException("Not supported yet.");
        public boolean resolveModuleLocation(XmlTransaction txn, XmlManager mgr,
                String nameSpace, XmlResults result)
                throws XmlException {
            System.err.println("<--->");
            throw new UnsupportedOperationException("Not supported yet.");
        @Override
        public XmlInputStream resolveModule(XmlTransaction txn, XmlManager mgr,
                String moduleLocation, String nameSpace)
                throws XmlException
    //        System.err.println("<--->");
    //        throw new UnsupportedOperationException("Not supported yet.");
            InputStream in = DatabaseResolver.class.getResourceAsStream(moduleLocation);
            return in == null ? null : mgr.createInputStream(in);
    class Database
        public static final String DATABASE_NS = "http://xml.kitfox.com/schema/database";
        public static final String CONTAINER_NAME = "base.dbxml";
        public static final String DOCUMENT_NAME = "test.xml";
        public static final String DOCUMENT_URI = "dbxml:/"
                + CONTAINER_NAME
                + "/"
                + DOCUMENT_NAME;
        public static final String DOCUMENT_PREFIX = "doc(\"dbxml:/"
                + CONTAINER_NAME
                + "/"
                + DOCUMENT_NAME + "\")";
        final File home;
        Environment env;
        XmlManager manager;
        XmlContainer container;
        Database(File home, boolean createIfAbsent)
            this.home = home;
            try {
                EnvironmentConfig config = new EnvironmentConfig();
                config.setAllowCreate(createIfAbsent);
                config.setInitializeLocking(true);
                config.setInitializeLogging(true);
                config.setInitializeCache(true);
                config.setTransactional(true);
                config.setRunRecovery(true);
                config.setThreaded(true);
                //config.setLockDetectMode(LockDetectMode.DEFAULT);
                env = new Environment(home, config);
                XmlManagerConfig managerConfig = new XmlManagerConfig();
                managerConfig.setAllowAutoOpen(true);
                managerConfig.setAdoptEnvironment(true);
                managerConfig.setAllowExternalAccess(true);
                manager = new XmlManager(env, managerConfig);
                manager.setDefaultContainerType(XmlContainer.NodeContainer);
                manager.registerResolver(new DatabaseResolver());
                if (manager.existsContainer(CONTAINER_NAME) == 0) {
                    container = manager.createContainer(CONTAINER_NAME);
                    //Initial document
                        InputStream is = null;
                        XmlInputStream xin = null;
                        URL initXml = getClass().getResource("/com/kitfox/dbtest/init.xml");
                        is = initXml.openStream();
                        xin = manager.createInputStream(is);
                        container.putDocument(DOCUMENT_NAME, xin);
                        xin.delete();
                } else {
                    container = manager.openContainer(CONTAINER_NAME);
            } catch (IOException ex) {
                Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
            } catch (DatabaseException ex) {
                Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
        public void dispose()
            try {
                if (container != null)
                    container.close();
                    container = null;
                if (manager != null)
                    manager.close();
                    manager = null;
                    //manager will auto close env
                    env = null;
            } catch (DatabaseException ex) {
                Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
        public void dump(PrintStream ps)
            try {
                XmlQueryContext ctx = manager.createQueryContext();
                String query = DOCUMENT_PREFIX;
                XmlResults res = manager.query(query, ctx);
                XmlValue value = res.next();
                value.getTypeName();
                value.getTypeURI();
                ps.println(value.asString());
                res.delete();
                ctx.delete();
            } catch (XmlException ex) {
                Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
        public String runQuery(URL queryURL)
            XmlQueryContext ctx = null;
            XmlResults res = null;
            XmlDocument queryDoc = null;
            String resp = null;
            try {
                XmlInputStream xin = manager.createInputStream(queryURL.openStream());
                queryDoc = manager.createDocument();
                queryDoc.setContentAsXmlInputStream(xin);
                XmlValue docValue = new XmlValue(queryDoc);
                if ("".equals(docValue.asString()))
                    throw new RuntimeException("Empty document!");
                ctx = manager.createQueryContext();
                ctx.setVariableValue("docURI", new XmlValue(DOCUMENT_URI));
                ctx.setVariableValue("request", docValue);
                docValue.asString();
                String query =
                        "import module namespace gbfn = 'http://xml.kitfox.com/xquery/test' at '/com/kitfox/dbtest/functions.xq';"
                        + "\n gbfn:runQuery(doc($docURI), $request)"
                res = manager.query(query, ctx);
                XmlValue respValue = res.next();
                resp = respValue.asString();
            } catch (IOException ex) {
                Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
            } catch (XmlException ex) {
                Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
            finally {
                if (queryDoc != null)
                    queryDoc.delete();
                if (res != null)
                    res.delete();
                if (ctx != null)
                    ctx.delete();
            return resp;
    * @author kitfox
    public class MainXmlInput {
        public static void deleteRecursive(File curFile)
            if (curFile.isDirectory())
                for (File file: curFile.listFiles())
                    deleteRecursive(file);
            curFile.delete();
         * @param args the command line arguments
        public static void main(String[] args) {
            File root = new File("gamedb");
            //Cleanup test dir
            deleteRecursive(root);
            root.mkdir();
            //Create the database
            Database gb = new Database(root, true);
            //Setting this to true will let all of the below tests run, but will
            // not solve some more complex queries that are not included in this
            // example
            if (false)
                gb.dispose();
                gb = new Database(root, true);
            System.err.println(gb.runQuery(MainXmlInput.class.getResource("/com/kitfox/dbtest/query.xml")));
            gb.dispose();
    }functions.xq
    module namespace gbq = "http://xml.kitfox.com/xquery/test";
    declare namespace err = "http://xml.kitfox.com/xquery/gamebase/error";
    declare function gbq:dump($root as node()) as element()
        $root/element()
    declare function gbq:runQuery($doc as document-node(), $req as document-node()) as element()
        $req/element()
    declare updating function gbq:runUpdate($doc as document-node(), $req as document-node())
        let $element := $req/root/element()
            return insert node <entry>{$element}</entry> into $doc/squirrel
    };init.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <root>
        <squirrel>
            <peanut/>
        </squirrel>
    </root>query.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <root>
        <larry>
            <curly>
                <moe/>
            </curly>
        </larry>
    </root>

    Here is a patch for your problem. Please tell me if it works.
    Lauren Foutz
    diff -r 3ea6fcd222af src/dbxml/Document.cpp
    --- a/src/dbxml/Document.cpp     Wed Nov 05 12:39:38 2008 -0500
    +++ b/src/dbxml/Document.cpp     Tue Nov 18 10:11:16 2008 -0500
    @@ -571,6 +571,10 @@
              consumed(getName(), consumed_);
              ret = new MemBufInputStream(0, 0, getName().c_str(),false);
    +     if(definitiveContent_ == DBT) {
    +          dbtContent_ = 0;
    +          definitiveContent_ = NONE;
    +     }
         return ret;
    @@ -680,6 +684,7 @@
         changeContentToNsDom(isns);
    +     if (!nsDocument_) return 0; //empty document
         if (nid.isDocRootNid())
              return nsDocument_->getDocumentNode();
         NsNode *nsNode = nsDocument_->getNode(nid, /*getNext*/false);
    diff -r 3ea6fcd222af src/dbxml/DocumentDatabase.cpp
    --- a/src/dbxml/DocumentDatabase.cpp     Wed Nov 05 12:39:38 2008 -0500
    +++ b/src/dbxml/DocumentDatabase.cpp     Tue Nov 18 10:11:16 2008 -0500
    @@ -184,9 +184,6 @@
                   id = ((Document&)old_document).getID();
                   new_document.getIDToSet() = id;
                   resetId = true;
    -               // clear modified flag if set on name
    -               const_cast<Document*>(&new_document)->
    -                    clearModified(Name(metaDataName_uri_name));
         } else {
              err = indexer.getContainer()->getDocument(
    diff -r 3ea6fcd222af src/dbxml/nodeStore/NsDocumentDatabase.cpp
    --- a/src/dbxml/nodeStore/NsDocumentDatabase.cpp     Wed Nov 05 12:39:38 2008 -0500
    +++ b/src/dbxml/nodeStore/NsDocumentDatabase.cpp     Tue Nov 18 10:11:16 2008 -0500
    @@ -173,9 +173,6 @@
                   id = ((Document&)old_document).getID();
                   new_document.getIDToSet() = id;
                   resetId = true;
    -               // clear modified flag if set on name
    -               const_cast<Document*>(&new_document)->
    -                    clearModified(Name(metaDataName_uri_name));
         } else {
    diff -r 3ea6fcd222af src/java/com/sleepycat/dbxml/XmlDocument.java
    --- a/src/java/com/sleepycat/dbxml/XmlDocument.java     Wed Nov 05 12:39:38 2008 -0500
    +++ b/src/java/com/sleepycat/dbxml/XmlDocument.java     Tue Nov 18 10:11:16 2008 -0500
    @@ -115,9 +115,7 @@
             content.stream = null;
             content.type = NONE;
             return ins;
    -     }else if (!content.hasContent() && docID == 0)
    -         return null;
    -     else
    +     } else
             return HelperFunctions.getContentAsXmlInputStream(this);
    @@ -127,9 +125,7 @@
             content.reader = null;
             content.type = NONE;
             return xer;
    -     }else if (!content.hasContent() && docID == 0)
    -         return null;
    -     else
    +     } else
             return HelperFunctions.getContentAsEventReader(this);
    @@ -214,6 +210,13 @@
         //The rest of this class is for internal use.
    +    protected boolean isConstructed()
    +    {
    +         if(results == null && docID == 0)
    +              return true;
    +         return false;
    +    }
    +   
         /* If both modified and removed are set to false then the meta data is
          * only being added if it does not already exist.
    @@ -257,11 +260,6 @@
         docID = documentId;
         cid = containerId;
         content = new Content();
    -    protected void finalize() throws XmlException {
    -     metaData.clear();
    -     content.clear();
         protected void copy(XmlDocument o) throws XmlException {
    @@ -359,6 +357,10 @@
         protected void setEventWriter(long writer){
         eventWriter = writer;
    +    }
    +   
    +    protected Content getEmptyContent() {
    +         return new Content();
         class Content {
    diff -r 3ea6fcd222af src/java/com/sleepycat/dbxml/XmlValue.java
    --- a/src/java/com/sleepycat/dbxml/XmlValue.java     Wed Nov 05 12:39:38 2008 -0500
    +++ b/src/java/com/sleepycat/dbxml/XmlValue.java     Tue Nov 18 10:11:16 2008 -0500
    @@ -9,6 +9,8 @@
    package com.sleepycat.dbxml;
    import java.util.*;
    +
    +import com.sleepycat.dbxml.XmlDocument.Content;
    public class XmlValue {
         protected Value value;
    @@ -69,7 +71,10 @@
         public XmlValue(XmlDocument document) throws XmlException
    -     XmlValue xmlvalue = HelperFunctions.createDocumentValue(document);
    +    Content con = document.content;
    +    document.content = document.getEmptyContent(); //Prevents the content from being consumed
    +    XmlValue xmlvalue = HelperFunctions.createDocumentValue(document);
    +    document.content = con;
         valueType = xmlvalue.getType();
         value = new NodeValue((NodeValue)xmlvalue.value);
         ((NodeValue)value).setDocument(document);
    diff -r 3ea6fcd222af src/java/dbxml_java_wrap.cpp
    --- a/src/java/dbxml_java_wrap.cpp     Wed Nov 05 12:39:38 2008 -0500
    +++ b/src/java/dbxml_java_wrap.cpp     Tue Nov 18 10:11:16 2008 -0500
    @@ -1516,10 +1516,8 @@
             XmlValue value((XmlValue::Type)type, v);
    SWIGINTERN XmlInputStream *HelperFunctions_getContentAsXmlInputStream(XmlDocument &doc){
    -         XmlEventReader &reader = doc.getContentAsEventReader();
    -         doc.setContentAsEventReader(reader);
    -         return doc.getContentAsXmlInputStream();
    +          return doc.getContentAsXmlInputStream();
    +      }
    SWIGINTERN XmlEventReader &HelperFunctions_getContentAsEventReader(XmlDocument &doc){
             return doc.getContentAsEventReader();
         }

  • FM for sending itab data to excel sheet

    Hi,
    Can any one tell FM for sending internal table data to excel.
    Thanks & Regards,
    Prasad reddy.

    Hi,
    If you want open Internal Table data in Excel automatically, try this FM: EXCEL_OLE_STANDARD_DAT.
    Here the sample program:
    REPORT  ZTEST .
    TABLES: USR03,DD02L.
    DATA: ZX030L LIKE X030L.
    DATA BEGIN OF ZDFIES OCCURS 0.
      INCLUDE STRUCTURE DFIES.
    DATA END OF ZDFIES.
    DATA: BEGIN OF FLDITAB OCCURS 0,
      FLDNAME(11) TYPE C,
    END OF FLDITAB.
    DATA ITABUSR03 LIKE USR03 OCCURS 0 WITH HEADER LINE.
    DATA TNAME LIKE DD02L-TABNAME.
    SELECT * FROM USR03 INTO TABLE ITABUSR03.
    TNAME = 'USR03'.
    PERFORM GETFIELEDS.
    PERFORM SHOW123.
    FORM GETFIELEDS.
      CALL FUNCTION 'GET_FIELDTAB'
        EXPORTING
          LANGU = SY-LANGU
          ONLY = SPACE
          TABNAME = TNAME
          WITHTEXT = 'X' IMPORTING
          HEADER = ZX030L
        TABLES
          FIELDTAB = ZDFIES
        EXCEPTIONS
          INTERNAL_ERROR = 01
          NO_TEXTS_FOUND = 02
          TABLE_HAS_NO_FIELDS = 03
          TABLE_NOT_ACTIV = 04.
      CASE SY-SUBRC.
        WHEN 0.
          LOOP AT ZDFIES.
          FLDITAB-FLDNAME = ZDFIES-FIELDNAME.
          APPEND FLDITAB.
          ENDLOOP.
        WHEN OTHERS.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          with SY-SUBRC.
      ENDCASE.
    ENDFORM.
    FORM SHOW123.
      CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
        EXPORTING
          FILE_NAME = 'C:USR03'
          DATA_SHEET_NAME = 'USER LIST'
        TABLES
          DATA_TAB = ITABUSR03
          FIELDNAMES = FLDITAB
        EXCEPTIONS
          FILE_NOT_EXIST = 1
          FILENAME_EXPECTED = 2
          COMMUNICATION_ERROR = 3
          OLE_OBJECT_METHOD_ERROR = 4
          OLE_OBJECT_PROPERTY_ERROR = 5
          INVALID_FILENAME = 6
          INVALID_PIVOT_FIELDS = 7
          DOWNLOAD_PROBLEM = 8
          OTHERS = 9.
      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.
    Regards,

Maybe you are looking for

  • Function module to retain data for a given period.

    Hi all, This is my requirement: I have a selection screen on which a specific number of months is entered. Using the FM 'FI_PERIOD_DETERMINE' and passing the current date to it, I'll be fetching the current fiscal year and fiscal period. I got to ret

  • Assign a SELECT item's list of values - APEX 2.2.0

    Hey, all, Is there a way to assign the list of values of a SELECT item programatically, besides the usual query-in-the-LOV? I am reusing a page 0 region and have a SELECT item that can take on a wide range of lists of values. Something like: AddOptio

  • Can't sync my videos!

    Hi, I have a sony cybershot DSC-W55 with 7.2 megapixels... when I connect the camera to my computer all of the photos and videos easily sync with iphoto, where I can view which ever. However, when I open imovie only my photos sync with the program. N

  • Java.lang.UnsatisfiedLinkError: no ocijdbc8

    I received the java.lang.UnsatisfiedLinkError: no ocijdbc8 error while running the following command: java OracleXML putXML -user xxx/xxx ..... I saw a few posts regarding dll files for NT but nothing for AIX. Any help would be greatly appreciated. T

  • Filtering Help system view by business questions

    My client wants to use RoboHelp to create a help system that covers ten web-based applications in one suite of products. The products are used by different roles on a commodities trading floor. The same person might use more than one of the applicati