Application Development and Automation 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: 
Read only

Fetch Billing Doc. No.

Former Member
0 Likes
931

HI EXPERTS,

I need to fetch the Billing Doc No. (VBRP-VBELN) on the base of Dilevery Doc. No. ( MSEG-XBLNR). I am passing XBLNR into VGEBL of VBRP. But it takes lots of time coz its not a PK. Is there any alternative to this.

Urgent.

Thanks.

Khan....

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
905

Hi Khan,

Considering getting the relation from Sales Document Flow (Table VBFA). Querying VBFA is not recommended for performance reasons, however there are function modules which optimize the query to VBFA like READ_VBFA.

Cheers.

6 REPLIES 6
Read only

Former Member
0 Likes
906

Hi Khan,

Considering getting the relation from Sales Document Flow (Table VBFA). Querying VBFA is not recommended for performance reasons, however there are function modules which optimize the query to VBFA like READ_VBFA.

Cheers.

Read only

0 Likes
905

hi Aditya,

Ok if I use Read_VBFA FM. I only need to fetch VBELN from it while passing my XBLNR into VBELV. Hoz do I only fetch my desired field in below FM. My code shows Runtime error. Plz help

CALL FUNCTION 'READ_VBFA'

EXPORTING

I_VBELV = VXBLNR

  • I_POSNV =

  • I_VBTYP_V =

I_VBTYP_N = 'M'

  • I_FKTYP =

  • I_BYPASSING_BUFFER =

  • I_REFRESH_BUFFER =

TABLES

E_VBFA =

  • EXCEPTIONS

  • NO_RECORD_FOUND = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

***********************************

Thanks.

Khan

Read only

0 Likes
905

Hi, You have to pass the item number as well for the FM to retreive the documents. Should you not have the Item number, make a direct select. But this can correspond to multiple Invoice documents. Also you have to consider if the billing document is cancelled. You can check the status of the cancellation with field VBRK-FKSTO.

Read only

0 Likes
905

HI Eswar

How v get the VBRK-FKSTO status. coz V dont want to go VBRP as it taks long time. Plz help.

Thanks.

Khan

Read only

0 Likes
905

Check below example:


PARAMETERS: p_vbelv TYPE vbeln_vl.

DATA: l_vbeln TYPE vbeln,
      l_fkdat TYPE fkdat.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    input         = p_vbelv
 IMPORTING
   OUTPUT        = p_vbelv.

SELECT SINGLE a~vbeln b~fkdat INTO (l_vbeln, l_fkdat)
       FROM vbfa AS a
       INNER JOIN vbrk AS b
       ON a~vbeln = b~vbeln
       WHERE a~vbelv = p_vbelv 
       AND   a~vbtyp_n = 'M' " Billing 
       AND   a~vbtyp_v = 'J'   " Delivery 
       AND   b~fksto NE 'X'.   " Billing document not cancelled
IF sy-subrc EQ 0.
  WRITE:/ 'Billing Document:', l_vbeln,
        / 'Date:', l_fkdat.
ENDIF.
Here parameter P_VBELV is you delivery number. Execute above code in a temporary program to check the results and use it as per your requirement.

Read only

0 Likes
905

Interesting....