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: 

Relation Between VBRP and VFSI (Points Will be awarded)

adnanmaqbool
Contributor
0 Kudos

Dear guys

I want to pick the cost from table VFSI (Shipment Costs) corresponding to VBRP (Billing: Item Data).

The Only relation between them is document number fields that VBELN and VBGEL due to which VFSI is taking too much time to fetch the data.

The KNUMV field which is the key field in VFSI is not matching with value of KNUMV field present in VBRP the only field whose values are matching is VBGEL in VBRP and VBELN in VFSI.

Is there any way to retriev data fast.

6 REPLIES 6

Former Member
0 Kudos

Hi,

look via SQVI to the both table.

i think it's VBELN and POSNR.

Regards, Dieter

Former Member
0 Kudos

Hi!

Try to read KONP table with the VBRP-KNUMV.

Then look for a field in KONP, which could be a key to VFSI.

Regards

Tamá

Former Member
0 Kudos

Hi Adnan..

Try to give better criteria to select data from VFSI..

Take the Document category VBTYP as 'M' if your document is an invoice, or check what other options are there for this field.. Secondly, give the Billing document number too.. VBELN..

SELECT <cost field>

INTO w_cost

FROM VFSI

UP TO 1 ROWS

WHERE knumv EQ 'the knumv you have'

AND VBTYP EQ 'Document Type'

AND vbeln EQ 'Document Number'.

Also, if you can give some value for Calculation base BERGL, then it will make the query much faster..

Thanks and Best Regards,

Vikas Bittera.

***Points for useful answers ***

adnanmaqbool
Contributor
0 Kudos

....

Message was edited by:

Adnan Maqbool

adnanmaqbool
Contributor
0 Kudos

My Query is Like This



  SELECT VBRP~MATNR VBRP~KOSTL VBRP~FKIMG VBRP~VGBEL VBRK~FKDAT
  VBRK~KNUMV VBRP~VBELN ZPLANTS~ABBR
    INTO CORRESPONDING FIELDS OF TABLE MAIN
      FROM VBRK
      INNER JOIN VBRP
      ON VBRP~VBELN = VBRK~VBELN
      INNER JOIN ZPLANTS
      ON VBRP~WERKS = ZPLANTS~PLANT
      INNER JOIN OIGSI
      ON VBRP~VGBEL = OIGSI~DOC_NUMBER
      INNER JOIN OIGSV
      ON OIGSI~SHNUMBER = OIGSV~SHNUMBER
      INNER JOIN ZSPAREA
      ON OIGSV~ROUTE = ZSPAREA~ROUTE
        WHERE VBRK~FKDAT IN DATE
        AND   VBRP~MATNR IN MATNR
        AND   VKORG = VKORG
        AND WERKS IN WERKS.

LOOP AT MAIN.               "Selecting Cost

  SELECT SINGLE NETWR
   INTO CORRESPONDING FIELDS OF MAIN
    FROM VFSI
    where VBELN = MAIN-VGBEL.
  MODIFY MAIN.

ENDLOOP.

0 Kudos

Hi Adnan,

Your select query should be like this:

LOOP AT MAIN. "Selecting Cost

SELECT NETWR

INTO CORRESPONDING FIELDS OF MAIN

FROM VFSI

UP TO 1 ROWS

where knumv EQ main-knumv

AND vbtyp EQ 'M' or the 'document type'

AND VBELN = MAIN-VGBEL.

ENDSELECT.

MODIFY MAIN.

ENDLOOP.

Thanks and Best Regards,

Vikas Bittera.

***Points for useful answers ***