SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

BAPI_PRICES_CONDITIONS



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI
View previous topic :: View next topic  
Author Message
vga
Мастер
Мастер


Age: 160
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Sat Nov 29, 2008 4:26 pm    Post subject: BAPI_PRICES_CONDITIONS Reply with quote

BAPI_PRICES_CONDITIONS - BAPI for Price and Rebate Usage Condition Records

Code:
* nur die rein den BAPI betreffenden Abschnitte
  DATA:
    dd02l_tabname LIKE dd02l-tabname,
*   BAPI_PRICES_CONDITIONS-Tabellen
    ti_bapicondct  TYPE TABLE OF bapicondct WITH HEADER LINE,
    ti_bapicondhd  TYPE TABLE OF bapicondhd WITH HEADER LINE,
    ti_bapicondit  TYPE TABLE OF bapicondit WITH HEADER LINE,
    ti_bapicondqs  TYPE TABLE OF bapicondqs WITH HEADER LINE,
    ti_bapicondvs  TYPE TABLE OF bapicondvs WITH HEADER LINE,
    to_bapiret2    TYPE TABLE OF bapiret2   WITH HEADER LINE,
    to_bapiknumhs  TYPE TABLE OF bapiknumhs,
    to_mem_initial TYPE TABLE OF cnd_mem_initial WITH HEADER LINE,
    help_vakey LIKE ti_bapicondct-varkey.

* Fehlerauswertung
  DATA: BEGIN OF fehler_tab OCCURS 0,  " Tabelle für Fehlermeldungen
          line LIKE sy-lisel,                               " 255 Char
        END OF fehler_tab.
*        returncode(2).

  TABLES: a914, a915, a916, a918.
*   Neue KonditionsNr holen für Neuanlage Kondition
  DATA: knumh_new TYPE knumh.
  DATA: ls_return TYPE bapiret2.
* weiter Daten zu Konditionen
  DATA: help_konp LIKE konp.
  DATA: help_konm LIKE konm.
  DATA: help_konw LIKE konw.



 SELECTION-SCREEN BEGIN OF BLOCK block5 WITH FRAME TITLE text-bl5.
  PARAMETERS:
    p_preis AS CHECKBOX MODIF ID upd,
    p_proz  TYPE kbetr_kond MODIF ID upd,
    p_datab LIKE a005-datab MODIF ID upd,
    p_datbi LIKE a005-datbi MODIF ID upd,
    p_waers LIKE a916-waerk DEFAULT 'EUR' MODIF ID upd.
  PARAMETERS:
    p_kappl LIKE a914-kappl DEFAULT 'V' NO-DISPLAY.
  SELECTION-SCREEN END OF BLOCK block5.



*---------------------------------------------------------------------*
*      Form  preisanpassung
*---------------------------------------------------------------------*
  FORM preisanpassung USING alter_preis TYPE kbetr_kond     " CURR 11.2
                            neuer_preis TYPE kbetr_kond.
    neuer_preis = alter_preis + ( alter_preis * p_proz / 100 ).
  ENDFORM.                    " preisanpassung
*


*---------------------------------------------------------------------*
*      Form  bapi_prices_conditions
*---------------------------------------------------------------------*
  FORM bapi_prices_conditions.
    CLEAR: ti_bapicondct, ti_bapicondhd, ti_bapicondit, ti_bapicondqs,
      ti_bapicondvs, to_bapiret2, to_bapiknumhs, to_mem_initial.
    REFRESH: ti_bapicondct, ti_bapicondhd, ti_bapicondit, ti_bapicondqs,
      ti_bapicondvs, to_bapiret2, to_bapiknumhs, to_mem_initial.

    gestern = sy-datum - 1.
    dd02l_tabname = 'A914'.
    PERFORM fill_a914.
    PERFORM bapi_buchen.
  ENDFORM.                    " bapi_prices_conditions


*---------------------------------------------------------------------*
*      Form  fill_a914
*---------------------------------------------------------------------*
  FORM fill_a914.
*  Bapi für Tabelle A914 füllen
*** alle markierten zutreffenden Konditionen aus A914 auslesen
    LOOP AT et_row_no. " enthält die markierten Zeilen
      IF p_ekinfo = ''.
        READ TABLE i_ausg INDEX et_row_no-row_id.
        SELECT SINGLE * FROM a914 CLIENT SPECIFIED
         WHERE mandt = sy-mandt
           AND kappl = p_kappl  " Applikation, V = Vetrieb
           AND kschl = i_ausg-kschl
           AND vkorg = i_ausg-vkorg
           AND vtweg = i_ausg-vtweg
           AND matnr = i_ausg-matnr
           AND kfrst = i_ausg-kfrst
           AND datbi = i_ausg-datbi
           and datab = i_ausg-datab.
        IF sy-subrc NE 0. " SELECT SINGLE * FROM a914
          CONTINUE.
        ENDIF. " sy-subrc ne 0. " SELECT SINGLE * FROM a914
        PERFORM zeitvergleich USING
          'A914' a914-kschl a914-knumh
          i_ausg-datab  i_ausg-datab_n
          i_ausg-datbi  i_ausg-datbi_n
          i_ausg-kbetr  i_ausg-kbetr_n.
      ELSE. " p_ekinfo = ''
        READ TABLE i_ausg_ek INDEX et_row_no-row_id.
        SELECT SINGLE * FROM a914 CLIENT SPECIFIED
         WHERE mandt = sy-mandt
           AND kappl = p_kappl  " Applikation, V = Vetrieb
           AND kschl = i_ausg_ek-kschl
           AND vkorg = i_ausg_ek-vkorg
           AND vtweg = i_ausg_ek-vtweg
           AND matnr = i_ausg_ek-matnr
           AND kfrst = i_ausg_ek-kfrst
           AND datbi = i_ausg_ek-datbi
           and datab = i_ausg_ek-datab.
        IF sy-subrc NE 0. " SELECT SINGLE * FROM a914
          CONTINUE.
        ENDIF. " sy-subrc ne 0. " SELECT SINGLE * FROM a914
        PERFORM zeitvergleich USING
          'A914' a914-kschl a914-knumh
          i_ausg_ek-datab  i_ausg_ek-datab_n
          i_ausg_ek-datbi  i_ausg_ek-datbi_n
          i_ausg_ek-kbetr  i_ausg_ek-kbetr_n.
      ENDIF." p_ekinfo = ''
    ENDLOOP. " at ET_ROW_NO
  ENDFORM.                                                  " fill_a914


*---------------------------------------------------------------------*
*      Form  zeitvergleich
*---------------------------------------------------------------------*
  FORM zeitvergleich USING    tabelle kschl knumh_alt
                              datab_alt datab_neu
                              datbi_alt datbi_neu
                              kbetr_alt kbetr_neu.

* so, wie ist das denn mit dem Gültigkeitszeitraum
    IF datbi_neu GT datbi_alt.
*   das neue Ende-Datum endet nach dem alten
      IF datab_neu LE sy-datum.
*     und die Kondition ist ab sofort gültig
*     ja gut, der einfache Fall 1a,
*     Teil 1: die alte Kondition enden lassen
*     Teil 2: und eine neue mit dem neuen Preis anlegen
        IF datbi_alt GE sy-datum.
*       alte Kondition ist noch gültig !!
          PERFORM bapi_fuellen USING tabelle 'AENDERN' ''
            kschl knumh_alt
            datab_alt gestern kbetr_alt.
        ENDIF. " datbi_alt ge sy-datum
        PERFORM bapi_fuellen USING tabelle 'ANLEGEN' 'X'
          kschl knumh_alt
          datab_neu datbi_neu kbetr_neu.
      ELSE. " datab_neu le sy-datum
*     Gültigkeit ab liegt in der Zukunft
*     ja gut, der einfache Fall 1b,
*     Teil 1: die alte Kondition in der Zukunft enden lassen
*     Teil 2: und eine neue mit dem neuen Preis anlegen
        if datab_alt = datab_neu.
          zukuenftig = datab_neu.
        else. " datab_alt = datab_neu
          zukuenftig = datab_neu - 1.
        endif. " datab_alt = datab_neu
        PERFORM bapi_fuellen USING tabelle 'AENDERN' ''
          kschl knumh_alt
          datab_alt zukuenftig kbetr_alt.
        PERFORM bapi_fuellen USING tabelle 'ANLEGEN' 'X'
          kschl knumh_alt
          datab_neu datbi_neu kbetr_neu.
      ENDIF. " datab_neu le sy-datum
    ELSEIF datbi_neu = datbi_alt.
*   dieselbe Kondition soll geändert werden???
      IF datab_neu LE sy-datum.
*     und die Kondition ist ab sofort gültig
*     ja gut, der einfache Fall 1a,
*     Teil 1: die alte Kondition enden lassen
*     Teil 2: und eine neue mit dem neuen Preis anlegen
        IF datbi_alt GE sy-datum.
*       alte Kondition ist noch gültig !!
          PERFORM bapi_fuellen USING tabelle 'AENDERN' ''
            kschl knumh_alt
            datab_alt gestern kbetr_alt.
        ENDIF. " datbi_alt ge sy-datum
        PERFORM bapi_fuellen USING tabelle 'ANLEGEN' 'X'
          kschl knumh_alt
          datab_neu datbi_neu kbetr_neu.
      ELSE. " datab_neu le sy-datum
*     Gültigkeit ab liegt in der Zukunft
*     ja gut, der einfache Fall 1b,
*     Teil 1: die alte Kondition in der Zukunft enden lassen
*     Teil 2: und eine neue mit dem neuen Preis anlegen
        if datab_alt = datab_neu.
*         es soll eindeutig der gleiche Satz geändert werden
          PERFORM bapi_fuellen USING tabelle 'AENDERN' 'X'
            kschl knumh_alt
            datab_alt datbi_alt kbetr_neu.
        else. " datab_alt = datab_neu
          zukuenftig = datab_neu - 1.
          PERFORM bapi_fuellen USING tabelle 'AENDERN' ''
            kschl knumh_alt
            datab_alt zukuenftig kbetr_alt.
          PERFORM bapi_fuellen USING tabelle 'ANLEGEN' 'X'
            kschl knumh_alt
            datab_neu datbi_neu kbetr_neu.
        endif. " datab_alt = datab_neu
      ENDIF. " datab_neu le sy-datum
    ELSE.  " datbi_neu > datbi_alt
*   das neue Ende-Datum endet VOR dem alten
*   der komplexere Fall 2a:
      IF datab_neu LE sy-datum.
*     und die Kondition ist ab sofort gültig
*     Teil 1: die alte Kondition sofort enden lassen
*     Teil 2: und eine neue mit neuem Preis mit neuer Gültigkeit
*     Teil 3: alte Kond. ab neuem Ende bis altem Ende anlegen
        PERFORM bapi_fuellen USING tabelle 'AENDERN' ''
          kschl knumh_alt
          datab_alt gestern kbetr_alt.
        PERFORM bapi_fuellen USING tabelle 'ANLEGEN' 'X'
          kschl knumh_alt
          datab_neu datbi_neu kbetr_neu.
        zukuenftig = datab_neu + 1.
        PERFORM bapi_fuellen USING tabelle 'ANLEGEN' ''
          kschl knumh_alt
          zukuenftig datbi_alt kbetr_alt.
      ELSE. " datab_neu le sy-datum
*     Gültigkeit ab liegt in der Zukunft
*     der komplexere Fall 2b:
*     Teil 1: die alte Kondition in der Zukunft enden lassen
*     Teil 2: und eine neue mit dem neuen Preis anlegen
*     Teil 3: alte Kond. ab neuem Ende bis altem Ende anlegen
        zukuenftig = datab_neu - 1.
        PERFORM bapi_fuellen USING tabelle 'AENDERN' ''
          kschl knumh_alt
          datab_alt zukuenftig kbetr_alt.
        PERFORM bapi_fuellen USING tabelle 'ANLEGEN' 'X'
          kschl knumh_alt
          datab_neu datbi_neu kbetr_neu.
        zukuenftig = datbi_neu + 1.
        PERFORM bapi_fuellen USING tabelle 'ANLEGEN' ''
          kschl knumh_alt
          zukuenftig datbi_alt kbetr_alt.
      ENDIF. " datab_neu le sy-datum
    ENDIF. " datbi_neu > i_ausg-datbi
  ENDFORM.                    " zeitvergleich




*---------------------------------------------------------------------*
*      Form  bapi_fuellen
*---------------------------------------------------------------------*
  FORM bapi_fuellen USING    tabelle operation erhoehung " X = JA
                             kschl knumh_alt
                             datab_neu
                             datbi_neu
                             kbetr_neu.

*    hier muss also jetzt der BAPI gefüllt werden
*    siehe auch https://www.sdn.sap.com/irj/sdn/thread?threadID=79265

    IF operation = 'ANLEGEN'. " ==> Kondition wird NICHT 'geändert'
*   Neue KonditionsNr holen für Neuanlage Kondition
      CLEAR: knumh_new.
      CALL FUNCTION 'NUMBER_GET_NEXT'
           EXPORTING
                nr_range_nr = '01'
                object      = 'KONH'
           IMPORTING
                number      = knumh_new
           EXCEPTIONS
                OTHERS      = 1.
      IF sy-subrc NE 0.
*         problems with the number range
        PERFORM error_message_syst CHANGING ls_return.
        APPEND ls_return TO to_bapiret2.
        CHECK 1 = 2.
      ENDIF.
    ENDIF. " operation = 'ANLEGEN'

* Inhalte aus Axxx
    CLEAR: ti_bapicondct.
* ti_bapicondct-operation
*003  Löschen: Nachricht enthält Objekte, die zu Löschen sind.
*004  Änderung: Nachricht enthält Änderungen
*005  Ersetze: Diese Nachricht ersetzt vorige Nachrichten
*009  Original: erste Nachricht zum Vorgang
*023  Warte/Abgleich: Daten sollen nicht eingespielt werden
*018  Wiederversenden
    IF operation = 'AENDERN'.
      ti_bapicondct-operation  = '004'.
    ELSEIF operation = 'ANLEGEN'.
      ti_bapicondct-operation  = '009'.
    ENDIF. " operation = 'AENDERN'
    ti_bapicondct-cond_usage = dd02l_tabname(1).
    ti_bapicondct-table_no   = dd02l_tabname+1(3).
    ti_bapicondct-applicatio = p_kappl. " Fix V
    ti_bapicondct-cond_type  = kschl.
    IF     tabelle = 'A914'.
      CONCATENATE a914-vkorg a914-vtweg " a914-kunnr
        a914-matnr INTO help_vakey.
    ELSEIF tabelle = 'A915'.
      CONCATENATE a915-vkorg a915-vtweg a915-kunnr
        a915-matnr INTO help_vakey.
    ELSEIF tabelle = 'A916'.
      CONCATENATE a916-vkorg a916-vtweg a916-pltyp
        a916-waerk INTO help_vakey.
        help_vakey+13 = a916-matnr.
    ELSEIF tabelle = 'A918'.
      CONCATENATE a918-spart a918-matnr
        INTO help_vakey.
    ENDIF. " Tabelle = 'A914'
*    CONDENSE help_vakey NO-GAPS.
    ti_bapicondct-varkey     = help_vakey.
*   Konditionsdatum gültig bis
    ti_bapicondct-valid_to   = datbi_neu.
*          ti_bapicondct-AGREE_COND =
    ti_bapicondct-valid_from = datab_neu.
    IF operation = 'ANLEGEN'.
      ti_bapicondct-cond_no = knumh_new.
    ELSEIF operation = 'AENDERN'.
      ti_bapicondct-cond_no = knumh_alt.
    ENDIF. " operation = 'ANLEGEN'
*          ti_bapicondct-VADAT      =
    APPEND ti_bapicondct.

* Inhalte aus KONH mit KNUMH aus Axxx
    CLEAR: ti_bapicondhd.

    ti_bapicondhd-operation  = ti_bapicondct-operation.
*          ti_bapicondhd-SD_DOC     = VBELN
*          ti_bapicondhd-ITM_NUMBER = POSNR
    ti_bapicondhd-cond_no    = ti_bapicondct-cond_no.
    ti_bapicondhd-applicatio = p_kappl. " Fix V.
    ti_bapicondhd-cond_type  = kschl.
    ti_bapicondhd-created_by = sy-uname.
    ti_bapicondhd-creat_date = sy-datum.
    ti_bapicondhd-cond_usage = ti_bapicondct-cond_usage.
    ti_bapicondhd-table_no   = ti_bapicondct-table_no.
    ti_bapicondhd-varkey     = help_vakey.
    ti_bapicondhd-valid_from = datab_neu.
    ti_bapicondhd-valid_to   = datbi_neu.
*          ti_bapicondhd-SEARCHTERM = KOSRT
*          ti_bapicondhd-RESPONS    = KZUST
*          ti_bapicondhd-PROMOT_NO  = KNUMA_PI
*          ti_bapicondhd-SALES_DEAL = KNUMA_AG
*          ti_bapicondhd-SALESQUOTE = KNUMA_SQ
*          ti_bapicondhd-STD_AGRMNT = KNUMA_SD
*          ti_bapicondhd-PROMOTION  = AKTNR
*          ti_bapicondhd-REBAGREEMT = KNUMA_BO
*          ti_bapicondhd-LIC_NO     = LICNO
*          ti_bapicondhd-LIC_DATE   = LICDT
*          ti_bapicondhd-VARDATE    = VADAT
    APPEND ti_bapicondhd.

* Inhalte aus KONP mit KNUMH aus Axxx
    CLEAR: ti_bapicondit.
    SELECT * FROM konp CLIENT SPECIFIED INTO help_konp
      WHERE mandt = sy-mandt AND knumh = knumh_alt.
*             keine Konditionen mit Löschkennzeichen anlegen
      IF help_konp-loevm_ko IS INITIAL.
        ti_bapicondit-operation  = ti_bapicondct-operation.
        ti_bapicondit-cond_no    = ti_bapicondct-cond_no.
        ti_bapicondit-cond_count = help_konp-kopos.
        ti_bapicondit-applicatio = help_konp-kappl.
        ti_bapicondit-cond_type  = help_konp-kschl.
        ti_bapicondit-text_no    = help_konp-knumt.
        ti_bapicondit-scaletype  = help_konp-stfkz.
        ti_bapicondit-scalebasin = help_konp-kzbzg.
        ti_bapicondit-scale_qty  = help_konp-kstbm.
        ti_bapicondit-unitmeasur = help_konp-konms.
*        ti_bapicondit-measur_iso = help_konp-.
***        ti_bapicondit-scale_val  = help_konp-kstbw.
*        ti_bapicondit-scale_val  = kbetr_neu.         "!!!!!
*        ti_bapicondit-currenckey = help_konp-konws.
*        ti_bapicondit-curren_iso = help_konp-konws.
        ti_bapicondit-calctypcon = help_konp-krech.
*       Prozentwerte werden falsch umgerechnet!!!
        IF help_konp-konwa = '%'.
          kbetr_neu = kbetr_neu / 10.
        ENDIF.
        ti_bapicondit-cond_value = kbetr_neu.         "!!!!!
        ti_bapicondit-condcurr   = help_konp-konwa.
*        ti_bapicondit-cond_iso   = help_konp-konwa.
        ti_bapicondit-cond_p_unt = help_konp-kpein.
        ti_bapicondit-cond_unit  = help_konp-kmein.
*            ti_bapicondit-conunitiso = help_konp-.
        ti_bapicondit-pricelevel = help_konp-prsch.
        ti_bapicondit-numconvert = help_konp-kumza.
        ti_bapicondit-denominato = help_konp-kumne.
        ti_bapicondit-base_uom   = help_konp-meins.
*            ti_bapicondit-baseqtyiso  = help_konp-.
***        ti_bapicondit-lowerlimit = help_konp-mxwrt.
***        ti_bapicondit-upperlimit = help_konp-gkwrt.
***        ti_bapicondit-plcondval  = help_konp-pkwrt. " ???
***        ti_bapicondit-cum_value  = help_konp-fkwrt. " ???
***        ti_bapicondit-cumm_accr  = help_konp-rswrt. " ???
*        ti_bapicondit-lowerlimit = kbetr_neu.         "!!!!!
*        ti_bapicondit-upperlimit = kbetr_neu.         "!!!!!
*        ti_bapicondit-plcondval  = kbetr_neu.         "!!!!!
*        ti_bapicondit-cum_value  = kbetr_neu.         "!!!!!
*        ti_bapicondit-cumm_accr  = kbetr_neu.         "!!!!!
*        ti_bapicondit-CURRENCY   = help_konp-konwa.
*            ti_bapicondit-CURR_ISO   = help_konp-.
        ti_bapicondit-condcurren  = help_konp-kwaeh.
*            ti_bapicondit-ISOCURRENC  = help_konp-.
****        ti_bapicondit-plan_basis  = help_konp-ukbas.
*        ti_bapicondit-plan_basis  = kbetr_neu.         "!!!!!
*            ti_bapicondit-RATE_UNIT   = help_konp-.
        ti_bapicondit-exclusion   = help_konp-kznep.
        ti_bapicondit-customer    = help_konp-kunnr.
        ti_bapicondit-vendor_no   = help_konp-lifnr.
        ti_bapicondit-tax_code    = help_konp-mwsk1.
        ti_bapicondit-indidelete  = help_konp-loevm_ko.
        ti_bapicondit-conditidx   = help_konp-zaehk_ind.
        ti_bapicondit-matlsettl   = help_konp-bomat.
***        ti_bapicondit-accruals    = help_konp-kbrue.
*        ti_bapicondit-accruals    = kbetr_neu.         "!!!!!
        ti_bapicondit-reb_retroa  = help_konp-kspae.
        ti_bapicondit-statofagre  = help_konp-bosta.
        ti_bapicondit-promot_no   = help_konp-knuma_pi.
        ti_bapicondit-sales_deal  = help_konp-knuma_ag.
        ti_bapicondit-salesquote  = help_konp-knuma_sq.
        ti_bapicondit-add_val_dy  = help_konp-valtg.
        ti_bapicondit-fix_val_dy  = help_konp-valdt.
        ti_bapicondit-pmnttrms    = help_konp-zterm.
        ti_bapicondit-numborders  = help_konp-anzauf.
        ti_bapicondit-minconbava  = help_konp-mikbas.
        ti_bapicondit-maxconbava  = help_konp-mxkbas.
***        ti_bapicondit-maxconval   = help_konp-komxwrt.
*        ti_bapicondit-maxconval   = kbetr_neu.         "!!!!!
        ti_bapicondit-incr_scale  = help_konp-klf_stg.
        ti_bapicondit-pricscale   = help_konp-klf_kal.
        ti_bapicondit-relprcg     = help_konp-vkkal.
        ti_bapicondit-promotion   = help_konp-aktnr.
        ti_bapicondit-rebagreemt  = help_konp-knuma_bo.
        ti_bapicondit-withtaxcod  = help_konp-mwsk2.
        ti_bapicondit-contract    = help_konp-vertt.
        ti_bapicondit-contractno  = help_konp-vertn.
        ti_bapicondit-flow_type   = help_konp-vbewa.
        ti_bapicondit-indimatmai  = help_konp-mdflg.
        ti_bapicondit-status      = help_konp-kfrst.
        ti_bapicondit-umsabst     = help_konp-uasta.
        APPEND ti_bapicondit.
      ENDIF. " help_konp-LOEVM_KO is initial
    ENDSELECT. " FROM konp
*    IF ti_bapicondit-cond_no IS INITIAL.
**           alle Pos mit Löschkennzeichen
**              CONTINUE.
*    ENDIF.

*         Inhalte aus KONM Konditionen (Mengenstaffel 1-dimensional)
    CLEAR: ti_bapicondqs.
    SELECT * FROM konm CLIENT SPECIFIED INTO help_konm
      WHERE mandt = sy-mandt AND knumh = knumh_alt.
      ti_bapicondqs-operation  = ti_bapicondct-operation.
*            TI_BAPICONDQS-SD_DOC      = VBELN.
*            ti_bapicondqs-itm_number  = posnr.
      ti_bapicondqs-cond_no     = ti_bapicondct-cond_no.
      ti_bapicondqs-cond_count  = help_konm-kopos.
      ti_bapicondqs-line_no     = help_konm-klfn1.
      ti_bapicondqs-scale_qty   = help_konm-kstbm.
      ti_bapicondqs-cond_unit   = help_konp-kmein.
*            ti_bapicondqs-t_unit_iso  =
***            Prozentwerte werden falsch umgerechnet!!!
**** TNT: bitte prüfen ob diese Umsetzung erforderlich ist !!!!!
***      IF help_konp-konwa = '%'.
***        help_konm-kbetr = help_konm-kbetr / 10.
***      ENDIF.
***      ti_bapicondqs-currency    = help_konm-kbetr.
      clear: kbetr_neu.
      if erhoehung = 'X'.
        PERFORM preisanpassung USING help_konm-kbetr kbetr_neu.
      else.
        kbetr_neu = help_konm-kbetr.
      endif. " erhoehung = 'X'
      ti_bapicondqs-currency    = kbetr_neu.
      ti_bapicondqs-condcurr    = help_konp-konwa.
*            ti_bapicondqs-curren_iso  =
      APPEND: ti_bapicondqs.
      CLEAR: help_konm.
    ENDSELECT. " from konm

*         Inhalte aus KONW Konditionen (Wertstaffel 1-dimensional)
    CLEAR: ti_bapicondvs.
    SELECT * FROM konw CLIENT SPECIFIED INTO help_konw
      WHERE mandt = sy-mandt AND knumh = knumh_alt.
      ti_bapicondvs-operation  = ti_bapicondct-operation.
*            ti_bapicondvs-SD_DOC      = VBELN.
*            ti_bapicondvs-ITM_NUMBER  = POSNR.
      ti_bapicondvs-cond_no     = ti_bapicondct-cond_no.
      ti_bapicondvs-cond_count  = help_konw-kopos.
      ti_bapicondvs-line_no     = help_konw-klfn1.
***      ti_bapicondvs-scale_val   = help_konw-kstbw.
      ti_bapicondvs-currenckey  = help_konp-konws.
*            ti_bapicondvs-CURRENCISO  =
****            Prozentwerte werden falsch umgerechnet!!!
**** TNT: bitte prüfen ob diese Umsetzung erforderlich ist !!!!!
***      IF help_konp-konwa = '%'.
***        help_konw-kbetr = help_konw-kbetr / 10.
***      ENDIF.
      clear: kbetr_neu.
      if erhoehung = 'X'.
        PERFORM preisanpassung USING help_konw-kbetr kbetr_neu.
      else.
        kbetr_neu = help_konw-kbetr.
      endif. " erhoehung = 'X'
      ti_bapicondvs-currency    = kbetr_neu.
      ti_bapicondvs-condcurr    = help_konp-konwa.
*            ti_bapicondvs-CURREN_ISO  =
      APPEND: ti_bapicondvs.
    ENDSELECT. " from konw
  ENDFORM.                    " bapi_fuellen


*--------------------------------------------------------------------*
*      Form  error_message_syst
*--------------------------------------------------------------------*
  FORM error_message_syst CHANGING pc_return TYPE bapiret2.
    CALL FUNCTION 'BALW_BAPIRETURN_GET2'
         EXPORTING
              type   = sy-msgty
              cl     = sy-msgid
              number = sy-msgno
              par1   = sy-msgv1
              par2   = sy-msgv2
              par3   = sy-msgv3
              par4   = sy-msgv4
         IMPORTING
              return = pc_return.
  ENDFORM.                    " error_message_syst



*---------------------------------------------------------------------*
*      Form  bapi_buchen
*---------------------------------------------------------------------*
  FORM bapi_buchen.
*             nu geiht datt los, denn man tau
    CALL FUNCTION 'BAPI_PRICES_CONDITIONS'
*               EXPORTING
*                 PI_INITIALMODE       = ' '
*                 PI_BLOCKNUMBER       =
      TABLES
        ti_bapicondct        = ti_bapicondct
        ti_bapicondhd        = ti_bapicondhd
        ti_bapicondit        = ti_bapicondit
        ti_bapicondqs        = ti_bapicondqs
        ti_bapicondvs        = ti_bapicondvs
        to_bapiret2          = to_bapiret2
        to_bapiknumhs        = to_bapiknumhs
        to_mem_initial       = to_mem_initial
      EXCEPTIONS
        update_error         = 1
        OTHERS               = 2.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.

    READ TABLE to_bapiret2 WITH KEY type = 'E'
      TRANSPORTING NO FIELDS.
    IF sy-subrc = 0. " READ TABLE to_bapiret2
      LOOP AT to_bapiret2 WHERE type NE 'I'
                            AND type NE 'S'
                            AND type NE 'W'.
* TNT
*        WRITE: / to_bapiret2-type, to_bapiret2-message,
*        to_bapiret2-id, to_bapiret2-log_no,
*        to_bapiret2-log_msg_no, to_bapiret2-message_v1,
*        to_bapiret2-message_v2, to_bapiret2-message_v3,
*        to_bapiret2-message_v4, to_bapiret2-parameter,
*        to_bapiret2-row, to_bapiret2-field.
        CONCATENATE to_bapiret2-type to_bapiret2-id(4)
          to_bapiret2-number to_bapiret2-message
          INTO fehler_tab-line SEPARATED BY ' '.
        APPEND fehler_tab.
      ENDLOOP. " AT to_bapiret2
    ELSE. " sy-subrc = 0. " READ TABLE to_bapiret2
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
*             EXPORTING
*             WAIT =
      IMPORTING
      return = to_bapiret2.
*           Erfolgsmeldung schreiben
      DESCRIBE TABLE ti_bapicondhd LINES sy-tfill.
      DATA: help_tfill(10).
      MOVE sy-tfill TO help_tfill.
      CONCATENATE help_tfill
        'Konditionen bearbeitet.'(104)
        INTO fehler_tab-line SEPARATED BY ' '.
      APPEND fehler_tab.
*               und noch 'markieren'
*TNT                it_daten-erfolg = 'KOND'.
*TNT                MODIFY it_daten.
    ENDIF. " sy-subrc = 0. " READ TABLE to_bapiret2
    CLEAR: ti_bapicondct, ti_bapicondhd, ti_bapicondit,
      ti_bapicondqs, ti_bapicondvs, to_bapiret2,
      to_bapiknumhs, to_mem_initial.
    REFRESH: ti_bapicondct, ti_bapicondhd, ti_bapicondit,
      ti_bapicondqs, ti_bapicondvs, to_bapiret2,
      to_bapiknumhs, to_mem_initial.
  ENDFORM.                    " bapi_buchen
Back to top
View user's profile Send private message Blog Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.