Skip to Content
0

Dump with Message Statement in User-Exit / BAdi while calling BAPI from FPM Application

Jan 18 at 02:15 PM

90

avatar image
Former Member

Hi,

We are developing a Floorplan Manager(FPM) application where we want to automate creation of Return Order, Return Delivery and Return Billing against Original Sales Order Flow.

To achieve Return documents creation, we are calling BAPI's (Example: BAPI_CUSTOMERRETURN_CREATE and BAPI_SALESORDER_CREATEFROMDAT2). But there had been lot of validations present in the custom development written in existing Customer-Exit's and BADI's where MESSAGE statement had been used to throw an error messages. This absolutely works fine as long as we run functionality using GUI transaction codes (Example: VA01)

However when we process the same functionality via FPM Application where BAPI's are triggering the same User-Exit's / BAdi's, SAP system gives a dump whenever these MESSAGE Statements are executed.

Though we could figured out that MESSAGE statement has to be altered as "MESSAGE ID 'XX' TYPE 'E' NUMBER '000' WITH MATNR INTO lv_message" to make sure FPM application do not short-dump, but we are looking for efficient and better way to handle such situation of may be one single MESSAGE syntax which should work fine in FPM and GUI transactions.

Could you please advise if you have any solution?

Thanks,

Bharath.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Mike Pokraka Jan 19 at 04:08 PM
-1

Never, never, never use a MESSAGE statement in a BAPI, that's just fundamentally wrong on several levels. Please review the development guidelines for BAPI's: GUI interaction is forbidden for anything intended to be used remotely, for exactly the reason you are encountering.

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Mike,

I agree your point but just to be clear we have not written any new MESSAGE Statement in BAPI. Let me explain again.

My customer has been using SAP system for years and they had implemented many User / Customer exits to customize their functional behaviour, they used MESSAGE statement. This absolutely works fine when this code is executed from GUI T-Codes.

Recently we started with new Development using Floorplan Manager where we are calling some BAPI's, existing code with MESSAGE statement written in some of these User/Customer Exits getting called, that is when we are getting dump in FPM application.

Now we are looking for a solution which should work correctly in both GUI and FPM.

Please note If we use MESSAGE ....INTO 'lv_var', then this will work from FPM but not in GUI.

Thanks,

Bharath.

0

If you call X from a BAPI and X writes a MESSAGE, your'e still writing a MESSAGE from the BAPI, just indirectly.

From the MESSAGE documentation:

Messages sent without one of the additions RAISING or INTO are a way of interacting with a user. Except for messages of the type "X", the statement MESSAGE should be use exclusively in the presentation logic layer and never in the application logic layer.

BAPI is part of the application logic. SAPGUI Presentation logic is different from Web Dynpro or FIORI or whatever else presentation logic. Use exceptions or return codes.

0
Former Member

Hi Mike,

We have tried different approaches, we are still not successful.

This is flow: Launch FPM application -> User select a original order -> Press button to process Return Flow -> Call BAPI to create Return Billing document -> Internally it executes User-Exit 'EXIT_SAPLV60B_001' . There was some customer specific logic written in which MESSAGE Statement is used. As soon as this MESSAGE statement is triggered, it issues a dump to FPM Application. Please note MESSAGE Statement works perfectly alright if we create a Return Billing document using VF01 transaction.

Tried following approaches to fix the FPM dump issue.

1.MESSAGE 'VF' type 'E'.....INTO lv_dummy. This will not give a dump but this does not stop further creation of Billing document.

2. Used Return Code by setting 'SY-SUBRC = 4' or tried with setting ERROR_FLAG. But these Return Codes are cleared as soon as control come out of User-Exit and Standard code continues to execute in FM 'RV_ACCOUNTING_DOCUMENT_CREATE'

3.Tried with RAISE EXCEPTION TYPE 'CX_CLASS'. This was also giving a dump. Additionally we thought of raising Function Module exceptions but here were no exceptions defined in User-Exit.

4.Created a separate OO class and storing the messages into an internal table from User-Exit. After BAPI has been executed. Before BAPI COMMIT is executed, we are checking whether internal table has any error message filled, then throw an error message. But by the time control come back to FPM application after User-Exit, Billing document was already created and saved in to the database due to internal commit in the Standard SAP Code.

All the options did not help us to fix the issue. Are we doing anything wrong?

Do you see any chances of fixing this issue? Kindly advice.

Thanks,

Bharath.

0
Naresh Raj Jan 31 at 10:18 AM
0

Tried following approaches to fix the FPM dump issue.

1.MESSAGE 'VF' type 'E'.....INTO lv_dummy. This will not give a dump but this does not stop further creation of Billing document.

may be you can control the above point by having an error flag in global attributes in class level, whenever above message is identified you mark the global error flag and control rest of the logic.


Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Naresh,

Thanks for your answer.

Below If you see the ABAP stack executed when 'Return Flow' Button is pressed from my FPM application.

After MESSAGE Statement is executed in User-Exit, control comes to 'RV_ACCOUNTING_DOCUMENT_CREATE', there it continues to create Billing document in the ABAP stack followed. I think Standard SAP should have provided some exceptions in the User-Exit FM by raising these from Exit could stop further execution. Otherwise i need to plugin my custom code after control come out of User-Exit and Before Standard SAP Creates Billing document, there i can read my global class attribute / Internal table, then let the code not continue to create billing document. I am looking for some pointer / approach where i can restrict the Billing document creation.

Thanks,

Bharath.

0