cancel
Showing results for 
Search instead for 
Did you mean: 

Error when Calling a BAPI in ALV custom button "could not ascertain code"

Former Member
0 Kudos

Hi,

I am getting the error "Could not ascertain code page" when i try to call my BAPI (to export to excel sheet) on click of a custom button in ALV.

I have done the creation and event handling etc for the custom button.

Kindly help if anybody knows this error.

Thanks

Roshan

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi Roshan,

I am also getting same error message.

Error "Could not ascertain code page".

If you able solve this error message can you tell me

How to solve this error message.

Former Member
0 Kudos

Actually I am passing a single value and fetching different records from tables based on that value. So the importing parameter is a variable and the BAPI fetches all the records which it saves in an excel sheet.

Hope it is clear to you

Former Member
0 Kudos

Thanks Suman....

But u r mistaken because both the i_methcode and lv_methcode are simple variable types.

They are neither internal tables nor structures.

So that is not the problem for sure.

Former Member
0 Kudos

Hi Roshan,

you told that i_mathcode and lv_mathcode neither table nor structure.Then what data you are exporting to the Excel file using your BAPI.

Thanks

Suman.

Former Member
0 Kudos

Thats because i need to download the data into a specific format(tree structure) different from what the standard export provides.

Plz solve it

Former Member
0 Kudos

Hi Roshan,

You are doing mistake here....

i_methcode is internal table in exporting parameter.But you are assignning structure to it thats why you are getting error.

call function 'ZBAPI_EXCEL_DLOAD_METHODOLOGY'

exporting

i_methcode = lv_methcode

tables

et_return = lt_return

.

get_attribute will return only structure.If you want to return the entire table data to internal table.you can do in this way...

data:

node_sflight type ref to if_wd_context_node,

elem_sflight type ref to if_wd_context_element,

lt_elements type WDR_CONTEXT_ELEMENT_SET,

stru_sflight type if_main=>element_sflight_node,

it_flights type if_main=>elements_sflight_node.

  • navigate from <CONTEXT> to <SFLIGHT_NODE> via lead selection

node_sflight_node = wd_context->get_child_node( name = ' FLIGHTS' ).

  • get element via lead selection

  • elem_sflight_node = node_sflight_node->get_element( ).

lt_elements = node_sflight->get_elements( ).

  • get all declared attributes

loop at lt_elements into elem_sflight.

elem_sflight->get_static_attributes(

importing

static_attributes = stru_sflight ).

append stru_sflight to it_flights.

endloop.

Now you have table data in the internal table it_flights.

( or )

data: node_flights type ref to if_wd_context_node,

it_flights type if_main=>elements_sflight_node.

node_sflight->get_static_attributes_table(

  • EXPORTING

  • FROM = 1

  • TO = 2147483647

IMPORTING

TABLE = TABLE

).

Thanks

Suman

Former Member
0 Kudos

Hello Roshan,

Why don you use the standard functionality for downloading the data to Excel from ALV Table ?

Regards

Vishal

Former Member
0 Kudos

I am creating a custom export button(after disabling the standard export button) to download the data into an excel sheet in my own format. I have created the new button. The code is given here.

data lr_buttonui2 type ref to cl_salv_wd_fe_button.

data input2 type ref to cl_salv_wd_function.

data: lr_column_settings type ref to if_salv_wd_column_settings,

lr_input_field type ref to cl_salv_wd_uie_input_field.

create object lr_buttonui2.

call method lr_buttonui2->set_text

exporting

value = 'Export'

.

input2 = lo_value->if_salv_wd_function_settings~create_function( id = 'EXPORT' ).

input2->set_editor( lr_buttonui2 ).

data lr_ref3 type ref to cl_salv_wd_fe.

call method input2->get_editor

receiving

value = lr_ref3

I have also created the event handler for my button and written the below code thr. I am caling a BAPI to download the data into my excel format. The problem is coming here only.

data: lt_return type table of bapiret2.

data lo_nd_methcode type ref to if_wd_context_node.

data lo_el_methcode type ref to if_wd_context_element.

data ls_methcode type wd_this->element_methcode.

data lv_methcode like ls_methcode-methcode.

  • navigate from <CONTEXT> to <METHCODE> via lead selection

lo_nd_methcode = wd_context->get_child_node( name = wd_this->wdctx_methcode ).

  • get element via lead selection

lo_el_methcode = lo_nd_methcode->get_element( ).

  • get single attribute

lo_el_methcode->get_attribute(

exporting

name = `METHCODE`

importing

value = lv_methcode ).

call function 'ZBAPI_EXCEL_DLOAD_METHODOLOGY'

exporting

i_methcode = lv_methcode

tables

et_return = lt_return

.

Plz give me a solution

Former Member
0 Kudos

Hi,

Can you post your code here and also tell me why you are calling BAPI.

thanks

Suman