Fuba Pricing bsp aufruf ohne Beleg VK11 PR00

SAP R/3 Vertrieb: Auftragsverwaltung, Versand und Transport, Fakturierung, Kreditmanagement, Außenhandel/Zoll...
17 Beiträge • Vorherige Seite 2 von 2 (current)
17 Beiträge Vorherige Seite 2 von 2 (current)

Re: Fuba Pricing bsp aufruf ohne Beleg VK11 PR00

Beitrag von foxtrot (ForumUser / 28 / 1 / 0 ) »
...habe selbst noch etwas weitergesucht:
SD_COND_DETERMINATION ist scheinbar sowas wie "pricing" und arbeitet ein ganzes Kalk.schema ab, vom Verwendungsnachweis eher für andere Anwendungen der Konditionstechnik.
Und beide FuB verwenden dann "weiter drinnen" den
SD_COND_ACCESS - der arbeitet aber schon auf der einzelnen Zeile der Zugriffsfolge.

Noch eine Erkenntnis meinerseits: wenn ich den PRICING verwende, muss ich ihn entweder pro Konditionsart extra aufrufen, weil in dem Kalk-schema, das wir verwenden, jede betroffene Kondition eine Bedingung hat, die die anderen ausschließen, oder ich muss mir ein neues Kalk-schema ohne Bedingungen bauen, damit ich mit einem Aufruf alle Konditionen bekomme...

Wie gesagt: falls doch noch wer einen FuBa weiß, der genau die Findung einer einzelnen Kondition kann...

gesponsert
Stellenangebote auf ABAPforum.com schalten
kostenfrei für Ausbildungsberufe und Werksstudenten


Re: Coding für Aufruf FuBa PRICING ohne Beleg

Beitrag von foxtrot (ForumUser / 28 / 1 / 0 ) »
solidforms hat geschrieben:

Code: Alles auswählen.

FUNCTION z_calculate_price .
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(IV_KUNNR) TYPE  KUNNR DEFAULT '100000'
*"     VALUE(IV_VKORG) TYPE  VKORG DEFAULT '1100'
*"     VALUE(IV_VTWEG) TYPE  VTWEG DEFAULT '10'
*"     VALUE(IV_SPART) TYPE  SPART DEFAULT '10'
*"     VALUE(IV_WERKS) TYPE  WERKS_D DEFAULT '1110'
*"     VALUE(IV_WAERS) TYPE  WAERS DEFAULT 'EUR'
*"     VALUE(IT_ITEM_IN) TYPE  ZITEM01_T OPTIONAL
*"  EXPORTING
*"     VALUE(IT_ITEM_OUT) TYPE  ZITEM02_T
*"  EXCEPTIONS
*"      VKORG_NOT_FOUND
*"      BUKRS_NOT_FOUND
*"      WERKS_NOT_FOUND
*"      KNA1_NOT_FOUND
*"      KNVV_NOT_FOUND
*"----------------------------------------------------------------------

* Deklarationen ------------------------------------------------------- *
  DATA: ls_item_in         TYPE zitem01_s,
        ls_item_out        TYPE zitem02_s,
        ls_t001            TYPE ty_t001,
        ls_tvko            TYPE ty_tvko,
        ls_t001w           TYPE ty_t001w,
        ls_kna1            TYPE ty_kna1,
        ls_knvv            TYPE ty_knvv.

  REFRESH: it_item_out.
* TVKO lesen ---------------------------------------------------------- *
  SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_tvko
         FROM tvko
         WHERE vkorg = iv_vkorg.
  IF sy-subrc NE 0.
    RAISE vkorg_not_found.
    EXIT.
  ENDIF.
* T001 lesen ---------------------------------------------------------- *
  SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_t001
         FROM t001
         WHERE bukrs = ls_tvko-bukrs.
  IF sy-subrc NE 0.
    RAISE bukrs_not_found.
    EXIT.
  ENDIF.
* T001W lesen --------------------------------------------------------- *
  SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_t001w
         FROM t001w
         WHERE werks = iv_werks.
  IF sy-subrc NE 0.
    RAISE werks_not_found.
    EXIT.
  ENDIF.
* KNA1 lesen ---------------------------------------------------------- *
  SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_kna1
         FROM kna1
         WHERE kunnr = iv_kunnr.
  IF sy-subrc NE 0.
    RAISE kna1_not_found.
    EXIT.
  ENDIF.
* KNVV lesen ---------------------------------------------------------- *
  SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_knvv
         FROM knvv
         WHERE kunnr = iv_kunnr
         AND   vkorg = iv_vkorg
         AND   vtweg = iv_vtweg
         AND   spart = iv_spart.
  IF sy-subrc NE 0.
    RAISE knvv_not_found.
    EXIT.
  ENDIF.

  LOOP AT it_item_in INTO ls_item_in.
      PERFORM calculate_price USING       ls_item_in
                                          ls_t001
                                          ls_tvko
                                          ls_t001w
                                          ls_kna1
                                          ls_knvv
                                          iv_waers
                              CHANGING    ls_item_out.

    APPEND ls_item_out TO it_item_out.
  ENDLOOP.

ENDFUNCTION.

*----------------------------------------------------------------------*
***INCLUDE LZCALCULATE_PRICEF01 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  CALCULATE_PRICE
*&---------------------------------------------------------------------*

FORM calculate_price  USING    ps_item_in  TYPE zitem01_s
                               ps_t001     TYPE ty_t001
                               ps_tvko     TYPE ty_tvko
                               ps_t001w    TYPE ty_t001w
                               ps_kna1     TYPE ty_kna1
                               ps_knvv     TYPE ty_knvv
                               pv_waers    TYPE waers
                      CHANGING ps_item_out TYPE zitem02_s.

* Deklarationen ------------------------------------------------------ *
  DATA: lv_spras      TYPE spras,
        lv_bwkey      TYPE mbew-bwkey.
  DATA: ls_komk_i     TYPE komk,
        ls_komp_i     TYPE komp.
  DATA: ls_komk_e     TYPE komk,
        ls_komp_e     TYPE komp,
        ls_mara       TYPE ty_mara,
        ls_mvke       TYPE ty_mvke,
        ls_mbew       TYPE ty_mbew,
        ls_vbpa       TYPE vbpavb,
        ls_mtcom      TYPE mtcom,
        ls_maapv      TYPE maapv,
        lv_vtext      TYPE bezei20,
        lv_vbeln      TYPE vbeln,
        lv_kontr      TYPE boole_d.
  DATA: lt_komv       TYPE TABLE OF komv,
        lt_tkomvd     TYPE TABLE OF komvd,
        lt_vbpa       TYPE TABLE OF vbpavb,
        lv_pltyp      TYPE knvv-pltyp,
        lv_matnr      TYPE matnr,
        lv_kunnr_za   TYPE kunnr.

* Initialisieren ----------------------------------------------------- *
  ps_item_out-errormsg = ''.
  ps_item_out-errorcode = 0.

* Materialview lesen ------------------------------------------------- *
  ls_mtcom-kenng = 'MAAPV'.
  ls_mtcom-matnr = ps_item_in-matnr.
  ls_mtcom-vkorg = ps_knvv-vkorg.
  ls_mtcom-vtweg = ps_knvv-vtweg.
  ls_mtcom-spras = sy-langu.
  ls_mtcom-maxtz = 100.

  CALL FUNCTION 'MATERIAL_READ'
    EXPORTING
      schluessel = ls_mtcom
    IMPORTING
      matdaten   = ls_maapv
*     RETURN     =
*     MATPER     =
    EXCEPTIONS
      OTHERS     = 25.
  IF sy-subrc <> 0.
    ps_item_out-errorcode = 200.
    CONCATENATE 'material not found: ' ls_mtcom-matnr INTO ps_item_out-errormsg.
  ENDIF.

* Kundenhierarchie lesen --------------------------------------------- *
  CALL FUNCTION 'SD_CUSTOMER_HIERARCHY_PATH'
    EXPORTING
      customer        = ps_kna1-kunnr
      date            = sy-datum
      htype           = 'Z'
      sales_channel   = ps_knvv-vtweg
      sales_division  = ps_knvv-spart
      sales_org       = ps_knvv-vkorg
    TABLES
      hpath           = lt_vbpa
    EXCEPTIONS
      hityp_not_exist = 1
      node_not_exist  = 2
      parvw_not_exist = 3
      OTHERS          = 4.
  IF sy-subrc <> 0 AND sy-subrc <> 2.
    ps_item_out-errorcode = 300 + sy-subrc.
    CASE sy-subrc.
      WHEN 1.
        ps_item_out-errormsg = 'Hityp not found: Z'.
      WHEN 3.
        ps_item_out-errormsg = 'Parvw not found.'.
    ENDCASE.
  ENDIF.

* Preisliste ggfs. aus Partner ZA ermitteln -------------------------- *
  READ TABLE lt_vbpa INTO ls_vbpa WITH KEY posnr = '000000'
                                           parvw = 'ZA'.
  IF sy-subrc = 0.
    lv_kunnr_za = ls_vbpa-kunnr.
    SELECT SINGLE pltyp INTO lv_pltyp
           FROM knvv
           WHERE kunnr = lv_kunnr_za
           AND   vkorg = ps_knvv-vkorg
           AND   vtweg = ps_knvv-vtweg
           AND   spart = ps_knvv-spart.
    SELECT SINGLE matnr INTO lv_matnr
          FROM a953
          WHERE kappl = 'V'
          AND ( kschl = 'ZPRF'
            OR  kschl = 'ZPR0' )
          AND   pltyp = lv_pltyp
          AND   matnr = ps_item_in-matnr
          AND   kfrst = space
          AND   datbi >= sy-datum.
    IF NOT lv_pltyp IS INITIAL AND
       NOT lv_matnr IS INITIAL.
    ELSE.
      CLEAR lv_pltyp.
    ENDIF.
  ELSE.
    lv_pltyp = ps_knvv-pltyp.
  ENDIF.

* Materialgruppentext ermitteln (T178T) ------------------------------ *
  SELECT SINGLE vtext INTO lv_vtext
    FROM T178T
    WHERE spras = ps_item_in-spras
    AND kondm = ls_maapv-kondm.

* Kontrakte suchen (VAPMA) ------------------------------------------- *
  CLEAR lv_vbeln.
  SELECT SINGLE vbeln INTO lv_vbeln
    FROM VAPMA
    WHERE matnr = ps_item_in-matnr
    AND   vkorg = ps_knvv-vkorg
    AND   trvog = '4'
    AND   vtweg = ps_knvv-vtweg
    AND   spart = ps_knvv-spart
    AND   auart = 'ZKM'
    AND   kunnr = ps_kna1-kunnr
    AND   datab <= sy-datum
    AND   datbi >= sy-datum.
  IF lv_vbeln IS INITIAL.
    lv_kontr = ' '.
  ELSE.
    lv_kontr = 'X'.
  ENDIF.

* KOMK füllen -------------------------------------------------------- *
  ls_komk_i-vkorg     = ps_knvv-vkorg.
  ls_komk_i-vtweg     = ps_knvv-vtweg.
  ls_komk_i-spart     = ps_knvv-spart.
  ls_komk_i-vkbur     = ps_knvv-vkbur.
  ls_komk_i-wkreg     = ps_t001w-regio.
  ls_komk_i-zterm     = ps_knvv-zterm.
  ls_komk_i-vsbed     = ps_knvv-vsbed.
  ls_komk_i-pltyp     = lv_pltyp.
  ls_komk_i-aland     = ps_t001-land1.
  ls_komk_i-bukrs     = ps_t001-bukrs.
  ls_komk_i-hwaer     = ps_t001-waers.
  ls_komk_i-waerk     = pv_waers.
  ls_komk_i-kunnr     = ps_kna1-kunnr.
  ls_komk_i-knrze     = ps_kna1-kunnr.
  ls_komk_i-kunre     = ps_kna1-kunnr.
  ls_komk_i-kunwe     = ps_kna1-kunnr.
  ls_komk_i-kappl     = 'V'.
  ls_komk_i-kalsm     = 'ZBAA02'.
  ls_komk_i-prsdt     = sy-datum.
  ls_komk_i-fkdat     = sy-datum.
  ls_komk_i-fbuda     = sy-datum.
  ls_komk_i-audat     = sy-datum.
  ls_komk_i-erdat     = sy-datum.
  ls_komk_i-land1     = ps_kna1-land1.
  ls_komk_i-taxk1     = '1'.
  ls_komk_i-land1_we  = ps_kna1-land1.
  ls_komk_i-aland_werk = ps_t001w-land1.
  ls_komk_i-auart     = 'ZES'.
  ls_komk_i-vbtyp     = 'C'.
  ls_komk_i-vkorgau   = ps_knvv-vkorg.
  ls_komk_i-auart_sd  = 'ZES'.
  ls_komk_i-trtyp     = 'H'.
  ls_komk_i-werks     = ps_t001w-werks.
*  ls_komk_i-vsbed     = '01'.
  ls_komk_i-ix_komk   = 1.
  LOOP AT lt_vbpa INTO ls_vbpa WHERE prfre   = 'X'
                               AND   histunr GT 0
                               AND   posnr   = '000000'.
    CASE ls_vbpa-histunr.
      WHEN '01'.
        ls_komk_i-hienr01 = ls_vbpa-kunnr.
      WHEN '02'.
        ls_komk_i-hienr02 = ls_vbpa-kunnr.
      WHEN '03'.
        ls_komk_i-hienr03 = ls_vbpa-kunnr.
      WHEN '04'.
        ls_komk_i-hienr04 = ls_vbpa-kunnr.
      WHEN '05'.
        ls_komk_i-hienr05 = ls_vbpa-kunnr.
      WHEN '06'.
        ls_komk_i-hienr06 = ls_vbpa-kunnr.
      WHEN '07'.
        ls_komk_i-hienr07 = ls_vbpa-kunnr.
      WHEN '08'.
        ls_komk_i-hienr08 = ls_vbpa-kunnr.
      WHEN '09'.
        ls_komk_i-hienr09 = ls_vbpa-kunnr.
      WHEN '10'.
        ls_komk_i-hienr10 = ls_vbpa-kunnr.
      WHEN '11'.
        ls_komk_i-hienr11 = ls_vbpa-kunnr.
      WHEN '12'.
        ls_komk_i-hienr12 = ls_vbpa-kunnr.
      WHEN '13'.
        ls_komk_i-hienr13 = ls_vbpa-kunnr.
      WHEN '14'.
        ls_komk_i-hienr14 = ls_vbpa-kunnr.
      WHEN '15'.
        ls_komk_i-hienr15 = ls_vbpa-kunnr.
    ENDCASE.
  ENDLOOP.

* KOMP füllen -------------------------------------------------------- *
  ls_komp_i-kposn         = '000010'.
  ls_komp_i-matnr         = ps_item_in-matnr.
  ls_komp_i-werks         = ps_t001w-werks.
  ls_komp_i-bwkey         = ps_t001w-werks.
  ls_komp_i-matkl         = ls_maapv-matkl.
  ls_komp_i-taxps         = '000010'.
  ls_komp_i-ean11         = ls_maapv-ean11.
  ls_komp_i-prodh         = ls_maapv-prdha.
  ls_komp_i-pmatn         = ps_item_in-matnr.
  ls_komp_i-meins         = ls_maapv-meins.
  ls_komp_i-mglme         = ps_item_in-menge.
  ls_komp_i-lagme         = ps_item_in-vrkme.
  ls_komp_i-mgame         = ps_item_in-menge.
  ls_komp_i-vrkme         = ps_item_in-vrkme.
  ls_komp_i-brgew         = ls_maapv-brgew.
  ls_komp_i-ntgew         = ls_maapv-ntgew.
  ls_komp_i-gewei         = ls_maapv-gewei.
  ls_komp_i-volum         = ls_maapv-volum.
  ls_komp_i-voleh         = ls_maapv-voleh.
  ls_komp_i-sktof         = ls_maapv-sktof.
  ls_komp_i-kondm         = ls_maapv-kondm.
  ls_komp_i-wkreg         = ps_t001w-regio.
  ls_komp_i-prsfd         = 'X'.
  ls_komp_i-evrwr         = 'X'.
  ls_komp_i-kursk         = 1.
  ls_komp_i-taxm1         = '1'.
  ls_komp_i-prsok         = 'A'.
  ls_komp_i-aubel         = '$TEMP'.
  ls_komp_i-aupos         = '000010'.
  ls_komp_i-pstyv         = 'ZTAN'.
*  ls_komp_i-zzroute       = ls_kna1-route.
  ls_komp_i-ix_komk         = 1.

* Preisfindung simulieren -------------------------------------------- *
  CALL FUNCTION 'PRICING'
    EXPORTING
      calculation_type = 'C'
      comm_head_i      = ls_komk_i
      comm_item_i      = ls_komp_i
    IMPORTING
      comm_head_e      = ls_komk_e
      comm_item_e      = ls_komp_e
    TABLES
      tkomv            = lt_komv.

* Ausgabestruktur füllen --------------------------------------------- *
  MOVE-CORRESPONDING ps_item_in TO ps_item_out.
* ps_item_out-kbetr = ls_komp_e-netpr.
  IF ps_item_in-menge NE 0 AND
     ps_item_in-menge NE 0.
    ps_item_out-kbetr = ls_komp_e-kzwi2
                      / ps_item_in-menge
                      / ls_komp_e-kpein.
  ELSE.
    ps_item_out-kbetr = ls_komp_e-netpr.
  ENDIF.
  ps_item_out-kpein = ls_komp_e-kpein.
  ps_item_out-kmein = ls_komp_e-kmein.
  ps_item_out-kwert = ls_komp_e-kzwi2.
  ps_item_out-waers = pv_waers.
  ps_item_out-kondm = ls_maapv-kondm.
  ps_item_out-vtext = lv_vtext.
  ps_item_out-kontr = lv_kontr.

ENDFORM.                    " CALCULATE_PRICE
Anmerkung dazu: die Typen ty_* habe ich in SAP nicht gefunden, aber si_* existiert für alle außer KNVV...?
Ich hab jetzt einfach mit "like" deklariert.

Und die Sache funktioniert jetzt einmal tatsächlich für zwei Konditionen... der Rest ist dann machbar.
Laufzeit muss ich mir dann am Q-System erst anschauen...

Vergleichbare Themen

5
Antw.
2928
Views
FUBA Pricing, manuelle Preisfindung über Code der Kondition PR00
von Hunty » 14.12.2022 15:25 • Verfasst in Sales and Distribution
2
Antw.
2408
Views
FUBA oder BAPI für VK11
von cuncon » 23.01.2019 15:22 • Verfasst in ABAP® für Anfänger
0
Antw.
1133
Views
FuBa Pricing
von slim » 10.07.2008 15:27 • Verfasst in ABAP® Core
0
Antw.
1962
Views
Fuba: Vorerfassten Beleg ändern
von krishanps » 17.06.2015 23:20 • Verfasst in ABAP® Core
0
Antw.
1297
Views
[SUCHE] Beleg vorerfassen / park document FUBA
von Schmarsi » 01.02.2012 16:03 • Verfasst in ABAP® Core

Aktuelle Forenbeiträge

Dialog-Container mit Toolbar/Status
vor 10 Stunden von DeathAndPain gelöst 22 / 3016
Daten an Tabelle binden
vor 15 Stunden von Lukas Sanders 2 / 985
Zeilenumbrüche ersetzen
vor 2 Tagen von ralf.wenzel 6 / 551

Newsletter Anmeldung

Keine Beiträge verpassen! Wöchentlich versenden wir lesenwerte Beiträge aus unserer Community.
Die letzte Ausgabe findest du hier.
Details zum Versandverfahren und zu Ihren Widerrufsmöglichkeiten findest du in unserer Datenschutzerklärung.

Aktuelle Forenbeiträge

Dialog-Container mit Toolbar/Status
vor 10 Stunden von DeathAndPain gelöst 22 / 3016
Daten an Tabelle binden
vor 15 Stunden von Lukas Sanders 2 / 985
Zeilenumbrüche ersetzen
vor 2 Tagen von ralf.wenzel 6 / 551

Unbeantwortete Forenbeiträge

aRFC im OO-Kontext
vor 4 Wochen von ralf.wenzel 1 / 2565
Hilfe bei SWEC/SWE2
September 2024 von retsch 1 / 9146