Example 2: Suggesting products in order entry In order entry (transaction VA01), the user
enters a customer number. Based on this customer number, we then suggest some products taken from previous orders. We present the
products as pushbuttons, and a simple click on the pushbutton
automatically enters the material number and the amount into the new
order. We also present 5 pushbuttons representing the the last 5
orders, showing the corresponding order date. Pressing one of these
pushbuttons displays a previous order.
VA01: new pushbutton "Previous
orders"
After entering the customer number, the user
may click on our new pushbutton to get the following information:
- 5 previous orders
- 5 products taken
from these orders, with amount, and short text (as a tooltip on
each pushbutton)
If you prefer more than 5 products, you
can display one or more additional button columns. If there is a really
large number of products to be presented, a good way is to use
an html-template and our "Viewer" component. The technique
presented here will remain essentially the same in this case, but the
product buttons would be shown via an html table.
Our additional product info
Clicking on a product
button will enter the product number and amount; clicking on an
order button displays the order (using transaction VA03). When
the window is no longer needed the
user can close it with the red cross.
Automatic entry of a product number and
amount
The scripts (based on an
IDES 4.6D system) are not particularly long, but they nonetheless represent a
fairly advanced level of handling GuiXT, and make use of a dynamic index. When you
modify the examples, please keep in mind the following restrictions
that apply to table transfers with "Call" in scripts:
- Use only
character-type fields (no integers or packed decimals) in your
table definition
- The standard maximum table
width is 256. Use the width:xxx parameter if you need a larger
table width, e.g. table.ORDERS(width:500)=orders.
Here the maximum value you can specify is 32000
- There is no limitation
on the number of lines in the table.
GuiXT script
"SAPMV45A.E4001.TXT"
if Q[Transaction=VA01] and Q[Page=Sales]
if V[VA01_KUNNR=&F[Sold-to party]] and V[VA01_KUNNR]
Offset (7,86)
Box (0,0) (6,44)
// close box
Pushbutton (0,43) "@02@" process="GetOrdersMaterials.txt"
using KUNNR = ""
Text (0,1) "Orders"
// Index
Set V[i] 1
Set V[row] 1
label next_order
if not V[VA01_VBELN&V[i]]
goto end_of_orders
endif
Pushbutton (&V[row],1) "@16\QOrder &V[VA01_VBELN&V[i]]@&V[VA01_AUDAT&V[i]]" "/OVA03" process="DisplayOrder.txt"
using VBELN = "&V[VA01_VBELN&V[i]]"
Set V[i] &V[i] + 1
Set V[row] &V[row] + 1
if V[i<6]
goto next_order
endif
label end_of_orders
// Index
Set V[i] 1
Set V[row] 1
Text (0,17) "Products"
label next_material
if not V[VA01_MATNR&V[i]]
goto end_of_materials
endif
Pushbutton (&V[row],17) "@40\Q&V[VA01_ARKTX&V[i]]@&V[VA01_MATNR&V[i]]" process="AddMaterial.txt" size=(1,16)
using MATERIAL = "&V[VA01_MATNR&V[i]]"
using AMOUNT = "&V[VA01_AMOUNT&V[i]]"
Text (&V[row],34) "&V[VA01_AMOUNT&V[i]] &V[VA01_VRKME&V[i]]"
Set V[i] &V[i] + 1
Set V[row] &V[row] + 1
if V[i<6]
goto next_material
endif
label end_of_materials
else
Pushbutton (7,86) "Previous orders" process="GetOrdersMaterials.txt"
using KUNNR = [Sold-to party]
endif
endif
InputScript "DisplayOrder.txt"
Parameter VBELN
Screen sapmv45a.0102
Set F[Order] "&U[VBELN]"
Enter
InputScript "AddMaterial.txt"
Parameter MATERIAL
Parameter AMOUNT
Set V[i] 1
label next_line
Set V[Material] "&cell[.,Material,&V[i]]"
// empty?
If not V[Material]
Set cell[All items,Material,&V[i]] "&U[MATERIAL]"
Set cell[All items,Order quantity,&V[i]] "&U[AMOUNT]"
Leave
endif
Set V[i] &V[i] + 1
if V[i<20]
goto next_line
endif
Function
"ZZ_GUIXT_CUSTOMER_ORDERS"
FUNCTION ZZ_GUIXT_CUSTOMER_ORDERS.
*"*"Local interface:
*" IMPORTING*" VALUE(KUNNR) TYPE KUNNR
*" VALUE(N_ORDERS) TYPE I DEFAULT 5
*" TABLES
*" ORDERS STRUCTURE ZZORDER
*" MATERIALS STRUCTURE ZZMATERIAL
*"----------------------------------------------------------------------
Tables: vakpa, vbap.
* Activate for debugging in RFC mode:
* call function 'SYSTEM_ATTACH_GUI'.
* Break-point.
* add leading 000... for numerical customer numbers
if kunnr co ' 0123456789'.
unpack kunnr to kunnr.
endif.
refresh: orders, materials.
select AUDAT VBELN from vakpa
into corresponding fields of vakpa
up to n_orders rows
where kunde = kunnr and parvw = 'AG'
order by audat descending.
orders-audat = vakpa-audat.
orders-vbeln = vakpa-vbeln.
Append orders.
select MATNR KWMENG VRKME ARKTX from vbap
into corresponding fields of vbap
where vbeln = orders-vbeln.
read table materials with key vbap-matnr.
IF sy-subrc ne 0.
materials-matnr = vbap-matnr.
materials-arktx = vbap-arktx.
materials-vbeln = vakpa-vbeln.
* Use "Write to" instead of "Move" for special fields
Write vbap-kwmeng to materials-menge unit vbap-vrkme.
Write vbap-vrkme to materials-vrkme.
Append materials.
endif.
endselect.
endselect.
endfunction.
InputScript
"GetOrdersMaterials.txt"
Parameter KUNNR
// Save customer number
Set V[VA01_KUNNR] "&U[KUNNR]"
// no customer number? Then no action
if not V[VA01_KUNNR]
Leave
endif
// Reset order and material table
Set V[empty] ""
CopyText fromString=empty toText=orders
CopyText fromString=empty toText=materials
Call "ZZ_GUIXT_CUSTOMER_ORDERS" in.KUNNR="&U[KUNNR]" table.ORDERS=orders table.MATERIALS=materials
// Index
Set V[i] 1
label next_order
CopyText fromText=orders toString=item line=&V[i]
if not Q[ok]
// Reset Order
Set V[VA01_ORDER&V[i]]
goto materials
endif
Set V[VA01_AUDAT&V[i]] "&V[item](1-4)/&V[item](5-6)/&V[item](7-8)"
Set V[VA01_VBELN&V[i]] "&V[item](9-18)"
Set V[i] &V[i] + 1
if V[i<6]
goto next_order
endif
label materials
Set V[i] 1
label next_material
CopyText fromText=materials toString=item line=&V[i]
if not Q[ok]
// Reset Material
Set V[VA01_MATNR&V[i]]
Leave
endif
Set V[VA01_MATNR&V[i]] "&V[item](1-18)"
Set V[VA01_AMOUNT&V[i]] "&V[item](19-33)"
Set V[VA01_VRKME&V[i]] "&V[item](34-36)"
Set V[VA01_MATVBELN&V[i]] "&V[item](37-46)"
Set V[VA01_ARKTX&V[i]] "&V[item](47-86)"
Set V[i] &V[i] + 1
if V[i<6]
goto next_material
endif
|