Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BSEG-BELNR based on VBRK-VBELN

arsul_parshuram
Participant
0 Kudos

Dear All,

Happpy Diwali.

I want BSEG-BELNR based on Invoice no(VBRK-VBELN).

Please tale me another way to get same data as per below code.

DATA : V_BELNR TYPE BKPF-BELNR.

LOOP AT IT_DATA .

SELECT SINGLE BELNR

INTO V_BELNR

FROM BSEG

WHERE VBELN = IT_DATA-INVNO

AND SHKZG = 'S'.

if sy-subrc = 0.

iT_DATA-BELNR = V_BELNR .

MODIFY IT_DATA TRANSPORTING BELNR.

endif.

CLEAR V_BELNR.

ENDLOOP.

Kindly advice another select query for above query.

Regards,

Parshuram.

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

As BSEG is a cluster your program performance will be very bad (full table scan). To get link between SD invoice (VBRK-VBELN) and FI accounting document (BKPF-BUKRSBELNRGJAHR) use the link to original document which is stored in FI :

- BKPF-AWTYP = 'VBRK'

- BKPF-AWKEY = VBRK-VBELN (*)

Regards,

Raymond

(*) field to map before statement SELECT, look a TTYP table with key 'VBRK'.

4 REPLIES 4

raymond_giuseppi
Active Contributor
0 Kudos

As BSEG is a cluster your program performance will be very bad (full table scan). To get link between SD invoice (VBRK-VBELN) and FI accounting document (BKPF-BUKRSBELNRGJAHR) use the link to original document which is stored in FI :

- BKPF-AWTYP = 'VBRK'

- BKPF-AWKEY = VBRK-VBELN (*)

Regards,

Raymond

(*) field to map before statement SELECT, look a TTYP table with key 'VBRK'.

0 Kudos

Thanks sir.

0 Kudos

Hi Parsuram ,

Please close the thread if your Qtn answered .

Regards,

Maruthi

MaruthiKona217
Explorer
0 Kudos

Hi Parshuram,

Please Select the BKPF-BELNR where BKPF-AWKEY = VBRK-VBELN And BKPF-AWTYP = 'VBRK' .

Select BSEG-BELNR from BSEG WHERE BUKRS = BKPF-BUKRS

BELNR = BKPF-BELNR

GJAHR = BKPF-GJAHR.

This Solution will work fast and efficiently.

Regards ,

Maruthi