‎2011 Jun 24 3:49 PM
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.
‎2011 Jun 24 3:52 PM
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.
‎2011 Jun 24 4:24 PM
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.
‎2011 Jun 24 4:30 PM
Please copy the explanation part. There is a part where it says ERROR ANALYSIS.
‎2011 Jun 24 4:31 PM
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.
‎2011 Jun 24 5:00 PM
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.
‎2011 Jun 24 5:02 PM
Hi Atul,
Thanks for the reply. That is the standard SAP code. It is not the custom code which I wrote.
Thanks.
‎2011 Jun 24 5:02 PM
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
‎2011 Jun 24 5:05 PM
Hi,
Make variable zqty1 type kwert instead of type "i". These must be the same type.
Ernesto
‎2011 Jun 24 5:41 PM
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..
‎2011 Jun 24 5:45 PM
Suman,
This is not changed recently. The code was changed in 2003. I checked this before opening the thread.
Thanks.
‎2011 Jun 24 5:56 PM
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.
‎2011 Jun 24 10:05 PM
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
‎2011 Jun 24 10:14 PM
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.
‎2011 Jun 24 4:37 PM
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.
‎2011 Jun 24 5:05 PM
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.
‎2011 Jun 24 5:07 PM
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.
‎2011 Jun 24 5:15 PM
John,
Yes. My breakpoint is entering into the IF statement.
Thanks.
‎2011 Jun 24 5:16 PM
Then investigate the difference in the XKWERT value when run from VA01 versus your BAPI call.
The answer is there.
‎2011 Jun 24 5:39 PM
Hi John,
When I debug thru VA01.
KOMP-ZZLTKZA = NOM
XKWERT = 48000.00
ZQTY1 = 4800000
ZQTY2 = 00000004800When I debug thru BAPI.
KOMP-ZZLTKZA = NOM
XKWERT = 38400000.00
It gives a dump right after this.
ZQTY1 = 0
ZQTY2 = 00000000000I 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.
‎2011 Jun 24 6:40 PM
Nani,
Need to see the BAPI call itself and the loading of the internal tables.
‎2011 Jun 24 7:04 PM
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.
‎2011 Jun 24 8:55 PM
Nani,
And you are using the same input data (sold-to, items/qtys) in your VA01 versus BAPI testing?
‎2011 Jun 24 10:03 PM
‎2011 Jun 27 5:48 AM
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
‎2011 Jun 25 6:11 AM
‎2011 Jun 25 1:43 PM