Skip to Content

In the Execute BW query using ABAP Part I we have seen how to

execute BW query using ABAP. Now in this part we will see how the result in XML

format can be transformed to internal table format and also sample code for

testing the whole solution.

<!column ><xsl:apply-templates/></column>

<xsl:copy>

    <xsl:apply-templates select=”@||text()”/>

 

<!column ><xsl:apply-templates/></column>

<xsl:copy>

    <xsl:apply-templates select=”@||text()”/>

 

To report this post you need to login first.

41 Comments

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

  1. Deepu Sasidharan
    Hi Raja,

    This is really great stuff.

    Can we get the PDF o/p of the query result. I have seen your related articles in the BSP forum, can we use the smart forms functionality along with BW to get the PDF o/p. Also have you tried XSL FO which can produce PDF o/p.

    Thanks.

    -Deepu

    (0) 
    1. Durairaj Athavan Raja Post author
      Hi Deepu,

      thanks for the comments.
      Now that the query results are in a internal table you could generate PDF either using OTF to PDF (Smart form) or spool to PDF.

      I haven’t tried XSL FO. Thats my next target, i will post the results once its done.

      Regards
      Raja

      (0) 
  2. Mike Gliebe
    Raja,  very nice.  I was wondering if it would be possible to make the FM RFC enabled?  We have a need to query data in BW from an R/3 system via ABAP.  Do you have any thoughts on this.  Thanks.
    (0) 
    1. Durairaj Athavan Raja Post author
      Should not be a problem. Just RFC enable the FM. But the calling system has to be on WAS so that you can use XSLT to parse the resulting XML into itab.

      Regards
      Raja

      (0) 
    1. Durairaj Athavan Raja Post author
      Hi Sheetal,

      Thanks for your comments.

      Its really difficult to address your question with the given explanation. If you just debugg the FM, you yourself will easily resolve the issue.

      Regards
      Raja

      (0) 
      1. Sheetal Pisolkar
        Sorry for not been clear enough about my problem.
        The values of wa_set-chavl is what i was looking for.
        Thanks again your weblog was very helpful.

        Regards,
        Sheetal.

        (0) 
  3. P Apurva
    Hi raja,

             This is really fantastic. Is it also possible to run a query view using abap and get the XML result?

    Cheers,
    Apurva

    (0) 
    1. Durairaj Athavan Raja Post author
      Yes. but needs little modification.

      The following method will give the view definition.
      CALL METHOD cl_rsz_www_db_interface=>get_view

      this would also return the query of the view.

      Get the query name and then create instance of  cl_rsr_request like below.

        CREATE OBJECT r_request
        EXPORTING i_genuniid = p_genuniid .

      I have checked some of the standard code of SAP this is what they are doing.

      For example you can check out the code at
      IF_SOAP_APPLICATION_RT~EXEC_PROCESSING

      Hope this helps.

      Regards
      Raja

      (0) 
    1. Durairaj Athavan Raja Post author
      Thanks for your concerns.
      Are you talking about the BAPI methods of ODBO Reporting? (using MDX). My knowledge of MDX is very poor and transaction MDXTEST dosent help much in generating the required MDX statements.

      The solution talked here is a pure custom one. Which uses the standard classes/methods.

      The closest FM which i found doing this kind of processing is RRW3_GET_QUERY_VIEW_DATA.

      It would be really helpful for us if you could give us the BAPI names which can be used for getting data from query.

      Regards
      Raja

      (0) 
    2. Mahesh Madhavan
      Dear Michael,

      You have left us in a cloud of confusion! Please reveal the names of those released BAPIs you were talking about.

      Thank you for your time.

      Regards,
      Mahesh M.S.

      (0) 
    1. Durairaj Athavan Raja Post author
      I am on a training course for next 5 days. As i have to simulate your case to see whats going wrong, it would take sometime. In the meantime, you can just debugg and see whats going wrong.

      Regards
      Raja

      (0) 
      1. Durairaj Athavan Raja Post author
        Luckily i was able to spare some time. I have simulated the scenario where i had 0costcenter in one column and a structure for plan/actual/variance colummns. This works fine. i didnt face the problem you are referring to. The only way out is to debugg.

        Regards
        Raja

        (0) 
    1. Durairaj Athavan Raja Post author
      this is very well handled in the FM. if you look at the code in the Y_EXECUTE_QUERY FM we created from PART I, when i build the meta table , i get the OUTPUTLEN from BAPI_IOBJ_GETDETAIL.
      the details structure returned by this BAPI gives me the right output length. we also have exactly the same scenario (coarea/costcenter)(4+6). this works very well.

      Can you debug and see whats going wrong?

      Regards
      Raja

      (0) 
    2. Anonymous
      Could you fix your problem? If so, could you please help me, what to do to fix this problem?

      Best Regards
      Stefan

      (0) 
  4. Bharat Patel
    Dear Raja

    This is really wonderful and also useful. I tried with very simple query and it worked fine. Now the query which i am trying to download has 2 dates and it is not extracting properly.

    Could you please guide on this.

    Thanks in advance.
    Bharat

    (0) 
    1. Durairaj Athavan Raja Post author
      hi Bharat,

      It should not be a problem, i guess i have tested this scenario as well. Anyhow can you tell me what exactly happenning- what is meant by not extracting properly.

      why dont you just debugg and see where it goes wrong.

      Regards
      Raja

      (0) 
      1. Bharat Patel

        Hi Raja<br/><br/>Thanks for reply. I did some amount of debugging abd found that it reads dates properly from query byt while assigning it assigns 10 digits to 8 digits and makes a mess of data.<br/>According to me following code is not working properly on my side..Bharat

        (0) 
  5. nikhil kelkar

    Hello,<br/>     I am a beginer in XSLT programming. I was reading SAP given transformation STRANSDEMO_FLIGHTS_A2X in was 6.4. Here i was not able to get following statement<br/><xsl:for-each select=”asx:abap[1]/asx:values[1]/FLIGHT_LIST[1]/*”><br/>I know that xsl:for-each select is for loop but<br/>wats the output of line <br/>asx:abap[1]/asx:values[1]/FLIGHT_LIST[1]<br/>also here why they have used index .<br/>Even in the example given by you , you have used similar index notation. what is the significance of this.<br/>      Also Sir, I tried to understand xslt through SAP help but as there is not proper documentation for each tag , I wasn’t able to understand to greater extent. If you have any better documentation about xslt then please provide the same.<br/>      Thank you.     

    (0) 
      1. nikhil kelkar

        Hello sir,<br/>         Thank you for the reply. I am already reading the documentation given in the link  specified by you. <br/><br/>In the statement below<br/><xsl:for-each select=”asx:abap[1]/asx:values[1]/FLIGHT_LIST[1]/“><br/>as we use <xsl:for-each select for loop,<br/>why do we need to need to specify the first line of the table . why cant we simply say /FLIGHT_LIST instead of /FLIGHT_LIST[1]/.<br/>also kindly let me know the significance of prefix asx:abap[1]/asx:values[1]. I know that they are used for accessing abap data but why do we require index in this case.<br/>Awaiting for the favourable response.<br/><br/><br/><br/><br/><br/>   

        (0) 
  6. Ramkumar Valluru
    Hi,
    I want to display the BI report data in bsp or webdynpro abap which is in arabic language.The BI system doesn’t support the non-unicode.so i have to get that report data into unicode sytem in webdynpro or bsp and encode that data and pass to Bi system.
    Is there any functionmodule to encode the data?
    How to display that report data in bsp and which UI element support the Browser.

    Please help me in the same.

    Thanking you in advacne..

    (0) 
  7. Vaibhav Kwatra
    Hi Raja,

    My query is regarding the parameters we are passing to the FM.

    According to the requirement, I have to execute a BI query from CRM system. So I was planning to use the RFC RRW3_GET_QUERY_VIEW_DATA. I have the query name also the variable names. The mandatory parameters to execute the query has multiple values. So my doubt here is it possible to pass the multiple values for a single variable to the input parameter  I_T_PARAMETER of the FM RFC RRW3_GET_QUERY_VIEW_DATA. Please share your thoughts/input.

    (0) 
  8. Richard Gordon
    I don’t know much about ABAP but have been trying to follow this example. I don’t understand how to test it. What am I supposed to do with the last piece of code? Create another FM and run that? I also don’t understand how that ties in with the XSLT Program.

    I know this is an old topic but any help would be appreciated

    Richard

    (0) 
  9. Mahesh Madhavan
    Dear Durairaj,

    I’m delighted to find that a way exists for reading BW query using ABAP. Now my doubt is, can a BW Workbook be also extracted, just as in the case of a BW query, using ABAP?

    I have been looking all over, but nobody could crack this.

    Thank you for your time.

    Regards,
    Mahesh M.S.

    (0) 
      1. Mahesh Madhavan
        Dear Durairaj,

        Thank you so much for your reply!

        In fact I’ve used a function module RRMX_WORKBOOK_READ to read the above mentioned table for getting the workbook contents. But it’s there in a binary format. So using neither the FM nor reading the table directly will make any difference.

        Could you please suggest a way to convert this binary format to the readable format? The conventional FMs for doing this, provided SAP is not yielding any result.

        Thank you again, for you time.

        Regards,
        Mahesh M.S.

        (0) 
        1. Durairaj Athavan Raja Post author
          Dear Mahesh,

          Sorry for the delayed reply. What do you want to do with the read workbook content, open in excel? from where an ABAP program or web app? In my case i have a BSP page which lists the workbook and on clicking it will open the particular workbook in excel. Is this something you would like to do ?

          (0) 
          1. Mahesh Madhavan
            Dear Durairaj,

            Thank you for your reply.

            My requirement is to extract the workbook contents into an internal table, just as it appears in the workbook. Is there really a way to do so?

            All my research regarding the extraction of data from a BW workbook into an internal table has so far been futile.

            Is there really a way out?

            Thank you for your time.

            Regards,
            Mahesh M.S.

            (0) 

Leave a Reply