Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

'Associated Type' in a BAPI TABLE Column for dynamic internal table

Former Member
0 Likes
873

Hello SAP gurus

I have written a BAPI that recieves 'TABLE NAME', 'COLUMNS TO SELECT' and 'WHERE TO CONDITION'.

So at the time of Runtime, table, columns etc., are determined dynamically and then using a dynamic internal table it returns the data.

For this I have defined the TABLES TAB of BAPI as follows.

Parameter Name Typing Associated Type

RESULT LIKE MPP_DYNAMIC

When I did the testing, it worked perfectly fine for simple custom tables that I have created.

However, when I tried to test this BAPI with table 'MARA', it crashes with the following error

-


Runtime Errors UC_OBJECTS_NOT_CONVERTIBLE

Error analysis

The statement

"MOVE src TO dst"

requires that the operands "dst" and "src" are convertible.

Since this statement is in a Unicode program, the special conversion

rules for Unicode programs apply.

In this case, these rules were violated.

-


I am not sure what I should be entering the TABLE tab. I tried EXPORT tab of BAPI and it didnt help.

Any suggestions or feedback will be highly appreciated.

Tks

Ram

Edited by: Prasad Ram on Mar 29, 2010 3:03 AM

Edited by: Prasad Ram on Mar 29, 2010 3:06 AM

2 REPLIES 2
Read only

Former Member
0 Likes
645

Hi Ram,

You want to create a dynamic internal table right?

Try this one:


  DATA: e_dyntab_tb            TYPE lvc_t_fcat,
             i_reftab               TYPE REF   TO data.
 
  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog = e_dyntab_tb          "Pass alv_fcat here
    IMPORTING
      ep_table        = i_reftab.
 
* Create Dynamic Work Area and assign to FS
  ASSIGN i_reftab->* TO <fs_final_itab>.      "Assigning the Final Table,
  CREATE DATA t_line_reftab LIKE LINE OF <fs_final_itab>.
 
  ASSIGN t_line_reftab->* TO <fs_line_reftab>.  "Create a Work Area



"e_dyntab_tb contains the structure of lvc_t_fcat and is being populated by:

  MOVE: c_matnr      TO e_dyntab_wa-fieldname.
  APPEND e_dyntab_wa TO e_dyntab_tb.
 
  MOVE: c_maktx         TO e_dyntab_wa-fieldname.
  APPEND e_dyntab_wa TO e_dyntab_tb.
 
  MOVE: c_meins      TO e_dyntab_wa-fieldname.
  APPEND e_dyntab_wa TO e_dyntab_tb.
 
 " So onu2026

Please let me know if you need more information.

Thanks,

Jun

Read only

0 Likes
645

Thanks for the response. I appreciate it.

I have created a dynamic internal table which is getting populated. Infact, It works for simple custom tables that has about 5 to 6 fields. However, when I try this BAPI to get data from standard tables (ex., MARA) I get that error I mentioned in the original post.

So my question now is 'HOW TO GET THIS DYNAMIC INTERNAL TABLE OUT OF BAPI'. What should be the definition in the 'TABLE' tab of Bapi.

Here is the code that I am using

-


function zbapi_search_from_sap_tables.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(TABNAME) TYPE TEXT20

*" VALUE(SELECTCOL) TYPE TEXT50

*" VALUE(WHERECOND) TYPE TEXT50

*" TABLES

*" RESULT STRUCTURE MPP_DYNAMIC

*"----


data: itab_ref type ref to data,

dy_line type ref to data,

tempstring type string.

create data itab_ref type standard table of (tabname).

field-symbols: <itab> type standard table,

<dyn_wa>.

assign itab_ref->* to <itab>.

create data dy_line like line of <itab>.

assign dy_line->* to <dyn_wa>.

define dselect.

select (&1) from (&2) into corresponding fields of table &3 where (&4).

end-of-definition.

dselect selectcol tabname <itab> wherecond.

loop at <itab> into <dyn_wa>.

result = <dyn_wa>.

condense result.

append result.

endloop.

-


If you have any suggestions, I would appreciate it.

Tks

Ram

Edited by: Prasad Ram on Mar 29, 2010 4:19 AM