Data retrieval
We read the pricing data from the customer master, sales data
(table KNVV), the texts from the corresponding text tables. The names
of the tables can often be found most easily via the F1 help,
"Technical info", on the corresponding fields. Here in transaction
VD03, press F1 on "01" at price group (bottom left) as well as on the text
"Bulk buyer" (bottom right):
That is, from table KNVV
we need the field KONDA and in addition from the text table T188T the text
VTEXT.
The procedure via
F1->Technical Info does not work in all SAP transactions, because
sometimes the database fields are not displayed directly, but an intermediate
intermediate table is used. In this case e.g. the database trace
ST01 is a possibility to find the tables.
To read the data
we have two options:
-
Data retrieval via the CIS ABAP interface
- Data Collection über
die RFC Select-Schnittstelle
The advantage of using the CIS ABAP interface is that we can read the texts for the price group, customer schema and price list at the same time. When using the RFC Select interface, we could either define a view in the SAP Data Dictionary that already contains all texts (join) and read it. However, the texts would be read anew from the database, although they may already be in the table buffer of the application server. Or we first get only the "raw data" and read the texts separately in VB.NET to it. In this case, we should definitely set the parameter cache="yes" in the S10 repository for the text tables to avoid having three RFC accesses to the text tables per client.
Overall, the way via the CIS ABAP interface is less problematic:
Vb.net
' Report Pricing
Public Function CreateReportPricing(Byval Keys _
As Dictionary(From String, String), _
Byval Id As String, Byval Customernumbers() As String, _
Byval Customernames() As String) As String
We use CIS addon ABAP function to read the VIS statistics S667
Clear input/output
Rfc_input.clear()
Rfc_output.clear()
Build up input
Dim s As Addonsimplestring =_
Directcast(rfc_input.addnew(), addonsimplestring)
S.content = Getitem(keys, "VKORG")
s = Directcast(rfc_input.addnew(), addonsimplestring)
S.content = Getitem(keys, "VTWKU")
s = Directcast(rfc_input.addnew(), addonsimplestring)
S.content = Getitem(keys, "spart")
' following parameters: customer numbers
For Each Cn As String In Customernumbers
s = Directcast(rfc_input.addnew(), addonsimplestring)
S.content = Cn
Next
Request data
Ic.rfcrequest("CISADDON.PRICING", "S", rfc_input, _
rfc_output, deferred:=True)
' execute all requests (one only in our case)
Ic.rfcexecutedeferredcalls(rfcmessages)
|
In the ABAP routine we get the organization keys VKORG, VTWEG, SPART and then all selected customer numbers. For performance reasons, it is now important not to request a separate select for each customer number, but to request all customer numbers in a single select. For this we use the option "for all entries in table" of the ABAP Select statement.
The entire ABAP routine then looks like this:
Abap
* Pricing
* In
* 1 VKORG
* 2 VTWEG
* 3 SPART
* 4 KUNNR and following: customer numbers
*
* Out
* KUNNR KONDA KONDATEXT KALKS KALKSTEXT PLTYP PLTYPTEXT
form PRICING tables reqparm resparm changing rc type c msg type c.
data: wa(8000).
data: sorg like knvv-sorg,
vtweg like knvv-vtweg,
saves like knvv-saves.
Read Table reqparm index 1 into sorg.
Read Table reqparm index 2 into vtweg.
Read Table reqparm index 3 into saves.
Read Table reqparm index 4 into wa.
* Customer numbers
data: begin of customers occurs 10,
account like kna1-account,
end of customers.
Data: k type i value 4.
Read Table reqparm index k into customers-account.
While sy-subrc Eq 0.
Append customers.
k = k + 1.
Read Table reqparm index k into customers-account.
Endwhile.
* no customers?
if customers[] is initial.
exit.
endif.
* Result tables
data: begin of r1 occurs 10,
account like knvv-account,
konda like knvv-konda,
lime like knvv-lime,
pltyp like knvv-pltyp,
end of r1.
Select account konda lime pltyp
from knvv
into corresponding fields of table r1
for all entries in customers
where sorg = sorg
ountry vtweg = vtweg
ountry saves = saves
ountry account = customers-account.
sort r1.
Data: condatext like t188t-vtext,
lime text like tvkdt-vtext,
pltyptext like t189t-ptext.
Loop at r1.
condatext = ''.
lime text = ''.
pltyptext = ''.
Select single vtext from t188t into condatext
where spras = sy-langu ountry konda = r1-konda.
Select single vtext from tvkdt into lime text
where spras = sy-langu ountry lime = r1-lime.
Select single ptext from t189t into pltyptext
where spras = sy-langu ountry pltyp = r1-pltyp.
* output result
Concatenate
r1-account
r1-konda
Condatext
r1-kalks
Lime text
r1-pltyp
Pltyptext
into wa separated by cl_abap_char_utilities=>horizontal_tab.
Append wa to resparm.
Endloop.
Final shape.
|
|
Layout
We build the output table in VB.NET as HTML string, using CSS to specify fonts, dimensions, colors etc. be set. A typical snippet of VB.NET coding:
Vb.net
For Each line As Addonsimplestring In Rfc_output
Dim Fields() As String = Line.content.Split(vbTab)
Account = Fields(0)
Konda = Fields(1)
condatext = Fields(2)
lime = Fields(3)
lime text = Fields(4)
Pltyp = Fields(5)
Pltyptext = Fields(6)
Sb.append("<div style='width:740px;
font-size:13px; margin-left:8px; clear:both;'>")
' customer nr
Sb.append("<div class='outputcelldiv'
style='text-align:left; width:80px;'>")
AppendString(sb, kunnr.TrimStart("0"))
Sb.append("</div>")
' customer
Sb.append("<div class='outputcelldiv'
style='text-align:left; width:220px;
margin-right:4px; text-overflow: ellipsis;'>")
AppendString(sb, customername(kunnr, customernumbers, customernames))
Sb.append("</div>")
' conda
Sb.append("<div class='outputcelldiv'
style='text-align:left; width:150px;'>")
AppendString(sb, konda & " " & Condatext)
Sb.append("</div>")
' Lime
Sb.append("<div class='outputcelldiv'
style='text-align:left; width:120px;'>")
AppendString(sb, kalks & " " & Lime text)
Sb.append("</div>")
' pltyp
Sb.append("<div class='outputcelldiv'
style='text-align:left; width:150px;'>")
AppendString(sb, pltyp & " " & Pltyptext)
Sb.append("</div>")
Sb.append("</div>")
Next
|
|