cancel
Showing results for 
Search instead for 
Did you mean: 

How to call two Bapi with same inputfield in webdynpro application

Former Member
0 Kudos

Hi All ,

Can anyone please let me know How to call two Bapi with same inputfield in webdypro application.?

Thanks in advance..!

Accepted Solutions (1)

Accepted Solutions (1)

S-H
Active Participant
0 Kudos

Hi Sharma,

As we discussed in the we can use the free programming to archive this.

Create a context in such a way that it should cover the fields for both the BAPI's. For example if you have a BAPI which require Employee Id, location and another Bapi which require Employee id, cost center and position. In such case create a context with 4 attributes one for Emp id, costcenter, location and position.

In the view create 4 input fields for Empl id, location, costcenter and position by binding the appropriate context. When user enters the input and clicks a button. In the button logic read the context and provides the values to the BAPI like provide the same employee id for both the bapi's and retrieve the data from Bapi and display it on the view.

Hope this helps.

Best regards,

Suresh

Former Member
0 Kudos

Hi Suresh ,

Thanks for ur reply ...!

still I am not getting... how to read read the context and provides the values to the BAPI .

Regrds

rahul

S-H
Active Participant
0 Kudos

Hi Sharma,

Reading the context and providng the values mean:

As i mentioned in the example create the context which is required in the component controller and in the view drag and drop the context.

Associate the context to the UI elements.

With the required input fields you would have also has the button for triggering the action. In the button method use the code wizard (or read the context using GET_ELEMENT method). Once you read the context you have the data which user would have provided, pass this data to the BAPI's and get the data and do the further action.

Best regards,

Suresh

Former Member
0 Kudos

Hi Suresh ,

I have created the context as you told me ...PART...this field I want to connect to both of my Bapi(import parameter --payment detail).

Could you please let me know how to pass this data to the BAPI's and get the data and do the further action

I try to connect , but I am getting error like this..

*******************************************************************

method ONACTIONGET_SEAR244 .

DATA:

node_bp TYPE REF TO if_wd_context_node,

elem_bp TYPE REF TO if_wd_context_element,

stru_bp TYPE if_profileview=>element_bp ,

item_part LIKE stru_bp-part.

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

node_bp = wd_context->get_child_node( name = if_profileview=>wdctx_bp ).

  • get element via lead selection

elem_bp = node_bp->get_element( ).

  • get single attribute

elem_bp->get_attribute(

EXPORTING

name = `PART`

IMPORTING

wd_comp_controller->execute_zbapi_tax_payer_profil(

).

wd_comp_controller->execute_zbapi_account_balance_(

).

value = item_part ).

endmethod.

          • ***************************************************

ERROR

***************************

Method ONACTIONGET_SEAR244

"= ..." expected after "WD_COMP_CONTROLLER->EXECUTE_ZBAPI_TAX_PAYER_PROFIL(".

****************************************************************************

Requirement like this...

A & B are two different Bapi

Bapi A :

import parameter : Payment Detail

Export : 1)cheque details

2) submission details

Bapi B :

import parameter : Payment Detail

Export : 1)material details

2) transition details

I want to connect both the Import parameter(input) Payment Detail from Bapi A & B to one single element or search element .

So once I will provide input & click on search

For example :

Payment Detail(input) : 111

Desired Output:

material details transition details cheque details submission details

5555 7777777 8888 99999

Once again...thanks for ur effort

Rahul

S-H
Active Participant
0 Kudos

Hi Sharma,

In the code which you mentioned there is an syntax error i.e. importing parameter is missing in the get_attribute method call.

**********************************

  • get single attribute

elem_bp->get_attribute(

EXPORTING

name = `PART`

IMPORTING

**********************************

It should be

  • get single attribute

elem_bp->get_attribute(

EXPORTING

name = `PART`

IMPORTING

value = item_part ).

Once you get the value/item_part you can pass this one to the BAPI. In the wd_comp_controller's methodss create additional importing parameter to pass the item_part to bapi call.

and pass the value to the bapi methods:

wd_comp_controller->execute_zbapi_tax_payer_profil( PART = item_part

).

wd_comp_controller->execute_zbapi_account_balance_( PART = item_part

).

In these componentcontroller method pass the PART parameter to the BAPI call's and get the data, once u get the data you can bind it to a context in componentcontroller. Use this context in the views and display the ouput to the user.

Best regards,

Suresh

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Sharma.

This was already discussed here.

You can extend the interfaces of execute methods by adding the parameter with the inputfield value and then set it manually in the part of the BAPI call.

Cheers,

Sascha

Former Member
0 Kudos

Hi ,

After reading the context Part ...code look like this ...

Could you please let me know how to connect this to import parameter

of two Bapi ?

method ONACTIONGET_SEAR244 .

DATA:

node_bp TYPE REF TO if_wd_context_node,

elem_bp TYPE REF TO if_wd_context_element,

stru_bp TYPE if_profileview=>element_bp ,

item_part LIKE stru_bp-part.

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

node_bp = wd_context->get_child_node( name = if_profileview=>wdctx_bp ).

  • get element via lead selection

elem_bp = node_bp->get_element( ).

  • get single attribute

elem_bp->get_attribute(

EXPORTING

name = `PART`

IMPORTING

value = item_part ).

endmethod.

rahul

Former Member
0 Kudos

Hi.

Do this:

wd_comp_controller->execute_zbapi_tax_payer_profil(

part = item_part

).

wd_comp_controller->execute_zbapi_account_balance_(

part = item_part

).

Then go to both methods and add part as importing parameter.

In these methods find the BAPI call and replace the existing item part with the one you defined as import parameter.

Cheers,

Sascha

Former Member
0 Kudos

Hi Sascha/Suresh ,

I am getting this error when I am trying to activate my view .

Could you let me knw also how to replace Part in controller method ?

ERROR :"ITEM_PART" is not type-compatible with formal parameter "PART".

**************************************************************************************

method ONACTIONGET_SEAR244 .

DATA:

node_bp TYPE REF TO if_wd_context_node,

elem_bp TYPE REF TO if_wd_context_element,

stru_bp TYPE if_profileview=>element_bp ,

item_part LIKE stru_bp-part.

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

node_bp = wd_context->get_child_node( name = if_profileview=>wdctx_bp ).

  • get element via lead selection

elem_bp = node_bp->get_element( ).

  • get single attribute

elem_bp->get_attribute(

EXPORTING

name = `PART`

IMPORTING

value = item_part ).

endmethod.

****************************************************************************************

-


Method in the controller----


METHOD execute_zbapi_tax_payer_profil .

  • declarations for context navigation

DATA:

node_zbapi_tax_payer_prof TYPE REF TO if_wd_context_node.

DATA:

node_changing_1 TYPE REF TO if_wd_context_node.

DATA:

node_accountdetail TYPE REF TO if_wd_context_node.

DATA:

node_addressdetails TYPE REF TO if_wd_context_node.

DATA:

node_alert_list TYPE REF TO if_wd_context_node.

DATA:

node_installmentplan TYPE REF TO if_wd_context_node.

DATA:

node_relationshipdetails TYPE REF TO if_wd_context_node.

DATA:

node_importing_1 TYPE REF TO if_wd_context_node.

-


Here I have added Part parameter after declaring as import parameter -


************************************************************

DATA:

node_PART TYPE REF TO if_wd_context_node.

****************************************************************

DATA:

lri_element TYPE REF TO if_wd_context_element,

loa_elements TYPE wdr_context_element_set.

  • declarations for fuba parameters

DATA:

attr_partner TYPE zbapi_partner_profile_header-partner.

DATA:

copy_c_accountdetail TYPE if_componentcontroller=>elements_accountdetail,

stru_c_accountdetail TYPE if_componentcontroller=>elements_accountdetail,

itab_c_accountdetail LIKE LINE OF stru_c_accountdetail.

DATA:

copy_c_addressdetails TYPE if_componentcontroller=>elements_addressdetails,

stru_c_addressdetails TYPE if_componentcontroller=>elements_addressdetails,

itab_c_addressdetails LIKE LINE OF stru_c_addressdetails.

DATA:

copy_c_alert_list TYPE if_componentcontroller=>elements_alert_list,

stru_c_alert_list TYPE if_componentcontroller=>elements_alert_list,

itab_c_alert_list LIKE LINE OF stru_c_alert_list.

DATA:

copy_c_installmentplan TYPE if_componentcontroller=>elements_installmentplan,

stru_c_installmentplan TYPE if_componentcontroller=>elements_installmentplan,

itab_c_installmentplan LIKE LINE OF stru_c_installmentplan.

DATA:

copy_c_relationshipdetails TYPE if_componentcontroller=>elements_relationshipdetails,

stru_c_relationshipdetails TYPE if_componentcontroller=>elements_relationshipdetails,

itab_c_relationshipdetails LIKE LINE OF stru_c_relationshipdetails.

  • get all involved child nodes

node_zbapi_tax_payer_prof = wd_context->get_child_node( `ZBAPI_TAX_PAYER_PROF` ).

node_changing_1 = node_zbapi_tax_payer_prof->get_child_node( `CHANGING_1` ).

node_accountdetail = node_changing_1->get_child_node( `ACCOUNTDETAIL` ).

node_addressdetails = node_changing_1->get_child_node( `ADDRESSDETAILS` ).

node_alert_list = node_changing_1->get_child_node( `ALERT_LIST` ).

node_installmentplan = node_changing_1->get_child_node( `INSTALLMENTPLAN` ).

node_relationshipdetails = node_changing_1->get_child_node( `RELATIONSHIPDETAILS` ).

node_importing_1 = node_zbapi_tax_payer_prof->get_child_node( `IMPORTING_1` ).

  • get input from context

node_importing_1->get_attribute(

EXPORTING

name = `PARTNER`

IMPORTING

value = attr_partner ).

loa_elements = node_accountdetail->get_elements( ).

LOOP AT loa_elements[] INTO lri_element.

lri_element->get_static_attributes( IMPORTING static_attributes = itab_c_accountdetail ).

INSERT itab_c_accountdetail INTO TABLE stru_c_accountdetail[].

ENDLOOP.

copy_c_accountdetail = stru_c_accountdetail[].

loa_elements = node_addressdetails->get_elements( ).

LOOP AT loa_elements[] INTO lri_element.

lri_element->get_static_attributes( IMPORTING static_attributes = itab_c_addressdetails ).

INSERT itab_c_addressdetails INTO TABLE stru_c_addressdetails[].

ENDLOOP.

copy_c_addressdetails = stru_c_addressdetails[].

loa_elements = node_alert_list->get_elements( ).

LOOP AT loa_elements[] INTO lri_element.

lri_element->get_static_attributes( IMPORTING static_attributes = itab_c_alert_list ).

INSERT itab_c_alert_list INTO TABLE stru_c_alert_list[].

ENDLOOP.

copy_c_alert_list = stru_c_alert_list[].

loa_elements = node_installmentplan->get_elements( ).

LOOP AT loa_elements[] INTO lri_element.

lri_element->get_static_attributes( IMPORTING static_attributes = itab_c_installmentplan ).

INSERT itab_c_installmentplan INTO TABLE stru_c_installmentplan[].

ENDLOOP.

copy_c_installmentplan = stru_c_installmentplan[].

loa_elements = node_relationshipdetails->get_elements( ).

LOOP AT loa_elements[] INTO lri_element.

lri_element->get_static_attributes( IMPORTING static_attributes = itab_c_relationshipdetails ).

INSERT itab_c_relationshipdetails INTO TABLE stru_c_relationshipdetails[].

ENDLOOP.

copy_c_relationshipdetails = stru_c_relationshipdetails[].

  • the invocation - errors are always fatal !!!

CALL FUNCTION 'ZBAPI_TAX_PAYER_PROFILE'

EXPORTING

partner = attr_partner

" importing

" profile_Header = wd_This->Profile_Header

" centraldetail = wd_This->Centraldetail

" centraldataperson = wd_This->Centraldataperson

" centraldataorganization = wd_This->Centraldataorganizat

" centraldatagroup = wd_This->Centraldatagroup

" communicationdetails = wd_This->Communicationdetails

" return = wd_This->Return_1

TABLES

alert_list = stru_c_alert_list

" idtypedetails =

addressdetails = stru_c_addressdetails

relationshipdetails = stru_c_relationshipdetails

" bankdetails =

" period_Key_Data =

" contract_Acc =

" credit_Worth =

" correspondence =

" accountreceivable =

accountdetail = stru_c_accountdetail

" paymentdetail =

installmentplan = stru_c_installmentplan

" installmentdetail =

.

  • store output to context

IF ( stru_c_accountdetail[] NE copy_c_accountdetail[] ).

node_accountdetail->bind_table( stru_c_accountdetail[] ).

ENDIF.

CLEAR: copy_c_accountdetail[], stru_c_accountdetail[].

IF ( stru_c_addressdetails[] NE copy_c_addressdetails[] ).

node_addressdetails->bind_table( stru_c_addressdetails[] ).

ENDIF.

CLEAR: copy_c_addressdetails[], stru_c_addressdetails[].

IF ( stru_c_alert_list[] NE copy_c_alert_list[] ).

node_alert_list->bind_table( stru_c_alert_list[] ).

ENDIF.

CLEAR: copy_c_alert_list[], stru_c_alert_list[].

IF ( stru_c_installmentplan[] NE copy_c_installmentplan[] ).

node_installmentplan->bind_table( stru_c_installmentplan[] ).

ENDIF.

CLEAR: copy_c_installmentplan[], stru_c_installmentplan[].

IF ( stru_c_relationshipdetails[] NE copy_c_relationshipdetails[] ).

node_relationshipdetails->bind_table( stru_c_relationshipdetails[] ).

ENDIF.

CLEAR: copy_c_relationshipdetails[], stru_c_relationshipdetails[].

ENDMETHOD.

Thanks for your time.

Rahul

Former Member
0 Kudos

Hi Sharma.

Did you use the wizard to create the data agthering in ONACTIONGET_SEAR244?

If not do it again with the wizard.

In the execute method you have to add the partner to the interface like I described above.

Then search this code:

CALL FUNCTION 'ZBAPI_TAX_PAYER_PROFILE'
EXPORTING
partner = attr_partner

and change it to:

CALL FUNCTION 'ZBAPI_TAX_PAYER_PROFILE'
EXPORTING
partner = attr_partner

This should be the easiest way.

But you also can change bot BAPI controller methods by reading the partner from context directly as you have done in ONACTIONGET_SEAR244. For this you have to replace the method:

* get input from context
node_importing_1->get_attribute(
EXPORTING
name = `PARTNER`
IMPORTING
value = attr_partner ).

by reading form the node which is bound to your input field. But take care of the types you have used.

Cheers,

Sascha

Former Member
0 Kudos

Hi ALL ,

Thanks for your time & effort !