TIPS & TRICKS



Using the Copytext Command | Finding the Weekday from a Date | Writing Long Text to PM Notifications with WebUI | Using Long Text in Sales and Distribution with SAPGUI | Building Launch Pads | 

Using Long Text in Sales & Distribution with SAPGUI

Long text is the bane of an SAP user's existence. It is necessary, yet is usually difficult to handle - especially in customized GuiXT screens. However, there is a method to handle long text. In this example, we will be discussing how to handle long text in the Sales & Distribution (SD) module, focusing on the Sales Order process We will start with the generic SD screen, as shown below:

GuiXT Solution Suite

In order to handle long text, the screen is redesigned as shown in the following screenshot:

GuiXT Solution Suite

The code for this result resides in two script files, as listed below. Please note that for this operation to work correctly, these script files must be in the script directory defined in the guixt.ini configuration file.

  • SAPMV45A.E04001.TXT
  • VA01_WRITE.TXT

The initial file is the SAPMV45A.E4001.TXT file. This file contains the code that specifies the layout of the SD 'Create Sales Order' screen. The code creates two pushbuttons and two long text boxes on the 'Create Sales Order' screen as shown in the example above. The actual code itself is as follows:

title " &V[today_d.m.y h:m] "
if Q[transaction=VA01]
if Q[page=Sales]
noscrollbar
text (7,81) "Terms of delivery"
textbox (6.5,98) (9.5,133) name="z_va01_termsofdel"
pushbutton (7,134) "@2L@Save " process="va01_write.txt" size="(1,8)"
using l_loc = "11"
using l_variable = "z_va01_termsofdel"
text (11,82) "Warranties"
textbox (10.5,98) (13.5,133) name="z_va01_warranties"
pushbutton (11,134) "@2L@Save " process="va01_write.txt" size="(1,8)"
using l_loc = "14"
using l_variable = "z_va01_warranties"
endif
endif

In the preceding code, two pushbuttons and two long text boxes are created on the 'Create Sales Order' screen. When a user writes text to any of the long text boxes, a pair of local variables are created and passed to the inputscript, which in this case is the VA01_WRITE.TXT file previously introduced. The two local variables are the following:

  • l_loc: The location of the long text control for terms of delivery and warranty on the SAP tree control
  • l_variable: The variable name associated with the GuiXT text box for terms of delivery and warranties.

Since the two variables are both local in nature, they are valid only for the particular inputscript. They are passed to the inputscript via the 'using' command as shown in the code above. In the inputscript, the user must utilize the 'parameter' command to retrieve the values associated with each variable. The values can be used within the inputscript by using the prefix 'U'. This will be demonstrated when we explain the inputscript below.

As specified earlier, there is also an additional file that is necessary to the transaction. This file contains the inputscript for writing long text to the VA01 transaction. The second script file is the VA01_WRITE.TXT script file, which contains the following code:

Parameter l_loc
Parameter l_variable

// Pad the location value to four digits
Set V[l_loc] "&U[l_loc]" + "10000"
Set V[l_loc] "&V[l_loc](2-5)"

// Create Standard Order: Overview
Screen SAPMV45A.4001
Enter "=KTEX_SUB" // Texts

// Create Standard Order: Header Data
Screen SAPMV45A.4002
Enter control="TableTreeControl" item="&V[l_loc];Column1" event="22"

Screen SAPMV45A.4002
Copytext fromText="&U[l_variable]" toScreen="P[Create]+(-3,0)"
Enter "/3" // Overview

This script navigates to the Header > Texts tab on the screen and clicks on the corresponding control using the control location taken from the l_loc variable. When the appropriate long text box opens, the 'CopyText' command is used to write the long text from the GuiXT long text box to the SAP long text box by using the position as a reference marker.

The 'toScreen' parameter referenced in the CopyText command contains the position of the 'Create' pushbutton which is located at the bottom of the SAP long text box. It specifies that the long text field will be located three rows up (-3,0) from the Create pushbutton. The location is less important than whether the pointer is in the box or not. As long as the position points anywhere inside the actual text box, users can read or write from that text box.