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

SD: BAPI_SALESORDER_CREATEFROMDAT2 run in simulation (testrun set): How to get pricing details/conditions?

Former Member
0 Likes
2,861

Hi there,

I advised to to use this BAPI for one to create sales order and 2nd also to 'simulate' the sales order. Simulation is done by setting the testrun flag in the interface.

How to get access to pricing elements in simulation running BAPI_SALESORDER_CREATEFROMDAT2?

But the task at hand includes to 'report' the pricing details (XKOMV) to the caller. That works fine in creation in user exits 'USEREXIT_SAVE_DOCUMENT_PREPARE' or 'USEREXIT_SAVE_DOCUMENT' to get access to the pricing details.

Unfortunately these exists are not called when the testing flag is set - and what is the best way to get access to the pricing elements/conditions here?

Any idea?

BAPI_SALESORDER_SIMULATE

I am aware of the BAPI_SALESORDER_SIMULATE - but let's assume that this would not be an option here?

Can it be done?

Thanks for your input,

CN

Hi there,

I advised to to use this BAPI for one to create sales order and 2nd also to 'simulate' the sales order. Simulation is done by setting the testrun flag in the interface.

How to get access to pricing elements in simulation running BAPI_SALESORDER_CREATEFROMDAT2?

But the task at hand includes to 'report' the pricing details (XKOMV) to the caller. That works fine in creation in user exits 'USEREXIT_SAVE_DOCUMENT_PREPARE' or 'USEREXIT_SAVE_DOCUMENT' to get access to the pricing details.

Unfortunately these exists are not called when the testing flag is set - and what is the best way to get access to the pricing elements/conditions here?

Any idea?

BAPI_SALESORDER_SIMULATE

I am aware of the BAPI_SALESORDER_SIMULATE - but let's assume that this would not be an option here?

Can it be done?

Thanks for your input,

CN

2 REPLIES 2
Read only

Former Member
0 Likes
1,400

You can try using the BAPI_SALESORDER_SIMULATE. Refer the below thread that also deals with the same requirement.

http://scn.sap.com/thread/180575

~Srini

Read only

Former Member
0 Likes
1,400

Hi Christian

You can do simulate pricing conditions using function module: GN_INVOICE_CREATE

You only have to fill mandatory fields as if you were creating a sales order, but in this case in structure xkomfkgn.

Example:

      clear: xkomfkgn, xkomfkgn[], xkomfk, xkomfk[], xkomfkgn, xkomfkgn[],

             xkomfkko, xkomfkko[], xkomv, xkomv[], xthead, xthead[],

             xvbfs, xvbfs[], xvbpa, xvbpa[], xvbfs, xvbfs[], xvbpa, xvbpa[],

             xvbrk, xvbrk[], xvbrp, xvbrp[], xvbss, xvbss[].


*   Before calling function module we have to fill structure xkomfkgn.

      select single * from mara CLIENT SPECIFIED

        where mandt = sy-mandt

        and   matnr = i_knmt-matnr.

      xkomfkgn-kwmeng = '1'.

      xkomfkgn-vrkme  = mara-meins.

      xkomfkgn-vkorg  = p_vkorg.

      xkomfkgn-vtweg  = vtweg.

      xkomfkgn-kunag  = i_knvv-kunnr.

      xkomfkgn-mandt  = sy-mandt.

      xkomfkgn-auart  = 'TA'.

      xkomfkgn-spart  = 10.

      xkomfkgn-fkara  = 'ZFXX'.

      xkomfkgn-pstyv  = 'TAN'.

      xkomfkgn-werks  = p_vkorg.

      xkomfkgn-matnr   = i_knmt-matnr.

      xkomfkgn-zzpos   = i_knmt-zzpos.

      xkomfkgn-zzkdmat = i_knmt-kdmat.

      xkomfkgn-kunwe = i_knvv-kunnr.

      xkomfkgn-zzmvgr1 = i_knmt-zzmvgr1.

      xkomfkgn-zterm = i_knvv-zterm.

      APPEND xkomfkgn.

*     We call function module GN_INVOICE_CREATE

      data: d like sy-datum.

      d = sy-datum - 1.

      CALL FUNCTION 'GN_INVOICE_CREATE'

        EXPORTING

          delivery_date = d

          invoice_date  = d

          invoice_type  = 'ZFXX'

          pricing_date  = d

          vbsk_i        = xvbsk

          id_kvorg      = 'X'

          id_no_dialog  = 'X'

        TABLES

          xkomfk        = xkomfk

          xkomfkgn      = xkomfkgn

          xkomfkko      = xkomfkko

          xkomv         = xkomv

          xthead        = xthead

          xvbfs         = xvbfs

          xvbpa         = xvbpa

          xvbrk         = xvbrk

          xvbrp         = xvbrp

          xvbss         = xvbss.



*     We fill general data

      i_datos-kunnr = i_knvv-kunnr.

      i_datos-matnr = i_knmt-matnr.

      i_datos-kdmat = i_knmt-kdmat.

      i_datos-vkorg = p_vkorg.

      i_datos-DATAC = sy-datum - 1.

      i_datos-waers = 'EUR'.

      i_datos-zterm = zterm.

      i_datos-vtext = vtext.



*     We get price (PR00)

      read table xkomv with key kschl = 'PR00'.

      if sy-subrc = 0.

        if xkomv-kpein <> 0.

          i_datos-prnet = ( xkomv-kbetr / xkomv-kpein ) * 1000.

        else.
          if xkomv-kmein = 'KG'.
            i_datos-prnet = ( xkomv-kbetr / 10 ) * 1000.
          else.
            i_datos-prnet = ( xkomv-kbetr / 10 ).
          endif.
        endif.
      endif.

Best Regards, Pablo Vicens.