Dear SAPLearners, in this blog post we will learn about VBFA table changes in S/4 HANA. This blog post is part of S/4 HANA Technical tutorials.
Lets get started
1. VBFA Primary Key change
Primary key of VBFA table has been changed compared to ECC system. A new field “RUUID” – SD Unique Document Relationship Identification is added.
2. Removal of VBFA fields
Extended SD Document Category fields VBTYPEXT_V, VBTYPEXT_N are removed.
3. VBTYP Field Length Extension
SD Document Category field “VBTYP” (VBTYP_V & VBTYP_N) is extended to CHAR-4 in S/4 HANA which is previously CHAR-1 in ECC system.
4. VBFA-STUFE Mystery
In initial release of S/4 HANA the field “STUFE” was removed. The field STUFE is introduced again in S/4 HANA 1511 SP04, 1610 SP02, 1709 and higher releases.
The decision to remove the field during initial S/4 HANA release is to reduce memory consumption. This lead to data inconsistency due to archiving of documents which is supported in S/4 HANA for on-premise installations.
So the field “STUFE” is added again to store the in-direct relationships of SD documents in the table.
Custom code adaption is required if the field is used during SELECT statements and the custom code has to be changed depends on S/4 HANA releases.
To mitigate custom code changes during migrations or installations it is recommended to use the new utility class “CL_SD_DOCUMENT_FLOW_RT” which is release independent.
Following are the list of methods for use to get SD document flow.
|HAS_SUCCESSOR||Check if a successor of a specific type exists|
|HAS_PREDECESSOR||Check if a predecessor of a specific type exists|
|GET_SUCCESSORS||Get successors of a specific type and path length|
|GET_PREDECESSORS||Get predecessors of a specific type and path length|
|BUILD_XVBFA_FROM_PREDECESSOR||Get all predecessors up to a maximum path length|
In addition to the above a utility class CL_SD_DOC_CATEGORY_UTIL and interface IF_SD_DOC_CATEGORY is delivered for the SD document category (VBTYP).
Below is the sample code on how to use class CL_SD_DOCUMENT_FLOW_RT to get SD flow documents.
To fetch successor SD document, deliveries
DATA pt_vbfa TYPE TABLE OF vbfa. DATA(lo_docflow_rt) = NEW cl_sd_document_flow_rt( ). * To fetch successor SD documents; deliveries CALL METHOD lo_docflow_rt->get_successors EXPORTING it_document = lt_sorders it_successor_type = cl_sd_doc_category_util=>rg_delivery_outgoing( ) iv_path_length = 1 IMPORTING et_item = lt_successors. LOOP AT lt_successors INTO ls_successors. ls_vbfa-vbelv = ls_successors-predecessor_id. ls_vbfa-vbtyp_n = ls_successors-successor_type. ls_vbfa-vbeln = ls_successors-successor_id. ls_vbfa-posnn = ls_successors-successor_item_id. APPEND ls_vbfa TO pt_vbfa. ENDLOOP.
To fetch predecessor documents; sales orders
* To fetch predecessor sD documents; sales orders DATA(lo_docflow_rt) = NEW cl_sd_document_flow_rt( ). CALL METHOD lo_docflow_rt->get_predecessors EXPORTING it_document = VALUE #( ( type = if_sd_doc_category=>credit_memo_req id = c_ls_vbrp-aubel ) ) it_predecessor_type = VALUE #( ( sign = 'I' option = 'EQ' low = if_sd_doc_category=>order ) ) iv_path_length = 2 IMPORTING et_document = DATA(lt_document).
Congrats!!! you have successfully learned about VBFA table changes in S/4 HANA. Next time you write an ABAP program to fetch SD document flow from VBFA table we hope you applied what you have learned here.
Please feel free to comment and let us know your feedback. Subscribe for more updates.
if you liked it, please share it! Thanks!