There are three possible ways to solve
this, one is somewhat tricky.The
underlying problem is that &V[_tabrow] which you use in
shdest1=V[SPT.cell.spmattext.&V[_tabrow]]
is already replaced by its actual value
when the script is interpreted, i.e. when the screen is
displayed. But you need the row number later on after the user
has pressed F4 in the table cell.
Method 1
Table (2,2) (14,132) name="SPT" title=
"Spare parts" rows=10 -singlerowselection
…
column "Spare part" size=16 name="spmat"
position= 4 searchhelp="MAT0M" shname1="MAKTG" shdest1="V[sptext]"
searchhelpprocess="set_material_text.txt"
With the InputScript "set_material_text.txt":
// InputScript
Set V[SPT.cell.spmattext.&V[_tabrow]]
"&V[sptext]"
Return
Method 2 (tricky)
We replace the & character in &V[_tabrow]
with a variable that contains the & character. This prevents &V[tabrow]
from being evaluated when the screen is displayed:
Table (2,2) (14,132) name="SPT" title=
"Spare part" rows=10 -singlerowselection
…
Set V[ampersand] "&"
column "Spare part" size=16 name="spmat"
position= 4 searchhelp="MAT0M" shname1="MAKTG" shdest1=V[SPT.cell.spmattext.&V[ampersand]V[_tabrow]]
Methode 3 (works even if material
number is entered manually)
Table (2,2) (14,132) name="SPT" title=
"Spare part" rows=10 -singlerowselection
column "Spare part" size=16 name="spmat"
position= 4 searchhelp="MAT0M"
column "Text" size= 30 name="spmattext"
position=2 -readonly
// Read material text
Set V[k] 1
Label read_mattext
Set V[matnr] "&V[SPT.spmat.&V[k]]"
if V[matnr]
// add leading zeroes
// numerical?
Set V[matnr2] "&V[matnr]" + 0
if V[matnr=&V[matnr2]]
Set V[matnr] (1-18)
"000000000000000000&V[matnr]" -alignright
endif
Call "BAPI_MATERIAL_GET_DETAIL"
cache= "session" in.MATERIAL="&V[matnr]"
out.MATERIAL_GENERAL_DATA= "matgendata"
Set V[SPT.cell.spmattext.&V[k]]
"&V[matgendata] (BAPIMATDOA-MATL_DESC)"
Set V[k] &V[k] + 1
goto read_mattext
endif