Read SAP Document flow in SAP SD

Create Change Document for Custom Table e1442419531234

SAP Document flow in SAP SD: This post will introduce a BAPI to read all the SAP Document flow for a SAP SD document. ( For example, read the delivery and Billing Document for Sales Order in SAP SD Sales and distribution).

SAP Document flow Overview

SAP Doc. Flow Tables and Tcodes

Get the most important list of SAP tcodes and SAP tables for documents flow in this post: ?Document Flow SAP SD and SAP MM with Tables and Tcodes

SAP Document flow BAPI

Read the SAP Doc. flow can be done by the function module?RV_ORDER_FLOW_INFORMATION.

Read SAP Document Flow using BAPI sample code

The following part is a sample ABAP code to read the SAP Document Flow for SAP SD sales Order.
The input is the SAP Order Number ( VBCO6-VBELN ) and the output LT_VBFA for the Document flow information.

DATA: lt_VBFA  TYPE TABLE OF VBFA.
DATA: LS_vbco6 TYPE vbco6.

PARAMETERS: p_vbeln type VBELN_D.

START-OF-SELECTION.

  " Initialize SAP Order
  ls_vbco6-vbeln = p_vbeln.
  ls_vbco6-posnr = '000000'.

  " Read SAP Doc. Flow for an Order
  CALL FUNCTION 'RV_ORDER_FLOW_INFORMATION'
    EXPORTING
      comwa         = ls_vbco6
    TABLES
      vbfa_tab      = lt_vbfa " SAP Doc. flow
    EXCEPTIONS
      no_vbfa       = 1
      no_vbuk_found = 2
      OTHERS        = 3.

  IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

Main SAP SD Document Category

When dealing with SAP Doc. Flow, it is important to understand the category of each documents in the flow. here the list of the most used SAP SD Document:

SD Doc. Category Description
AInquiry
BQuotation
COrder
DItem proposal
EScheduling agreement
FScheduling agreement with external service agent
GContract
HReturns
IOrder w/o charge
JDelivery
KCredit memo request
LDebit memo request
MInvoice
NInvoice cancellation
OCredit memo
PDebit memo
QWMS transfer order
RGoods movement
SCredit memo cancellation
TReturns delivery for order
UPro forma invoice
VPurchase Order
WIndependent reqts plan
XHandling unit
0Master contract
1Sales activities (CAS)
2External transaction
3Invoice list
4Credit memo list
5Intercompany invoice
6Intercompany credit memo
7Delivery/shipping notification
8Shipment
aShipment costs
bCRM Opportunity
cUnverified delivery
dTrading Contract
eAllocation table
gRough Goods Receipt (only IS-Retail)
hCancel goods issue
iGoods receipt
jJIT call
pGoods Movement (Documentation)
rTD Transport (only IS-Oil)
sLoad confirmation reposting (only IS-Oil)
tGain / loss (only IS-Oil)
uReentry into storage (only IS-Oil)
vData Collation (only IS-Oil)
wReservation (only IS-Oil)
xLoad confirmation goods receipt (only IS-Oil)
:Service Order
.Service Notification
*Pick Order