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

I want to fetch kbetr using VBELN from VBRK and KONV Table.

DATA : BEGIN OF it_vbrk OCCURS 10,

vbeln type vbeln,

knumv type knumv,

END OF it_vbrk.

DATA : BEGIN OF it_konv OCCURS 10,

kschl type kschl,

knumv type knumv,

kbetr type kbetr,

END OF it_konv.

DATA :BEGIN OF it_final OCCURS 10,

vbeln type vbeln,

kschl type kschl,

knumv type knumv,

kbetr type kbetr,

END OF it_final.

PARAMETER : v_vbeln type vbrk-vbeln.

"v_knumv type vbrk-knumv.

break abap1.

SELECT vbeln knumv FROM VBRK

INTO it_VBRK

WHERE

VBELN = v_vbeln.

ENDSELECT.

"SELECT vbeln FROM vbrk INTO TABLE it_vbrk WHERE vbeln = v_vbeln.

*AND knumv = v_knumv.

*SELECT kbetr FROM konv INTO TABLE it_konv

* FOR ALL ENTRIES IN it_vbrk

* WHERE knumv = it_vbrk-knumv AND kschl =

*'ZF02' .

select kbetr

from konv client specified

into table it_konv

for all entries in it_vbrk

where mandt = sy-mandt

and knumv = it_vbrk-knumv

and kschl =

'ZF02' .

LOOP AT it_final.

it_final-kbetr = it_konv-kbetr.

READ TABLE it_vbrk WITH KEY vbeln = it_vbrk-vbeln.

IF sy-subrc = 0.

it_final-vbeln = it_vbrk-vbeln.

it_final-knumv = it_vbrk-knumv.

ENDIF.

APPEND it_final.

CLEAR : it_final,it_konv , it_vbrk.

ENDLOOP.

LOOP AT it_final.

WRITE : it_final-kbetr.

ENDLOOP.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Dec 11, 2014 at 06:42 AM

    Hi Dheeraj,

    I guess you want to fetch the values of KBETR from KONV table based on the VBELN from VBRK table, If that is the case below code would help you. this code will display the values for all entries of VBELN in VBRK.

    *&---------------------------------------------------------------------*

    *& Report ZTESTZ

    *&

    *&---------------------------------------------------------------------*

    *&

    *&

    *&---------------------------------------------------------------------*



    REPORT ztestz.





    TYPES : BEGIN OF ty_vbrk,

    vbeln TYPE vbrk-vbeln,

    knumv TYPE vbrk-knumv,

    END OF ty_vbrk,



    BEGIN OF ty_konv,

    knumv TYPE konv-knumv,

    kbetr TYPE konv-kbetr,

    END OF ty_konv.



    DATA : lt_vbrk TYPE STANDARD TABLE OF ty_vbrk,

    lt_konv TYPE STANDARD TABLE OF ty_konv,

    lwa_vbrk TYPE ty_vbrk,

    lwa_konv TYPE ty_konv.



    SELECT vbeln knumv FROM vbrk

    INTO TABLE lt_vbrk.



    SELECT knumv kbetr FROM konv

    INTO TABLE lt_konv

    FOR ALL ENTRIES IN lt_vbrk

    WHERE knumv = lt_vbrk-knumv.



    LOOP AT lt_konv INTO lwa_konv.



    READ TABLE lt_vbrk INTO lwa_vbrk WITH KEY knumv = lwa_konv-knumv.



    WRITE : lwa_vbrk-vbeln , lwa_konv-knumv , lwa_konv-kbetr.

    WRITE : /.



    ENDLOOP.

    Please let us know for further queries.


    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 11, 2014 at 06:19 AM

    Hi Dheeraj,

    You have just posted your code. What is your question?

    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.