Select on BSEG-AUGDT

Hello all,
I don't understand why i do this selection:
    SELECT hkont shkzg wrbtr dmbtr vbund augdt belnr
        INTO CORRESPONDING FIELDS OF TABLE lt_bseg
        FROM bseg
        WHERE belnr = lt_bkpf-belnr
        AND   gjahr = lt_bkpf-gjahr
        AND   bukrs = lt_bkpf-bukrs
        AND   hkont IN s_hkont
        AND ( vbund NE c_off AND vbund IN s_vbund )
       AND ( augdt = '' OR  augdt GT p_budat ).
The system give no answer if i don' select the field bseg-augdt, the system gives answer. I check there are records on my table.
Thanks for your help
Philippe

This is my global coding:
* Projet : ARVATO                                                      *
*REPORT  zarvfi_fi07c_11                        .              "JOC01(-)
REPORT  zarvfi_fi07c_1                         .            "JOC01(+)
* Include des forms
INCLUDE zarvfi_fi07c_11_top. " Déclarations de données et tables
* SELECTION-SCREEN - Paramètres
* Paramètres fonctionnels (critère de sélection)
SELECTION-SCREEN BEGIN OF BLOCK b_sel
                   WITH FRAME
                   TITLE text-001.
PARAMETERS :
* Code société sélectionnée
      p_bukrs LIKE t001-bukrs OBLIGATORY,
* Exercice sélectionné
*      p_gjahr LIKE bsis-gjahr OBLIGATORY,                  "JOC02(-)
      p_gjahr LIKE bsis-gjahr NO-DISPLAY,                   "JOC02(+)
* Période "fin" sélectionnée
*      p_monat LIKE bsis-monat OBLIGATORY,                  "JOC02(-)
      p_monat LIKE bsis-monat NO-DISPLAY,                   "JOC02(+)
* Date de rapprochement                                     "JOC02(+)
      p_budat LIKE bsis-budat OBLIGATORY.                   "JOC02(+)
SELECT-OPTIONS :
* Numéros de compte sélectionnés
      s_hkont FOR bsis-hkont,
* Code société S/L
      s_vbund FOR bsis-vbund.
SELECTION-SCREEN END OF BLOCK b_sel.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK main
                   WITH FRAME
                   TITLE text-002.
* Type et chemin de fichier d'extraction
*PARAMETERS:
*  cb_unix AS CHECKBOX,
*  cb_pc   AS CHECKBOX.
PARAMETERS : f_name LIKE rlgrap-filename  OBLIGATORY.
SELECTION-SCREEN END OF BLOCK main.
*=======================================================================
*           E V E N E M E N T S
*=======================================================================
*======================================================================
INITIALIZATION.
*======================================================================
* Begin JOC(+)
* La zone 'Date de rapprochement' de l'écran de sélection est grisée
* et non éditable
  LOOP AT SCREEN.
    CASE screen-name.
      WHEN 'P_MONAT'.
        screen-input = '0'.
        screen-active = '0'.
        MODIFY SCREEN.
      WHEN 'P_GJAHR'.
        screen-input = '0'.
        screen-active = '0'.
        MODIFY SCREEN.
    ENDCASE.
  ENDLOOP.
*======================================================================
AT SELECTION-SCREEN.
*======================================================================
* Sélection d'un fichier dans l'arborescence
  PERFORM f0600_afficher_exercice CHANGING p_monat p_gjahr.
* End JOC(+)
*======================================================================
AT SELECTION-SCREEN ON VALUE-REQUEST FOR f_name.
*======================================================================
* Sélection d'un fichier dans l'arborescence
  PERFORM f0500_chercher_fichier CHANGING f_name.
*======================================================================
START-OF-SELECTION.
*======================================================================
* Sélection des données suivant les critères de sélection-utilisateur
  PERFORM f1000_selection_data TABLES t_display.
*======================================================================
END-OF-SELECTION.
*======================================================================
*======================================================================
*    EXTRACTION
*======================================================================
* Construction de la table d'extraction
  PERFORM f1100_build_data_file.
*&  Include           ZARVFI_FI07C_11_F01                              *
*&      Form  f1000_selection_data
*       text
*      -->P_T_DISPLAY  text
FORM f1000_selection_data  TABLES   p_t_display STRUCTURE t_display.
* Table de stockage de pièces comptables
  DATA : BEGIN OF lt_bkpf OCCURS 0.
          INCLUDE STRUCTURE bkpf.
  DATA : END OF lt_bkpf.
  DATA : BEGIN OF lt_bseg OCCURS 0.
          INCLUDE STRUCTURE bseg.
  DATA : END OF lt_bseg.
* Initialiser les tables internes de données
  FREE    : t_data, lt_bkpf.
  CLEAR   : t_data, lt_bkpf.
  REFRESH : t_data, lt_bkpf.
* Récupération des données comptables INTERCO *
* Begin JOC03(+)
  SELECT  bukrs gjahr monat
          belnr budat waers
      FROM bkpf
      INTO CORRESPONDING FIELDS OF TABLE lt_bkpf
      WHERE  bukrs EQ p_bukrs
      AND    budat LT p_budat
      ORDER BY belnr gjahr.
  IF sy-subrc NE '0'.
    WRITE : 'Pas de données pour cette sélection BKPF'.
  ENDIF.
  LOOP AT lt_bkpf.
    MOVE-CORRESPONDING lt_bkpf TO t_data.
    CLEAR lt_bseg.
    REFRESH lt_bseg.
    SELECT hkont shkzg wrbtr dmbtr vbund
        INTO CORRESPONDING FIELDS OF TABLE lt_bseg
        FROM bseg
        WHERE belnr = lt_bkpf-belnr
        AND   gjahr = lt_bkpf-gjahr
        AND   bukrs = lt_bkpf-bukrs
        AND   hkont IN s_hkont
        AND ( vbund NE c_off AND vbund IN s_vbund )
        AND ( augdt = '' OR  augdt GT p_budat ).
* Attention : pas de move-corresponding sinon bukrs, etc. écrasés
    LOOP AT lt_bseg.
      MOVE     lt_bseg-hkont TO t_data-hkont.
      MOVE     lt_bseg-shkzg TO t_data-shkzg.
      MOVE     lt_bseg-wrbtr TO t_data-wrbtr.
      MOVE     lt_bseg-dmbtr TO t_data-dmbtr.
      MOVE     lt_bseg-vbund TO t_data-vbund.
      APPEND t_data.
    ENDLOOP.
  ENDLOOP.
* Tri de la table pour l'ALV
  SORT t_data BY hkont vbund waers.
  LOOP AT t_data.
    SELECT SINGLE gvtyp
             INTO t_data-gvtyp
             FROM ska1
             WHERE saknr = t_data-hkont
             AND ktopl = gc_pco.
    MODIFY t_data.
  ENDLOOP.
  DELETE t_data
      WHERE ( gvtyp <> c_off AND gjahr <> p_gjahr ).
* End JOC03(+)
** JOC01(-) Begin
* Requête principale : BSIS - T001 - SKAT
*        bukrs      LIKE t001-bukrs,     " Société
*        gjahr      LIKE bsis-gjahr,     " Exercice comptable
*        monat      LIKE bsis-monat,     " Période "fin"
*        hkont      LIKE bsis-hkont,     " Numéro de compte
*        txt20      LIKE skat-txt20,     " Désignation synth cpte
*        belnr      LIKE bsis-belnr,     " Numéro de pièce comptable
*        budat      LIKE bsis-budat,     " Date comptable
*        waers      LIKE bsis-waers,     " Clé de devise de la transact
*        wrbtr      LIKE bsis-wrbtr,     " Montant en devise pièce
*        iwaers     LIKE bsis-waers,     " Clé de devise interne
*        dmbtr      LIKE bsis-dmbtr,     " Montant en devise interne
*        vbund      LIKE bsis-vbund,     " code société s/l
*  SELECT  b~bukrs
*          b~gjahr
*          b~monat
*          b~hkont
*          s~txt20
*          b~belnr
*          b~budat
*          b~waers
*          b~shkzg
*          b~wrbtr
*          t~waers
*          b~dmbtr
*          b~vbund
*  FROM bsis AS b
*  INNER JOIN skat AS s ON   s~saknr = b~hkont
*  INNER JOIN t001 AS t ON   t~spras = s~spras
*                       AND  t~ktopl = s~ktopl
*                       AND  t~bukrs = b~bukrs
*  INTO CORRESPONDING FIELDS OF TABLE t_data
*  WHERE  b~bukrs EQ p_bukrs
*  AND    b~gjahr EQ p_gjahr
*  AND    b~hkont IN s_hkont
*  AND    b~monat LE p_monat
*  AND    s~spras EQ c_spras
*  AND    s~ktopl EQ c_ktopl
*  AND    b~vbund NE c_off
*  ORDER BY b~hkont b~vbund b~waers.
*  IF sy-subrc NE '0'.
*    WRITE : 'Pas de données pour cette sélection'.
*  ENDIF.
** JOC01(-) End
* JOC01(+) Begin
* Requête principale : BSIS
*        bukrs      LIKE t001-bukrs,     " Société
*        gjahr      LIKE bsis-gjahr,     " Exercice comptable
*        monat      LIKE bsis-monat,     " Période "fin"
*        hkont      LIKE bsis-hkont,     " Numéro de compte
*        belnr      LIKE bsis-belnr,     " Numéro de pièce comptable
*        budat      LIKE bsis-budat,     " Date comptable
*        waers      LIKE bsis-waers,     " Clé de devise de la transact
*        wrbtr      LIKE bsis-wrbtr,     " Montant en devise pièce
*        iwaers     LIKE bsis-waers,     " Clé de devise interne
*        dmbtr      LIKE bsis-dmbtr,     " Montant en devise interne
*        vbund      LIKE bsis-vbund,     " code société s/l
** Begin JOC03(-)
*  SELECT  b~bukrs
*          b~gjahr
*          b~monat
*          b~hkont
*          b~belnr
*          b~budat
*          b~waers
*          b~shkzg
*          b~wrbtr
*          b~dmbtr
*          b~vbund
*  FROM bsis AS b
*  INNER JOIN bkpf AS a                                 "JOC02(+)
*              ON  a~bukrs = b~bukrs                    "JOC02(+)
*              AND a~belnr = b~belnr                    "JOC02(+)
*              AND a~gjahr = b~gjahr                    "JOC02(+)
*  INTO CORRESPONDING FIELDS OF TABLE t_data
*  WHERE  b~bukrs EQ p_bukrs
**  AND    b~gjahr EQ p_gjahr                                " FBI01(-)
**  AND    a~gjahr LE p_gjahr                   " FBI01(+) JOC02(-)
*  AND    ( a~budat LE p_budat
*           OR b~augdt = '0'
*           OR b~augdt GE p_budat )    "JOC02(+)
*  AND    b~hkont IN s_hkont
*  AND    ( b~vbund NE c_off AND b~vbund IN s_vbund )
*  ORDER BY b~hkont b~vbund b~waers.
*  IF sy-subrc NE '0'.
*    WRITE : 'Pas de données pour cette sélection'.
*  ENDIF.
** JOC01(+) End
** End JOC03(-)
ENDFORM.                    " f1000_selection_data
*&      Form  f1100_build_data
*       text
*      -->P_T_DISPLAY  text
FORM f1100_build_alv_data  TABLES   p_t_data    STRUCTURE t_data
                                    p_t_display STRUCTURE t_display.
  DATA : lv_compte   LIKE bsis-hkont,   " Var pr cumul solde
         lv_dmbtr    LIKE bsis-dmbtr,
         lv_wrbtr    LIKE bsis-wrbtr,
         lx_flag_new_hkont TYPE c,    "Flag changt de compte
         lx_flag_new_vbund TYPE c,    "Flag changt de société SL
         lx_flag_new_waers TYPE c.    "Flag changt de devise transaction
  CLEAR : lv_compte,
          lx_flag_new_hkont,
          lx_flag_new_vbund,
          lx_flag_new_waers,
          lv_dmbtr,
          lv_wrbtr.
* Initialiser les tables internes de données
  FREE    : p_t_display.
  CLEAR   : p_t_display.
  REFRESH : p_t_display.
* Construction des données à afficher         *
  LOOP AT p_t_data.
* Société
* Exercice comptable
* Période "fin"
* Numéro de compte
* Numéro de pièce comptable
* Date comptable
* Clé de devise de la transaction
* Clé de devise interne
* Code société S/L
* Désignation synthétique du compte
    SELECT SINGLE txt20 FROM skat
    INTO p_t_data-txt20
    WHERE spras EQ c_spras
    AND   ktopl EQ c_ktopl
    AND   saknr EQ p_t_data-hkont.
* Devise interne
    SELECT SINGLE waers FROM t001
    INTO p_t_data-iwaers
    WHERE bukrs = p_t_data-bukrs
    AND   spras = c_spras.
    MOVE :
           p_t_data-bukrs  TO p_t_display-bukrs,
*           p_t_data-gjahr TO p_t_display-gjahr,    "JOC02(-)
           p_gjahr         TO p_t_display-gjahr,            "JOC02(+)
           p_monat         TO p_t_display-monat,
           p_t_data-hkont  TO p_t_display-hkont,
           p_t_data-txt20  TO p_t_display-txt20,
           p_t_data-belnr  TO p_t_display-belnr,
           p_t_data-budat  TO p_t_display-budat,
           p_t_data-waers  TO p_t_display-waers,
           p_t_data-iwaers TO p_t_display-iwaers,
           p_t_data-vbund  TO p_t_display-vbund.
    IF p_t_data-shkzg EQ c_credit.
      p_t_display-wrbtr = 0 - p_t_data-wrbtr.
      p_t_display-dmbtr = 0 - p_t_data-dmbtr.
    ELSE.
      p_t_display-wrbtr = p_t_data-wrbtr.
      p_t_display-dmbtr = p_t_data-dmbtr.
    ENDIF.
    IF p_t_data-wrbtr EQ 0.
      CONTINUE.
    ENDIF.
    APPEND  p_t_display.
** JOC01(+) Begin
*    AT NEW hkont.
*      MOVE 'X' TO lx_flag_new_hkont.
*      AT NEW vbund.
*        MOVE 'X' TO lx_flag_new_vbund.
*        AT NEW waers.
*          MOVE 'X' TO lx_flag_new_waers.
*        ENDAT.
*      ENDAT.
*    ENDAT.
** JOC01(+) End
** Montant en devise pièce
** & Montant en devise interne signés
*    IF p_t_data-shkzg EQ c_credit.
*      p_t_data-wrbtr = 0 - p_t_data-wrbtr.
*      p_t_data-dmbtr = 0 - p_t_data-dmbtr.
*    ENDIF.
*    MOVE :
*     p_t_data-bukrs TO p_t_display-bukrs,
*     p_t_data-gjahr TO p_t_display-gjahr,
*     p_monat        TO p_t_display-monat,
*     p_t_data-hkont TO p_t_display-hkont,
*     p_t_data-txt20 TO p_t_display-txt20,
*     p_t_data-belnr TO p_t_display-belnr,
*     p_t_data-budat TO p_t_display-budat,
*     p_t_data-waers TO p_t_display-waers,
*     p_t_data-iwaers TO p_t_display-iwaers,
*     p_t_data-vbund TO p_t_display-vbund.
**   Si on reste sur le même n° de compte
*    IF ( lx_flag_new_hkont IS INITIAL
*     AND lx_flag_new_vbund IS INITIAL
*     AND lx_flag_new_waers IS INITIAL ).
*      ADD p_t_data-dmbtr TO p_t_display-dmbtr.
*      ADD p_t_data-wrbtr TO p_t_display-wrbtr.
*      COLLECT p_t_display.
*    ELSE.
**   Si on change de n° de compte
*      MOVE :
*       p_t_data-wrbtr TO p_t_display-wrbtr,
*       p_t_data-dmbtr TO p_t_display-dmbtr.
*      APPEND  p_t_display.
*    ENDIF.
*    CLEAR :
*        lx_flag_new_hkont,
*        lx_flag_new_vbund,
*        lx_flag_new_waers.
** JOC01(+) End
  ENDLOOP.
ENDFORM.                    " f1100_build_alv_data

Similar Messages

  • Selection from bseg with year

    Hi,
    Iam trying to use bsak-budat with bseg-gjahr.But lengths are not same. I had offsetting with budat.But values are not matching...could any one tell me how to do that?
    points guaranteed
    cheers
    kaki
        select BUKRS LIFNR AUGDT AUGBL GJAHR BELNR  BUZEI BUDAT BLDAT
            CPUDT WAERS BLART BSCHL SHKZG DMBTR WRBTR SGTXT HKONT SKFBT
             from bsak
             into corresponding fields of table t_bsak
              where
              lifnr in s_lifnr and
              BUKRS in s_bukrs and
              budat le s_budat and                          augdt in s_augdt.
    loop at t_bsak.
      l_year = t_bsak-budat(4).
    endloop.
      CHECK NOT t_bsak[] IS INITIAL.
      select BUKRS LIFNR AUGDT AUGBL GJAHR BELNR
           SHKZG DMBTR WRBTR SGTXT SKFBT KOSTL BSCHL HKONT BUZEI
         into corresponding fields of table t_bseg from bseg
                FOR ALL ENTRIES IN t_bsak
                where belnr = t_bsak-belnr and
                      gjahr = l_year and        " xxxxxx
                      bukrs = t_bsak-bukrs.

    Define a field I_YEAR in int table T_BSAK.
    DATA Begin of t_BSAK,
    I_YEAR LIKE BSEG-GJAHR,
    end of t_bsak.
    loop at t_bsak.
    t_bsak-l_year = t_bsak-budat(4).
    modify t_bsak.
    endloop.
    Then
    select BUKRS LIFNR AUGDT AUGBL GJAHR BELNR
    SHKZG DMBTR WRBTR SGTXT SKFBT KOSTL BSCHL HKONT BUZEI
    into corresponding fields of table t_bseg from bseg
    FOR ALL ENTRIES IN t_bsak
    where belnr = t_bsak-belnr and
    gjahr = t_bsak-i_year and " xxxxxx
    bukrs = t_bsak-bukrs.
    Alternatively why not select gjahr from BSAK .
    Cheers .
    Sanjay

  • Select From BSEG

    Hi
    The below mentioned piece of code is throwing a dump in Production system.
    Is there any way of alternate selection.
      IF NOT it_pos[] IS INITIAL.
        SELECT * FROM bseg INTO
                 TABLE it_bseg
                 FOR ALL ENTRIES  IN it_pos
                     WHERE  bukrs IN dd_bukrs
                     AND    belnr = it_pos-belnr
                     AND    gjahr = it_pos-gjahr.
      ENDIF.
    Regards
    Subin.S

    I think you need to post a few more details of the environment and error to assist people in offering solution.
    Questions I think of are:
    - What type of dump are you getting? - Out of Time? Out of Memory? Other?
    - How many entries are in internal table it_pos[] before the BSEG select starts?
    - How many entries are in BSEG approximately?
    - Do you need all the BSEG records to be selected into an internal table at once or can you process them in smaller sets?
    - Do you have a number of other large internal tables in your program?  Can any of these be cleared to free up memory?
    - can you run SQL trace (ST05) against the program to see the execution time for each fetch from BSEG and how many records each fetch returns?
    - why are you doing two selects from BSEG? What is the difference between them? normally better to get all the fields at the same time instead of selecting twice.
    - in Development or Test where there is less data, does tha program run OK?  If so, can you run it in SE30 to see what that transaction highlights as performance or similar issues?
    - what table or tables do you fill table it_pos[] from?  are there any duplicate records in this internal table?
    - what SAP version are you running?  32 bit or 64 bit?  What database?
    To solve an issue like this with a program these and probably dozens of other questions must be asked and answered - and as the person on the site you are the only one able to get the answers. 
    Posting more details will help forum readers to evaluate the issue in light of their experience and to provide further suggestions.  The more information you can give - the more likely that someone will be able to answer.
    thanks
    Andrew

  • Identify a change in BSEG-AUGDT

    Hello,
    I am looking for a trigger that occurs after an invoice is cleared in a payment run (F110),
    and the field BSEG-AUGDT is updated.
    I tried to use the FM SAMPLE_PROCESS_00001430 , but it didn't work.
    Thank you,
    Dan

    Hi
    Try with BTE 1820 (process). See Note 912374 - Payment program: Payment method determination from contract, to check if it could help you
    Regards
    Eduardo

  • Selection from BSEG table

    Hi all
    In one of my program i have to use selection from BSEG by using non key fields like anln1, hkont  etc.
    My program run time taking too much time i.e 1.5 to 2hrs
    Is there any criteria to reduce my run time.
    plz help
    thks
    sateesh

    Hi
    If you need a select by field hkont (so G/L account) use the table BSIS (open item) and BSAS (cleared item)  instead of BSEG, just Eric said.
    SELECT * FROM BSAS WHERE BUKRS = BUKRS
                                              AND HKONT = HKONT.
       SELECT SINGLE * FROM BSEG WHERE BUKRS = BSAS-BUKRS
                                                              AND BELNR = BSAS-BELNR
                                                              AND GJAHR = BSAS-GJAHR
                                                              AND BUZEI  = BSAS-BUZEI.
             SELECT SINGLE * FROM BKPF WHERE BUKRS = BSAS-BUKRS
                                                                   AND BELNR = BSAS-BELNR
                                                                   AND GJAHR = BSAS-GJAH.
    Max
    Edited by: max bianchi on Nov 5, 2008 11:03 AM

  • FBL3N - Dynamic selection ignores BSEG-NPLNR

    Good afternoon to all:
    I want to add BSEG-NPLNR (Network) to the dynamic selection for FBL3N.
    I use SE36 to add BSEG-NPLNR to the selection view of logic database SDF, but FBL3N ignores the selection I enter there. 
    I read in OSS note 310886 that fields from BSEG are ignored in the dynamic selection even though they are added to the selection view of the logical database SDF. 
    What is the other option to add BSEG-NPLNR to the dynamic selection of FBL3N?
    Thanks

    if you want to add BSEG-NPLNR (Network) to the dynamic selection for FBL3N you must first set at least, one key param of the logical data base (transaction FBL3N use SDF Logical Database).
    The key params of this logical database are:
    Chart of Accounts
    G/L account
    Company Code
    if you set any of this 3 params, your BSEG-NPLNR filter will work, otherwise, it will be ignored.

  • Need to select from BSEG on Non Key fields.

    Hi all,
    I am developing a report on Work Order Cost Analysis. The selection screen has Order Type (AFPO-DAUAT), Plant (AFPO-DWERK), Date range (AFKO-GLTRI) and Part Number (AFKO-PLNBEZ) as the selection criteria. <b>All the orders and their corresponding object numbers (OBJNR) are picked in an internal table</b>, for all orders that fulfill the selection criteria and their Actual Finish Date (AFKO-GLTRI) falls between the entered date range.
    Now comes the problem, <b>corresponding to these Order Numbers I need to pick records from BSEG.</b> Since this is not a key field in BSEG, its not indexed and the report times out on the Development Server itself.
    <b>I also tried using COEP</b> table as the fields that I need are present there as well (Though I am not sure weather it would be give me all the lines of records that I need from BSEG), but that operation also times out.
    LDBs also don't seem to help. Is there any way I can achieve the above?
    <b>PLEASE HELP. REWARDS GUARANTEED.</b>
    Regards,
    Nikhil

    OK - a couple of things:
    In the select from covp, you are retrieving the CO document data not the FI document data, so you need the reference documents.
    Even though OBJNR is the first field of a key it will not be very selective. It would be better if you could specify more fields. Fortunately, some are standard and you can probably figure out what to use. If you can limit this to a single fiscal year, it would be best. Failing that, you should specify any (or all) fiscal years in a range table (using =).
    This is the select that I came up with:
    SELECT refbk refbn refgj refbz
           FROM  covp
           INTO  CORRESPONDING FIELDS OF TABLE it_covp
           FOR ALL ENTRIES IN it_worder
           WHERE lednr = '00'               "Standard ledger
           AND   objnr = it_worder-objnr
           AND   gjahr IN s_gjahr
           AND   wrttp = '04'               "Actuals
           AND   versn = '000'              "Plan/Actual ver.
           AND orgvg = 'RFBU'.              "FI Postings
    I filled s_gjahr with the individual years from 1995 to 2006 and it ran in under 20 minutes. (The first select was wide open and selected all.)
    Rob
    By the way - do you still need to go to BSEG, or can you get everything you need from COVP?
    Message was edited by: Rob Burbank

  • Selecting from bseg

    Abap Gurus,
    I am fetching belnr dmbtr buzei hkont from bseg
    for all entries from one table say 'TAB'
    where hkont = TAB-hkont
    and koart = 'S'.
    but in in the code inspector check it;s showing error
    The message is
    "Large table BSEG: No field of a table index in WHERE"
    How to optimize a fetch from a larger cluster table BSEG
    rewards if useful.
    Thanks in advance

    Hi,
         Alternatives to Reading BSEG (Accounting Document Segment).
    Since performance is an issue if reading data from BSEG table ( being a cluster table ), maybe you would
    consider using the tables:
              BSAD      Accounting     : Secondary Index for Customers (Cleared Items)
              BSAK      Accounting     : Secondary Index for Vendors (Cleared Items) 
              BSAS      Accounting     : Secondary Index for G/L Accounts (Cleared Items)
              BSID      Accounting     : Secondary Index for Customers
              BSIK      Accounting     : Secondary Index for Vendors    
              BSIS      Accounting     : Secondary Index for G/L Accounts
              instead of BSEG.
              It depends on what your program has to select (if you're only looking for customers
              you can use BSID and BSAD etc.)
              These are normal database tables, not clusters. Normally every record from BSEG
              can be found back in one of these 6 tables and a program which selects data from
              these tables runs faster than from BSEG.
    Reward points if helpful
    Thanks
    Shambhu

  • Selecting from bseg misses dupicalte entry

    Hi,
    i select entries from bkpf/bseg as below:
      select bukrs belnr gjahr budat bldat waers
             into table lt_bkpf
             from bkpf
             where bukrs in s_bukrs
             and   blart in s_blart
             and   bldat in s_bldat
             and   budat in s_budat
      select bukrs belnr hkont wrbtr dmbtr shkzg vbund
             from bseg
             into table lt_bseg
             for all entries in lt_bkpf
             where bukrs =   lt_bkpf-bukrs
             and   belnr =   lt_bkpf-belnr
             and   gjahr =   lt_bkpf-gjahr
             and   hkont in  s_hkont.
    this works fine except for a few docs which all have the same 'issue' where there is a duplicate WRBTR value in bseg. e.g.
    BUKRS|BELNR|BUZEI|WRBTR|HKONT
    1000|12345678|001|1000.00|7777
    1000|12345678|002|1355.00|7777
    1000|12345678|003|1000.00|7777
    1000|12345678|004|9879.00|7777
    my select statements output :
    1000|12345678|001|1000.00|7777
    1000|12345678|002|1355.00|7777
    1000|12345678|004|9879.00|7777
    Notice that item 3 is not found.
    Note 416076 looks kind of related but we are on 470 and that is only for 4.6X.
    Any ideas, as I am stumped?
    thanks.

    This is a trap when using the FOR ALL ENTRIES option on a select.  It is mentioned in the documentation of the command.  It is not related to indexes of the table.
    FOR ALL ENTRIES has the same result as a SELECT DISTINCT -- duplicates are removed from the result set.
    to get all entries that exist, make sure you specify ALL fields of the table primary key in the list of fields you retrieve.
    so add the missing two fields to your internal table and modify your BSEG select to the following.
      select bukrs belnr GJAHR BUZEI hkont wrbtr dmbtr shkzg vbund
             from bseg
             into table lt_bseg
             for all entries in lt_bkpf
             where bukrs =   lt_bkpf-bukrs
             and   belnr =   lt_bkpf-belnr
             and   gjahr =   lt_bkpf-gjahr
             and   hkont in  s_hkont.
    This will get all BSEG entries.
    To prove this in DEV/Unit Test environment with less data available, try the following:
      select bukrs shkzg
             from bseg
             into table lt_bseg
             for all entries in lt_bkpf
             where bukrs =   lt_bkpf-bukrs
             and   belnr =   lt_bkpf-belnr
             and   gjahr =   lt_bkpf-gjahr
             and   hkont in  s_hkont.
    Andrew

  • Performance Issue: Select From BSEG & BKPF

    Hi experts,
    Performance issue on the select statements; how can I improve the performance?
    Select Company Code (BUKRS)
    Accounting Document Number (BELNR)
                        Document Type (BLART)
                        Posting Date in the Document (BUDAT)
                        Document Status (BSTAT)
                        Reversal Document or Reversed Document Indicator (XREVERSAL)
               From Accounting Document Header (BKPF)
                 Into I_BKPF
             Where BKPF-BUKRS = I_VBAK-BUKRS_VF
           BKPF-BLART = ‘KI’
                        BKPF-BUDAT = SY-DATUM – 2 days
                        BKPF-BSTAT = Initial
                        BKPF-XREVERSAL <> ‘1’ or ‘2’
    Select Company Code (BUKRS)
                        Accounting Document Number (BELNR)
                        Assignment Number (ZUONR)
                        Sales Document (VBEL2)
                        Sales Document Item (POSN2)
                        P & L Statement Account Type (GVTYP)
                From Accounting Document Segment (BSEG)
                  Into I_BSEG
              Where BSEG-BUKRS = I_VBAK-BUKRS
            BSEG-VBELN = I_VBAK-VBEL2
            BSEG-POSN2 = I_VBAP-POSNR
                 BSEG-BELNR = I_BKPF-BELNR
                         P & L Statement Account Type (GVTYP) = ‘X’

    Hi,
    to improve the performance, you can use the secondary indices viz., BSIK / BSAK, BSID / BSAD, BSIS.
    Hope this helps.
    Best Regards, Murugesh AS

  • Selecting from BKPF and BSEG

    Hi all,
    Can someone help me optimize the performance of this code as i don't know how else to select from BSEG as i cannot use a join coz its a cluster table. I need to find a way to improve the perfomance.Any help would be much appreciated.
    SELECT belnr gjahr bukrs budat stblg awkey blart
             FROM bkpf INTO CORRESPONDING FIELDS OF TABLE t_bkpf
             WHERE belnr IN s_belnr and
                   gjahr = p_gjahr  and
                   bukrs = p_bukrs.
      LOOP AT t_bkpf.
          SELECT belnr gjahr buzei ebeln ebelp
               wrbtr fipos geber fistl fkber
               augbl augdt shkzg
        INTO CORRESPONDING FIELDS OF table t_bseg
        FROM bseg
        WHERE belnr = t_bkpf-belnr
        AND   gjahr = t_bkpf-gjahr
        AND   bukrs = t_bkpf-bukrs.
    Thanks alot
    seema

    Hi Seema,
    You have to avoid the database retrival inside the loop.You can use for all entries.
    This is taken from a link.
    Some of the SAP tables are not transparant, but pooled or clustered. Be aware of this !
    There are a lot of limitations on how such tables can be accessed. You can not include such
    tables in database views and join constructs. The FI-GL table BSEG, which is one of our
    biggest PR1 tables, is an example of a clustered table. At the database-level, there is no table
    called BSEG, but instead RFBLG is being used for the BSEG data. Most of the fields known
    in BSEG are not known in the database table RFBLG, but are compressed in a VARDATA
    field of RFBLG. So tests in the WHERE clause of SELECTs agains BSEG are not used by
    the database (e.g. lifnr = vendor account number, hkont = G/L account, kostl = cost center).
    As a consequence, these tests are done after the facts similar to using the CHECK statement,
    and as already said in tip 1, CHECK statements are worse than tests in the WHERE-clause.
    Check this link also.
    How to Read BSEG Efficiently
    you'll never select table bkpf alone.
    alternatives:
    1) select with header information from bkpf
    2) use secondary index tables
    Re: Tuning cluster table selection
    3) use logical data base e.g.: BRF
    Hope this helps.If so,reward points.Otherwise, get back.

  • Selection from bsak & bseg

    Hi experts,
    Iam trying to extract data from bsak & bseg something like..
    Litm  pk
    001   31 19000038 20050303   20050610
    but i need to extract compelete Line items & posting keys like..
    Litm  pk  budat    belnr     augbl
    001   31  20051010 190000038 20050303
    002   40
    003   40
    004   40 
    001   31  20051010 190000039 20050303
    002   40
    003   40
    004   40  
    Could any one tell me how can achieve this logic through internal table?Points guaranteed.
    reward guaranteed
    Kaki

    Hi all,
    Pls look into my code.I need to display complete "Line item" and "posting keys" for the particular "Doc no".
    REPORT  Z1F_RFKEPL00 no standard page heading
            line-size 140
            line-count 65
            message-id Z1.
    TABLES: LFA1,t005t,bsak,bseg,t001,skat.
    data: begin of t_bsak occurs 0,
            bukrs like bsak-bukrs,        "company code
            lifnr like bsak-lifnr,        "Vendor acc number
            augdt like bsak-augdt,        "Clearing date
            AUGBL like bsak-AUGBL,        "Clearing Document
            GJAHR like bsak-GJAHR,        "year
            belnr like bsak-belnr,        "Document number
            BUZEI like bsak-BUZEI,        "Line Item
            budat like bsak-budat,        "Posting Date in the Document
            bldat like bsak-bldat,        "Document date in document
            blart like bsak-blart,        "Document type
            BSCHL like bsak-BSCHL,        "Posting key
            WAERS like bsak-WAERS,        "Currency key
            CPUDT like bsak-cpudt,        "Accounting Document Entry Date
            SHKZG like bsak-shkzg,        "Debit/Credit Indicator
            DMBTR like bsak-dmbtr,        "Amount in local currency
            WRBTR like bsak-wrbtr,        "Amount in document currency
            SGTXT like bsak-sgtxt,        "Item Text
            SAKNR LIKE bsak-saknr,        "G/L Account Number
            hkont like bsak-hkont,        "General Ledger Account
            SKFBT LIKE BSAK-SKFBT,        "Amount Eligible for Cash Discount
            KOSTL LIKE BSEG-KOSTL,        "Cost center
            ktopl like t001-ktopl,        "chart of accounts
            txt20 like skat-txt20,        "Short test for the GL acc
          end of t_bsak.
    data: begin of t_lfa1 occurs 0,
            lifnr like lfa1-lifnr,
            name1 like lfa1-name1,
            land1 like lfa1-land1,
            landx like t005t-landx,
          end of t_lfa1.
    data: begin of t_header occurs 0,
            bukrs like bsak-bukrs,
            hkont like bsak-hkont,
            lifnr like bsak-lifnr,
            land1 like lfa1-land1,
            landx like t005t-landx,
          end of t_header.
    data: begin of t_data occurs 0,
             belnr like bsak-belnr,
             bukrs like bsak-bukrs,
             gjahr like bsak-gjahr,
             hkont like bsak-hkont,
             augbl like bsak-augbl,
             bschl like bsak-bschl,
             buzei like bsak-buzei,
             KOSTL LIKE BSEG-KOSTL,
    end of t_data.
    selection-screen begin of block blk1 with frame title text-001.
    select-options: s_lifnr for bsak-lifnr,
                    s_bukrs for bsak-bukrs.
    selection-screen end of block blk1.
    selection-screen begin of block blk2 with frame title text-002.
    parameters s_budat like bsik-budat default sy-datum.
    select-options: s_augdt for bsak-augdt.
    selection-screen end of block blk2.
    selection-screen begin of block blk3 with frame title text-003.
    parameters: stand as checkbox default 'X',
                park as checkbox.
    selection-screen end of block blk3.
    start-of-selection.
      perform process_data.
    top-of-page.
      perform set_page_header.
    *&      Form  process_data
          text
    form process_data.
      data: line like t_bsak occurs 0 with header line.
      data: l_wrbtr(10) type c.
      data: l_debit type bsak-wrbtr,l_credit type bsak-wrbtr,
            l_balance type bsak-wrbtr.
      data:l_hkont(10) type n.
    select BUKRS LIFNR AUGDT AUGBL GJAHR BELNR BUZEI BUDAT BLDAT
             CPUDT WAERS BLART BSCHL SHKZG DMBTR WRBTR SGTXT HKONT SKFBT
            from bsak
            into corresponding fields of table t_bsak
             where BUKRS in s_bukrs and budat le s_budat   " Open  items
                             order by lifnr.
      select BUKRS LIFNR AUGDT AUGBL GJAHR BELNR  BUDAT BLDAT CPUDT
      WAERS BLART  SHKZG DMBTR WRBTR SGTXT SKFBT KOSTL BSCHL hkont BUZEI
             from bsak into corresponding fields of table t_bsak
              where BUKRS eq '1000' and
                     lifnr = 'AARONWU'.
      sort t_bsak by BUDAT.
      loop at t_bsak.
        select belnr bukrs gjahr hkont buzei bschl from bseg
                into table t_data  where belnr = t_bsak-belnr and
                                     bukrs = t_bsak-bukrs and
                                     gjahr = t_bsak-gjahr.
       select single * from bseg
                where belnr = t_bsak-belnr and
                                    bukrs = t_bsak-bukrs and
                                    gjahr = t_bsak-gjahr.
       move-corresponding bseg to t_data.
       move bseg-belnr to t_data-belnr.
       move bseg-bukrs to t_data-bukrs.
       move bseg-gjahr to t_data-gjahr.
       move bseg-hkont to t_data-hkont.
       move bseg-kostl to t_data-kostl.
       move bseg-bschl to t_data-bschl.
       if sy-subrc = 0.
         append t_data.
         clear t_data.
       endif.
    endloop.
    loop at t_bsak.
    to get vendor name
        select single * from lfa1 where lifnr = t_bsak-lifnr.
        move lfa1-lifnr to t_lfa1-lifnr.
        move lfa1-land1 to t_lfa1-land1.
        move lfa1-name1 to t_lfa1-name1.
        if sy-subrc = 0.
          append t_lfa1.
          clear t_lfa1.
        endif.
      endloop.
    to get vendor country
      loop at t_lfa1.
        select single * from t005t where land1 = t_lfa1-land1 and
                                         SPRAS = 'E'.
        move t005t-landx to t_lfa1-landx.
        if sy-subrc = 0.
          modify t_lfa1.
          clear t_lfa1.
        endif.
      endloop.
      delete adjacent duplicates from t_lfa1.
    *Display----
    *to display header
    data: l_buzei type bseg-buzei.
      loop at t_lfa1.
        write:/1(6) t_bsak-bukrs    color 2,
                7(8) t_bsak-hkont    color 2,
                18(10) t_bsak-lifnr   color 2.
        write:/30(10) t_lfa1-name1.
        write:/30(10) t_lfa1-landx.
        uline.
        loop at t_bsak where lifnr = t_lfa1-lifnr.
          l_wrbtr = t_bsak-wrbtr.
          if t_bsak-wrbtr = t_bsak-skfbt.
            concatenate l_wrbtr '-' into l_wrbtr.
          endif.
         loop at t_data where belnr = t_bsak-belnr and
                               bukrs = t_bsak-bukrs and
                               gjahr = t_bsak-gjahr.
            l_buzei = t_data-buzei.
          endloop.
          write:/15(10) t_bsak-BUDAT no-zero    color 2,
                  26(5) t_bsak-BLART            color 2,
                  30(10) t_bsak-belnr           color 2,
                  42(10) t_bsak-BLDAT           color 2,
                  58(5)  t_bsak-buzei           color 2,
                  63(4)  t_bsak-BSCHL           color 2,
                  75(7)  t_bsak-AUGDT           color 2,
                  84(10) t_bsak-AUGBL           color 2,
                  119(7) t_bsak-WAERS           color 2,
                126(12) t_bsak-WRBTR          color 2.
                  126(12) l_wrbtr               color 2.
          write:/55 t_bsak-sgtxt.
       write:/60(10) t_bsak-hkont,
             80(10) t_bsak-kostl,
             90(30) t_bsak-txt20.
            clear l_wrbtr.
        endloop.
        uline.
        write:/1(6) t_bsak-bukrs    color 2,
               7(8) t_bsak-hkont    color 2,
               18(10) t_bsak-lifnr   color 2.
        uline.
      endloop.
      write:/1(6) t_bsak-bukrs    color 2,
             7(8) t_bsak-hkont    color 2,
            18(10) t_bsak-lifnr   color 2,
            105(5)  t_bsak-waers  color 2.
      line[] = t_bsak[].
      loop at line.
        if line-shkzg = 'H'.
          l_debit = l_debit + line-wrbtr.
        endif.
        if line-shkzg = 'S'.
          l_credit = l_credit + line-wrbtr.
        endif.
      endloop.
      l_balance = l_debit -  l_credit.
      write:115(15) l_debit.   write:135(1) 'D'.
      write:/115(15) l_credit. write:135(1) 'C'.
      for balnce
      write:/90(5) 'Bal.:'.
      write:115(15) l_balance.
      clear: l_debit,l_credit,l_balance.
      uline.
    endform.                    "process_data
    *&      Form  set_page_header
          text
    FORM set_page_header.
      call function 'Z_REPORT_TITLE'
        EXPORTING
          line_size       = sy-linsz
          sy_title        = 'List of Vendor Line Items'
          uline           = 'X'
          first_page_only = ' '.
      write :1(15)  'Allocation'            color col_heading,
             15(10) 'Pstng'         color col_heading,
             25(5)  'Do'             color col_heading,
             30(10) 'Documnet'          color col_heading,
             40(10) 'Doc'        color col_heading,
             50(8)  'BusA'              color col_heading,
             58(5)  'LIm'        color col_heading,
             63(4)  'PK'         color col_heading,
             67(4)  'S'       color col_heading,
             71(4)  'P'       color col_heading,
             75(7)  'Clrg'       color col_heading,
             82(10) 'Clearing'       color col_heading,
             92(20) 'D/c discount Amnt'       color col_heading,
             112(5) 'Rsn'       color col_heading,
             117(2) 'G'       color col_heading,
             119(7)  'Curr-'       color col_heading,
             126(12) 'Amount in'       color col_heading,
             138(2)  'T'       color col_heading.
      write space.
      write :1(15)  'number'            color col_heading,
             15(10) 'date'            color col_heading,
             25(5)  'ty'      color col_heading,
             30(10) 'number'     color col_heading,
             40(18) 'date'         color col_heading,
             58(5)  ''        color col_heading,
             63(4)  ''         color col_heading,
             67(4)  'I'       color col_heading,
             71(4)  'K'       color col_heading,
             75(7)  'date'       color col_heading,
             82(24) 'doc.no'       color col_heading,
             105(20) 'in LC'       color col_heading,
             112(5) 'code'       color col_heading,
             117(2) 'L'       color col_heading,
             119(7) 'ency'       color col_heading,
             126(12) 'doc.curr.'       color col_heading,
             138(2) 'X'       color col_heading.
      write space.
      uline.
    ENDFORM.                    " set_page_header

  • How to fetch data from bseg based  on 2 internal tables in 1 select query?

    hi,
    i have bukrs and belnr in one internal table and bukrs and vbeln in another internal table..now if i select from bseg twice using for all entries for fields bukrs vbeln and bukrs belnr twice in 2 select statements its fine..but since bseg is a huge table i want to use select only once..but the problem is that none of the belnrs in the one internal table will have vbeln in another internal table....ie if vbeln is selected from bseg based on belnr in 1 internal table non eof those vbeln will be equal to vbeln on another internal tables..in this scenario even if i take all data from two internal tables into 1 single internal table and then use for all entries on vbeln and belnr of that table ..but i think this will not work because and AND operator will not work because no record will satisfy both vbeln and belnr conditions..even if i use OR operator if the 1st condition satisfies the select clause will not enter into the second clause and all the records will not be fetched...Please help how should i tackle this..

    Hi vijaya,
    no simple select statement solution so far.
    As BSEG is a huge table you should try to get the full key values into another internal table first.
    SAP avoids direct selections from BSEG.
    Pleas consider the use of one of the secondary index tables first:
          BSAD : Accounting: Secondary Index for Customers (Cleared Items)
          BSAK : Accounting: Secondary Index for Vendors (Cleared Items)
          BSAS : Accounting: Secondary Index for G/L Accounts (Cleared Item
          BSEC : One-Time Account Data Document Segment
          BSEG : Accounting Document Segment
          BSID : Accounting: Secondary Index for Customers
          BSIK : Accounting: Secondary Index for Vendors
          BSIS : Accounting: Secondary Index for G/L Accounts
    you may include
          BKPF : Accounting Document Header
    for restrictions about time and document type.
    The last step is a FOR ALL ENTRIES selection from BSEG providing the full key values.
    Although you may have even more selects, the overall performance will be much better.
    Regards,
    Clemens

  • Abap query to select a line item # from bseg on basis of following pattern:

    Hello,
    I want to retrieve the line item # from bseg which has the following pattern,
    account type = S
    AND
    gl account starting from 135***** , 136***** , 137*****
    , 138***** , 139*****
    hope i am comprehendable. How do i go on writing the query,
    Thanks..
    Shehryar

    Hi Shehryar,
    This will fetch records with GL A/C starting with <b>13</b> only , if you want 14 and others also write sepearate conditions using <b>LIKE</b> statements.
    REPORT zztest.
    DATA : itab TYPE STANDARD TABLE OF bseg WITH HEADER LINE.
    SELECT * FROM bseg INTO TABLE itab WHERE <b>koart = 'S'
    AND
    hkont LIKE '13%'</b>.
    This will take a lot of DB time for fetching the records, try to include Key Fields(BUKRS and GJAHR .. if possible others).
    Regards,
    Arun Sambargi.
    Regards

  • Adding a BSEG field to the FB03 dynamic selection screen

    Hello,
    We have a requirement wherein we want to add a field from BSEG in the dynamic selection screen of FB03.
    We found that the logical database behind this is BRF.  So we created a u2018CUSu2019 selection view for the logical database and added the field from BSEG to the functional group
    and checked the checkbox u201CPreselectu201D for it to appear automatically in the FB03 screen.
    But we still couldnu2019t see the field in FB03 dynamic selection.
    On analysis, we found that only tables are that are defined in the nodes (Extras  Selection views) can be used to create the dynamic selection and BSEG was not available
    as one of the node.  So we added BSEG as one of the node by adding the below code to the SELECTION of the logical database.
    SELECTION-SCREEN DYNAMIC SELECTIONS FOR TABLE BSEG.
    Even after that, we couldnu2019t see the field from BSEG in the dynamic selection.
    Are we missing anything here?
    I see many threads here on similar lines but no one has posted the exact step. Any help is highly appreciated.
    Thanks a lot.
    Regards,
    Suganya

    Hi
    If you want to take the line item details than you can refer these t-codes rather than customizing.
    S_AC0_52000887 - Receivables: Profit Center
    S_AC0_52000888 - Payables: Profit Center
    S_ALR_87012332 - G/L Account Statements
    Here by using the dynamic selection you can get the results. Use object list display and select the layout for more fields.
    Thanks

Maybe you are looking for

  • Error message "No bootable device--in​sert boot disk"

    Greetings. My HP Pavilion DV5-1213em is displaying the following error message on a black screen " No bootable device--insert boot disk and press any key" . I would be grateful for advice as to what has gone wrong and what I now need to do. I am unab

  • Color Picker no longer working since 2.4 (changes to galery.xml?)

    Hey, I'm using a web galery and since the update to 2.4 (and 2.5) the colour pickers do not longer work in the module. I can't get a hold of the developer (for the last 3 montsh) so need to fix this issue myself. Does anybody know if there were chang

  • Driver for HP Photosmart 7510 for Mac OSX 10.8.4

    Hi All, I have an HP Photosmart printer and the drivers won't install on my new MacBookPro which has Mac OSX 10.8.4 I am unable to find any drivers on HP support for this OS. The drivers installed without any problems on my recent iMac which had OSX

  • I lost all of my iPhoto pictures i think. when i click on iPhoto it says "which photo library do you want iPhoto to use"

    the version of my laptop is 10.8.5 there is no photo library anywhere on my computer the "pictures" folder only has a "photo booth library" which i am not concerned with i believe this has happened before (couple of months ago) but I'm not sure how i

  • Spell Check error

    I have been having a problem with e-mail -- that has since migrated to Safari as well. When sending a message or trying to enter a password and using a special character or carriage return I get an "Alert" that the "Spell Checker" can't be found (app