cancel
Showing results for 
Search instead for 
Did you mean: 

PASSING GLOBAL VARIABLES TO BAPI'S

Former Member
0 Kudos

Hi all,

I want to pass global variables to many bapi's

I have created a node with 3 attributes of type(structure) BAPI_BCA_STR_CN_ACCT_EXT.

now i am using a service call to call the required bapi,inside this method i am writing this code...

  • declarations for context navigation

DATA lo_bapi_bca_paymitem_ge TYPE REF TO if_wd_context_node.

DATA lo_changing TYPE REF TO if_wd_context_node.

DATA lo_paymentitemdetail TYPE REF TO if_wd_context_node.

  • DATA lo_importing_1 TYPE REF TO if_wd_context_node.

  • DATA lo_accountident TYPE REF TO if_wd_context_node.

DATA lo_account_details TYPE REF TO if_wd_context_node .

DATA lo_element TYPE REF TO if_wd_context_element.

DATA lt_elements TYPE wdr_context_element_set.

  • declarations for parameters

  • DATA ls_c_accountident TYPE if_componentcontroller=>element_accountident.

DATA ls_account_details TYPE if_componentcontroller=>element_account_details.

DATA lt_c_paymentitemdetail TYPE if_componentcontroller=>elements_paymentitemdetail.

DATA ls_c_paymentitemdetail LIKE LINE OF lt_c_paymentitemdetail.

DATA lt_c_paymentitemdetail_cp TYPE if_componentcontroller=>elements_paymentitemdetail.

  • get all involved child nodes

lo_bapi_bca_paymitem_ge = wd_context->get_child_node( wd_this->wdctx_bapi_bca_paymitem_ge ).

lo_changing = lo_bapi_bca_paymitem_ge->get_child_node( wd_this->wdctx_changing ).

lo_paymentitemdetail = lo_changing->get_child_node( wd_this->wdctx_paymentitemdetail ).

  • lo_importing_1 = lo_bapi_bca_paymitem_ge->get_child_node( wd_this->wdctx_importing_1 ).

  • lo_accountident = lo_importing_1->get_child_node( wd_this->wdctx_accountident ).

lo_account_details = wd_context->get_child_node( wd_this->wdctx_ACCOUNT_DETAILS ).

  • get input from context

  • lo_element = lo_accountident->get_element( ).

  • lo_element->get_static_attributes(

  • IMPORTING static_attributes = ls_c_accountident ).

  • lt_elements = lo_paymentitemdetail->get_elements( ).

  • LOOP AT lt_elements[] INTO lo_element.

  • lo_element->get_static_attributes( IMPORTING static_attributes = ls_c_paymentitemdetail ).

  • INSERT ls_c_paymentitemdetail INTO TABLE lt_c_paymentitemdetail[].

  • ENDLOOP.

*

  • lt_c_paymentitemdetail_cp = lt_c_paymentitemdetail[].

*

  • get input from context

lo_element = lo_account_details->get_element( ).

lo_element->get_static_attributes(

IMPORTING static_attributes = ls_account_details ).

lt_elements = lo_paymentitemdetail->get_elements( ).

LOOP AT lt_elements[] INTO lo_element.

lo_element->get_static_attributes( IMPORTING static_attributes = ls_c_paymentitemdetail ).

INSERT ls_c_paymentitemdetail INTO TABLE lt_c_paymentitemdetail[].

ENDLOOP.

lt_c_paymentitemdetail_cp = lt_c_paymentitemdetail[].

  • the invocation - errors are always fatal !!!accountident = lo_accountident

CALL FUNCTION 'BAPI_BCA_PAYMITEM_GET_LIST'

EXPORTING

account_details = lo_account_details

" datefrom = wd_this->datefrom

" dateto = wd_this->dateto

" maxrows = wd_this->maxrows

" processextension = wd_this->processextension

" openlog = wd_this->openlog

" withnotes = wd_this->withnotes

" valuedatefrom = wd_this->valuedatefrom

" valuedateto = wd_this->valuedateto

" IMPORTING

" morerows = wd_this->morerows

" archpostdate = wd_this->archpostdate

TABLES

" extensionin =

paymentitemdetail = lt_c_paymentitemdetail

" itemstatus =

" itemtype =

" return =

" extensionout =

" paymentitemnotes =

.

  • store output to context

IF lt_c_paymentitemdetail[] NE lt_c_paymentitemdetail_cp[].

lo_paymentitemdetail->bind_table( lt_c_paymentitemdetail[] ).

ENDIF.

CLEAR lt_c_paymentitemdetail_cp[].

CLEAR lt_c_paymentitemdetail[].

ENDMETHOD.

BUT IT IS SHOWING A RUN-TIME ERROR....PLZ HELP ME SOLVE IT,

Thanks n regards,

Urvashi

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hi urbashi......

first mention the eroor that you are getting.

always pass a variable to the bapi and not directly an object.

you have used lt_c_paymentitemdetail[]. do not use internal table with header lines. for it is not supported in oops.

---regards,

alex b justin

Former Member
0 Kudos

THE ERROR M GETTIN IS: Incorrect parameter with CALL FUNCTION.

THANKS N REGARDS,

URBASHI

Former Member
0 Kudos

hi urbashi......

the error is because......

1) you might be passing a variable of different data type to the bapi.

or

2) you ight be passing an internal table instead of a single variable.

---regards,

alex b justin

Former Member
0 Kudos

hi alex,

for the above prob i have created 3 context node..

account1 with attribute bank-key

account2 with attribute bank-country

account3 with attribute accno.

These 3 nodes are binded to 3 input fields,

now on the click of the action m reading these 3 values individually and storing it into an Internal Table.

now this Internal table is passed to the Api as shown below but its still showing error( Type conflict when calling a function module.)

code...............

method ONACTIONGET_ITEM .

data itab type standard table of BAPI_BCA_STR_CN_ACCT_EXT.

data wa type BAPI_BCA_STR_CN_ACCT_EXT.

*reading bank-country

DATA lo_nd_account_details TYPE REF TO if_wd_context_node.

DATA lo_el_account_details TYPE REF TO if_wd_context_element.

DATA ls_account_details TYPE wd_this->element_account_details.

DATA lv_bank_country LIKE ls_account_details-bank_country.

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

lo_nd_account_details = wd_context->get_child_node( name = wd_this->wdctx_account_details ).

  • get element via lead selection

lo_el_account_details = lo_nd_account_details->get_element( ).

  • get single attribute

lo_el_account_details->get_attribute(

EXPORTING

name = `BANK_COUNTRY`

IMPORTING

value = lv_bank_country ).

WA-ACCOUNT_NUMBER = lv_bank_country.

Append WA to ITAB.

*reading bank-key

DATA lo_nd_account_details1 TYPE REF TO if_wd_context_node.

DATA lo_el_account_details1 TYPE REF TO if_wd_context_element.

DATA ls_account_details1 TYPE wd_this->element_account_details1.

DATA lv_bank_code LIKE ls_account_details1-bank_code.

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

lo_nd_account_details1 = wd_context->get_child_node( name = wd_this->wdctx_account_details1 ).

  • get element via lead selection

lo_el_account_details1 = lo_nd_account_details1->get_element( ).

  • get single attribute

lo_el_account_details1->get_attribute(

EXPORTING

name = `BANK_CODE`

IMPORTING

value = lv_bank_code ).

WA-ACCOUNT_NUMBER = lv_bank_code.

Append WA to ITAB.

*reading account-number

DATA lo_nd_account_details2 TYPE REF TO if_wd_context_node.

DATA lo_el_account_details2 TYPE REF TO if_wd_context_element.

DATA ls_account_details2 TYPE wd_this->element_account_details2.

DATA lv_account_number LIKE ls_account_details2-account_number.

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

lo_nd_account_details2 = wd_context->get_child_node( name = wd_this->wdctx_account_details2 ).

  • get element via lead selection

lo_el_account_details2 = lo_nd_account_details2->get_element( ).

  • get single attribute

lo_el_account_details2->get_attribute(

EXPORTING

name = `ACCOUNT_NUMBER`

IMPORTING

value = lv_account_number ).

CALL FUNCTION 'BAPI_BCA_PAYMITEM_GET_LIST'

EXPORTING

ACCOUNTIDENT = itab

  • DATEFROM =

  • DATETO =

  • MAXROWS =

  • PROCESSEXTENSION =

  • OPENLOG = 'X'

  • WITHNOTES =

  • VALUEDATEFROM =

  • VALUEDATETO =

  • IMPORTING

  • MOREROWS =

  • ARCHPOSTDATE =

  • TABLES

  • * EXTENSIONIN =

  • PAYMENTITEMDETAIL =

  • ITEMSTATUS =

  • ITEMTYPE =

  • RETURN =

  • EXTENSIONOUT =

  • PAYMENTITEMNOTES =

.

Edited by: Urbashi Dewan on Jan 16, 2008 8:11 AM

Former Member
0 Kudos

Hi Urbashi.

Better approach is go to ST22-> Your dump should come here. Look in details about the dump.

In the Error Analysis column, it will tell you which field is giving you the problem.

Hope it helps...

Former Member
0 Kudos

hi urbashi.......

for the exporting parameter ACCOUNTIDENT you are passing an internal table.... but its a single parameter and not a table..... that solves it.

---regards,

alex b justin