Display a list in html format

Users often require additional information about business objects they are dealing with in a transaction. Sometimes the SAP standard system offers these possibilities on a button or in the menu. In other cases the only way to access the additional information is for the user to open an additional mode and to navigate to the right transaction or to call up the right report and then, in most cases, enter the object keys again. 

With InputAssistant and Viewer there are several easier ways to access and handle additional information. The following explains one of these techniques:

  • You look for a standard ABAP report that displays the information you need, or you write a suitable new ABAP report;
  • WIth GuiXT you add onto the screen a new button that invokes an InputScript, passing the necessary key information to it;
  • In the InputScript you call a function module that produces the required ABAP list in html format, and returns it to the script;
  • Finally, with the Viewer component you display the list.

This approach has several advantages:

  • Often there already exists a standard report that you can use, either as it is, or as a good basis for your own implementation;
  • Only one function call is needed, avoiding extra roundtrips between frontend and application server;
  • The user can scroll the list locally and thus work with the list independently of the SAP sessions;
  • Additionally, you can easily combine several lists in one display.

Alternatively you can call the ABAP report via a /O… command (new session), and use the normal SAP display. This is somewhat easier to implement and requires no extra function call, but the advantages of local scrolling and the option of combining several lists into one are sacrificed.   

Example:  Displaying stock overview and sales summary in VA01

In the order entry transaction VA01, we offer two new buttons in the toolbar: “Sales summary” and “Stock overview”. The first button shows previous sales for the given customer, using a standard report. The second pushbutton shows the stock overview for all materials on the current table page. It also uses a standard report, produced for each material and then combined into one list.

Sap Guixt webreport1 Display a list in html format
 VA01: new pushbuttons “Sales Summary and “Stock overview” 

Sap Guixt webreport2 Display a list in html format
Sales summary report in a separate browser window 

 

Sap Guixt webreport3 Display a list in html format
Stock overview  in a separate browser window 

 

GuiXT script “SAPMV45A.E4001.TXT”

if Q[Transaction=VA01] and Q[Page=Sales]
  Pushbutton (toolbar) “Sales Summary”  process=”SalesSummary.txt”
  Pushbutton (toolbar) “Stock overview” process=”StockOverview.txt”
endif

InputScript “SalesSummary.txt”

Call “ZZ_GUIXT_CUSTOMER_PAYMENTS” in.KUNNR=”&F[Sold-to party]” table.HTML=htm

// Buld temp filename using Windows TMP environment variable
Set V[VA01_viewfile] “&%[TMP]\guixtview.html”

// Write to temp file
CopyText fromText=”htm” toFile=”&V[VA01_viewfile]“

// Display list (coordinates: for window sizing only)
View (0,0) (30,120) “&V[VA01_viewfile]” -floating 

InputScript “StockOverview.txt”

// Show stock overview for all materials on this page
Set V[material]

// del material number table
CopyText fromString=”material” toText=mat

Set V[i] 1

label item
Set V[material] “&cell[All items,Material,&V[i]]”
if not V[material]
  goto end_of_page
endif
CopyText fromString=”material” toText=”mat” -appendline 
Set V[i] &V[i] + 1
goto item

label end_of_page

Call “ZZ_GUIXT_STOCK_OVERVIEW” table.TMAT=mat table.HTML=htm

// Buld temp filename using Windows TMP environment variable
Set V[VA01_viewfile] “&%[TMP]\guixtlist.html”

// Write to temp file
CopyText fromText=”htm” toFile=”&V[VA01_viewfile]“ 

// Display list (coordinates: for window sizing only)
View (0,0) (30,120) “&V[VA01_viewfile]” -floating 

 

Function “ZZ_GUIXT_CUSTOMER_PAYMENTS”

FUNCTION ZZ_GUIXT_CUSTOMER_PAYMENTS.
*”———————————————————————-
*”*”Local interface:
*” IMPORTING
*” VALUE(KUNNR) TYPE KUNNR
*” TABLES
*” HTML STRUCTURE W3HTML OPTIONAL
*”———————————————————————-

* Debugging in RFC mode:
* call function ‘SYSTEM_ATTACH_GUI’.
* break-point.

data: abaplist like abaplist occurs 1 with header line.

* Add leading 000…
if kunnr co ‘ 0123456789′.
  unpack kunnr to kunnr.
endif.

* Produce report
Submit RVKUSTA1
    exporting list to memory
    and return
      with KUNNR EQ kunnr
      with VKORG EQ ’1000′.

* get list from memory
CALL FUNCTION ‘LIST_FROM_MEMORY’
     TABLES
        LISTOBJECT = abaplist.

* and convert to html
CALL FUNCTION ‘WWW_HTML_FROM_LISTOBJECT’
     TABLES
        HTML = html
        LISTOBJECT = abaplist.

ENDFUNCTION.

Function “ZZ_GUIXT_STOCK_OVERVIEW”

FUNCTION ZZ_GUIXT_STOCK_OVERVIEW.
*”————————–
——————————————–
*”*”Local interface:
*” TABLES
*” HTML STRUCTURE W3HTML OPTIONAL
*” TMAT STRUCTURE W3HTML
*”———————————————————————-

* Debugging in RFC mode:
* call function ‘SYSTEM_ATTACH_GUI’.
* break-point.

data: abaplist like abaplist occurs 1 with header line.
data: lhtml like W3HTML occurs 1 with header line.

DATA: matnr like mara-matnr.

refresh html.

* Process all material numbers, append html lists
loop at tmat.
  matnr = tmat.

* Add leading 000…
  if matnr co ‘ 0123456789′.
    unpack matnr to matnr.
  endif.

* Produce report
  Submit RMMMBEST
    exporting list to memory
    and return
      with MS_MATNR EQ matnr.

* get list from memory
  CALL FUNCTION ‘LIST_FROM_MEMORY’
     TABLES
        LISTOBJECT = abaplist.

* and convert to html
  CALL FUNCTION ‘WWW_HTML_FROM_LISTOBJECT’
     TABLES
        HTML = lhtml
        LISTOBJECT = abaplist.

  Append lines of lhtml to html.

endloop.
ENDFUNCTION.

 

Display a list in html format