cancel
Showing results for 
Search instead for 
Did you mean: 

Publishing and Consuming Query Webservice - Query_View_Data

Former Member
0 Kudos

Hi Experts,

I have set up "Query_View_Data" taking reference from Weblog

/people/prakash.darji/blog/2006/09/04/work-with-xmla-web-service-for-bi-data-in-external-applications --> Document : Web Services within SAP NetWeaver 2004s BI - Create, Discover, and Consume! --> Page Nos. 26 to 42.

I am able to test my Query Webservice from my BW system using transaction WSADMIN & the Request as well as Response are successful.

Now I am trying to create a Visual Composer - iView.

In this iView, I am trying to define the webservice (Tools --> Define Webservice).

The URL which I enter for the webservice is :

http://<Server>:<Port>/sap/bw/xml/soap/queryview?wsdl

Port I am using same as my VC / EP Port.

I am getting an Error Message : Invalid Webservice URL

Am I missing anything ?

Please suggest.

Thanks and regards - Rajesh Sarin (09987014089)

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I am trying to use "GetQueryViewData" Method to consume my BI Query Data as a Webservice within a VC Model.

Refering to my earlier post, we did the Port Settings in Visual Administrator for the WS URL : http://<server>:<port>/sap/bc/srt/rfc/sap/QUERY_VIEW_DATA?sap-client=100&wsdl=1.1

After this in Visual Composer Model, I am trying to create an iView and then now I am able to find the BI Query "GetQueryViewData" WebService in "Find Data Services".

But when I drag this "GetQueryViewData" webservice to VC iView, I get an error message :

===========================================================

Failed to Fetch MetaData : Portal Request Failed due to : Cannot Import the selected operation. Mandatory Port AxisData includes nested tables which are not presently supported by Visual Composer.

===========================================================

For this Webservice using Method "GetQueryViewData", when it is executed, would ask for the Input Parameters - InfoProvider, Query, ViewId, Parameter and then it gives the result of the BI Query with Output Parameters as AxisData, AxisInfo, CellData, TextSymbols.

Question : Can we Model in Visual Composer using Webservice - "GetQueryViewData" Method ?

Thanks a lot for the time / help extended, in advance.

regards,

Rajesh Sarin (+91-9987014089)

Former Member
0 Kudos

Hi Experts,

In one of the SDN Articles - “Consuming a BI Web Service via the Portal – a Practical Application”, link :

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6c94707f-0d01-0010-c199-e00532e6...

Page 42 of this article for VC (SP8) mentions :

• If the nested table is a mandatory field – the operation can not be used (error

message)

• If the nested table is an optional field – the table will be omitted (warning

message)

In case of BI WebService, we do encounter Mandatory Nested Tables (Fact - Dimension - SID - Master Data) and BI Queries would be using these Nested Tables.

Does that mean - VC cannot handle BI Web Service ?

=========================================

(Surely I do understand that if both BW and VC/EP are owned by the same company direct BI Connection is the best way. But, I am trying this approach with an assumption that my BW WebService is consumed by a Third Party VC / EP to whom I am allowing limited access, and donot want him to have a direct BI Connection.)

regards,

Rajesh Sarin

Former Member
0 Kudos

Why can't you use native SAP BI connectivity from VC to BI? This works much better than web services.

Former Member
0 Kudos

Thanks Deepu,

Surely I do understand that if both BW and VC/EP are owned by the same company direct BI Connection is the best way.

But, I am trying this approach with an assumption that my BW WebService is consumed by a Third Party VC / EP to whom I am allowing limited access, and donot want him to have a direct BI Connection.

regards,

Rajesh Sarin

Former Member
0 Kudos

Hi Experts,

My question is, if VC can handle BI Query WebService.

Reference :

Note 1004108 - Release Restrictions for SAP NetWeaver CE 7.1

Validity: valid since 30.09.2007

SAP NetWeaver Visual Composer: Certain complex structures in data services are not supported

Certain data services whose input or output ports contain nested structures with tables cannot be used for modeling in SAP NetWeaver Visual Composer. Please see attached document for a detailed description of such cases. Workaround: Do not use services that contain nested structures that contain tables in the input or output ports.

(Changed at 31.07.2007)

regards,

Rajesh Sarin

Former Member
0 Kudos

If you wanted to do thiss, you should write a wrapper around the queryviewdata web service in abap and create a new web service that renders a table output instead of the MDX based output... This would be a viable option.

Former Member
0 Kudos

Thanks a lot Mr Prakash. I will surely try your suggestion. Would it be possible to share the template or code sample for this purpose. Your personal support has been really a source of inspiration to try out newer approaches. Regards - Rajesh Sarin

Former Member
0 Kudos

Unfortuantely, I am no longer working on NW topics and don't have time to write something up. You can look at my weblog on Web SErvices which has some sample javascript. You could replicate this logic in ABAP.

Former Member
0 Kudos

Thanks Mr Prakash.

Former Member
0 Kudos

Hi,

I have created a Z-FunctionModule as a wrapper for Function Module RRW3_GET_QUERY_VIEW_DATA. From the output of this RRW3_GET_QUERY_VIEW_DATA, I am reading the Axis Data and Cell Data and populating an internal table which has only 3 columns x-axis data, y-axis data and cell data. This is the query result.

I have created a Web-Service from this Z-Function Module. I am able to test the results of this Web-Service from the EP-WebServices Navigator.

Also created the Visual Administrator Settings for the Web-Service.

I am able to drag this Web-Service to my Visual Composer Model iView. Now when I test this Web-Service from VC iView, I am getting error message "Portal Request Failed (Could not execute Web-Service Operation).

Can you please help.

regards - Rajesh Sarin

Former Member
0 Kudos

Hi Rajesh,

You mentioned "I am reading the Axis Data and Cell Data and populating an internal table which has only 3 columns x-axis data, y-axis data and cell data". This is what I am trying to do.

I looked at content of E_AXIS_DATA but don't know how to match it with content from E_CELL_DATA. Could you kindly share me some hint?

For example, I intend to get

<b>Product OrderAmount</b>

[code]Phone $1.693,70

Phone $29,00

TV $859,62[/code]

But now I can only get “$1.693,70, $29,00”, don't know how to get the corresponding product info of the orderamount.

Thanks,

Ray

athavanraja
Active Contributor
0 Kudos

i have already written the wrapper for RRW3_GET_QUERY_VIEW_DATA

it works for almost all types of queries

ZBW_QUERY_OUTPUT_METADATA structure definition


FIELDNAME   type	LVC_FNAME
OUTPUTLEN  type	LVC_OUTLEN
DATATYPE    type	DATATYPE_D
SCRTEXT_L   type	SCRTEXT_L

top include

function-pool z_firp_eq_nu  message-id brain.
type-pools: rrx1 .
data: r_request type ref to cl_rsr_request.
data: r_dataset type ref to cl_rsr_data_set.
data: zcx_message type ref to cx_rsr_x_message.
data: zcx_root type ref to cx_root.
data: lcount type i .
data: xcount type i .
data: wa_var type rrx1_s_var.
data: i_var type rrx1_t_var.
data: i_var_final type rrx1_t_var.
data: wf_variant type variant .
data: wa_axis like line of r_dataset->n_sx_version_20a_1-axis_data .
data: wa_axis_info like line of r_dataset->n_sx_version_20a_1-axis_info .
data: wa_chars like line of wa_axis_info-chars .
data: tmp_char type rrws_thx_axis_chars.
data: wa_tmp_char type rrws_sx_axis_chars .
data: wa_attrinm type rrws_s_attrinm.

data: wa_cell like line of r_dataset->n_sx_version_20a_1-cell_data .
data: wa_textsymbols like line of r_dataset->n_sx_version_20a_1-txt_symbols .
data: wa_textsymbols1 like line of r_dataset->n_sx_version_20a_1-txt_symbols .
data: wa_set like line of wa_axis-set.
data: tmp_set type rrws_tx_set.
data: wa_tmp_set type rrws_sx_tuple .
data: wa_dattrinm type rrws_s_attributes .
data: i_iset_iobjnm type  rsd_iobjnm ,
      e_iobjnm type  rsd_iobjnm .

data: q_variables type rrxw3tquery .
  data: q_return like bapiret2 occurs 0 with header line .
  data: error_string type string.
  data: no_of_chars type  i ,
        no_of_keyf type i .
  data: var_nam(10) .
  data: iobj_detail like bapi6108 .
  data: iobj_details like bapi6108 occurs 0 with header line .
  data: it_fieldcat type lvc_t_fcat,
        is_fieldcat like line of it_fieldcat.
  data: new_table type ref to data.
  data: new_line  type ref to data.
  field-symbols: <ltable> type any table,
                 <l_line>  type any,
                 <l_field> type any.

  data: meta_data like zbw_query_output_metadata occurs 0 with header line .
  data: r_result type string .
  data: off  type i,
      moff type i,
      mlen type i.
  data: iobj_return like bapiret2 occurs 0 with header line .
  data: wf_ip type rsinfoprov ,
        wf_query type rszcompid .

  data: i_axis_info type  rrws_thx_axis_info ,
        i_cell_data type  rrws_t_cell ,
      i_axis_data type  rrws_thx_axis_data ,
      i_txt_symbols type  rrws_t_text_symbols .

data: stat_tab type zfi_qstat_fm .

  data: n_counter(3) type n .
  data: char_count type i .
  data: wf_fldnm(40) .

  data: struct_type type ref to cl_abap_structdescr,
tab_type type ref to cl_abap_tabledescr ,
      comp_tab type cl_abap_structdescr=>component_table,
      comp like line of comp_tab,
      dref type ref to data ,
      dref1 type ref to data ,
      op_len type i .

function module source code.

function z_execute_query_nu.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(QUERY_NAME) TYPE  CHAR50
*"  EXPORTING
*"     VALUE(XML_OUT) TYPE  STRING
*"     VALUE(META_OUT) TYPE  STRING
*"  TABLES
*"      QUERY_VARIABLES TYPE  RRXW3TQUERY
*"      RETURN STRUCTURE  BAPIRET2 OPTIONAL
*"      META STRUCTURE  ZBW_QUERY_OUTPUT_METADATA OPTIONAL
*"  EXCEPTIONS
*"      BAD_VALUE_COMBINATION
*"      USER_NOT_AUTHORIZED
*"      UNKNOWN_ERROR
*"      QUERY_NOT_FOUND
*"      NO_APPLICABLE_DATA
*"      INVALID_VARIABLE_VALUES
*"      NO_AUTHORITY
*"      ABORT
*"      INVALID_INPUT
*"      INVALID_VIEW
*"----------------------------------------------------------------------

* update custom stat table.

  clear stat_tab .
  call function 'CONVERSION_EXIT_GENID_INPUT'
    exporting
      input  = query_name
    importing
      output = stat_tab-query.

  stat_tab-mandt = sy-mandt .
*stat_tab-query = query_name .
  stat_tab-rdate = sy-datum .
  stat_tab-rtime = sy-uzeit .
  stat_tab-ruser = sy-uname .
  call function 'SOTR_SERV_TABLE_TO_STRING'
   exporting
     flag_no_line_breaks       = 'X'
*   LINE_LENGTH               =
*   LANGU                     = SY-LANGU
   importing
     text                      = stat_tab-comments
    tables
      text_tab                  = query_variables .

  modify zfi_qstat_fm from stat_tab .

  clear: wf_ip, wf_query .
  split query_name at '/' into wf_ip wf_query .
  clear :q_variables ,i_axis_info,i_cell_data,i_axis_data,i_txt_symbols.
  refresh: q_variables,i_axis_info,i_cell_data,i_axis_data,i_txt_symbols .

  q_variables[] = query_variables[] .

  call function 'RRW3_GET_QUERY_VIEW_DATA'
   exporting
     i_infoprovider                = wf_ip
     i_query                       = wf_query
*   I_VIEW_ID                     =
     i_t_parameter                 = q_variables
   importing
     e_axis_info                   = i_axis_info
     e_cell_data                   = i_cell_data
     e_axis_data                   = i_axis_data
     e_txt_symbols                 = i_txt_symbols
   exceptions
     no_applicable_data            = 1
     invalid_variable_values       = 2
     no_authority                  = 3
     abort                         = 4
     invalid_input                 = 5
     invalid_view                  = 6
     others                        = 7 .

  case sy-subrc .

    when 0 .
** find no. of key figures
      clear: lcount ,wa_axis , wa_axis_info .
      read table i_axis_data  into wa_axis with key axis = '000'  .
      if sy-subrc eq 0 .
        clear no_of_keyf .
        loop at wa_axis-set into wa_set .
          at new tuple_ordinal .

            no_of_keyf = no_of_keyf + 1 .
          endat .
        endloop .
        clear wa_set .
*        DESCRIBE TABLE wa_axis-set LINES no_of_keyf .
      endif .

** find number of characteristics
      read table i_axis_info  into wa_axis_info with key axis = '001'  .
      if sy-subrc eq 0 .
        clear no_of_chars .
        describe table wa_axis_info-chars lines no_of_chars .
      endif .

      clear : iobj_detail , iobj_details .
      refresh iobj_details .
      clear wa_axis_info .
* get chars. details
      read table i_axis_info  into wa_axis_info with key axis = '001'  .
      if sy-subrc eq 0 .
        clear wa_chars .
        refresh tmp_char .

        loop at wa_axis_info-chars into wa_chars .
          clear wa_tmp_char .
          move-corresponding wa_chars to wa_tmp_char .
          insert wa_tmp_char into table tmp_char.
          if not wa_chars-attrinm[] is initial .
            loop at wa_chars-attrinm into wa_attrinm .
              clear :wa_tmp_char-chanm , wa_tmp_char-caption .
              move: wa_attrinm-attrinm to wa_tmp_char-chanm ,
                    wa_attrinm-caption to wa_tmp_char-caption .
              insert wa_tmp_char into table tmp_char.
            endloop .
          endif .
        endloop .


        loop at tmp_char into wa_chars .
          clear off .
******** added on 01/01/2006

          clear :off, moff, mlen .
          find '___' in section offset off of
                 wa_chars-chanm .
*               MATCH OFFSET moff
*               MATCH LENGTH mlen.
          if sy-subrc eq 0 .
            clear : i_iset_iobjnm , e_iobjnm .
            move: wa_chars-chanm to i_iset_iobjnm .
            call function 'RSD_IOBJNM_GET_FROM_INFOSET'
              exporting
                i_iset_iobjnm       = i_iset_iobjnm
             importing
               e_iobjnm            = e_iobjnm
*   E_INFOSET           =
*   E_FIELDNM           =
*   E_UNINM             =
*   E_IOBJ_TEXT         =
*   E_T_IOBJ_CMP        =
             exceptions
               name_error          = 1
               no_field            = 2
               others              = 3 .

            clear wa_chars-chanm  .
            move: e_iobjnm to wa_chars-chanm .
*    off = moff + mlen .
*          SHIFT wa_set-chanm LEFT BY off PLACES .
          else.

************end of 01/01/2006

            find '__' in section offset off of
                   wa_chars-chanm
                   match offset moff
                   match length mlen.
            if sy-subrc eq 0 .
              off = moff + mlen .
              shift wa_chars-chanm left by off places .
            endif .
          endif . " two __ or three _
          clear: iobj_return .
          refresh : iobj_return .

          call function 'Z_BAPI_IOBJ_GETDETAIL'
            exporting
              version    = rs_c_objvers-active
              infoobject = wa_chars-chanm
            importing
              details    = iobj_detail.


          if  not iobj_detail is initial .
            move-corresponding iobj_detail to iobj_details .
            append iobj_details .
            clear iobj_details .
          else .
            move: wa_chars-chanm to iobj_detail-infoobject ,
                  wa_chars-caption to iobj_detail-textlong .
            move-corresponding iobj_detail to iobj_details .

            append iobj_details .
            clear iobj_details .

          endif .
          clear : iobj_detail .
        endloop .
      endif .

* build field cat. for building the itab
      clear: is_fieldcat, it_fieldcat .
      refresh : it_fieldcat .
      loop at iobj_details .
        is_fieldcat-fieldname = iobj_details-infoobject .
        if is_fieldcat-fieldname+0(1) eq '0' .
          shift is_fieldcat-fieldname left by 1 places .
        endif .
*        IF iobj_details-datatp = 'CHAR' .
*          is_fieldcat-datatype = iobj_details-datatp.
        is_fieldcat-outputlen = '130' .
*        ELSE .
        is_fieldcat-datatype = 'CHAR' . "iobj_details-datatp.
*          is_fieldcat-outputlen = iobj_details-outputlen .
*        ENDIF .

        is_fieldcat-scrtext_l = iobj_details-textlong.
        append is_fieldcat to it_fieldcat.
        clear : is_fieldcat .
      endloop .


      clear :n_counter, wa_axis .
      read table i_axis_data  into wa_axis with key axis = '000'  .
      if sy-subrc eq 0 .
        loop at wa_axis-set into wa_set .
          at new tuple_ordinal .

            n_counter = n_counter + 1 .

            concatenate 'VALUE' n_counter into is_fieldcat-fieldname .
            is_fieldcat-outputlen = '30'.
            is_fieldcat-datatype = 'CHAR'.
          endat .
          concatenate is_fieldcat-scrtext_l wa_set-caption into is_fieldcat-scrtext_l separated by  ` ` .

*        is_fieldcat-scrtext_l = wa_set-caption.
          at end of tuple_ordinal .
            shift is_fieldcat-scrtext_l left deleting leading ' ' .
            append is_fieldcat to it_fieldcat.
            clear : is_fieldcat .
          endat .

        endloop .
      endif .

      clear meta_data .
      refresh meta_data .
      loop at it_fieldcat into is_fieldcat .

        move-corresponding is_fieldcat to meta_data .
        append meta_data .
        clear: meta_data, is_fieldcat .
      endloop .

* create itab
      sort it_fieldcat by fieldname.
      delete adjacent duplicates from it_fieldcat comparing fieldname .
      clear: comp , comp_tab ,is_fieldcat .
      refresh comp_tab .

      loop at it_fieldcat into is_fieldcat .
        clear op_len .
        op_len = is_fieldcat-outputlen .
        comp-name = is_fieldcat-fieldname.
        comp-type = cl_abap_elemdescr=>get_c( op_len ).
        append comp to comp_tab.
        clear : is_fieldcat , comp .
      endloop .

      clear struct_type .

call method cl_abap_structdescr=>create
  exporting
    p_components = comp_tab
    p_strict     = cl_abap_structdescr=>false
  receiving
    p_result     =  struct_type .

*      struct_type = cl_abap_structdescr=>create( comp_tab ).
      clear tab_type .
      call method cl_abap_tabledescr=>create
        exporting
          p_line_type  = struct_type
          p_table_kind = cl_abap_tabledescr=>tablekind_std
*    P_UNIQUE     = ABAP_FALSE
*    P_KEY        =
*    P_KEY_KIND   = KEYDEFKIND_DEFAULT
        receiving
          p_result     = tab_type .

      create data dref1 type handle tab_type.

      assign dref1->* to <ltable>.

      create data dref type handle struct_type.

      assign dref->* to <l_line>.


*      CALL METHOD cl_alv_table_create=>create_dynamic_table
*        EXPORTING
*          it_fieldcatalog = it_fieldcat
*        IMPORTING
*          ep_table        = new_table.
*
*
** Create a new Line with the same structure of the table.
*      ASSIGN new_table->* TO <ltable>.
*      CREATE DATA new_line LIKE LINE OF <ltable>.
*      ASSIGN new_line->* TO <l_line>.


      clear :wa_axis , char_count , lcount, xcount.
      refresh tmp_set .
      loop at i_axis_data into wa_axis where axis = '001' .
        loop at wa_axis-set into wa_set .
          clear wa_tmp_set .
          move-corresponding wa_set to wa_tmp_set .
          insert wa_tmp_set into table tmp_set.
          if not wa_set-attributes[] is initial .
            loop at wa_set-attributes into wa_dattrinm .
              clear: wa_tmp_set-chanm , wa_tmp_set-chavl , wa_tmp_set-chavl_ext , wa_tmp_set-caption .
              move: wa_dattrinm-attrinm to wa_tmp_set-chanm ,
                    wa_dattrinm-attrivl to wa_tmp_set-chavl ,
                    wa_dattrinm-attrivl to wa_tmp_set-chavl_ext ,
                    wa_dattrinm-caption to wa_tmp_set-caption .

              insert wa_tmp_set into table tmp_set.
            endloop .
          endif .


        endloop .
      endloop .

      loop at tmp_set into wa_set .
        at new tuple_ordinal .
          if lcount gt 0 .
            lcount = lcount - 1 .
          endif .
          clear <l_line> .
        endat .
        clear off .
******** added on 01/01/2006

        clear :off, moff, mlen .
        find '___' in section offset off of
               wa_set-chanm .
*               MATCH OFFSET moff
*               MATCH LENGTH mlen.
        if sy-subrc eq 0 .
          clear : i_iset_iobjnm , e_iobjnm .
          move: wa_set-chanm to i_iset_iobjnm .
          call function 'RSD_IOBJNM_GET_FROM_INFOSET'
            exporting
              i_iset_iobjnm       = i_iset_iobjnm
           importing
             e_iobjnm            = e_iobjnm
*   E_INFOSET           =
*   E_FIELDNM           =
*   E_UNINM             =
*   E_IOBJ_TEXT         =
*   E_T_IOBJ_CMP        =
           exceptions
             name_error          = 1
             no_field            = 2
             others              = 3 .

          clear wa_set-chanm  .
          move: e_iobjnm to wa_set-chanm .
*    off = moff + mlen .
*          SHIFT wa_set-chanm LEFT BY off PLACES .
        else.

************end of 01/01/2006
          find '__' in section offset off of
                 wa_set-chanm
                 match offset moff
                 match length mlen.
          if sy-subrc eq 0 .
            off = moff + mlen .
            shift wa_set-chanm left by off places .
          endif .
        endif . " check three _ or two _

        if wa_set-chanm+0(1) eq '0' .
          shift wa_set-chanm left by 1 places .
        endif .
        assign component wa_set-chanm of structure <l_line> to <l_field>.
        if wa_set-chavl = '#' .
*            <l_field> =  wa_set-chavl_ext .
        else .
          concatenate wa_set-chavl_ext wa_set-caption into <l_field> separated by ' ' .
        endif .

        at end of tuple_ordinal .
          clear: xcount , char_count , n_counter .

          lcount = lcount + 1 .

          loop at i_cell_data into wa_cell from lcount .

            n_counter = n_counter + 1 .
            if n_counter gt no_of_keyf .
              exit .
            endif .

            concatenate 'VALUE' n_counter into wf_fldnm .
            assign component wf_fldnm of structure <l_line> to <l_field>.

            <l_field> = wa_cell-value .


          endloop .

          lcount = lcount + no_of_keyf .
          insert <l_line> into table <ltable>.

        endat .


      endloop .
      clear :xml_out, meta .
      refresh meta .

      meta[] = meta_data[] .
      call transformation (`ID`)
            source meta   = meta_data[]
                   output = <ltable>[]
            result xml xml_out.

    when 1 .
      raise no_applicable_data .
    when 2 .
      raise invalid_variable_values .
    when 3 .
      raise no_authority .
    when 4 .
      raise abort .
    when 5 .
      raise invalid_input .
    when 6 .
      raise invalid_view .
    when others .
      raise unknown_error .
  endcase .

endfunction.

Z_BAPI_IOBJ_GETDETAIL source (this is called in the main fm)

function z_bapi_iobj_getdetail.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(VERSION) LIKE  BAPI6108-VERSION DEFAULT 'A'
*"     VALUE(INFOOBJECT) LIKE  BAPI6108-INFOOBJECT
*"  EXPORTING
*"     VALUE(DETAILS) LIKE  BAPI6108 STRUCTURE  BAPI6108
*"     VALUE(RETURN) LIKE  BAPIRET2 STRUCTURE  BAPIRET2
*"  TABLES
*"      COMPOUNDS STRUCTURE  BAPI6108CM OPTIONAL
*"      ATTRIBUTES STRUCTURE  BAPI6108AT OPTIONAL
*"      NAVIGATIONATTRIBUTES STRUCTURE  BAPI6108AN OPTIONAL
*"      ATRNAVINFOPROVIDER STRUCTURE  BAPI6108NP OPTIONAL
*"      HIERARCHYCHARACTERISTICS STRUCTURE  BAPI6108HC OPTIONAL
*"      ELIMINATION STRUCTURE  BAPI6108IE OPTIONAL
*"----------------------------------------------------------------------
type-pools:rs ,rsa .
* Local data declarations
  data: l_msgv1            like sy-msgv1,
        l_msgv2            like sy-msgv2,
        l_msgv3            like sy-msgv3,
        l_s_dtel           type rsddtel,
        l_s_viobj          type rsd_s_viobj,
        l_t_iobj_cmp       type rsd_t_iobj_cmp,
        l_s_iobj_cmp       type rsd_s_iobj_cmp,
        l_t_atr            type rsd_t_atr,
        l_s_atr            type rsd_s_atr,
        l_s_atr_nav        type rsd_s_atr_nav,
        l_t_atr_nav        type rsd_t_atr_nav,
        l_s_bapi_iobj_cmp  like bapi6108cm,
        l_s_bapi_atr       like bapi6108at,
        l_s_bapi_atr_nav   like bapi6108an.

* Initialization
  clear: return,
         details.
  refresh: compounds,
           attributes,
           navigationattributes,
           atrnavinfoprovider,
           hierarchycharacteristics,
           elimination.


  call function 'RSD_IOBJ_GET'
    exporting
      i_iobjnm       = infoobject
      i_objvers      = version
    importing
      e_s_viobj      = l_s_viobj
      e_t_iobj_cmp   = l_t_iobj_cmp
      e_t_atr        = l_t_atr
      e_t_atr_nav    = l_t_atr_nav
    exceptions
      iobj_not_found = 1
      illegal_input  = 2
      others         = 3.
  if sy-subrc <> 0.
    l_msgv1 = infoobject.
    l_msgv2 = version.
    call function 'BALW_BAPIRETURN_GET2'
      exporting
        type   = rs_c_error
        cl     = rsa_c_rsar
        number = '316'
        par1   = l_msgv1
        par2   = l_msgv2
      importing
        return = return
      exceptions
        others = 0.
* Das InfoObject &1 existiert nicht in der Version &2
    exit.
  endif.

  move-corresponding l_s_viobj to details.
  details-infoobject = l_s_viobj-iobjnm.
  details-version    = l_s_viobj-objvers.
  details-type       = l_s_viobj-iobjtp.
  details-textshort  = l_s_viobj-txtsh.
  details-textlong   = l_s_viobj-txtlg.
*-- Add DDIC properties to InfoObject
  call function 'RSD_DTELNM_GET_FOR_IOBJ'
    exporting
      i_iobjnm   = l_s_viobj-iobjnm
    importing
      e_dtelnm   = l_s_dtel-dtelnm
    exceptions
      name_error = 1
      others     = 2.
  .
  if sy-subrc <> 0.
    l_msgv1 = 'Data element for InfoObject'.  "#EC NOTEXT
    l_msgv2 = l_s_viobj-iobjnm.
    l_msgv3 = 'does not exsist'.
    call function 'BALW_BAPIRETURN_GET2'
      exporting
        type   = rs_c_error
        cl     = rsa_c_rsar
        number = '051'
        par1   = l_msgv1
        par2   = l_msgv2
        par3   = l_msgv3
      importing
        return = return
      exceptions
        others = 0.
    exit.
  else.
    call function 'RSD_DTEL_GET'
      exporting
        i_dtelnm       = l_s_dtel-dtelnm
      importing
        e_s_dtel       = l_s_dtel
      exceptions
        dtel_not_found = 1
        doma_not_found = 2
        illegal_input  = 3
        others         = 4.
    .
    if sy-subrc <> 0 and version ne rs_c_objvers-delivery.
      l_msgv1 = 'Data element'.       "#EC NOTEXT
      l_msgv2 = l_s_dtel-dtelnm.
      l_msgv3 = 'does not exsist in DDIC'.    "#EC NOTEXT
      call function 'BALW_BAPIRETURN_GET2'
        exporting
          type   = rs_c_error
          cl     = rsa_c_rsar
          number = '051'
          par1   = l_msgv1
          par2   = l_msgv2
          par3   = l_msgv3
        importing
          return = return
        exceptions
          others = 0.
      exit.
    else.
*-- Due to special logic digits includes value of LENG from DDIC
      details-leng = l_s_dtel-digits.
*     from SP13: deicmals are part of the BAPI-DETAILS structure
      details-decimals = l_s_dtel-decimals.
    endif.
  endif.

  loop at l_t_iobj_cmp into l_s_iobj_cmp.
    clear: l_s_bapi_iobj_cmp.
    move-corresponding l_s_iobj_cmp to l_s_bapi_iobj_cmp.
    l_s_bapi_iobj_cmp-infoobject = l_s_iobj_cmp-iobjnm.
    append l_s_bapi_iobj_cmp to compounds.
  endloop.
  loop at l_t_atr into l_s_atr.
    clear: l_s_bapi_atr.
    move-corresponding l_s_atr to l_s_bapi_atr.
    append l_s_bapi_atr to attributes.
  endloop.
  loop at l_t_atr_nav into l_s_atr_nav.
    clear: l_s_bapi_atr_nav.
    move-corresponding l_s_atr_nav to l_s_bapi_atr_nav.
    append l_s_bapi_atr_nav to navigationattributes.
  endloop.
* navigation attributes InfoProvider
  data: l_s_naip       type  rsd_s_naip.
  data: l_s_bapi_naip  type  bapi6108np.
  l_s_bapi_naip-infoobject = l_s_viobj-iobjnm.
  loop at l_s_viobj-t_naip into l_s_naip.
    move-corresponding l_s_naip to l_s_bapi_naip.
    append l_s_bapi_naip to atrnavinfoprovider.
  endloop.
* hierarchy charact.
  data: l_s_hiecha      type rsd_s_hiecha.
  data: l_s_bapi_hiecha type bapi6108hc.
  l_s_bapi_hiecha-chabasnm = l_s_viobj-chabasnm.
  loop at l_s_viobj-t_hiecha into l_s_hiecha.
    move-corresponding l_s_hiecha to l_s_bapi_hiecha.
    append l_s_bapi_hiecha to hierarchycharacteristics.
  endloop.
* charact for inter charact. elimination
  data: l_s_ice         type rsd_s_ice.
  data: l_s_bapi_ice    type bapi6108ie.
  l_s_bapi_ice-infoobject = l_s_viobj-iobjnm.
  loop at l_s_viobj-t_ice into l_s_ice.
    move-corresponding l_s_ice to l_s_bapi_ice.
    append l_s_bapi_ice to elimination.
  endloop.

* set names of DDIC objects
  call function 'RSD_CHKTAB_GET_FOR_CHA_BAS'
    exporting
      i_chabasnm       = l_s_viobj-chabasnm
      i_s_viobj        = l_s_viobj
      i_t_atr          = l_t_atr
    importing
      e_chktab         = details-chktab
      e_chntab         = details-chntab
      e_chttab         = details-chttab
      e_txttab         = details-txttab
*     E_SIDTAB         =
*     E_SIDVIEW        =
*     E_ASITAB         =
*     E_ASISTR         =
*     E_ASTTAB         =
*     E_CHKNEW         =
    exceptions
      name_error       = 0.
  call function 'RSD_HIETAB_GET_FOR_CHA_BAS'
    exporting
      i_chabasnm       = l_s_viobj-chabasnm
      i_s_viobj        = l_s_viobj
   importing
      e_hietab         = details-hietab
      e_hintab         = details-hintab
*     E_HSITAB         =
*     E_HSIVIEW        =
*     E_INCTAB         =
    exceptions
      name_error       = 0.

endfunction.

check this and let me know how it goes.

Regards

Raja

Former Member
0 Kudos

Hi,

Thanks for the effort. I will surely test the code sample provided by you & put feedback over here for any issues / suggestions.

In the meantime, I had consulted an ABAP colleague who helped me with the bug in our version of the code.

Thanks once again.

(As a reciprocation - I have rewarded maximum points possible for your efforts - category - solved the problem)

regards,

Rajesh Sarin

Former Member
0 Kudos

Hi Durairaj,

Thanks for help, I am reading your nice code

Thanks,

Ray

athavanraja
Active Contributor
0 Kudos

the code i had provided returns the result in XML format. in case if you want it in itab format. do the following

create a exporting parameter like below

OUTPUTTAB TYPE REF TO DATA

after call transformation code add the following (just the code in bold)

call transformation (`ID`)
              source meta   = meta_data[]
                     output = <ltable>[]
              result xml xml_out.
      <b>  get reference of <ltable> into outputtab</b> .

and in the program calling this fm add the following data declaration

data: outdref type ref to data .

field-symbols: <outtab> type any table .

call function 'Z_EXECUTE_QUERY_NU'

exporting

query_name = p_query

importing

xml_out = bwstring2

outputtab = <b>outdref</b>

tables

query_variables = query_string

  • RETURN =

meta = meta

exceptions

bad_value_combination = 1

user_not_authorized = 2

unknown_error = 3

query_not_found = 4

no_applicable_data = 5

invalid_variable_values = 6

no_authority = 7

abort = 8

invalid_input = 9

invalid_view = 10

others = 11 .

if sy-subrc = 0.

assign outdref->* to <outtab> .

endif .

amine_lamkaissi
Active Contributor
0 Kudos

Hi Durairaj,

I would like to buid a program to extract into csv file the outputs of queries. I tried to use your program but i have many errore.

Do you have a version of your program that you van give me?

thanks.

Amine

amine_lamkaissi
Active Contributor
0 Kudos

btw, what is zfi_qstat_fm type?

Thanks.

Answers (0)