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 using BAPI for Creating SO

Former Member
0 Likes
2,571

Dear Experts,

I am creating the Sales Order with Reference to Contract.

My user will send a file where it contains, Ship to part, Net weight, Date, Incoterms, Material number, Shipping condition and Shipping type. Depends on Unit provide in Contract, same is using while passing the value to BAPI

I am using BAPI_SALESORDER_CREATEFROMDAT2.

I am passing all the information required. But at end i am getting the message in RETURN Parameters as (SD Document ********** is Archived or not in Database). And getting as Updated Terminated. When i check in ST22 - its giving as

Error analysis
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught
     in
    procedure "OIC_UPDATE_FORMULAE" "(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:
    If you use an ABAP/4 Open SQL array insert to insert a record in
    the database and that record already exists with the same key,
    this results in a termination.

    (With an ABAP/4 Open SQL single record insert in the same error
    situation, processing does not terminate, but SY-SUBRC is set to 4.)

When i am trying to Create Sales Order manually (with refernce to Contrace), i can able to Create Sales Order. But while using BAPI, i am unable to create.

Kindly help to solve the issue.

Thanks & Regards,

Srinivas

14 REPLIES 14
Read only

Sijin_Chandran
Active Contributor
0 Likes
2,448

Hi Srini ,

I guess the problem is with the Contract you have passed while creating Sale Order using BAPI ,

Have you checked with that particular Contract ?

Read only

0 Likes
2,448

Hi Sijin,

Thanks for your reply.

I check the Contract what i am passing to BAPI.

header-doc_type = ***.
header-ref_doc   = **********.

In Header i am passing Contract Number and in HeaderX with 'X'.

Thanks & Regards,

Srinivas

.

Read only

0 Likes
2,448

No , am saying that try creating a Sale Order manually with Contract using VA01 .

Read only

0 Likes
2,448

Hi Sajin,

I can able to create Sales Order manually with Contract.

I check whether any Incomplete log, there is no error.

Thanks & Regards,

Srinivas

Read only

gurunathkumar_dadamu
Active Contributor
0 Likes
2,448

Hi ,

check whether the contract is created or not and also check in database  tables.make sure that pass  same data which is contact.

let me know if still any issues.

Regards,

Gurunath Kumar D

Read only

0 Likes
2,448

Hi Kumar,

Contract is created, and i can able to create Sales Order manually without error. but while using BAPI, i am getting error.

Its failing in Standard Code

 

IF

L_REC_UPD NE SPACE.
CLEAR L_REC_UPD.
INSERT OICQ8 FROM TABLE XOICQ8. - trying to insert the Record which already exits.

this is taking from ST22 dump.

Thanks & Regards,

Srinivas

Read only

0 Likes
2,448

Hi Srini ,

Paste your program .

Read only

0 Likes
2,448

Hi Sajin,

Please the code. Date is in US format MM/DD/YYYY. This format will depends upon our User Profile.

  header-doc_type   = p_auart.
  header-ref_doc    = p_zsd_spl-vbelnc ( Contract number).
  header-refdoc_cat = wc_g.
  header-sales_org  = wc_2072.
  header-distr_chan = wc_30.
  header-division   = wc_41.
  header-purch_no_c = p_zsd_spl-bstkd.
  header-ship_cond  = wa_vsbed.
  header-ship_type  = p_zsd_spl-vsbed.
  header-req_date_h = p_zsd_spl-loaddat.
  header-name       = p_zsd_spl-bol ( Internal Number or Name).
  header-price_date = p_zsd_spl-loaddat.
  headerx-sales_org = wc_x.
  headerx-distr_chan = wc_x.
  headerx-division   = wc_x.
  headerx-ref_doc    = wc_x.
  headerx-refdoc_cat = wc_x.
  headerx-purch_no_c = wc_x.
  headerx-ship_cond  = wc_x.
  headerx-ship_type  = wc_x.
  headerx-req_date_h = wc_x.
  headerx-sales_grp  = wc_x.
  headerx-name       = wc_x.
  headerx-price_date = wc_x.

  item-itm_number = '000010'.
  item-material   = p_zsd_spl-matnr.
  IF wlv_vrkme = 'GAL'.
    item-target_qty = p_zsd_spl-qtygal.
    item-sales_unit = 'GLL'.
  ELSEIF wlv_vrkme = 'GLL'.
    item-target_qty = p_zsd_spl-qtygal.
    item-sales_unit = 'GLL'.
  ELSE.
    item-target_qty = p_zsd_spl-qtylb.
    item-sales_unit = 'LB'.
  ENDIF.
  item-ship_point = wa_vstel.
  item-route      = wa_route.
  item-plant      = wa_werks.
  item-store_loc  = wa_loc.
  item-ref_doc    = p_zsd_spl-vbelnc.
  item-ref_doc_it = p_zsd_spl-posnrc.
  item-ref_doc_ca = wc_g.
  item-val_contr  = p_zsd_spl-vbelnc (Contract Number).
  item-val_con_i  = p_zsd_spl-posnrc.
  APPEND item.

  itemx-itm_number = '000010'.
  itemx-material   = wc_x.
  itemx-target_qty = wc_x.
  itemx-sales_unit = wc_x.
  itemx-ship_point = wc_x.
  itemx-route      = wc_x.
  itemx-plant      = wc_x.
  itemx-store_loc  = wc_x.
  itemx-ref_doc    = wc_x.
  itemx-ref_doc_it = wc_x.
  itemx-ref_doc_ca = wc_x.
  itemx-val_contr  = wc_x.
  itemx-val_con_i  = wc_x.
  APPEND itemx.

  schedules-itm_number = item-itm_number.
  schedules-req_qty = item-target_qty.
  APPEND schedules.

  schedulesx-itm_number = item-itm_number.
  schedulesx-req_qty = wc_x.
  APPEND schedulesx.

  partner-partn_role = 'WE'.
  partner-partn_numb = p_zsd_spl-kunwe (Ship to Party).
  APPEND partner.

In my example. Sold to party will differ from Shipt to party.

Thanks & Regards,

Srinivas

Read only

0 Likes
2,448

Hi srini,

i think no need to pass the reference doc no as contract no.

Regards,

Gurunath

Read only

0 Likes
2,448

Hi Kumar,

I created a new contract with Sales Unit GAL, Now i can able to create Sales order.

But when i try to created the Contract with Sales unit LB, but i am unable to create SO through BAPI, but manually i can able to create SO.

I am passing the reference doc no as contract no.

I am not aware why this happen when Sales Unit is LB. I will try to create Sales Order with sales unit TO also. I will check whether i can able to create SO or Not.

Thanks & Regards,

Srinivas

Read only

0 Likes
2,448

Hi Kumar,

I had a problem regarding ship to party.

When i run the BAPI to create SO with reference Contract, It should copy the exisiting values from contract and need to create SO.

Eg. Sold to party in Contract is XXXXXX

      Ship to party in Contract is YYYYY.

It should copy these values.

But while mainiting the Customer YYYYY, we maintian two Ship to Party - YYYYY and NNNNN.

So in BAPI, it is picking this NNNNN( from KNVP Table)  instead of XXXXX and creating SO. So my Pricing is not calculated. In KNVP table, for Ship to party we have 2 entries ( YYYYY and NNNNN).

The value NNNNN is passing as Sold to Party to created SO. But it is wrong.

Kindly sort my problem.

Thanks & Regards,

Srinivas

Read only

0 Likes
2,448

Hi Srini,

while picking the sols-to-party and ship to party pick the values based on partner function.

if partner func = 'AG'.  (ship-to-party)

pick the partner value and paas it.

endif.

if partner func = 'WE' (ship-to-party)

pick the partner value

endif.

Regards,

Gurunath Kumar D

Read only

0 Likes
2,448

Hi,

I am getting same dump while creating Sales Order with refernece to contract, by using BAPI.

I am passing all the information required. But at end i am getting the message in RETURN Parameters as (SD Document ********** is Archived or not in Database). And getting as Updated Terminated. When i check in ST22 - its giving as

Error analysis
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught
     in
    procedure "OIC_UPDATE_FORMULAE" "(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:
    If you use an ABAP/4 Open SQL array insert to insert a record in
    the database and that record already exists with the same key,
    this results in a termination.

    (With an ABAP/4 Open SQL single record insert in the same error
    situation, processing does not terminate, but SY-SUBRC is set to 4.)

Kindly help me to solve this.

Thanks & Regards,

Srinivas

Read only

RaymondGiuseppi
Active Contributor