cancel
Showing results for 
Search instead for 
Did you mean: 

Need Sales Contract No. in Invoice in SMARTFORM

Former Member
0 Kudos

Hi,

I need Sales Contract number in Invoice Smartform. I tried to fetch Contract number form VBFA table

but Contract number is not there but in Sales Document flow for invoice,it is created with reference of Contract number but there is no Contract number in Table VBFA for that Billing Doc no. Is there any other method to fetch it..I want to fetch Sales Contract number and Sales contract date in Invoice Smartfrom

Please do needful.

Accepted Solutions (1)

Accepted Solutions (1)

Jelena
Active Contributor
0 Kudos

1) If you're using the standard interface with LBBIL_INVOICE structure, take a look at HD_REF underneath it - the contract number might already be in one of the fields.

2) Check the following fields: VBRK-ZUKRI, VBRK-XBLNR, VBRP-AUBEL

3) If all else fails, you'll need to look up the document that "stands" between the invoice and the contract, as suggested above.

Actually I would've mentioned this to your SD consultant - it doesn't seem right that the referenced document is not reflected in the document flow. He/she might want to change the configuration.

Former Member
0 Kudos

Hi Jelena,

Sales contract is reflected in Document flow but there is no entry for that Contract number in Table VBFA...Thats y I m not able to fetch it. I dont know whether this problem is bcos of Configuration Settings or any other problem.

Anyways I m not able to get the Sales contract number and Contract date because it is not available in LBBIL_INVOICE Structure. Is there any other way to get it??

Thanks...

Jelena
Active Contributor
0 Kudos

In this case there is no direct link between the invoice and the contract. See what other document is listed in the document flow between the contract and the invoice (it could be a sales order or a delivery, or both). You will need to do at least 2 look-ups (may be combined with JOIN) to get the contract, as already suggested by Pawan, or something similar.

Check VBFA records for all the documents in the flow. Additionally, see how VGBEL/VGPOS fields are filled in in VBAP/VBRP. Sometimes it is more efficient to use those fields instead of reading VBFA. It depends though - see what works best in your system. Get help from your SD consultant, if necessary.

Answers (1)

Answers (1)

Pawan_Kesari
Active Contributor
0 Kudos

try this logic

first select sales order from you invoice number


select vbelv posnv
from vbfa
where vbeln = invoice number
and vbtyp_N = 'M'
and vbtyp_V = 'C' .

Then use these sales order and get records from VBAP, field VGBEL and VGPOS has Sales order contract.

select vgbel vgpos 
from vbap
where vbeln = vbfa-vbelv
and posnr = vbfs-posnr.