venerdì 19 giugno 2009

Ricercare valori in un set

Per poter gestire dinamicamente un set di valori è possibile creare tramite la transazione GS01 un set di valori specificando il riferimento al campo di una tabella per indicare la tipologia di valori che il set contiene. La transazione appare cosi:


Per poter verificare se un determinato valore è presente nel set creato è possibile utilizzare la seguente function:



DATA va_trovato LIKE aasel1-option.
DATA setid LIKE sethier-setid.

CLEAR: aktyp,
setid,
wa_tcode,
va_trovato.


MOVE 'Z_TRANS_FATT_MOD' TO setid.
MOVE sy-tcode TO wa_tcode.

CALL FUNCTION 'Z_CTRL_SET'
EXPORTING
setid = setid
val_da_trovare = wa_tcode
IMPORTING
val_trovato = va_trovato
EXCEPTIONS
set_not_found = 1
illegal_field_replacement = 2
illegal_table_replacement = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

La funtion può restituisce nel valore va_trovato solo 2 valori: SI o NO.

Il test da eseguire è :
if va_trovato EQ 'SI'.

1 commento:

  1. Wow, fantastic blog format! How long have you ever been running a blog for?

    you make blogging glance easy. The whole look of your site is great, let alone the content!


    Feel free to visit my site: best buy beats headphones

    RispondiElimina