cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using BAPIs

Former Member
0 Kudos

Hello Everyone,

I am having a strange problem when using the BAPI_PO_GETDETAIL1 bapi. I am passing the input parameters to this BAPI as soon as a PO is created (by firing a plug to this DISPLAY view). The display view is not showing anything unless I insert a Breakpoint and then create the PO. Does anyone know how to fix this?

Please let me know if you need any more clarification. I would appreciate your help.

Regards,

Gopal.

Accepted Solutions (1)

Accepted Solutions (1)

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

You are passing the input parameters to the BAPI and simultaneoulsy firing to the display view rght?

Priya

Former Member
0 Kudos

Hi Priya,

Thanks for your reply. Yes, I am passing the input parameters to BAPI_PO_CREATE and then firing the Output(PO Number) to BAPI_PO_GETDETAIL (to Display BAPI). Then, i am getting the above issues.

I hope you understand my issue. Please do let me know if you need more clarification.

Regards,

Gopal.

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Is the PO created properly.

since you mentioned that

The display view is not showing anything unless I insert a Breakpoint and then create the PO.

may be the PO is not created so the BAPI , BAPI_PO_GETDETAIL (to Display BAPI) is not getting any data to display..

can you place your code once.

Priya

Former Member
0 Kudos

Hi Priya,

Thanks a lot for your quick reply. Yes, the PO is getting created and the whole process is working if I insert a "Break Point" in "Execute method of BAPI_PO_GETDETAIL" of Component Controller. If I dont create a "Breakpoint" then it is not displaying the BAPI even though the PO is getting created as I can see the PO in ME23!!

I haven't got a clue of why this is happening?

Regards,

Gopal.

Former Member
0 Kudos

Hi,

After this PO gets created are you shwing any meesage to the user....

I guess, the control is getting back to the initial thing...

Once you clikc the EXECUTE/SUBMIT button which calls this EXECUTE method of BAPI then the control is not getting back ..

Once the PO is created then that FM willl retun the PO number right..Try to throw that PO number as a success message,,,

Regards,

Lekha.

Former Member
0 Kudos

Hi Lekha,

Thanks a lot for your reply. Yes, I am trying to display a message to the user once the PO is created. But, I am trying to display the message in another view to which an outbound plug is fired. Also, I have created a Message Area in that view. My code is as follows. Please have a look and let me know if I need to change anything. This code is part of "onActionCreatePurchaseOrder" Method of the "Main" View.


lo_componentcontroller->EXECUTE_BAPI_PO_CREATE( ).
lo_nd_return->get_static_attributes_table( IMPORTING table = lt_return ).

* Get Vendor Email Address

nd_po_header->get_attribute( EXPORTING NAME = 'VENDOR' IMPORTING VALUE = VENDOR ).
lo_nd_importing_4->set_attribute( EXPORTING NAME = 'OBJ_TYPE' VALUE = 'LFA1' ).
lo_nd_importing_4->set_attribute( EXPORTING NAME = 'OBJ_ID'   VALUE = VENDOR ).
lo_nd_importing_4->set_attribute( EXPORTING NAME = 'CONTEXT1' VALUE = '0001' ).
lo_nd_importing_4->set_attribute( EXPORTING NAME = 'IV_CURRENT_COMM_DATA' VALUE = 'X' ).

lo_componentcontroller->EXECUTE_BAPI_ADDRESSORG_GETDET( ).

lo_nd_BAPIADSMTP = wd_context->get_child_node( name = wd_this->wdctx_BAPIADSMTP ).
lo_nd_BAPIADSMTP->get_attribute( EXPORTING NAME = 'E_MAIL' IMPORTING VALUE = EMAIL ).

*Display PO using BAPI_PO_GETDETAIL and BAPI_PO_GETDETAIL1
lo_nd_exporting->get_attribute( EXPORTING NAME = 'PURCHASEORDER' IMPORTING VALUE = PO_NUMBER ).

lo_nd_importing_5->set_attribute( EXPORTING name = 'PURCHASEORDER' value = PO_NUMBER ).
lo_nd_importing_6->set_attribute( EXPORTING name = 'PURCHASEORDER' value = PO_NUMBER ).
        
wd_this->fire_to_po_created_plg( ).

lo_componentcontroller->execute_bapi_po_getdetail1( ).
lo_componentcontroller->execute_bapi_po_getdetail( ).

CONCATENATE PO_TEXT1 PO_NUMBER PO_TEXT2 EMAIL INTO PO_MESSAGE_TEXT
      SEPARATED BY SPACE.

LOOP AT lt_return INTO ls_return.
      IF ls_return-type EQ 'S'.
            wd_this->lo_tray->set_enabled( abap_false ).
            CALL METHOD lo_message_manager->report_success
              EXPORTING
                message_text = PO_MESSAGE_TEXT.
      ENDIF.
ENDLOOP.

Let me know if you need anymore clarification regarding my issue.

Regards,

Gopal.

Former Member
0 Kudos

Hi,

After the PO gets created are you displaying the messge in same or other view..

Regards,

Lekha.

Former Member
0 Kudos

Hi Lekha,

I am displaying the message in other view after the PO is created.

Regards,

Gopal.

Former Member
0 Kudos

This you were able to display when you keep break point....is that so..

Have you checked in debugging...the fire of event is taking place or not...

One thing you do...delete the navgiation plugs and create them again....

Former Member
0 Kudos

Hi Lekha,

Yes, I am able to display the PO if I insert a Breakpoint in the BAPI_PO_GETDETAIL execute method in Component Controller. I have also checked in debugging and the Event is getting fired. I'll try to delete the Navigation link and create it again and will let you know of the progress.

Regards,

Gopal.

Former Member
0 Kudos

Hi Lekha,

I did delete the Navigation Link and Re-created it again. But, it is still doing the same thing. It is throwing the following error message.

Adapter error in &VIEW_ELEMENT_TYPE& "COST_CENTER" of view "Z_PO_CREATE_REVENUE_TEST1.PO_DETAILS": Context binding of property VALUE cannot be resolved: Node PO_DETAILS.1.POACCOUNT does not contain any elements

Which means that the values are not reaching the Context node of BAPI_PO_GETDETAIL. But, it is still working if we insert a Breakpoint!!!!!!!!!

This is very strange for us.

Regards,

Gopal.

Former Member
0 Kudos

Hi,

I cannot excatly look into your issue unless i develop the same....

I guess there is a problem with the context mapping and it's type as your getting some dump...

Please check all the ndoes, attributes and thier type...check wether the GETDETIAL bapi is expcecting the same strcuture as of context node...

Regards,

Lekha.

Former Member
0 Kudos

Hi ,

it looks like some synchronization issue....when you put the break point while trying to create the po...you give system enough time to do all the updates to the system...and you are able to see the po details in the next view for this newly created po....

if you do not put the break...system is not able to find the newly created po...and hence give you the error...or does not display anything....

try to do two things....put a 1 sec delay (for testing purposes only) to see if it does the trick, inbetween your po creation and than call to the bapi which gives you the details to see the same po....

secondly try to separate the calls of create po and get details for this newly created po into two different methods....

i see you are firing the plug....why do not you put the get details bapi calls into your display view methods....you might see some methods automatically gets created when you create your plugs for that view....check methods with name startingHANDLEFROM-

these handlefrom methods gets executed everytime you comein to the view....

let us know...

thanks..

AS..

Former Member
0 Kudos

Hi AS,

Thanks a lot for your reply. I did try to separate the method calls by putting the "get details" bapi calls into my display view methods. But, it is still giving the same problem.

But, I have not tried the 1sec delay method. Can, I know of how to insert the 1sec delay in the method? I would appreciate your help.

Regards,

Gopal.

Former Member
0 Kudos

Hi,

you can use wait statement to do that: WAIT UP TO 1 SECONDS.

But it might not be a good idea...it is just for testing purposes....you might want to find other ways of knowing if the system updated all the tables before you can call your get details bapi....perhaps a select on the po table and if your find your newly created po...than you can call this get details bapi...

thanks...

AS.

Answers (2)

Answers (2)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

This is fairly normal that there is a slight delay after the call to create before the document is available. The main work process is freed while the bulk of the update work happens asychronously in the V2 update process. If you go into the SAPGUI transactions and create a new document and then immediately try to edit it, you will get a message that it is still locked. The update process can take even longer if you have output determination occuring on create.

Former Member
0 Kudos

Hi Thomas,

Thanks for your reply. Is there any way, so that I can insert a 2secs delay in the program after "PO Creation" statement?

Regards,

Gopal.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Sure:

wait up to 2 SECONDS.

Former Member
0 Kudos

Hi Thomas and AS,

Thanks a lot for your reply. That did the work. But, am I allowed to use the Wait Statement? Because, "AS" mentioned that we should only use this for Test Purposes, is it not a good thing to use in production system when we Go Live?

Regards,

Gopal.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

The WAIT statement itself is perfectly fine to use. I think what the person was getting at is that it isn't a guarentee fix. It might take longer than 2 seconds under certain circumstances. It might be wise to build in a data check in addition to the wait to see if the data is really there. Perhaps perform the wait/check in a loop a few times only exiting when the data is found or some maximum wait time occurs.

The WAIT statement itself is actually not a bad thing. It puts the user session to sleep and swaps it out of the dialog workprocess, freeing up the system resources during this time. It is much more efficient than constantly looping or performing a do loop.

Former Member
0 Kudos

Thats great Thomas. Thanks a lot for the info.

Regards,

Gopal.

Former Member
0 Kudos

Please paste your code....