Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dump while creating sales order using BAPI

Former Member
0 Likes
3,002

Hi Experts,

I am trying to create a sales order in my alv report using BAPI_SALESORDER_CREATEFROMDAT2. I get a dump while executing the program. Please suggest me where I am going wrong.

----------------------------------------------------------------------------------------------------
|Source Code Extract                                                                               |
----------------------------------------------------------------------------------------------------
|Line |SourceCde                                                                                |
----------------------------------------------------------------------------------------------------
|    1|FORM FRM_KOND_BASIS_604.                                                                    |
|    2|*{   INSERT         DEVK910738                                        1                     |
|    3|                                                                                |
|    4|data:  zuomqtyo   LIKE ekpo-menge,                                                          |
|    5|       zuomqtyn   LIKE ekpo-menge,                                                          |
|    6|       zqty1      type i,                                                                   |
|    7|       zqty2(11)   type n.                                                                  |
|    8|                                                                                |
|    9|** Round up billing qty                                                                     |
|   10|   if komp-zzLTKZA ne 'VAR'.                                                                |
|   11|                                                                                |
|>>>>>|      zqty1   = xkwert.                                                                     |
|   13|      compute zqty2   = zqty1 / 1000.                                                       |
|   14|      xkwert = zqty2 * 1000.                                                                |
|   15|                                                                                |
|   16|     exit.                                                                                |
|   17|   endif.                                                                                |
|   18|                                                                                |
|   19|                                                                                |
|   20|** Samples                                                                                |
|   21|                                                                                |
|   22|  if komp-MATKL = '5400'.                                                                   |
|   23|                                                                                |
|   24|    check not xkomv-kmein is initial.                                                       |
|   25|    check not komp-vrkme  is initial.                                                       |
|   26|                                                                                |
|   27|** Make sure base is correct when sales unit and pricing unit differ                        |
|   28|   if komp-vrkme ne xkomv-kmein.                                                            |
|   29|                                                                                |
|   30|     zuomqtyo = komp-MGAME.                                                                 |
|   31|                                                                                |
----------------------------------------------------------------------------------------------------

Thanks.

26 REPLIES 26
Read only

Former Member
0 Likes
2,600

Hi Nani,

There could be a problem with the data type of the fields you are using. Could you please copy/paste the Dump?

Thanks

Ernesto.

Read only

0 Likes
2,600

Hi Ernesto,

Thanks for the reply. I am not able to copy/paste the whole dump because it exceeds maximum characters. Please let me know what portion of dump analysis do I need to provide.

Thanks.

Read only

0 Likes
2,600

Please copy the explanation part. There is a part where it says ERROR ANALYSIS.

Read only

0 Likes
2,600

Hi,

It seems, the issue is with the below line of your code.

zqty1 = xkwert

Can you make the data tpe of 'Zqty1' same as data type of 'xkwert' refering to.

Let us know, if it helps you. Thanks.

Read only

0 Likes
2,600

Hi Ernesto,

Here is the error analysis part.


----------------------------------------------------------------------------------------------------
|Error analysis                                                                                |
|    An exception occurred that is explained in detail below.                                      |
|    The exception, which is assigned to class 'CX_SY_CONVERSION_OVERFLOW', was not                |
|     caught in                                                                                |
|    procedure "FRM_KOND_BASIS_604" "(FORM)", nor was it propagated by a RAISING                   |
|     clause.                                                                                |
|    Since the caller of the procedure could not have anticipated that the                         |
|    exception would occur, the current program is terminated.                                     |
|    The reason for the exception is:                                                              |
|    In the current arithmetic operation with operands of type P an overflow                       |
|    has been detected. Possible causes are:                                                       |
|                                                                                |
|    1. The result field of type P is too small to store the result.                               |
|                                                                                |
|    2. The result or an intermediate result has more than 31 decimal places.                      |
|                                                                                |
|                                                                                |
----------------------------------------------------------------------------------------------------

Thanks.

Read only

0 Likes
2,600

Hi Atul,

Thanks for the reply. That is the standard SAP code. It is not the custom code which I wrote.

Thanks.

Read only

0 Likes
2,600

Hi,

Thanks for that. As it was said before, make sure both fields have the same type. The type of the target field is smaller than the type of the source field.

Ernesto

Read only

0 Likes
2,600

Hi,

Make variable zqty1 type kwert instead of type "i". These must be the same type.

Ernesto

Read only

0 Likes
2,600

Nani, There was some modification made through " *{ INSERT DEVK910738 ". Its a custom code. Check last changed by the Include of the FORM FRM_KOND_BASIS_604..

Read only

0 Likes
2,600

Suman,

This is not changed recently. The code was changed in 2003. I checked this before opening the thread.

Thanks.

Read only

0 Likes
2,600

I replied to your response to Atul

Nani wrote:

Thanks for the reply. That is the standard SAP code. It is not the custom code which I wrote.

Read only

0 Likes
2,600

This is not changed recently. The code was changed in 2003. I checked this before opening the thread.

It may have not been changed recently, but the problem is in the custom code.

If you took this to SAP, the first thing they would say is "remove that code and try again".

I think the ball is in your court.

Rob

Read only

0 Likes
2,600

Hi,

This is a custom condition base value routine (You can check the routine in VOFM). These routine are used in pricing procedure in your project. The dump is due to data conversion problem ( overflow).

Now you are seeing a difference of value when you are doing a BAPI and VA01 for XKWERT for the same data you are using.

For that you need check the value XKWERT in debug mode step by step where the value changes.

Thanks.

Read only

Former Member
0 Likes
2,600

The code is dumping in a custom 604 pricing condition.

This should mean that a std VA01 transaction dumps as well. Please verify.

If VA01 dumps, I would go to the developer that created or applied recent changes to this pricing condition.

Read only

0 Likes
2,600

Hi John,

Thanks for the reply. When I create a sales order thru VA01. I am not getting a dump. It gets created sucessfully. I really don't have idea why I am getting such type of dump while creating it thru alv program.

Thanks.

Read only

0 Likes
2,600

Nani,

Set a breakpoint at this statement:

if komp-zzLTKZA ne 'VAR'.

Now run VA01 - does the debugger enter into this IF when running from VA01 - I am assuming that it is not.

Read only

0 Likes
2,600

John,

Yes. My breakpoint is entering into the IF statement.

Thanks.

Read only

0 Likes
2,600

Then investigate the difference in the XKWERT value when run from VA01 versus your BAPI call.

The answer is there.

Read only

0 Likes
2,600

Hi John,

When I debug thru VA01.


KOMP-ZZLTKZA = NOM
XKWERT = 48000.00
ZQTY1 = 4800000
ZQTY2 = 00000004800

When I debug thru BAPI.


KOMP-ZZLTKZA = NOM
XKWERT = 38400000.00
It gives a dump right after this.
ZQTY1 = 0
ZQTY2 = 00000000000

I am specifying same order quantity and Unit of measure in VA01 as well as my BAPI. I really don't have have idea why there is a value difference in XKWERT field in VA01 versus my BAPI.

Please advice/suggest me. Thanks.

Read only

0 Likes
2,600

Nani,

Need to see the BAPI call itself and the loading of the internal tables.

Read only

0 Likes
2,600

John,

Here is what I am doing.


*Assign Header Data And Move To Header Data Final Table
          GS_ORDERHEADERIN-DOC_TYPE            = GC_AUART.
          GS_ORDERHEADERIN-SALES_ORG           = GC_SORG.
          GS_ORDERHEADERIN-DISTR_CHAN          = GC_DISTC.
          GS_ORDERHEADERIN-DIVISION            = GC_DIVI.
          GS_ORDERHEADERIN-ORD_REASON          = GC_AUGRU.
          GS_ORDERHEADERIN-REQ_DATE_H          = WA-USAGE_DATE.
          GS_ORDERHEADERIN-PURCH_DATE          = WA-USAGE_DATE.
          GS_ORDERHEADERIN-PURCH_NO_C          = WA-USAGE_DOC.
         
*Assign Header Data And Move To Header Data Final Table
          GS_ORDERHEADERINX-DOC_TYPE           = GC_FLAG.
          GS_ORDERHEADERINX-SALES_ORG          = GC_FLAG.
          GS_ORDERHEADERINX-DISTR_CHAN         = GC_FLAG.
          GS_ORDERHEADERINX-DIVISION           = GC_FLAG.
          GS_ORDERHEADERINX-ORD_REASON         = GC_FLAG.
          GS_ORDERHEADERINX-REQ_DATE_H         = GC_FLAG.
          GS_ORDERHEADERINX-PURCH_DATE         = GC_FLAG.
          GS_ORDERHEADERINX-PURCH_NO_C         = GC_FLAG.

*ASSIGN ITEMS DATA AND MOVE TO ITEMS DATA FINAL TABLE
        GS_ORDERITEMSIN-ITM_NUMBER         = WA-POSNR.
        GS_ORDERITEMSIN-MATERIAL           = WA-MATERIAL.
        GS_ORDERITEMSIN-TARGET_QTY         = WA-EXT_QTY.      "EXT_QTY is of type LFIMG
        GS_ORDERITEMSIN-TARGET_QU          = WA-EXT_UOM.      "EXT_UOM is of type VRKME
        APPEND GS_ORDERITEMSIN TO GT_ORDERITEMSIN.
        CLEAR GS_ORDERITEMSIN.

*Assign Items Data And Move To Items Data Final Table
        GS_ORDERITEMSINX-ITM_NUMBER        = WA-POSNR.
        GS_ORDERITEMSINX-MATERIAL          = GC_FLAG.
        GS_ORDERITEMSINX-TARGET_QTY        = GC_FLAG.
        GS_ORDERITEMSINX-TARGET_QU         = GC_FLAG.
        APPEND GS_ORDERITEMSINX TO GT_ORDERITEMSINX.
        CLEAR GS_ORDERITEMSINX.

*Assign Schedule Lines Data And Move To Schedule Lines Final Table
        GS_ORDER_SCHEDULES_IN-ITM_NUMBER   = WA-POSNR.
        GS_ORDER_SCHEDULES_IN-REQ_DATE     = WA-USAGE_DATE.
        GS_ORDER_SCHEDULES_IN-REQ_QTY      = WA-EXT_QTY.      "EXT_QTY is of type LFIMG
        APPEND GS_ORDER_SCHEDULES_IN TO GT_ORDER_SCHEDULES_IN.
        CLEAR  GS_ORDER_SCHEDULES_IN.

*Assign Schedule Lines Data And Move To Schedule Lines Final Table
        GS_ORDER_SCHEDULES_INX-ITM_NUMBER  = WA-POSNR.
        GS_ORDER_SCHEDULES_INX-REQ_DATE    = GC_FLAG.
        GS_ORDER_SCHEDULES_INX-REQ_QTY     = GC_FLAG.
        APPEND GS_ORDER_SCHEDULES_INX TO GT_ORDER_SCHEDULES_INX.
        CLEAR  GS_ORDER_SCHEDULES_INX.

*Assign Sold-To-Partner Data And Move To Final Partners Table
        GS_ORDERPARTNERS-PARTN_ROLE          = GC_SP.
        GS_ORDERPARTNERS-PARTN_NUMB          = GV_SOLD.
        APPEND GS_ORDERPARTNERS TO GT_ORDERPARTNERS.
        CLEAR  GS_ORDERPARTNERS.

*Assign Ship-To-Partner Data And Move To Partners Table
        GS_ORDERPARTNERS-PARTN_ROLE          = GC_SH.
        GS_ORDERPARTNERS-PARTN_NUMB          = GV_SHIP.
        APPEND GS_ORDERPARTNERS TO GT_ORDERPARTNERS.
        CLEAR  GS_ORDERPARTNERS.

*Clear Global Variable Field Of Sales Document
          CLEAR:GV_SALESDOCUMENT.

"Right after pressing F6 button after this. It gives me dump.
*Call Function Module To Create Sales Order
          CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
            EXPORTING
              ORDER_HEADER_IN     = GS_ORDERHEADERIN
              ORDER_HEADER_INX    = GS_ORDERHEADERINX
            IMPORTING
              SALESDOCUMENT       = GV_SALESDOCUMENT
            TABLES
              ORDER_ITEMS_IN      = GT_ORDERITEMSIN
              ORDER_ITEMS_INX     = GT_ORDERITEMSINX
              ORDER_SCHEDULES_IN  = GT_ORDER_SCHEDULES_IN
              ORDER_SCHEDULES_INX = GT_ORDER_SCHEDULES_INX
              ORDER_PARTNERS      = GT_ORDERPARTNERS
              RETURN              = GT_BAPIRETURN.

IF SY-SUBRC = 0.
*Call Function Module For BAPI Commit
            CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
              EXPORTING
                WAIT = GC_FLAG.

ENDIF.

All my BAPI tables have been filled with required data in them. But, still it is giving me a dump.

I would really appreciate if some one could suggest me where I am going wrong.

Thanks.

Read only

0 Likes
2,600

Nani,

And you are using the same input data (sold-to, items/qtys) in your VA01 versus BAPI testing?

Read only

0 Likes
2,600

Yes. Of course.

Read only

0 Likes
2,600

Hi,

whatever the reason will be for the different values, field ZQTY1 is defined too short and will lead to a dump also inj other cases. Default length of type I will no tbe enough to get the field value.

Regards,

Klaus

Read only

Former Member
0 Likes
2,600

Check following thread

Markus Doehr explain very well.


Markus Doehr wrote :

Runtime Errors CONVT_OVERFLOW

Note 1167551 - Error message instead of CONVT_OVERFLOW dump in SAPLGLT0

to avoid the dump. Neverless, the number is too big to be handled.


Read only

Clemenss
Active Contributor
0 Likes
2,600

Hi Nani,

use ABAP bulit-in function ROUND.

Regards,

Clemens