Skip to Content
author's profile photo Former Member
Former Member

Need help in select statement

hi all

i am stuck at one point i am selecting values from vbrk ainto one internal table and then putting loop on Internal table. and then i have to match the vbeln from bseg table with internal table value. but it taking long time more then 10 min. plz help i am attaching the code also..

SELECT vkorg kunag fkart vbeln erdat netwr FROM vbrk INTO TABLE t_itab

WHERE vkorg IN s_vkorg

AND kunag IN s_kunag

AND fkart IN s_fkart

AND erdat IN s_erdat.

CHECK sy-subrc EQ 0.

LOOP AT t_itab.

SELECT vbeln FROM bseg INTO table t_bseg

WHERE vbeln eq t_itab-vbeln

AND bschl EQ '01'

AND augbl EQ ''.

CHECK sy-subrc EQ 0.

loop at t_bseg.

MOVE: t_itab-kunag TO t_final-kunag,

t_itab-fkart TO t_final-fkart,

bseg-vbeln TO t_final-vbeln,

t_itab-erdat TO t_final-erdat,

t_itab-netwr TO t_final-netwr.

APPEND t_final.

*check sy-subrc eq 0.

SELECT SINGLE name1 FROM kna1 INTO t_final-name1

WHERE kunnr = t_final-kunag.

APPEND t_final.

i hope i am clear what i have to do...

i have to get data from vbrk and then i have to match vbrk-vbeln by bseg vbeln for exsisting document no.

plz help me

its urgent

thanks in advance

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 24, 2005 at 11:40 AM

    HI,

    First check t_itab for vbeln..if sy-subrc ne 0..then delete that records.

    endloop.

    next iteration.

    fill up directly from t_itab to t_final..here vblen available because now it has the values which were there in bseg.

    Y do u need t_bseg?

    Hope u r clear

    Message was edited by: raja gurrala

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 24, 2005 at 11:40 AM

    use inner join on VBELN field

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 24, 2005 at 11:40 AM

    Hi Parul,

    Change your code like this...

    1.SELECT vkorg kunag fkart vbeln erdat netwr FROM vbrk INTO TABLE t_itab

    WHERE vkorg IN s_vkorg

    AND kunag IN s_kunag

    AND fkart IN s_fkart

    AND erdat IN s_erdat.

    2. SELECT vbeln FROM bseg for all entries in t_itab

    INTO table t_bseg

    WHERE vbeln eq t_itab-vbeln

    AND bschl EQ '01'

    AND augbl EQ ''.

    3. SELECT SINGLE name1 FROM kna1 for all entries in t_itab

    INTO t_final-name1

    WHERE kunnr = t_itab-kunag.

    <b>Sorry, select the name1 values into another internal table...</b>

    now sort these internal tables on the key fields, and then loop at t_itab, read the other two internal tables and populate your final internal table.

    Regards,

    Raj

    Message was edited by: Rajasekhar Dinavahi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 24, 2005 at 11:45 AM

    Hi parul,

    can you access another tables insted of BSEG.

    In the BSID, BSAD, BSIK, BSAK... there very similar information of bseg but divided by vendor, customer,....

    it can help you.

    Can you some filed like bukrs and gjahr to access before the bkpf and after the bseg?

    bye

    enzo

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 24, 2005 at 11:48 AM

    create the join of both table bseg and vbrk base d on condition and vbeln......

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      add field vbeln like bseg vbeln in iternal table

      SELECT vbrkvkorg vbrkkunag vbrkfkart vbrkerdat vbrknetwr bsegvbeln FROM vbrk inner join bseg

      on vbrkvbeln = bsegvbeln

      INTO TABLE t_itab

      WHERE vbrk~vkorg IN s_vkorg

      AND vbrk~kunag IN s_kunag

      AND vbrk~fkart IN s_fkart

      AND vbrk~erdat IN s_erdat.

      AND bseg~bschl EQ '01'

      AND bseg~augbl EQ ''.

      CHECK sy-subrc EQ 0.

  • author's profile photo Former Member
    Former Member
    Posted on Nov 24, 2005 at 12:08 PM

    Hi Parul,

    Please avoid writing joins on BSEG...not advisable.

    declare your t_bseg as

    data: begin of t_bseg,

    vbeln like bseg-vbeln,

    end of t_bseg.

    You can try the alternate way of accessing other tables like BSIK etc...but never write joins on BSEG.

    Check this code....

    ******

    REPORT Z_TESTRAJ

    NO STANDARD PAGE HEADING

    LINE-SIZE 200

    MESSAGE-ID ZZ.

    TYPES: BEGIN OF X_VBRK,

    VKORG TYPE VKORG,

    KUNAG TYPE KUNAG,

    FKART TYPE FKART,

    VBELN TYPE VBELN_VF,

    ERDAT TYPE ERDAT,

    NETWR TYPE NETWR,

    END OF X_VBRK.

    TYPES: BEGIN OF X_BSEG,

    VBELN TYPE VBELN_VF,

    END OF X_BSEG.

    TYPES: BEGIN OF X_KNA1,

    KUNNR TYPE KUNNR,

    NAME1 TYPE NAME1,

    END OF X_KNA1.

    DATA: T_ITAB TYPE STANDARD TABLE OF X_VBRK WITH HEADER LINE,

    T_BSEG TYPE STANDARD TABLE OF X_BSEG WITH HEADER LINE,

    T_KNA1 TYPE STANDARD TABLE OF X_KNA1 WITH HEADER LINE.

    START-OF-SELECTION.

    SELECT VKORG KUNAG FKART VBELN ERDAT NETWR FROM VBRK INTO TABLE T_ITAB.

    IF SY-SUBRC = 0.

    SELECT VBELN INTO TABLE T_BSEG

    FROM BSEG FOR ALL ENTRIES IN T_ITAB

    WHERE VBELN EQ T_ITAB-VBELN

    AND BSCHL EQ '01'

    AND AUGBL EQ ''.

    SELECT NAME1 INTO TABLE T_KNA1 FROM KNA1 FOR ALL ENTRIES IN T_ITAB

    WHERE KUNNR = T_ITAB-KUNAG.

    ENDIF.

    ******

    Regards,

    Raj

    Message was edited by: Rajasekhar Dinavahi

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.