Va05 Enhancement
Va05 Enhancement
Symptom
The optimized reports use a predefined set of database tables for the selection (VBAK and
VBAP, among others).
However, you want to add additional tables to this list. This may be delivered tables (for
example, MARA) as well as customer-specific tables (for example, in the Z* namespace).
Other Terms
VA05, VA15, VA25, VA45, SDO1
SD_SALES_DOCUMENT_VA15
SD_SALES_DOCUMENT_VA25
SD_SALES_DOCUMENT_VA45
SD_SALES_DOCUMENT_VIEW
SD_SALES_DOCUMENT_SDO1
Solution
This consulting note describes how you can adjust the optimized reports according to your
requirements. For this, this SAP Note describes several scenarios as examples.
In general, the following applies: If you use the BAdIs to define additional output fields,
they are initially not contained in the output list. However, you can use the button for
changing the layout to add them to your display variant.
data:
lt_fieldname type tdt_fieldname.
append 'ERDAT' to lt_fieldname.
Note that the entry date (ERDAT) is used for the calculation of the weekday. Therefore, this
must be specified as a required component (REQUIRED_COMP).
The result is an additional column in the output list. This column has the heading "My
Weekday". (If the field TEXT is not explicitly filled in ADAPT_RESULT_COMP, the system uses
the heading from the data element WEEK_DAY.) This field is filled in the method
POST_PROCESSING:
field-symbols:
<lv_erdat> type datum,
<lv_my_calc_field> type char10.
try.
assign component 'MYCALCFIELD' of structure cs_result
to <lv_my_calc_field>.
assign component 'ERDAT' of structure cs_result
to <lv_erdat>.
if <lv_erdat> is assigned and
<lv_my_calc_field> is assigned and
<lv_erdat> is not initial.
* Calculate weekday of creation date
call function 'DATE_TO_DAY'
exporting
date = <lv_erdat>
importing
weekday = <lv_my_calc_field>.
endif.
catch cx_root.
endtry.
2) Field from a database table selected by default
In the optimized reports, the following database tables are already selected by default:
ADRC ("Addresses (Business Address Services)")
VBAK ("Sales Document: Header Data")
VBAP ("Sales Document: Item Data")
VEDA ("Contract Data")
VBKD ("Sales Document: Business Data")
VBPA ("Sales Document: Partner")
VBEP ("Sales Document: Schedule Line Data")
These table names are also contained in the interface IF_SDOC_SELECT (attribute
CO_TABLENAME).
You now want to display an additional field from one of these database tables. This field
can be a standard field as well as a customer-specific field (append structure).
For example, if you want to display the "Material Group" field (MATKL) from the database
table VBAP, you must implement the method ADAPT_RESULT_COMP as follows:
In another example, you can add a column for the customer expected price or the customer
value (condition category J, condition types EDI1 and EDI2 in the standard system) to the
display. To do this, you can use the following source code:
Addresses must be handled in a special way because a partner function is always required for
this. From a technical point of view, the field ADRC-ADDRNUMBER must be selected from the
field VBPA-ADRNR (refer to the attached graphic). For the partner function "SP" (sold-to
party), the two table aliases VBPA_AG and ADRC_AG exist. They can be uniquely determined
from the document header and used for user-defined fields; for example, to display the city
of the sold-to party:
In addition, the table alias VBPA_ZM exists, which is filled from the order header and the
partner function specified on the selection screen.
3) Field from a database table not selected by default
Based on example 2), you also want to display the valuation class of the material group
(BKLAS) from the database table T023. To do this, implement the method ADAPT_RESULT_COMP as
follows:
data:
lt_join_metadata type if_sdoc_select=>tct_join_metadata.
Since you now want to read a field from the table T023, meta data for accessing the table
T023 is required. This is achieved by linking the field T023-MATKL to the field VBAP-MATKL
using a JOIN condition.
For client-specific tables, the system automatically generates a JOIN condition on SY-MANDT.
data:
lt_join_metadata type if_sdoc_select=>tct_join_metadata.
The JOIN condition can also be set up with a constant value (for example, of the logon
language) instead of another database field.
data:
lt_join_metadata type if_sdoc_select=>tct_join_metadata.
In principle, specifying the alias is optional because it is used only in rare cases.
However, if it is used, it must be set consistently (in addition to the physical table name)
in CT_RESULT_COMP and in LT_JOIN_METADATA.
Note that no enhancement points are available for the new transaction SDO1. If required, use
transaction VA05 together with its enhancement points.
Each of these enhancement spots contains the following two static enhancement points:
EXT1
Here, you can define your own selection fields. If you want to, for example,
provide a parameter for the user name, implement the following source code:
PARAMETERS: PUNAME type XUBNAME default SY-UNAME.
For a select option, you can implement the following lines:
DATA: GV_USERNAME type XUBNAME.
SELECT-OPTIONS: SUNAME for GV_USERNAME default SY-UNAME.
EXT2
At this point, transfer the user entries to an internal structure for further
processing. For this, two macro definitions are available. Proceed as follows to transfer a
parameter, for example, to filter according to the field USERNAME of the database table
ZMY_TABLE:
transfer_parameter 'ZMY_TABLE' 'USERNAME' PUNAME.
For a select option, implement the following source code:
transfer_select_option 'ZMY_TABLE' 'USERNAME' SUNAME.
Note that, at runtime, dynamic JOIN conditions must be set up between the database tables
selected by default (see above) and the database table referenced by you (in the example:
ZMY_TABLE). For this, you must implement the internal table CT_ADDITIONAL_TABLE_METADATA
from the method ADAPT_RESULT_COMP of the BAdI mentioned above (see the above examples).
Additional pushbuttons in the output list
If you require further pushbuttons in the output list, you can implement the BAdI
BADI_SDOC_VIEW_CUSTOM_FUNC. This is contained in the enhancement spot ES_SDOC_VIEW and
contains the following methods:
DEFINE_CUSTOM_FUNCTION
This method is called when the output list is set up to define additional
pushbuttons.
Refer to the above description for the parameter IV_APPLICATION_ID.
You can use the changing table CT_CUSTOM_FUNCTION to add any number
of additional pushbuttons. To do this, specify a (technical) name and a text for each
function. The text can be filled language-dependently, for example, using SY-LANGU. The name
corresponds to FCODE in the screen programming and it must be unique within
CT_CUSTOM_FUNCTION.
The sequence of the lines in CT_CUSTOM_FUNCTION corresponds to the
sequence of the buttons in the output list.
DO_CUSTOM_FUNCTION
This method is called when the user chooses a function that has previously been
defined.
IV_NAME contains the technical name of the function that is triggered. In the
implementation, a check for IV_NAME should always take place (even if only one additional
function has been defined) because this source code is also processed for functions that are
offered by IBUs or SAP partners (using BADI_SDOC_VIEW_CUSTOM_FUNC_INT).
The importing table IT_RESULT contains all lines of the output list. The
importing table IT_SELECTED_ROWS contains only the selected lines (the entries contain the
line numbers referring to IT_RESULT).
You can use the changing table CT_MESSAGE to add T100 messages to the message
log.
The additional functions are displayed in the output list with up to six buttons. If more
than six functions are defined (the total number of defined functions in
BADI_SDOC_VIEW_CUSTOM_FUNC and BADI_SDOC_VIEW_CUSTOM_FUNC_INT), the system displays a dialog
box when you choose the sixth button. In this dialog box, the remaining functions are
available for selection.
Software Components
Software Component From To
3367135 SD-SLS-GF-RE
3296415 Open quantity and Net value in VA05 for partially processed sales documents
3320658 SD-SLS-GF-RE VA05 CX_SDOC_REPORTING when joining to custom tables or fields with special characters
2322762 SD-SLS-GF-RE SQL Exception when adding custom columns to report layout for HANA database in VA05
2192630 SD-SLS-GF-RE Incorrect SQL statement implementing report optimization described in note 1780163
2160169 SD-SLS-GF-RE SQL Exception when adding custom columns to report layout by means of SDOC classes
note1780163_db_tables.pdf 91 application/pdf