Topic


 

The "sales" report shows the annual sales for the last 5 years of chosen customers.

Getting the data

We take the data for the sales statistics from SAP table S001 which is part of the sales information system (VIS).
The materialnumber is part of the key for this standard table, but we don't need this.
In order to reduce the bulk of what we have to read we can define our own statistics table within the VIS, e.g. "S950" that looks similar to S001 but without the material number. Then we can read the sales data from that table instead.

We read the data from the CIS ABAP interface:

VB.net
 ' Report Sales1
Public Function CreateReportSales1(ByVal keys _
     As Dictionary(Of 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

        ' 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, "VTWEG")

        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.VIS01", "S", rfc_input, rfc_output, _
                           deferred:=True)

        ' execute all requests (one only in our case)
        ic.RfcExecuteDeferredCalls(rfcmessages)'

....

 



Within the ABAP method we recieve the organizational keys VKORG, VTWEG, SPART and then the selected customer numbers.
For performance purposes it is important not to call a select statement for each customer number, but to request all customer numbers with one single select statement. Therefore we use the option "for all entries in table" of the ABAP select statement.

The crux of our ABAP coding is the following:


 

ABAP
data: begin of r1 occurs 10,
          kunnr  like s001-kunnr,
          spmon  like s001-spmon,
          umnetwr like s001-umnetwr,
          stwae   like  s001-stwae,
        end of r1.
  
  Select kunnr spmon umnetwr stwae
           from S001
             into corresponding fields of table r1
               for all entries in customers
              where kunnr = customers-kunnr
              and   vkorg = vkorg
              and   vtweg = vtweg
              and   spart = spart
              and   spmon GE spmon.

 

Please have a look at the ABAP function module /GUIXT/CISADDON_INTERFACE, which is shipped with CIS mobile, for more details.
 

Layout

The output table will be built up as an HTML string. We use CSS for choosing the font, margins, colors etc. Here is a typical part of our VB.NET coding:
 
VB.net
 ' Buld up HTML output table
        Dim sb As New StringBuilder


... 
        'Title
        sb.Append("<div style='width:700px; font-size:12pt; 
        font-weight:bold; margin: 10px 0px 10px 5px; 
                  color:#606060;'>")
        AppendString(sb, ic.MessageText("REPORT_SALES_TITLE1")
        & year4 & " - " & year0 & ic.MessageText
                                      ("REPORT_SALES_TITLE2"))
        sb.Append("</div>")

        ' column headings
        sb.Append("<div class='colhead01' style='width:740px; 
             font-size:12px; margin-bottom:4px;'>")

        ' customer number
        sb.Append("<div class='colhead' style='float:left; 
              text-align:left; width:80px;'>")
        AppendString(sb, ic.MessageText("REPORT_SALES_COL1"))
        sb.Append("</div>")

        ' customer
        sb.Append("<div class='colhead' style='float:left; 
                text-align:left; width:190px; margin-right:4px;'>")
        AppendString(sb, ic.MessageText("REPORT_SALES_COL2"))
        sb.Append("</div>")


        ' year4
        sb.Append("<div class='colhead' style='float:left; 
                      text-align:right; width:80px;'>")
        sb.Append(year4.ToString)
        sb.Append("</div>")

        ' year3
        sb.Append("<div class='colhead' style='float:left; 
                       text-align:right; width:80px;'>")
        sb.Append(year3.ToString)
        sb.Append("</div>")
...

 

Additional parameters

No additional parameters