Show TOC

field-get MacroLocate this document in the navigation structure

Use

You use the field-get macro to get the values of variables from the ITS during PAI.

This is useful for retrieving large or unknown amounts of data such as an HTML text area:

  • If the text area contains a small amount of data, you can use a step loop in SAP system

  • If the text area contains a large amount of data, a step loop may not be large enough to hold all the data coming from the Web browser, so the text could be truncated.

    In this case, you can use the field-get macro in the PAI module of the transaction.

field-get
contextfield-name     (in, char)
contextfield-index    (in, num)
contextfield-value    (out, itab)
contextfield-length   (out, num)
         

Parameter

Description

contextfield-name

Context field name.

contextfield-index

Context field index.

contextfield-value

Context field value.

The macro accepts any internal table and copies the value of the context field to the internal table components. If one internal table record is not enough, it adds additional records.

contextfield-length

Context field length.

  • If the call to field-get is successful, contextfield-value and contextfield-length contain the appropriate values from the ITS and sy-subrc is set to 0

  • If the call to field-get is unsuccessful, contextfield-value and contextfield-length are unchanged and sy-subrc is set to a value other than 0

Example

Suppose an HTML template contains the following code:

<form action="`wgateUrl()`">
<textarea name="textpad" wrap="physical" rows="25" cols="100"
Please enter your text here.
</textarea>
<input type=submit name="~OKCode=TEXT" value="Send text">
</form>
         

In ABAP, you could handle this as follows:

process after input.
   module fcode.
module fcode.
   if sy-ucomm = 'TEXT'.
      perform get_textarea.
   endif.
endmodule.
form get_textarea.
   data: len type i.
   data: idx type i.
   data: wide_row(80)  occurs 0 with header line.
   data: wide_text(80) occurs 0 with header line.
   idx = 1.
   loop.
      field-get 'textpad' idx wide_row len.
      if sy-subrc <> 0.
         exit.
      endif.
      append lines of wide_row to wide_text.
      idx = idx + 1.
   endloop.
endform.

         

If all 100 characters of a line in textpad have been used, the ITS splits the line and places the remaining 20 characters in a new row of the table wide_row. As a result, the whole variable is transferred into the table wide_text via the table wide_row, regardless of the size of textarea.

Note

field-get calls are not buffered on the application server, but executed immediately. Since this requires a separate request to the ITS over the network, there are performance implications. For this reason, you should use this macro only if you need to retrieve mass data from the ITS context. Otherwise, you use regular SAP system fields.