SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software SAP ABAP Programming and HANA Database Tutorials
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Windows, Windows Phone, SAP and ABAP, like SAP UI5, Screen Personas, etc.




CRM Companies List
Web Based CRM Software




Get Proforma Invoice from Commercial Invoice in ABAP

If proforma invoice is used in SAP system, it is a common requirement to print proforma invoice number for given commercial invoice number like the case on Sales invoice outputs, SAP Smartform output. It is best practice to use SAP sales document flow table or document flow function modules to find proforma invoice for commercial invoice. This ABAP tutorial shows ABAP codes to manage this task.

If ABAP developers check the document category VBTYP value range, they will see that for commercial invoices M is used. On the other hand for pro-forma invoices U is used on VBTYP data values. So in VBRK ABAP table, developers can distinguish proforma and commercial invoices using the document category types.

SD document category VBTYP value for proforma invoice
SAP SD document category VBTYP value for proforma invoice and commercial invoice

Let's now search Sales Document Flow ABAP table and use document category types to find a preceeding proforma invoice with VBTYP value equal to U for a given commercial invoice. Here is sample ABAP codes that query VBFA Sales Document Flow SAP table to find the related proforma invoice document number for a given commercial invoice.

DATA lv_proforma_invoice TYPE vbeln.
DATA p_vbfa TYPE vbfa.
DATA ls_vbfa TYPE vbfa.
DATA lt_vbfa TYPE TABLE OF vbfa.

SELECT * FROM vbfa INTO TABLE lt_vbfa
 WHERE vbeln = is_bil_invoice-hd_gen-bil_number "Commercial
 AND vbtyp_v = 'J' . " Delivery document

IF sy-subrc = 0.
 LOOP AT lt_vbfa INTO ls_vbfa.
  SELECT SINGLE * INTO p_vbfa FROM vbfa
   WHERE vbelv = ls_vbfa-vbelv
   AND posnv = ls_vbfa-posnv
   AND vbtyp_v = 'J'
   AND vbtyp_n = 'U'.
  IF gv_customs_inv IS INITIAL.
   lv_proforma_invoice = p_vbfa-vbeln.
  ENDIF.
 ENDLOOP.
ENDIF.

ABAP programmers will realize that first from sales document flow I find out the delivery documents. Then from delivery document, again using document flow I find the related proforma invoice document. So the above ABAP code works in two steps to get the proforma invoice for a given sales invoice number.






SAP Tutorials

SAP Tutorial

SAP Forums

SAP Tools

SAP Transaction Codes Table






Related Articles and Tutorials(http://www.kodyaz.com/sap-abap/proforma-invoice-from-commercial-invoice.aspx)
Complex Conditions in SAP Smartform with AND/OR
Convert Smartform to PDF in Print Preview Mode
Export SAP Data to Fixed Length Text File
SAP Invoice Output ZZZZ is not Defined
Complete List of SAP Modules
Email Spool Request using SAPOffice - Spool to PDF
Sales Tables among ABAP Tables (SAP Sales and Distribution SD Tables)
SAP Invoice Output Determination Analysis for Not Created Output Message
SAP Payment Terms Table and ZTERM Texts Table for ABAP Developers
SAPScript Transaction Codes
Free Adobe LiveCycle Designer Download
Change Output Condition Records
SAP Smartforms Table for Sales Order and Invoice Outputs
SAP Smartforms Tutorial - How to Create Smartform
SAP Smartforms Tutorial - Table Calculations using Count
SAP Smartforms Tutorial - Table Calculations using Sum Total
Adobe Forms Table Header is Missing After Second Page
Assign SAP Item Category to Sales Document Type using SPRO
Message no XS826: Cannot process message; no node determined for 76550052
How to Spell Numbers using ABAP Spell_Amount Function Module
Create Sales Order, Delivery and Billing Document in SAP
Delete Entries in NAST Table using RSCLNAST ABAP Program
How to Export IDOC as Excel and Save as Local File from WE02 Transaction
Export SAP Spool Requests as PDF using SP01 Transaction
How to Find Output Determination Procedure for a Billing Document
How to Disable Word Editor in SAP Smartform Text
Import and Export SO10 Standard Text using RSTXSCRP ABAP Program
Invoice Split due to Manual Invoice Maintenance Check on Sales Order
Invoice Output fail because of missing Billing Type text in TVFKT table
Move Minus Sign from Right to Left of Negative Number in SAP Smartform
Print SAP Outputs From Two Printers at the Same Time
Get Proforma Invoice from Commercial Invoice in ABAP
SAP VKM3 to Release Sales Order from Credit Block
Get SAP Document Flow using SD_DOCUMENT_FLOW_GET ABAP Function Module
SAP Output Management - Create New SAP Output Type
SAP Purchase Order Tables, Transaction Codes and Output
Graphics White Background Displayed Grey on SAP Smartform Output
SE63 Smartform Translation and Export using SLXT Program
SAP Smartform Runtime Error CX_SY_CONVERSION_NO_NUMBER
Window MAIN does not fit onto page PAGE (height)
SAP Smartforms Table Parameter in Form Routine
Trigger Output Re-Determination for Billing Documents
VF31 SAP Transaction to Reprocess Billing Output Messages
Web DynPro Tutorial - Display Spool Requests using Web DynPro Table


Copyright © 2004 - 2017 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems