Date COnv

I want to convert a[b] java.sql.date obj to java.sql.gregoriancalendar..
SInce iam using Jdk1.5 i cannot use the methods like getDay(),getMonth() etc of Java.util.Date.
It is given that we have to use Calendar.get(DAY_OF_WEEK)...
But how to do this.... either conv
1) java.sql.date obj to java.sql.gregoriancalendar..
2) get the Day, month etc
plz help

Calendar.setTimeInMillis(Date.getTime());

Similar Messages

  • Oracle9i Enterprise Edition Release 9.2.0.7.0 - Imp. and data conv. problem

    hello,
    I have problem with importing and conversion of external data. I have data like example below:
    --------1--------2--------3--------4--------5--------6--------7----
    0000SLOVAC IMPORTYSGA SIVACYS 0509720070227
    25112007022706881952VF7FCKFVC28871406 00ACESIEUR10100000é00000000071049é
    Data in bold are numbers with last character that is calculated like the example below.
    First number format is S9(2)V999999 -> 0100000é le signe est sur l'avant dernier octet C(+) D(-)
    Example 1, en hexa :
    0100000é => +01,000000
    FFFFFFFC S99V999999
    01000000
    Second number format is S9(13)V99 -> 00000000071049é
    Example 2, en hexa
    00000000071049é
    FFFFFFFFFFFFFFC
    000000000710490 => +0000000007104,90
    S9999999999999V99
    other example:
    example 00ACESIEUR10100000é00000000087498I
    en hexa:
    00000000087498I
    FFFFFFFFFFFFFFC
    000000000874989 => +0000000008749,89
    S9999999999999V99
    I need help with creating a function that will transform from "00000000087498I" to real number like "+0000000008749,89", but I really don't know how to do that.
    Can anyone help me with my problem or explain to me how to do that?
    Thanks for your time and best regards

    No it is not so simple. This "le signe est sur l'avant dernier octet" means that the sign is last character in number.
    The sign "é" and "I" are just in my example and they are somehow calculated but I don't know how?
    If I take my example there is field with format S9(13)V99 and with value 00000000071049é (and with last sign "é") and I think the last sign is somehow calculated from number. And then from this value I get the number.
    00000000071049é
    FFFFFFFFFFFFFFC
    000000000710490 => +0000000007104,90
    S9999999999999V99
    Everything I try, calculating from binary to hex, or anything other, I don't get the result or the last sign and I wonder if there is some function in PL/SQL that I can use to get the result I want?
    Or if you have some idea how to help me to get from "00000000071049é" to "+0000000007104,90" from example above?
    Here are some other examples, just for help:
    000000204592D
    000000183882D
    000000139441C
    000000182979H
    000000083361F
    000000083361F
    000000083361F
    000000059033F
    000000066273E
    000000069011G
    000000102615B
    000000092362F
    000000138215‚
    000000138215‚
    000000138215‚
    000000138215‚
    000000106760C
    000000106760C
    000000106760C
    000000115024A
    000000115024A
    000000115024A
    000000115024A
    000000115024A
    000000088149B
    000000084459I

  • Uploading of Excel data in Internal Table in WebUI

    Hello All ,
    I have Requirment to Upload the .xls or .xlxs file into Excel . Can any one explain me me how to do i have followed
    i have used the following code
    1. In the application use file upload to upload the file.
    2. caputure the content and length
    DATA: data TYPE REF TO CL_HTMLB_FILEUPLOAD.
    data ?= CL_HTMLB_MANAGER=>GET_DATA(
    request = runtime->server->request
    name = 'fileUpload'
    id = 'xx').
    name = data->file_name.
    content = data->file_content.
    length = data->file_length.
    content_type = data->file_content_type.
    3. Then read the data using the class
    DATA: conv TYPE REF TO CL_ABAP_CONV_IN_CE.
    conv = CL_ABAP_CONV_IN_CE=>CREATE( input = CONTENT ).
    conv->READ( importing data = Variable len = length ).
    Here in Read its throughing some junk data which is not in a readable format.
    Done this with reference to the link below
    Upload Excel Files to ITable
    Regards,
    Kiran Posanapalli
    Edited by: posanapalli kiran on Jan 6, 2010 8:27 AM
    Edited by: posanapalli kiran on Jan 6, 2010 8:32 AM

    this is a trial method and right now i am trying to read only the first cell of the excel sheet and return that value and show it in the UI when the user presses the button but this code is not returning any value.
    METHOD read_excel.
      INCLUDE ole2incl.
      DATA: filename(128) TYPE c,
                excel TYPE ole2_object,
                cell TYPE ole2_object,
                workbook TYPE ole2_object,
               pfile TYPE localfile VALUE
               'C:\Documents and Settings\I047323\Desktop\new.xls',
                name TYPE string.
      CREATE OBJECT excel 'EXCEL.APPLICATION'.
      SET PROPERTY OF excel 'VISIBLE' = 0.
      CALL METHOD OF excel 'WORKBOOKS' = workbook.
      CALL METHOD OF workbook 'OPEN'
        EXPORTING  #1       = pfile.
        CALL METHOD OF excel  'CELLS' = cell
          EXPORTING
            #1      = 1
            #2      = 1
        GET PROPERTY OF cell 'VALUE' = value.
      CALL METHOD OF workbook 'SAVE'.
      CALL METHOD OF workbook 'CLOSE'.
      CALL METHOD OF excel 'QUIT'.
      FREE OBJECT excel.
    ENDMETHOD.
    Edited by: neelima v on Jan 14, 2008 4:06 PM

  • Date in miliseconds

    hi,
    i try to store current date value as integer in my database so i will be able to compare dates by sql command simply like comparing integer values. this is the method i use when i code in PHP. so for this purpose i use Date classes getTime() method to get the time in miliseconds. but i want to ignore hour,minute,second,milisecond values. i need only day,month and year in miliseconds. but how?
    also how can i reverse the process to get day,month and year from such milisecond representation?
    thaks for your helps...

    Try this one :))
    import java.util.Calendar;
    import java.util.Date;
    public class DateConverter {
      Calendar calendar;
         public DateConverter() {
              this( Calendar.getInstance() );
      public DateConverter( Calendar cal ) {
        super();
        calendar = cal;
      public long toMillis( Date d ) {
        long result = -1;
        calendar.clear();
        calendar.setTime( d );
        clearTime();
        result = calendar.getTime().getTime();
        return result;
      private void clearTime() {
        calendar.set( Calendar.HOUR, 0 );
        calendar.set( Calendar.MINUTE, 0 );
        calendar.set( Calendar.SECOND, 0 );
        calendar.set( Calendar.MILLISECOND, 0 );
      public Date toDate( long millis ) {
        Date result;
        result = new Date( millis );
        calendar.clear();
        calendar.setTime( result );
        clearTime();
        result = calendar.getTime();
        return result;
      public static void main(String[] args) {
        DateConverter conv = new DateConverter();
        Date now = new Date();
        System.out.println( "Now is " + now + "\n -> millis " + now.getTime() );
        System.out.println( " -> becomes " + conv.toMillis( now ) );
        System.out.println( " -> as Date " + conv.toDate( conv.toMillis( now ) ) );
        long then = System.currentTimeMillis();
        System.out.println( "Then is " + then + "\n -> Date " + new Date( then ) );
        System.out.println( " -> becomes " + conv.toDate( then ) );
        System.out.println( " -> as millis " + conv.toMillis( conv.toDate( then ) ) );
    }Delivers:
    Now is Thu Jan 02 12:34:36 GMT+01:00 2003
    -> millis 1041507276338
    -> becomes 1041505200000
    -> as Date Thu Jan 02 12:00:00 GMT+01:00 2003
    Then is 1041507276598
    -> Date Thu Jan 02 12:34:36 GMT+01:00 2003
    -> becomes Thu Jan 02 12:00:00 GMT+01:00 2003
    -> as millis 1041505200000

  • How to upload chinese word in the R/3 with fileupload element?

    HI, experts,
    I am working with a File Upload Web Dynpro Application. And i am using the File Upload UI Element to upload data to R/3, every thing works fine if i upload the file that content is English word. I have 2 questions :
    (1)But it give me dump. Stat 'A character set conversion is not possible'  if I try to upload the file that content is Chinese word.
    (2) But it give me dump. Stat 'A character set conversion is not possible' if I try to upload a pdf file that content is English word.
    The code is:
    method ONACTIONON_UPLOAD .
    DATA XCONTENT TYPE XSTRING.
    DATA: CONTENT TYPE STRING .
    DATA: MIME_1 TYPE STRING .
    DATA: NAME TYPE STRING .
    DATA:
    ROWS TYPE STANDARD TABLE OF STRING ,
    WA_ROWS(300) TYPE C .
    DATA: CONV TYPE REF TO CL_ABAP_CONV_IN_CE.
    DATA: INPUT TYPE REF TO IF_WD_CONTEXT_NODE.
    INPUT = WD_CONTEXT->GET_CHILD_NODE( 'INPUT' ).
    INPUT->GET_ATTRIBUTE( EXPORTING NAME = 'UPLOAD' IMPORTING VALUE = XCONTENT ).
    INPUT->GET_ATTRIBUTE( EXPORTING NAME = 'FILENAME' IMPORTING VALUE = NAME ).
    INPUT->GET_ATTRIBUTE( EXPORTING NAME = 'MIMETYPE' IMPORTING VALUE = MIME_1 ).
    CONV = CL_ABAP_CONV_IN_CE=>CREATE( INPUT = XCONTENT ).
    CONV->READ( IMPORTING DATA = CONTENT ).
    SPLIT CONTENT AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE ROWS .
    LOOP AT ROWS INTO WA_ROWS .
    ENDLOOP.
    endmethod.
    could you please suggest for uploading Chinese word ?
    could you please suggest for uploading English word in the pdf file?
    Thanks
    Mahesh

    Hi, experts,
    It is ok. I changed my code. The chinese word is transfered the R/3 system.
    Thanks.
    Best regards,
    tao

  • UNICODE --- translate error

    Hi,
    Can anybody with following code. I am converting program to unicode and getting an error 'Null space must be a data type C N D T'. Here is the code.
    DATA       NULL_SPACE(2)        TYPE x VALUE '0020'.
    TRANSLATE BDCDATA-FVAL USING NULL_SPACE.
    Regards,
    venkat.

    Do something like below: -
    data: left_content    type string,
          right_content   type string,
          xcontent   type xstring.
    data: w_longchar(20).
    constants: c_unknown(7) value 'Unknown'.
    xcontent = '0020'.
    data: conv   type ref to cl_abap_conv_in_ce.
    conv = cl_abap_conv_in_ce=>create( input = xcontent ).
    conv->read( importing data = left_content ).
    - Cheers

  • Sending an excel spreadsheet attachment on an E-Mail

    Afternoon,
    Based upon program BCS_EXAMPLE_5 I have created a program that generates an e-mail and creates a spreadsheet attachment. The problem I have is how do get the contents of an internal table into the spreadsheet attachment?
    My attempt at resolving the problem has been as follows:-
    I have declared a variable document which points to the class cl_document_bcs. I have then instantiated the variable using a static method. I then call the method add_attachment (document->add_attachment) and pass the text content which contains two lines of text.
    This creates a spreadsheet will the two lines of text in the first cell.
    Could I use the binary content instead? If so how do I declare a variable that has the same type as a work area of binary content because this has a data type of RAW.
    Any assistance would be very much appreciated. A copy of my code can be seen below:-
    Thanks and regards
    John.
    REPORT bcs_example_5.
    This example shows how to send
      - a simple text provided in an internal table of text lines
      - and an attached MS word document provided in internal table
      - to some internet email address.
    All activities done via facade CL_BCS!
    DATA: send_request       TYPE REF TO cl_bcs.
    DATA: text               TYPE bcsy_text.
    DATA: text_content       TYPE soli_tab.
    DATA: wa_text_content    TYPE soli.
    DATA: binary_content     TYPE solix_tab.
    DATA: wa_binary_content  TYPE solix.
    DATA: document           TYPE REF TO cl_document_bcs.
    DATA: sender             TYPE REF TO cl_sapuser_bcs.
    DATA: recipient          TYPE REF TO if_recipient_bcs.
    DATA: bcs_exception      TYPE REF TO cx_bcs.
    DATA: sent_to_all        TYPE os_boolean.
    Data to be included in the spreadsheet
    DATA:  text2(100) TYPE c VALUE 'ABC'.
    DATA:  int TYPE i VALUE 258.
    DATA:  buffer TYPE xstring.
    DATA:  conv TYPE REF TO cl_abap_conv_out_ce.
    START-OF-SELECTION.
      PERFORM main.
          FORM main                                                     *
    FORM main.
      TRY.
        -------- create persistent send request ------------------------
          send_request = cl_bcs=>create_persistent( ).
        -------- create and set document with attachment ---------------
        create document from internal table with text
          APPEND 'Hello world!' TO text.
          document = cl_document_bcs=>create_document(
                          i_type    = 'RAW'
                          i_text    = text
                          i_length  = '12'
                          i_subject = 'test created by BCS_EXAMPLE_5' ).
        add attachment to document
        BCS expects document content here e.g. from document upload
        binary_content = ...
    *TRY.
         conv = cl_abap_conv_out_ce=>create(
              encoding                      = 'UTF-8'
              endian                        = 'L'
       REPLACEMENT                   = '#'
       IGNORE_CERR                   = ABAP_FALSE
    CATCH CX_PARAMETER_INVALID_RANGE .
    CATCH CX_SY_CODEPAGE_CONVERTER_INIT .
    **ENDTRY.
         CALL METHOD conv->write( data = text n = 4 ).
         CALL METHOD conv->write( data = int ).
         buffer = conv->get_buffer( ).
          wa_text_content = '1234567890ABCDE'.
          APPEND wa_text_content TO text_content.
          wa_text_content = '1234567890ABCDE'.
          APPEND wa_text_content TO text_content.
          wa_binary_content = buffer.
         APPEND wa_binary_content TO binary_content.
         wa_binary_content = '11111111'.
         APPEND wa_binary_content TO binary_content.
          CALL METHOD document->add_attachment
            EXPORTING
              i_attachment_type    = 'XLS'
              i_attachment_subject = 'c:\temp\book2'
              i_att_content_text   = text_content.
             i_att_content_hex    = binary_content
        add document to send request
          CALL METHOD send_request->set_document( document ).
        --------- set sender -------------------------------------------
        note: this is necessary only if you want to set the sender
              different from actual user (SY-UNAME). Otherwise sender is
              set automatically with actual user.
          sender = cl_sapuser_bcs=>create( sy-uname ).
          CALL METHOD send_request->set_sender
            EXPORTING
              i_sender = sender.
        --------- add recipient (e-mail address) -----------------------
        create recipient - please replace e-mail address !!!
          recipient = cl_cam_address_bcs=>create_internet_address(
                                            '[email protected]' ).
        add recipient with its respective attributes to send request
          CALL METHOD send_request->add_recipient
            EXPORTING
              i_recipient = recipient
              i_express   = 'X'.
        ---------- send document ---------------------------------------
    set send immediately flag
          CALL METHOD send_request->set_send_immediately( 'X' ).
          CALL METHOD send_request->send(
            EXPORTING
              i_with_error_screen = 'X'
            RECEIVING
              result              = sent_to_all ).
          IF sent_to_all = 'X'.
            WRITE text-003.
          ENDIF.
          COMMIT WORK.
    *                     exception handling
    * replace this very rudimentary exception handling
    * with your own one !!!
        CATCH cx_bcs INTO bcs_exception.
          WRITE: 'Fehler aufgetreten.'(001).
          WRITE: 'Fehlertyp:'(002), bcs_exception->error_type.
          EXIT.
      ENDTRY.
    ENDFORM.                    "main

    Hi,
    See the Blog..
    /people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface
    Here is the example program to send the EXCEL as a attachment in a email
    http://www.erpgenie.com/sap/abap/code/abap58.htm
    Regards
    Sudheer

  • ABAP webDynpro MS Office component usage throws -  Access via 'NULL' object

    I am trying to include MS office word in my custom ABAP webDynro application based on the sample SAP Package SIOS for all the MS office component usage. <br>
    In WDMODIFY method  , when the courser is reaching the point to call office component  it throws a Null pointer exception. Not sure , if i am missing some thing here or skip a step. Please advice. <br>
    get the IOS interface <br>
      wd_this->factory ?= office->_method_handler. <br>
    Below is the code for WDMODIFY <br>
    method WDDOMODIFYVIEW . <br>
    DATA: <br>
        office TYPE REF TO cl_wd_view_element, <br>
        office_res TYPE REF TO cl_wd_view_element,<br>
        mime_repository TYPE REF TO if_mr_api,<br>
        content TYPE xstring, <br>
        url TYPE string VALUE <br>
    '/SAP/BC/WebDynpro/SAP/PUblic/BC/ssr/uuielibs/office_integration' & <br>
    '/iostest_fields.doc'. <br>
      DATA refexp TYPE REF TO cx_ios_exception.
      DATA: msgid TYPE syst-msgid,
         msgnr TYPE syst-msgno,
         msgty TYPE syst-msgty.
      get message manager
      DATA: l_current_controller TYPE REF TO if_wd_controller,
            l_message_manager    TYPE REF TO if_wd_message_manager.
      DATA envproxy TYPE REF TO if_ios_environment.
    just do it once
      CHECK first_time = abap_true.
      mime_repository = cl_mime_repository_api=>get_api( ).
      CALL METHOD mime_repository->get
        EXPORTING
          i_url     = url
        IMPORTING
          e_content = content.
      wd_context->set_attribute( name = 'DATAS' value = content ).
    get the office control
      office ?= view->get_element( 'GENERIC_OFFICE' ).
      ASSERT ID sios_demo CONDITION  office IS BOUND.
    not possible : Missing bugfix component bc-wd-aba
    office_res ?= view->get_element( 'RESULT_DOCUMENT' ).
    ASSERT ID sios_demo CONDITION  office IS BOUND.
    get the IOS interface
      wd_this->factory ?= office->_method_handler.
      ASSERT ID sios_demo CONDITION wd_this->factory IS BOUND.
    wd_this->factory_res ?= office_res->_method_handler.
    ASSERT ID sios_demo CONDITION wd_this->factory_res IS BOUND.
      TRY.
          wd_this->factory->get_wordprocessing_proxy(
             IMPORTING proxy = wd_this->document  ).
          ASSERT ID sios_demo CONDITION wd_this->document IS BOUND.
         wd_this->factory_res->get_wordprocessing_proxy(
            IMPORTING proxy = wd_this->document_res  ).
         ASSERT ID sios_demo CONDITION wd_this->document IS BOUND.
    *calling    setfields
          DATA co_error_info_getfields TYPE REF TO if_wd_context_element.
          DATA co_error_info_getfields_stru TYPE wdr_ext_attribute_pointer.
          co_error_info_getfields = wd_context->get_lead_selection( ).
          co_error_info_getfields_stru-attribute_name =
    'error_info_getfields'.
          co_error_info_getfields_stru-element = co_error_info_getfields.
          DATA fields TYPE if_ios_wordprocessing=>fields_type.
          DATA fieldstable TYPE if_ios_wordprocessing=>fields_type_table.
          DATA co_fieldcontent TYPE REF TO if_wd_context_element.
          DATA co_fieldcontent_stru TYPE wdr_ext_attribute_pointer.
          DATA inputfield1 TYPE xstring.
          DATA tabulator TYPE xstring.
          DATA endofline TYPE xstring.
          DATA: conv TYPE REF TO cl_abap_conv_out_ce.
          DATA: testfielddata TYPE string.
          testfielddata = 'SAPTEST'.
          conv = cl_abap_conv_out_ce=>create( encoding = '4110'
    ignore_cerr = abap_true ).
          CALL METHOD conv->convert( EXPORTING data = 'field1'
                                           IMPORTING buffer =
    fields-fieldidentifier  ).
          CALL METHOD conv->convert( EXPORTING data = testfielddata
                                           IMPORTING buffer = fields-value
          CALL METHOD conv->convert( EXPORTING data =
    cl_abap_char_utilities=>horizontal_tab
                                           IMPORTING buffer = tabulator  ).
          CALL METHOD conv->convert( EXPORTING data =
    cl_abap_char_utilities=>cr_lf
                                           IMPORTING buffer = endofline  ).
          wd_context->set_attribute( name = 'inputfield1'
                                     value = testfielddata ).
          APPEND fields TO fieldstable.
          wd_context->set_attribute( name = 'fieldcontent' value =
    fieldstable ).
          co_fieldcontent = wd_context->get_lead_selection( ).
          co_fieldcontent_stru-attribute_name = 'fieldcontent'.
          co_fieldcontent_stru-element = co_fieldcontent.
    document is set through datasource!
          wd_this->document->setfields( EXPORTING fieldsptr =
    co_fieldcontent_stru
                                                  tabulator = tabulator
                                                  endofline = endofline
                                                  errorinformation =
    co_error_info_getfields_stru ).
    *calling    opening result document
          DATA co_error_getcontent TYPE REF TO if_wd_context_element.
          DATA co_error_getcontent_stru TYPE wdr_ext_attribute_pointer.
          co_error_getcontent = wd_context->get_lead_selection( ).
          co_error_getcontent_stru-attribute_name = 'error_getcontent'.
          co_error_getcontent_stru-element = co_error_getcontent.
          DATA co_createdcontent TYPE REF TO if_wd_context_element.
          DATA co_createdcontent_stru TYPE wdr_ext_attribute_pointer.
          co_createdcontent = wd_context->get_lead_selection( ).
          co_createdcontent_stru-attribute_name = 'createdcontent'.
          co_createdcontent_stru-element = co_createdcontent.
    waiting of ACF Patch!
         wd_this->document->getcontent( errorinformation =
    *co_error_getcontent_stru
         contentpointer_result =  co_createdcontent_stru ).
    *calling    reopening template
          DATA error_opendocument TYPE REF TO if_wd_context_element.
          DATA error_opendocument_stru TYPE wdr_ext_attribute_pointer.
          error_opendocument = wd_context->get_lead_selection( ).
          error_opendocument_stru-attribute_name = 'error_opendocument'.
          error_opendocument_stru-element = error_opendocument.
         wd_this->document_res->if_ios_document~opendocument( EXPORTING errorinformation = error_opendocument_stru ).
        CATCH cx_ios_document INTO refexp.
        CATCH cx_ios_communicationwrapper INTO refexp.
        CATCH cx_ios_factory INTO refexp.
        CATCH cx_ios_environment INTO refexp.
        CATCH cx_ios_exception INTO refexp.
      ENDTRY.
      IF refexp IS NOT INITIAL.
        refexp->get_message( IMPORTING
                  mtype = msgty
                  number = msgnr
                  mid = msgid ).
        l_current_controller ?= wd_this->wd_get_api( ).
        CALL METHOD l_current_controller->get_message_manager
          RECEIVING
            message_manager = l_message_manager.
      report message
        CALL METHOD l_message_manager->report_t100_message
          EXPORTING
            msgid = msgid
            msgno = msgnr
            msgty = msgty.
      ENDIF.
    endmethod.
    Edited by: suryajoshi on Jan 13, 2011 5:04 PM

    Thanks for your reply.
    I have defined DATAS attribute  as XSTRING.  You are right i am using SIOS code from WDMODIFY.
    I am getting exception at this line:  Please advice. Its seems that factory is not been recognize. I double check , factory is present in attributes Tabs of the View.
    get the IOS interface
      wd_this->factory ?= office->_method_handler.
      ASSERT ID sios_demo CONDITION wd_this->factory IS BOUND.

  • Error while uploading file?

    Hi all
    I am uploading data from CSV, while uploading i am getting error "Unable to interpret "7086,,203,23-Jul-10,,7086,,,B7306663,,72" as a number." Error is coming at some fields.. there i am using some data element which is of type int1 and another one is CURR field. Any specific type definitions required here... pleaes help...
    Thanks,
    Kris.

    Hi Sarbjeet,
    Please look at once to this code i am using...
    get the datasource Xstring
      wd_context->get_attribute(
         EXPORTING
           name =  'HEADER_DATASOURCE'
         IMPORTING
           value = lw_head_datasource ).
    *CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
    *EXPORTING
    *in_xstring = lw_head_datasource
    *IMPORTING
    *out_string = lw_head_string.
    DATA : conv   TYPE REF TO CL_ABAP_CONV_IN_CE.
    Creates a Conversion Instance
    CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
          EXPORTING
            INPUT       = lw_head_datasource
            ENCODING    = 'UTF-8'
            REPLACEMENT = '?'
            IGNORE_CERR = ABAP_TRUE
          RECEIVING
            CONV        = conv.
          conv->READ( importing data = lw_head_string ).
    get the data of file
       split  lw_head_string at cl_abap_char_utilities=>newline
        into TABLE lt_head_data.
    delete the header
      DELETE lt_head_data INDEX 1.
    get all the field name
      LOOP AT lt_head_data into lw_head_string.
        SPLIT lw_head_string at cl_abap_char_utilities=>horizontal_tab
         into table lt_head_field.
    ***get all the 6 fields of one line
        READ TABLE lt_head_field INTO lv_head_field INDEX 1.
        ls_head_context-DEALER_CODE = lv_head_field.
        READ TABLE lt_head_field INTO lv_head_field INDEX 2.
        ls_head_context-CLAIM_TYPE = lv_head_field.
    I have around 40 fields.. i am getting error here...
        READ TABLE lt_head_field INTO lv_head_field INDEX 23.
        ls_head_context-KMS_HRS_PERDAY= lv_head_field.
    If i change the type KMS_HRS_PERDAY from INT1 to CHAR1 it is working fine... can u help me .. please
    Thanks,
    kris.

  • Upload Excel Files to ITable

    Hi... maybe someone of you have been reading about how to upload excel files to an internal table using function module ALSM_EXCEL_TO_INTERNAL_TABLE.
    The problem that I found with this technique is that it is not possible to use this FM with the SAP WAS because it gives a runtime dump (it only works if the file is on the client machine and if the function module is called from SAPGUI.
    Then I have found the topic
    Re: BSP and Excel
    And one guy puts something interesting like this:
    1. In the application use file upload to upload the file.
    2. caputure the content and length
    DATA: data TYPE REF TO CL_HTMLB_FILEUPLOAD.
    data ?= CL_HTMLB_MANAGER=>GET_DATA(
    request = runtime->server->request
    name = 'fileUpload'
    id = 'xx').
    name = data->file_name.
    content = data->file_content.
    length = data->file_length.
    content_type = data->file_content_type.
    3. Then read the data using the class
    DATA: conv TYPE REF TO CL_ABAP_CONV_IN_CE.
    conv = CL_ABAP_CONV_IN_CE=>CREATE( input = CONTENT ).
    conv->READ( importing data = Variable len = length ).
    Now... has anyone continued with this sample? has anyone put the contents into an internal table (with the READ method)...
    If someone did it please show me how to..
    Thanks
    Ariel

    Hi Craig,
    Ok, I was reading the Thomas's Blog and the thread about excel. The blog talks about encoding and the thread is about how to "download" the table. I want to upload the excel to an internal table.
    So, I am almost finishing the code.. But I have a problem (named DUMP) when I create the "conv" object (check the code) the problem is because I dont know how to call the create method indicating 'UFT-16' as encoding.
    I show you my "OnInputProcessing" code:
    IF button_event->id = 'btnUpload'.
      fileUpload ?= CL_HTMLB_MANAGER=>GET_DATA(
                           request = request
                           id      = 'txtFile'
                           name    = 'fileUpload' ).
      IF ( fileUpload->file_name  NE '' ) AND
         ( fileUpload->file_length GT 0 ).
         IF fileUpload->file_content_type
            = 'application/vnd.ms-excel'.
            DATA: content   TYPE ZMTVEMAT,
                  conv      TYPE REF TO CL_ABAP_CONV_IN_CE,
                  viewoff   TYPE REF TO CL_ABAP_VIEW_OFFLEN,
                  it_off    TYPE ABAPOFFLENTAB,
                  wa_off    TYPE ABAPOFFLEN,
                  dd_fields TYPE DDFIELDS,
                  wa_fields TYPE DFIES,
                  len       TYPE I.
            conv = CL_ABAP_CONV_IN_CE=>CREATE(
                      encoding = 'UTF-16'
                      endian   = 'L'
                      input    = fileUpload->file_content ).
            CALL FUNCTION 'TR_NAMETAB_GET'
               EXPORTING
                IV_TABNAME                   = 'ZMTVMAT'
                IV_GET_LENGTHS_IN_CHARMODE   = 'X'
                IV_GET_TEXTS                 = ' '
               IMPORTING
                ET_DFIES                     = dd_fields.
                LOOP AT dd_fields INTO wa_fields.
                  MOVE wa_fields-offset TO wa_off-ioff.
                  MOVE wa_fields-intlen TO wa_off-ilen.
                  APPEND wa_off TO it_off.
                ENDLOOP.
       viewoff = CL_ABAP_VIEW_OFFLEN=>CREATE( tab = it_off ).
                conv->READ(
                            exporting
                              view = viewoff
                            importing
                              data = content
                              len = len ).
    This is the DUMP
    Runtime Errors         CONVT_CODEPAGE_INIT                               
    Exception              CX_SY_CODEPAGE_CONVERTER_INIT                     
           Occurred on     30.11.2004 at 13:20:47                                                                               
    The conversion of some code pages is not supported.                                                                               
    What happened?                                                                               
    The conversion of texts in code page 'UTF-' to code page '1100' is not   
    supported.                                                               
    Thanks
    Ariel

  • JMS, MQSeries, R/3 Link, NT and AIX...

    Hi all,
    To put you in situation, I have a java application which can run from any type of OS as of now. It sends documents to a queue (IDOCS) and those documents are then sent to SAP by an R/3 Link adapter. Using native binding and running the java application on the same computer as the QueueManager (AIX) it was all working fine.
    Now, I have translated my app to use JMS instead and tried to run it on my Windows 2000 PC. The message are sent allrigth to the queue, but R/3 Link is now giving me a handfull of errors, complaining about conversion, character sets and things like that.
    Here is a sample of errors I get:
    02/18/03 17:00:39 SMQ4165: Warning on MQGET from inbound queue. Reason code 2110.
    EXPLANATION: The attempt to get a message from the inbound message queue returned a warning. The warning code was 2110. The message will be passed to the use
    r exit if one has been specified. If no exit was specified, the message will be passed to the bad message queue. If no bad message queue was specified, the
    message will be left on the inbound queue, and the server will terminate.
    ACTION: None.
    02/18/03 17:00:39 SMQ4192: A data conversion problem occurred on the MQGET. Attempting to process message.
    EXPLANATION: A warning was issued because the message needs codepage conversion, but the message is either not in MQSTR format, or a user-defined data- conver
    sion exit call failed.
    ACTION: Ensure that incoming messages from machines with a different code page, are in MQSTR format or that there is a user exit defined to convert messages i
    n other formats.
    02/18/03 17:00:40 SMQ4167: IDoc has an invalid structure version. IDoc value="16777216". Expected value="1".
    EXPLANATION: The value of the version field in the IDoc header structure contains an invalid value.
    ACTION: Ensure that the IDoc message starts with a valid version of the Saplink header structure (MQSAPH).
    02/18/03 17:00:40 SMQ4191: A message was put to the bad message queue. Bad message type 1, reason 4108.
    EXPLANATION: The message was not in a valid IDoc format. The bad message type is 1 and the bad message reason is 4108.
    ACTION: Check the bad message reason code in the bad message header of the message. Attempt to correct the error and send the message again.
    I finally set the CCSID to 819 in the connection string, now I suspect that my problem is related to the encoding I use but I can't find what to set it to instead. I write everything in a ByteMessage by the way, just as I was doing it with the native bindings.
    Does anyone know how I am supposed to set this up? What encoding type should I set it to? Is the CCSID correct? previously, I was setting the format this way: bytesMessage.format = "MQHSAP ";
    But using JMS, there is no such property so I tried to just write it to the ByteMessage, not sure this works either...
    Thanks in advance,
    Daniel
    If it can be of any help, here is a code fragment of what I am doing:
    using native binding, which was working fine
    //Add the mandatory R3/Link header to our message
    bytesMessage.writeBytes("SAPH");
    bytesMessage.writeInt(1);
    bytesMessage.writeInt(108);
    bytesMessage.writeInt(273);
    bytesMessage.writeInt(819);
    bytesMessage.writeBytes("MQSTR ");
    for(int i = 28; i < 108; i++)
    bytesMessage.writeByte(32);
    bytesMessage.writeBytes(textMessage);
    bytesMessage.encoding = MQC.MQENC_INTEGER_NORMAL;
    bytesMessage.format = "MQHSAP ";
    And using JMS:
    //Test code
    queue = session.createQueue("queue://" + manager + "/" + name + "?priority=5&persistence=2&targetClient=1&encoding=" +
    MQC.MQENC_INTEGER_REVERSED + "&CCSID=819");
    //Add the mandatory R3/Link header to our message
    bytesMessage.writeBytes("SAPH".getBytes());
    bytesMessage.writeInt(1);
    bytesMessage.writeInt(108);
    bytesMessage.writeInt(273);
    bytesMessage.writeInt(819);
    bytesMessage.writeBytes("MQSTR ".getBytes());
    StringBuffer padding = new StringBuffer(80);
    for(int i = 28; i < 108; i++)
    padding.append(" ");
    bytesMessage.writeBytes(padding.toString().getBytes());
    bytesMessage.writeBytes("MQHSAP ".getBytes());
    bytesMessage.writeBytes(textMessage.getBytes());
    queueSender.send(bytesMessage);

    Hi There,
    I know you used JMS and Link for R/3.
    Now I am doing the same but I am getting the same problem besides I am doing what you mention in the forum.
    Can you give me a hand to fix this?
    I have configured and MQSeries under win2003 and in the same machine a Link 4 R/3. I have a Java app using a .bindings file to connect to the Q and send a message the same way you did, but i am getting this error:
    IDoc has an invalid structure header. IDoc value="RFH ". Expected value="SAPH".
    IDoc has an invalid structure version. IDoc value="2". Expected value="1".
    IDoc has an invalid system number. IDoc value=<T.
    IDoc has an invalid client. IDoc value=�Y&#9830;.
    IDoc has an invalid language. IDoc value=.
    A message was put to the bad message queue. Bad message type 1, reason 4110.
    It seems as if the all the JMS headers are at the begining of the msg and it always throw the same error. it doesn't matter what data I put in the bytesMessage.
    I would really appreciate your help.
    Here a portion code of my SendMessage operation.
         public String EnviarMsg(String Msg) throws JMSException {
              String resp = null;
              try {
                   if (getQueueSend() == null) {
                        // Create un objeto QueueSender como productor del mensaje.
                        setQueueSend(QSess.createSender(MQueue));
                        // Crear y enviar un mensaje a la cola.
                   * Aqui viene codigo para enviar msgs a la cola en formato SAP
                   txtMsg = QSess.createBytesMessage();
                   txtMsg.writeBytes("SAPH".getBytes());
                   txtMsg.writeInt(1);
                   txtMsg.writeInt(108);
                   txtMsg.writeInt(273);
                   txtMsg.writeInt(819);
                   txtMsg.writeBytes("MQSTR ".getBytes());
                   byte b = 32;
                   for(int i=28; i<108; i++)
                        txtMsg.writeByte(b);
                   txtMsg.writeBytes(Msg.getBytes());
                   //txtMsg.encoding = MQC.MQENC_INTEGER_NORMAL;
                   txtMsg.setStringProperty("JMS_IBM_Format", "MQHSAP ");
                   //txtMsg.setText(Msg);
                   // QueueSend.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
                   // QueueSend.setTimeToLive(30000);Funciona. Probado con el MQSeries
                   // 6.0
                   QueueSend.send(txtMsg);
                   resp = "OK";

  • The use of CL_ABAP_CONV_OUT_CE to create an unicode-16 (UTF-16) file

    Hello,
    I have to create a file iwth normal text in UTF-16 format. In ABAP the creation of an UTF-8 file is very easy (open dataset for output in UTF-8).
    However UTF-16 is barely documented. and the normal open dataset does not support utf-16.
    The only thing i could find out that you have to use class CL_ABAP_CONV_OUT_CE for it and open it as BINARY.
    But i don't know how to do it. Could someone help. an small example would be perfect.
    Thanx in advance.
    Regards, Frank

    Hi,
    Please check this piece of code
    DATA conv TYPE REF TO cl_abap_conv_in_ce.
    DATA buffer(4) TYPE x.
    DATA text(100) TYPE c.
    buffer = '41424344'.
    conv = cl_abap_conv_in_ce=>create(
    encoding = 'UTF-8' ).
    conv->convert(
    EXPORTING input = buffer
    IMPORTING data = text ).
    write: / text.
    Example for class cl_abap_conv_out_ce.
    data: text(100) type c value 'ABCD',
    conv type ref to cl_abap_conv_out_ce,
    buffer type xstring.
    conv = cl_abap_conv_out_ce=>create(
    encoding = 'UTF-8'
    endian = 'L'
    call method conv->write( data = text n = 4 ).
    buffer = conv->get_buffer( ).
    write:/ buffer.
    Also
    you do not need to replace TRANSLATE ... TO UPPER/LOWER CASE in Unicode systems.
    You just need to take care that the arguments fit:
    The arguments of these instructions must be single fields of type C, N, D, T or STRING or structures of character-type only.
    Regards
    Hiren K.Chitalia

  • CSV file upload into interal table with unicode system.

    Hi everyone.
    I have a problem. I made a sample program to upload CSV file to server memory;iternal table i mean. if csv file has numeric and english data, it works well. but it's not work when i made a csv file with Korean. my code is below. how can i do??
    DATA: FILEUPLOAD TYPE REF TO CL_HTMLB_FILEUPLOAD.
    DATA: CONTENT_LENGTH TYPE STRING,
          FILE_CONTENT TYPE XSTRING ,
          FILE_LENGTH TYPE STRING ,
          FILE_MIME_TYPE TYPE STRING ,
          FILE_NAME TYPE STRING .
    DATA: CONTENT TYPE STRING.
    FILEUPLOAD ?= CL_HTMLB_MANAGER=>GET_DATA(
                           REQUEST = REQUEST
                           ID      = 'file1'
                           NAME    = 'fileUpload' ).
    FILE_NAME      = FILEUPLOAD->FILE_NAME.
    FILE_MIME_TYPE = FILEUPLOAD->FILE_CONTENT_TYPE.
    FILE_LENGTH    = FILEUPLOAD->FILE_LENGTH.
    FILE_CONTENT   = FILEUPLOAD->FILE_CONTENT.
    data: conv type ref to CL_ABAP_CONV_IN_CE .
    data: tmp type string.
    data: cnt type i.
        CONV = CL_ABAP_CONV_IN_CE=>CREATE( INPUT = FILE_CONTENT
                                           ENCODING = 'UTF-8' ).
        CONV->READ( EXPORTING N = cnt
                    IMPORTING DATA = CONTENT ).
        tmp = content.

    Hi,
    Pls check threads like
    File Download / Upload Question
    Eddy
    PS. Reward the useful answers and you will get <a href="http:///people/baris.buyuktanir2/blog/2007/04/04/point-for-points-reward-yourself">one point</a> yourself!

  • German Special Characters in XSTRING to STRING conversion

    Hi Experts,
    I have a CSV file (created from a Windows Excel file) with German Special Characters (e.g. 'ä', 'Ä') and I am trying to read this into ABAP internal tables. By using the THTMLB tag 'thtmlb:fileUpload' I get an XSTRING and I am trying to convert this into STRING. However, wheny trying to do this I get an exception 'CX_SY_CONVERSION_CODEPAGE'.
    This is my coding:
      data: conv   type ref to cl_abap_conv_in_ce.
      conv = cl_abap_conv_in_ce=>create( input = lr_upload->file_content ).
      conv->read( importing data = lv_content ).
    Note: lr_upload is my XSTRING object from the file upload, lv_content is a STRING.
    In the CSV file the German special characters look fine and the SAP system is a Unicode system, but it seems like there are some problems with the conversions somehow. Any ideas from the experts?
    Thanks a lot and Regards,
    Jens

    As you mention a csv file I'm wondering if your encoding is wrong: I.e. when you create your instance of cl_abap_conv_in_ce you don't specify the encoding of your source hex string, so that means the default encoding is used, which should be UTF-8 in your case. So if your csv file is not encoded in UTF-8, specify the correct encoding in the create method and see if that helps.
    Depending on how you get the file contents you might actually be able to combine the file retrieval with the conversion in one step. E.g. if the file is read from the application server you could specify the used code page via [open dataset ... in legacy text mode ... code page|http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET_MODE.htm#&ABAP_ALTERNATIVE_4@4@]. Similarly method gui_upload of class cl_gui_frontend_services also allows you to specify a code page.
    If all of this doesn't help, post some further details on your file (e.g. sample content & encoding) and possibly add some further details from the exception you're getting. As you mention a Unicode system it basically means that we should be able to convert all characters without any problem as long as we specify the correct source code page.
    Cheers, harald

  • How to run TagLibrary program

    Hi frnds,
    i am working on Jsp Tag Small example ..I wrote one JSP file,One .tld file and one .java files .That java file is compiled properly.While running that program i am getting error as below:
    1..org.apache.jasper.JasperException: /Date.jsp(7,7) Unable to load tag handler class "tagexamples.PageVisitTag" for tag "test:pageVisit"
    Here with i sent my File Structure and Source file also :
    1.Date.jsp
    <%@ page language="java" import ="java.util.Date" %>
    <%@ page import="tagexamples.*" %>.
    <html>
    <title>Simple Date Tag</title>
         <body>
              <%@ taglib uri="/pageVisit.tld" prefix ="test" %>
              <h2> <test:pageVisit /></h2>
              <h2> Current System Date is <%= new Date().toString() %></h2>
         </body>
    </html>
    2.pageVisit.tld
    <?xml version="1.0" encoding ="ISO-8859-1" ?>
    <!DOCTYPE taglib PUBLIC "=//Sun.Microsystems,Inc.//DTD Jsp Tag Library 1.1//EN"
              "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
    <taglib>
         <tlibversion>1.0</tlibversion>
         <jspversion>1.1</jspversion>
         <shortname>date</shortname>
         <info>
              A simple tag Library for example
         </info>
         <tag>
              <name>pageVisit</name>
              <tagclass>tagexamples.PageVisitTag</tagclass>
              <bodycontent>empty</bodycontent>
              <info>
                   This tag Output the LastTime u have viisted the page in the Last MOnth..
                   This tag Ocntains empty Body and no attributes
              </info>
         </tag>
    </taglib>
    3.PageVisitTag.java
    package tagexamples;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    import java.util.Date;
    import java.io.IOException;
    public class PageVisitTag extends TagSupport
         public int doStartTag() throws JspTagException
              Cookie info = null;
              String msg = "This is the First time u have Visited this page" ;
              //Get all Cookine s that Came from the Request
              Cookie[] cookies = ((HttpServletRequest)pageContext.getRequest()).getCookies();
              for (int i=0;i< cookies.length;i++)
                   info = cookies;
                   if(info.getName().equals("MyCookie"))
                        found = true;
                        break;
              }//for
              String newValue =""+System.currentTimeMillis();
              if(!found)
                   //Create a new Cookie and set its age
                   info = new Cookie ("MyCookie",newValue);
                   info.setMaxAge(60*1);
                   info.setPath("/");
                   ((HttpServletResponse)pageContext.getResponse()).addCookie(info);
              }else {
                   long conv = new Long(info.getValue()).longValue();
                   msg = "U Last visited this site on "+new Date(conv);
                   //Set the new value of the Cookie and adddd it to the Response
                   info.setValue(newValue);
                   info.setMaxAge(10*24*60*60); //keep the cookie for One Month
                   //Set the Path so that the Cookie is available everywhere on the Server
                   info.setPath("/");
                   ((HttpServletResponse)pageContext.getResponse()).addCookie(info);
              } //else
              try{
                   JspWriter out = pageContext.getOut();
                   out.write(msg);
                   }catch(IOException e){
                        throw new JspTagException("JspWriter not There :"+e);
                   return SKIP_BODY;
         }//doStartTag ends
         public int doEndTag() throws JspTagException {
              if(!found){
                   //Don't Compare current and Cookie time this time
                   return SKIP_PAGE;
              }else {
                   return EVAL_PAGE;
         }//doEnd Tag ends
              boolean found = false;
         } //Class ends
    while running the above files in Tomcat it giving above error:
    i am running by:
    http://localhost/TagExamples/Date.jsp
    and
    I kept files in the below Structre order.
    My file Structure is :
    D:\jakarta-tomcat-5.0.16\webapps\TagExamples\WEB-INF\classess\tagexamples\PageVisitTag.java
    D:\jakarta-tomcat-5.0.16\webapps\TagExamples\Date.jsp
    D:\jakarta-tomcat-5.0.16\webapps\TagExamples\pageVisit.tld
    Just tell me is it Correct ..? and what is the Problem in COding and how to run a Tag Library
    If anybody know the Solution just reply .send me the mail
    [email protected]
    with regards,
    Ramesh P
    98459 35822

    Do (dir if on windows, ls if on *nix) and you will probably see an A directory in the A directory.  That came from your last compilation attempt.  Remove it and everything in it.  Now,
    cd ..
    javac A/Convertible.java
    java A.Convertible

Maybe you are looking for