Writing Long Text to PM Notifications with WebUI
In our previous tip we discussed how to handle long text in the SAPGUI Sales and Distribution module. In this tip, we will continue with the long text discussion and focus on writing long text to SAP with the Synactive WebUI suite. In this example, we will use the Plant Maintenance module's IW21 Create Notification transaction. This is often useful to add information relating to a particular notification. In the following example, we are displaying the default IW21 WebUI screen, as shown below:
In its default state, the Create Notifications screen cannot handle long text. Therefore, using GuiXT, we have modified it to appear as it does in the example shown below:
In the example shown above, what we have done is to remove most of the default input fields and replace them with fields for entering long text to the Notification screen. The code that achieves this result resides in three separate files, as defined below:
- SAPLIQS0.E0100.TXT
- DRAWNEWROWS.TXT
- Z_IW21_DEMOSAVE.TXT
We created a new script directory and specified the location in the guixt.ini configuration files. The initial script file is the SAPLIQS0.E0100.TXT file. This script file refers to the main IW21 screen, as shown in the example above. The code is as follows:
if Q[transaction=IW21]
del F[Notification]
del F[Notification.2]
del G[Reference]
inputfield (3,0) "Functional Location" (3,22) name="z_iw21_funcloc" size="18" techname="RIWO1-TPLNR" //searchhelp="IFLM"
inputfield (4,0) "Date" (4,22) name="z_iw21_date" size="10" techname="VIQMEL-QMDAT"
box (5,0) (11,78) "Long Text"
Set V[rowindex] "6"
if not V[indexname]
Set V[indexname] "1"
Set V[index] "1"
Set V[newindex] "5"
else
Set V[index] "&V[indexname]"
endif
pushbutton (&V[rowindex],76) "@0I@" process="drawnewrows.txt"
using g_push = "P"
Label DrawFields
if V[indexname>&V[newindex]]
Goto DrawFieldsEnd
endif
if V[index>&V[newindex]]
goto DrawFieldsEnd
endif
text (&V[rowindex],0) "&V[indexname]" size="3" "-border"
inputfield (&V[rowindex],3) name="z_longdesc_&V[indexname]" size="72" "-nolabel"
Set V[rowindex] "&V[rowindex]" + "1"
Set V[indexname] "&V[indexname]" + "1"
goto DrawFields
Label DrawFieldsEnd
Set V[indexname] "&V[index]"
Set V[rowindex] "&V[rowindex]" - "1"
pushbutton (&V[rowindex],76) "@0H@" process="drawnewrows.txt"
using g_push = "N"
Set V[rowindex] "&V[rowindex]" + "1"
pushbutton (14,10) "@2L@SAVE" "/niw21" process="z_iw21_demosave.txt" size="(1,10)"
endif
The code uses an IF statement to delete the default fields from the IW21 default screen and then creates a new structure, adding a fields entitled 'Functional Location' directly below the Notification Type and also adding a Date field to contain the actual notification date.
The actual long text fields themselves are defined in the 'drawnewrows' function, which is called in the SAPLIQS0.E0100.TXT file. Note how we are creating the long text fields - we are using individual inputfields and adding up and down buttons for scrolling. We used this method because long text controls cannot be created for WebUI. The code is as follows:
Parameter g_push
if U[g_push=P]
if V[indexname>1]
Set V[indexname] "&V[indexname]" - "5"
Set V[newindex] "&V[newindex]" - "5"
endif
if V[indexname<0]
Set V[indexname] ""
endif
endif
if U[g_push=N]
// if V[z_longdesc_&V[indexname]] // If Last Row Contains Value, then scroll
Set V[indexname] "&V[indexname]" + "5"
Set V[newindex] "&V[newindex]" + "5"
endif
//endif
//endif
return
There is one additional file necessary to enabling long text entry in the Create Notifications transaction in WebUI as well. This is the z_iw21_demosave.txt file, which contains the code that allows long text to be saved and transferred to SAP once it is entered in the WebUI. This code is as follows:
// Create PM Notification: Initial Screen
// Screen SAPLIQS0.0100
Enter
// Create PM Notification: Maintenance request
Screen SAPLIQS0.7200
Set F[Funct. Location] "&V[z_iw21_funcloc]"
Set F[Notif.date] "&V[z_iw21_date]"
Enter "=TXQM"
// Change Long text on PM notification: %00000000001 Language EN
Screen SAPLSTXX.2101
Enter "/Menu=3,5"
Screen SAPLWB_CUSTOMIZING.0999
Set C[Graphical PC editor] ""
Enter
// Change Long text on PM notification: %00000000001 Language EN
Screen SAPLSTXX.1100
Set V[index1] "1" //index for textbox content starting from line 1
Set V[index2] "3" //index for the table row starting from line 3
Set V[index3] "3"
Label copy_text
if not V[z_longdesc_&V[index1]]
goto end_tb
else
Set cell[Table,3,&V[index2]] "&V[z_longdesc_&V[index1]]"
Set V[index3] "&V[index3]" + 1
Setcursor cell[Table,3,&V[index3]]
Enter
endif
Screen SAPLSTXX.1100
Set V[index1] "&V[index1]" + 1
Set V[index2] "&V[index2]" + 1
goto copy_text
Enter
// Change Long text on PM notification: %00000000001 Language EN
Screen SAPLSTXX.1100
Label end_tb
Enter "/3"
// Create PM Notification: Maintenance request
Screen SAPLIQS0.7200
Set V[z_*] ""
Set V[index*] ""
Enter "/11"
