Upload a CSV Excel File or Text File in SAP CRM WebUI

SAP CRM Technical Consultants sometimes comes across a requirement from the clients on business scenarios where they are asked to upload a File from the Presentation Server ( e.g Desktop, PC, Laptop, etc. ) into Application Server i.e SAP CRM System. This may be due a wide range of business requirements ranging from Mass Operations like bulk upload of Business Partners in the system and mass upload of data from external sources for Lead Generation. Based on the business case either a plain and simple flat file is used or a CSV File can also be fed into. Text File has the flexibility of platform independence and can be used and downloaded across multiple environments.

In the sample code below, either a CSV File can be used or a text file can also be used. I have created my own Z Component and have used the SAP Standard Component – GS_FILE_UPLOAD as a component usage in my component. Here the only intention is to upload a table of Business Partners into the system.

Assumptions

I have made the following assumptions regarding the technical skill which I feel is a prerequisite in order to execute the sample example provided in this document.

  • Have knowledge on SAP CRM Web UI Programing
  • Have knowledge on Component creation, View and Runtime Repository Editors
  • Have knowledge on Component Usage

If you don’t have extensive skills in the above mentioned topics still you can proceed with this document. But you may need to refer some document on basics of SAP CRM Web UI programming.

I guess there must be some existing component in the system. If you don’t have an existing component then you can create a sample component with any model node. This is just for your reference and will brush up your old skills of component creation.

Execute the CRM Web UI workbench Transaction Code : BSP_WD_CMPWB. Create a component here and toggle off the enhancement set button as we will not be enhancing any standard component here. 

ScreenHunter_01 Sep. 25 00.22.gif

Next step is to create a new View as shown below :

ScreenHunter_02 Sep. 25 00.28.gif

Add or create a New Node with the structure already defined as shown below and then complete the subsequent steps to complete the view creation. Then add the view into the Runtime Repository.

ScreenHunter_03 Sep. 25 00.32.gif

ScreenHunter_04 Sep. 25 00.35.gif

Then complete the configuration by adding the fields in the result list.

ScreenHunter_05 Sep. 25 00.38.gif

Add two buttons for upload and clearing the uploaded data as shown below:

ScreenHunter_08 Sep. 25 00.42.gif

If you have an already existing Web UI Component, then in order to upload Text/CSV Excel Files in SAP CRM Web Client UI the following steps needed to be performed. We will be using an already existing Web UI Component as component usage and there is no further requirement of JavaScript Coding. The excel files that need to be uploaded must be of type CSV – comma separated values excel. In additional plain text files can also be used. The uploaded data is stored as content in a string.

Use an already existing SAP CRM Web UI component

ScreenHunter_12 Oct. 29 03.16.gif

Create a New View

ScreenHunter_03 Oct. 29 03.01.gif

Add the following 2 Events in the View

ScreenHunter_05 Oct. 29 03.02.gif

In the Upload method add the following piece of code

ScreenHunter_09 Oct. 27 00.59.gif

Define the following Popup Access Interface in the Implementation Class of the View

ScreenHunter_07 Oct. 29 03.07.gif

In the other Method – EH_ONUPLOAD_POPUP_CLOSED put the following piece of code. Here based on the content we need to classify the data into appropriate structure.

ScreenHunter_09 Oct. 29 03.09.gif

METHOD eh_onupload_popup_closed.

  TYPES: BEGIN OF l_ty_attr_struct,

            businesspartner TYPE bu_partner,

            partnerdescription TYPE bu_descrip_long,

           END OF l_ty_attr_struct.

  DATA:l_v_file_content        TYPE string,

       l_i_file_content        TYPE stringtab,

       l_v_file_type           TYPE string,

       l_v_file_name           TYPE string,

       l_o_outputnode          TYPE REF TO cl_bsp_wd_context_node,

       l_o_collection_wrapper  TYPE REF TO cl_bsp_wd_collection_wrapper,

       l_if_property           TYPE REF TO if_bol_bo_property_access,

       l_o_msg_service         TYPE REF TO cl_bsp_wd_message_service,

       l_i_bp                  TYPE  zbupa_desc,

       l_wa_bp                 TYPE    zbupa_desc,

       l_v_status              TYPE zmember_status,

       l_o_entity              TYPE REF TO cl_crm_bol_entity,

       l_i_return              TYPE bapiret2_t,

       l_wa_return             TYPE bapiret2,

       l_v_struct_ref          TYPE REF TO zaccount_upload1,

       l_o_value_node          TYPE REF TO cl_bsp_wd_value_node,

       l_if_bo_coll            TYPE REF TO if_bol_bo_col,

       l_v_fired_plug          TYPE        seocmpname.

  FIELD-SYMBOLS: <fs_file_content> TYPE string,

                 <l_fs_wa_data>  TYPE zaccount_upload1.

  l_v_fired_plug = ci_if_popup->get_fired_outbound_plug( ).

  CASE l_v_fired_plug.

    WHEN ‘leave’.

*       get results of popup

      l_o_outputnode ?= ci_if_popup->get_context_node( ‘FILE’ ). “#EC NOTEXT

      l_o_collection_wrapper = l_o_outputnode->get_collection_wrapper( ).

      l_if_property           = l_o_collection_wrapper->get_current( ).

      CALL METHOD l_if_property->get_property_as_value

        EXPORTING

          iv_attr_name = ‘FILE_CONTENT_TYPE’                “#EC NOTEXT

        IMPORTING

          ev_result    = l_v_file_type.

      CALL METHOD l_if_property->get_property_as_value

        EXPORTING

          iv_attr_name = ‘FILE_NAME’                        “#EC NOTEXT

        IMPORTING

          ev_result    = l_v_file_name.

*       Check the MIME file type and the file extension

      IF ( l_v_file_type CP ‘text/plain’ )

        OR ( l_v_file_type CP ‘text/comma-separated-values’ )

        OR ( l_v_file_type CP ‘application/vnd.ms-excel’ AND l_v_file_name CP ‘*.csv’ ). “#EC NOTEXT

        CALL METHOD l_if_property->get_property_as_value

          EXPORTING

            iv_attr_name = ‘FILE_CONTENT_STRING’            “#EC NOTEXT

          IMPORTING

            ev_result    = l_v_file_content.

        IF l_v_file_content IS  INITIAL.

          l_o_msg_service ?= me->view_manager->get_message_service( ).

          l_o_msg_service->add_message( iv_msg_type       = ‘E’

                                       iv_msg_id         = ‘CRM_UI

                                       iv_msg_number     = ‘030’ ). “#EC NOTEXT

          EXIT.

        ENDIF.

        IF  me->typed_context->exupd2->collection_wrapper IS BOUND.

          me->typed_context->exupd2->collection_wrapper->clear( ).

        ENDIF.

*   Split filecontent into separate lines and store them in table

        SPLIT l_v_file_content AT cl_abap_char_utilities=>cr_lf INTO TABLE l_i_file_content.

        CLEAR l_v_file_content.

*   Remove empty lines from filecontent table and store on value node

        LOOP AT l_i_file_content ASSIGNING <fs_file_content>.

          IF NOT <fs_file_content> IS INITIAL.

            l_wa_bp-partner = <fs_file_content>.

            APPEND l_wa_bp TO l_i_bp.

          ENDIF.

        ENDLOOP.

        IF l_i_bp[] IS NOT INITIAL.

          CREATE OBJECT l_if_bo_coll TYPE cl_crm_bol_bo_col.

          IF l_if_bo_coll IS BOUND.

            l_if_bo_coll->set_multi_select( abap_true ).

          ENDIF.

          LOOP AT l_i_bp INTO l_wa_bp.

            REFRESH l_i_return.

            CALL FUNCTION ‘BUPA_DESCRIPTION_GET’

              EXPORTING

                iv_partner          = l_wa_bp-partner

              IMPORTING

                ev_description_long = l_wa_bp-partner_desc

              TABLES

                et_return           = l_i_return.

            IF l_i_return IS NOT INITIAL.

              CLEAR l_wa_return.

              READ TABLE l_i_return INTO l_wa_return WITH KEY type = ‘E’.

              IF sy-subrc = 0.

                l_wa_bp-partner_desc = l_wa_return-message.

              ENDIF.

            ENDIF.

            CREATE DATA l_v_struct_ref.

            ASSIGN l_v_struct_ref->* TO <l_fs_wa_data>.

            <l_fs_wa_data>-partner_id =  l_wa_bp-partner.

            <l_fs_wa_data>-partner_descr =  l_wa_bp-partner_desc.

            CREATE OBJECT l_o_value_node

              EXPORTING

                iv_data_ref = l_v_struct_ref.

            l_if_bo_coll->add( l_o_value_node ).

            l_if_bo_coll->if_bol_bo_col_multi_sel~mark( EXPORTING iv_bo = l_o_value_node ).

            UNASSIGN <l_fs_wa_data>.

          ENDLOOP.

        ENDIF.

*        ENDIF.

        me->typed_context->exupd2->collection_wrapper->set_collection( l_if_bo_coll ).

        me->typed_context->exupd2->collection_wrapper->publish_current( ).

      ELSE.

*         We assume an incorrect file type: it’s neither a plain text file nor a .csv file

*         Therefore -> raise an error message

        l_o_msg_service ?= me->view_manager->get_message_service( ).

        l_o_msg_service->add_message( iv_msg_type       = ‘E’

                                     iv_msg_id         = ‘CRM_UI’

                                     iv_msg_number     = ‘018’ ). “#EC NOTEXT

      ENDIF.

    WHEN OTHERS.

  ENDCASE.

ENDMETHOD.

Add the following lines of code in the HTML file of the view

ScreenHunter_14 Oct. 27 01.06.gif

In the Component a new component Usage needs to be added

ScreenHunter_11 Oct. 29 03.13.gif

Now run the component

ScreenHunter_17 Oct. 27 01.08.gif

Click on Upload

ScreenHunter_18 Oct. 27 01.09.gif

Click the Upload File

ScreenHunter_21 Oct. 27 01.11.gif

Upload the File

ScreenHunter_22 Oct. 27 01.12.gif

To report this post you need to login first.

20 Comments

You must be Logged on to comment or reply to a post.

  1. Savaridasan P

    Hi Samantak,

    Thanks you for the great effort on this document sharing. πŸ™‚

    I am getting error on the event UPLOAD_POPUP_CLOSED

    ERROR:

    Type “CGTGDT_BUPA_DESC” is unknown  

    can u suggest wht the type to be. Thanking you

    cheers,

    Das

    (0) 
    1. Samantak Chatterjee Post author

      Hi Savaridasan,

      Thanks for referring the above mentioned document and getting some help from it.

      Regarding the error, it is due to the DDIC Object Table Type CGTGDT_BUPA_DESC. This is a local table type from my system. You need to replace it with the local table type from your system e.g. ZBUPA_UPLOAD.

      I will modify the post accordingly.

      Thanks for pointing it out.

      Let me know if you face some other issues.

      Thanks,
      Samantak.

      (0) 
      1. Savaridasan P

        Hi Samantak,Thank so much for your help,

        I tried coding like this below..in local types

        TYPES:
        BEGIN OF cgtgds_bupa_desc,
                      partner TYPE bu_partner,
                      partner_desc TYPE bu_descrip_long,
        END OF cgtgds_bupa_desc.

        and for l_i_bp, l_wa_bp is this correect?

        Data:

        l_i_bp                  TYPE TABLE OF  cgtgds_bupa_desc,
        l_wa_bp                 TYPE    cgtgds_bupa_desc,

        The excel – csv file data is like below,

        when i test to upload from excel – csv file the output is like this below snapshot

        The description text is not assigning to the correct tab..i tried changing the attributes in the split code..but same..can u help me in this..

        Thanking you,

        Das

        (0) 
        1. Samantak Chatterjee Post author

          Hi Savaridasan,

          The types definition is correct but what I have suggest here is just an example. You can also add your own fields.

          TYPES : BEGIN OF l_ty_bupa,

                         partner           TYPE bu_partner,

                        partner_desc TYPE bu_descrip_long,

                         first_name      TYPE bu_name,

                             END OF l_ty_bupa.

          And yes. Your work area and the internal tables are correct. You can changes the naming convention to adjust your requirement like lt for local types and gt for global types.

          Now, for the excel – this is not correct. The excel should only contain the Business Partner Numbers in seperate rows like as shown below

                   ScreenHunter_17 Nov. 01 02.48.gif

          The business partners should already be existing in the system. Then based on the existing BP’s the descriptions will be retrieved and then they will be populated in the local structure and will be added to the Business Object Collection.

          ScreenHunter_18 Nov. 01 02.50.gif

          CREATE DATA l_v_struct_ref.

                      ASSIGN l_v_struct_ref->* TO <l_fs_wa_data>.

                      <l_fs_wa_data>-partner_id =  l_wa_bp-partner.

                      <l_fs_wa_data>-partner_descr =  l_wa_bp-partner_desc.

                      CREATE OBJECT l_o_value_node

                        EXPORTING

                          iv_data_ref = l_v_struct_ref.

                      l_if_bo_coll->add( l_o_value_node ).

          Hope this will help and will clear your issues with the coding.

          Let me know if you still have some more issues or concerns.

          Thanks,

          Samantak.

          (0) 
          1. Savaridasan P

            Hi Samantak,

            Thank you so much for the explanation..understood πŸ™‚

            Got the result. 😎   Samantak, wish u to contribute more Helpful Post like this further 😎

            Best Wishes πŸ™‚

            Cheers,

            Das

            (0) 
            1. Samantak Chatterjee Post author

              Hi Savaridasan,

              Thanks a lot for you comments and suggestions based on which I modified some of the code.

              Feeling good that it was of some help to you.  πŸ™‚

              Thanks a lot. πŸ™‚

              Best Regards,

              Samantak.

              (0) 
  2. nagaraju k

    Hi Experts,

    I have the same requirement but not thru WebUI, its from GUI.

    I need to create BP(Sold-to-party) from report program, need to upload excel file into internal table in CRM GUI not thru CRM WebUI.

    I couldn’t find any function module related to upload excel file into internal table in CRM.

    Please help me.

    Regards,

    Nagaraju

    (0) 
    1. LuΓ­s PΓ©rez Grau

      Hi Nagraju,

      Have you check the abap2xls project?

      http://wiki.scn.sap.com/wiki/display/ABAP/abap2xlsx

      If you have the option to convert the xlsx to a flat file with tab separators or a csv file you can use wide know CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD static method.

      this two options are the most cross plaform, because there are other FM which can upload excel direclty but some are related to some ECC module, so you probably won’t have it on your CRM.

      Cheers!

      Luis

      (0) 
    1. Samantak Chatterjee Post author

      Hi Assaf,

      Can you let me know more on the type of error you got regarding the View EXUPD2. Also, it would be really great if you can add some photographs or screen shots.

      Thanks in advance.

      Best Regards,

      Samantak.

      (0) 
  3. Joanem Assaf

    Hi Samantak,

    My problem is the “Upload” Button actions not enable component GS_FILE_UPLOAD. Now add it to ID “CuFileUpload” in MainWindow.

    Can you help me!

    Thanks.

    (0) 
  4. Achu C

    Hi Samantak,

    Thanks for the document.. it is helping me to solve my req.

    I referred the doc to upload excel to service contract item list assignment block.

    I followed all the steps mentioned above and modified according to my req.

    am getting upload button and popup to select file, but after selection and press upload there is no data coming to my view.

    here is the code..

    METHOD EH_ONUPLOAD_POPUP_CLOSED.

    * Added by wizard: Handler for event ‘upload_popup_closed’

       TYPES: BEGIN OF L_TY_ATTR_STRUCT,

                   NUMBER_INT TYPE CRMT_ITEM_NO,

                   NUMBER_PARENT TYPE CRMT_ITEM_NO_PARENT,

                   ORDERED_PROD TYPE CRMT_ORDERED_PROD_DB,

                   QUANTITY TYPE CRMT_SCHEDLIN_QUAN,

                   UNIT TYPE CRMT_PROCESS_QTY_UNIT,

                  END OF L_TY_ATTR_STRUCT.

       DATA:L_V_FILE_CONTENT        TYPE STRING,

            L_I_FILE_CONTENT        TYPE STRINGTAB,

            L_V_FILE_TYPE           TYPE STRING,

            L_V_FILE_NAME           TYPE STRING,

            L_O_OUTPUTNODE          TYPE REF TO CL_BSP_WD_CONTEXT_NODE,

            L_O_COLLECTION_WRAPPER  TYPE REF TO CL_BSP_WD_COLLECTION_WRAPPER,

            L_IF_PROPERTY           TYPE REF TO IF_BOL_BO_PROPERTY_ACCESS,

            L_O_MSG_SERVICE         TYPE REF TO CL_BSP_WD_MESSAGE_SERVICE,

            L_I_BP                  TYPE TABLE OF L_TY_ATTR_STRUCT,

            L_WA_BP                 TYPE L_TY_ATTR_STRUCT,

    *       l_v_status              TYPE zmember_status,

            L_O_ENTITY              TYPE REF TO CL_CRM_BOL_ENTITY,

            L_I_RETURN              TYPE BAPIRET2_T,

            L_WA_RETURN             TYPE BAPIRET2,

            L_V_STRUCT_REF          TYPE REF TO CRMST_ADMINI_BTIL,

            L_O_VALUE_NODE          TYPE REF TO CL_BSP_WD_VALUE_NODE,

            L_IF_BO_COLL            TYPE REF TO IF_BOL_BO_COL,

            L_V_FIRED_PLUG          TYPE        SEOCMPNAME.

       FIELD-SYMBOLS: <FS_FILE_CONTENT> TYPE STRING,

                      <L_FS_WA_DATA>  TYPE CRMST_ADMINI_BTIL.

       L_V_FIRED_PLUG = CI_IF_POPUP->GET_FIRED_OUTBOUND_PLUG( ).

       CASE L_V_FIRED_PLUG.

         WHEN ‘leave’.

    *       get results of popup

           L_O_OUTPUTNODE ?= CI_IF_POPUP->GET_CONTEXT_NODE( ‘FILE’ ). “#EC NOTEXT

           L_O_COLLECTION_WRAPPER = L_O_OUTPUTNODE->GET_COLLECTION_WRAPPER( ).

           L_IF_PROPERTY           = L_O_COLLECTION_WRAPPER->GET_CURRENT( ).

           CALL METHOD L_IF_PROPERTY->GET_PROPERTY_AS_VALUE

             EXPORTING

               IV_ATTR_NAME = ‘FILE_CONTENT_TYPE’                “#EC NOTEXT

             IMPORTING

               EV_RESULT    = L_V_FILE_TYPE.

           CALL METHOD L_IF_PROPERTY->GET_PROPERTY_AS_VALUE

             EXPORTING

               IV_ATTR_NAME = ‘FILE_NAME’                        “#EC NOTEXT

             IMPORTING

               EV_RESULT    = L_V_FILE_NAME.

    *       Check the MIME file type and the file extension

           IF ( L_V_FILE_TYPE CP ‘text/plain’ )

             OR ( L_V_FILE_TYPE CP ‘text/comma-separated-values’ )

             OR ( L_V_FILE_TYPE CP ‘application/vnd.ms-excel’ AND L_V_FILE_NAME CP ‘*.csv’ ) “#EC NOTEXT

             OR ( L_V_FILE_TYPE CP‘application/vnd.openxmlformats-officedocument.spreadsheetml.sheet’ ).

             CALL METHOD L_IF_PROPERTY->GET_PROPERTY_AS_VALUE

               EXPORTING

                 IV_ATTR_NAME = ‘FILE_CONTENT_STRING’            “#EC NOTEXT

               IMPORTING

                 EV_RESULT    = L_V_FILE_CONTENT.

             IF L_V_FILE_CONTENT IS  INITIAL.

               L_O_MSG_SERVICE ?= ME->VIEW_MANAGER->GET_MESSAGE_SERVICE( ).

               L_O_MSG_SERVICE->ADD_MESSAGE( IV_MSG_TYPE       = ‘E’

                                            IV_MSG_ID         = ‘CRM_UI’

                                            IV_MSG_NUMBER     = ‘030’ ). “#EC NOTEXT

               EXIT.

             ENDIF.

             IF  ME->TYPED_CONTEXT->BTADMINI->COLLECTION_WRAPPER IS BOUND.

               ME->TYPED_CONTEXT->BTADMINI->COLLECTION_WRAPPER->CLEAR( ).

             ENDIF.

    *   Split filecontent into separate lines and store them in table

             SPLIT L_V_FILE_CONTENT AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE L_I_FILE_CONTENT.

             CLEAR L_V_FILE_CONTENT.

    *   Remove empty lines from filecontent table and store on value node

             LOOP AT L_I_FILE_CONTENT ASSIGNING <FS_FILE_CONTENT>.

               IF NOT <FS_FILE_CONTENT> IS INITIAL.

                 SPLIT <FS_FILE_CONTENT> AT ‘,’ INTO L_WA_BP-NUMBER_INT L_WA_BP-NUMBER_PARENT L_WA_BP-ORDERED_PROD.

    *            L_WA_BP-NUMBER_INT = <FS_FILE_CONTENT>-NUMBER_INT.

    *            L_WA_BP-NUMBER_PARENT = <FS_FILE_CONTENT>-NUMBER_PARENT.

    *            L_WA_BP-ORDERED_PROD = <FS_FILE_CONTENT>-ORDERED_PROD.

                 APPEND L_WA_BP TO L_I_BP.

               ENDIF.

             ENDLOOP.

             IF L_I_BP[] IS NOT INITIAL.

               CREATE OBJECT L_IF_BO_COLL TYPE CL_CRM_BOL_BO_COL.

               IF L_IF_BO_COLL IS BOUND.

                 L_IF_BO_COLL->SET_MULTI_SELECT( ABAP_TRUE ).

               ENDIF.

               LOOP AT L_I_BP INTO L_WA_BP.

    *            REFRESH L_I_RETURN.

    *            CALL FUNCTION ‘BUPA_DESCRIPTION_GET’

    *              EXPORTING

    *                IV_PARTNER          = L_WA_BP-PARTNER

    *              IMPORTING

    *                EV_DESCRIPTION_LONG = L_WA_BP-PARTNER_DESC

    *              TABLES

    *                ET_RETURN           = L_I_RETURN.

    *

    *

    *            IF L_I_RETURN IS NOT INITIAL.

    *              CLEAR L_WA_RETURN.

    *              READ TABLE L_I_RETURN INTO L_WA_RETURN WITH KEY TYPE = ‘E’.

    *              IF SY-SUBRC = 0.

    *                L_WA_BP-PARTNER_DESC = L_WA_RETURN-MESSAGE.

    *              ENDIF.

    *            ENDIF.

    *

    *

                 CREATE DATA L_V_STRUCT_REF.

                 ASSIGN L_V_STRUCT_REF->* TO <L_FS_WA_DATA>.

                 <L_FS_WA_DATA>-NUMBER_INT =  L_WA_BP-NUMBER_INT.

                 <L_FS_WA_DATA>-NUMBER_PARENT =  L_WA_BP-NUMBER_PARENT.

                 <L_FS_WA_DATA>-ORDERED_PROD =  L_WA_BP-ORDERED_PROD.

    *            <L_FS_WA_DATA>-PARTNER_DESCR =  L_WA_BP-PARTNER_DESC.

                 CREATE OBJECT L_O_VALUE_NODE

                   EXPORTING

                     IV_DATA_REF = L_V_STRUCT_REF.

    *

    *

    *

    *

                 L_IF_BO_COLL->ADD( L_O_VALUE_NODE ).

                 L_IF_BO_COLL->IF_BOL_BO_COL_MULTI_SEL~MARK( EXPORTING IV_BO = L_O_VALUE_NODE ).

                 UNASSIGN <L_FS_WA_DATA>.

               ENDLOOP.

             ENDIF.

    *        ENDIF.

             ME->TYPED_CONTEXT->BTADMINI->COLLECTION_WRAPPER->SET_COLLECTION( L_IF_BO_COLL ).

             ME->TYPED_CONTEXT->BTADMINI->COLLECTION_WRAPPER->PUBLISH_CURRENT( ).

           ELSE.

    *         We assume an incorrect file type: it’s neither a plain text file nor a .csv file

    *         Therefore -> raise an error message

             L_O_MSG_SERVICE ?= ME->VIEW_MANAGER->GET_MESSAGE_SERVICE( ).

             L_O_MSG_SERVICE->ADD_MESSAGE( IV_MSG_TYPE       = ‘E’

                                          IV_MSG_ID         = ‘CRM_UI’

                                          IV_MSG_NUMBER     = ‘018’ ). “#EC NOTEXT

           ENDIF.

         WHEN OTHERS.

       ENDCASE.

    ENDMETHOD.

    Capture.PNG

    am uploading……

    number_int

    number_parent

    ordered_prod

    from excel(*.csv)

    Capture1.PNG

    please help me on this…

    thanks,

    vinnu.

    (0) 
    1. Samantak Chatterjee Post author

      Hi Vinnu,

      I checked your code and it looked fine. Can you put a break point at the follwoing place and check if the data is coming properly.

      CALL METHOD L_IF_PROPERTY->GET_PROPERTY_AS_VALUE

                 EXPORTING

                   IV_ATTR_NAME = ‘FILE_CONTENT_STRING’            “#EC NOTEXT

                 IMPORTING

                   EV_RESULT    = L_V_FILE_CONTENT.

      Next check the following lines

      SPLIT L_V_FILE_CONTENT AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLEL_I_FILE_CONTENT.


      SPLIT <FS_FILE_CONTENT> AT ‘,’ INTO L_WA_BP-NUMBER_INT L_WA_BP-NUMBER_PARENT L_WA_BP-ORDERED_PROD.


      Is the content getting populated properly ? I need the screenshots of the above mentioned codes.


      I will also try to paste the code in my system and try to replicate the scenario if I have time.


      Thanks in advance.


      Best Regards,

      Samantak Chatterjee.

      (0) 
      1. Achu C

        Hi Samantak,

        Thanks for your prompt reply.

        I checked in debugging, data populating in above mentioned lines.

        please find the screenshots../wp-content/uploads/2015/04/1_689018.png

        /wp-content/uploads/2015/04/4_689019.png

        /wp-content/uploads/2015/04/5_689020.png

        /wp-content/uploads/2015/04/7_689022.png

        /wp-content/uploads/2015/04/8_689023.png

        /wp-content/uploads/2015/04/10_689026.png

        and the .csv file is /wp-content/uploads/2015/04/11_689027.png

        and .htm code also modified according to my req. as already some buttons are there in the view please find in first screen shot( I also tried same code you mentioned in the doc, but my prvious buttons getting disappear and also data is not coming to view)

        <%@page language=”abap” %>
        <%@extension name=”chtmlb” prefix=”chtmlb” %>
        <%@extension name=”thtmlb” prefix=”thtmlb” %>
        <%@extension name=”bsp” prefix=”bsp” %>
        <%
        data:lv_cellerator_selectionmode type string,
             lv_cellerator_editmode type string,
             lv_cellerator_selectioncolumn type string.
             BTADMINI->set_selection_mode( BTADMINI->SELMODE_MULTI ).
        cl_thtmlb_util=>translate_selection_mode(
        exporting
          iv_selection_mode = BTADMINI->SELMODE_MULTIEDIT
          iv_all_rows_editable = ‘X’
        importing
          ev_selection_mode = lv_cellerator_selectionmode
          ev_edit_mode      = lv_cellerator_editmode
          ev_selection_column = lv_cellerator_selectioncolumn ).
        %>
        <thtmlb:button id = “Click”
                       onClick = “UPLOAD”
                       text    = “Upload” />
        <thtmlb:button id = “Clear”
                       onClick = “CLEAR”
                       text    = “Clear” />

        <thtmlb:areaFrameSetter toolbarButtons  = “<%= controller->gt_button_tib %>”
                                maxButtonNumber = “3”
                                displayMode     = “<%= controller->view_group_context->is_view_in_display_mode( controller ) %>” />

        <chtmlb:tableExtension tableId = “Table”
                               layout  = “NORMAL” >
          <chtmlb:configTable actions               = “<%= controller->gt_button %>”
                              actionsMaxInRow       = “5”
                              id                    = “Table”
                              onRowSelection        = “select”
                              table                 = “//BTAdminI/Table”
                              width                 = “100%”
                              selectedRowIndexTable = “<%= BTAdminI->SELECTION_TAB %>”
                              selectionMode         = “<%= BTAdminI->SELECTION_MODE %>”
                              allRowsEditable       = “TRUE”
                              visibleRowCount       = “10”
                              visibleFirstRow       = “<%= BTAdminI->VISIBLE_FIRST_ROW_INDEX %>”
                              displayMode           = “<%= controller->view_group_context->is_view_in_display_mode( controller ) %>”
                              usage                 = “ASSIGNMENTBLOCK”
                              personalizable        = “TRUE”
                              downloadToExcel       = “TRUE” />
        </chtmlb:tableExtension>

        thanks,

        vinnu.

        (0) 
        1. Achu C

          Hi Samantak,

          any help on above issue….

          I couldn’t find the problem in the code. In my exploration, my excel data set to “btadmini”

          in “upload_popup_closed” event. but after that do_prepare_output is being triggered and there its calling btadmini into lr_cn.

          DATA: lr_cn TYPE REF TO cl_bsp_wd_context_node_tv.

          ***

             lr_cn ?= get_context_node( gc_context_node_admini ).

          in upload_popup_closed event entities are type cl_bsp_wd_value_node.

          but here in do_prepare_output  entities should be in cl_crm_bol_entity. because this reason my excel data not coming into  do_prepare_output..?

          I dont know whether my thinking is right or wrong.

          how to convert value node to bol entity…?

          thanks in advance..

          (0) 
          1. Samantak Chatterjee Post author

            Hi Vinnu,

            A couple of quick doubts. Why do you need to put code in DO_PREPARE_OUTPUT Method ?

            In the event Popup Close, you need to create the Value node and then set the collection. Automatically, it will populate the context node. Also, you don’t need to populate the model node.

            Even I used this code in one of my projects and found the same is working fine. Only limitation is regarding the usage of CSV File.

            Hope I’m able to provide some input here. Can you provide the entire code and the same data in the file. I can create a Z Component and try to replicate the entire scenario.

            Hope this helps.

            Thanks,

            Samantak.

            (0) 
            1. Achu C

              Hi samantak,


              Thanks for quick reply..

              No. I didn’t write any code in do_prepare_output. I am talking about standard one… After excel data set to btadmini successfully in upload_popup_closed event then cursor moves to do_prepare_output(standard, not enhanced). Our data should populate in lr_cn which is the type of cl_bsp_wd_context_node_tv in do_prepare_output

              If data is not flown through do_prepare_output.. How it can be populate in the items view… Correct me if I am wrong…..

              I provided entire code which I have written in my last update with csv file screenshot.. I written the code in itemslist.htm, eh_onupload, eh_onupload_popup_close . Only..

              My req is to add excel data to itemlist assignment block which has bol entity “btadmini” not to ddic structure( z table) ..



              Thanks in advance..

              (0) 
              1. Samantak Chatterjee Post author

                Hi Vinnu,

                If your requirement is to add excel data to a BOL Entity node then you need to follow a little bit different approach. The data extraction logic will remain the same. But the way you populate the node will not be the same. The BTADMINI is a model node and hence the best way to populate would be to use the GENIL Class if possible.

                You can probably check the multiple components available and check the code base from them. I will try to code some thing and provide the input here.

                Hope this helps.

                Thanks,

                Samantak Chatterjee.

                (0) 

Leave a Reply