How to create set values in sap abap programming language

First, we need to use the FM G_SET_GET_ID_FROM_NAME to get the SETID based on the Setname in GS03



DATAlt_t134t      TYPE TABLE OF t134t,
          ls_t134t      TYPE t134t,
          t_set_values  TYPE TABLE OF rgsb4,
          wa_tsetvalues TYPE rgsb4.


    CALL FUNCTION 'G_SET_GET_ALL_VALUES'
      EXPORTING
        client        sy-mandt
        setnr         'ZMM_MTYPE'
        table         'T134T'
        class         '0000'
        fieldname     'MTART'
      TABLES
        set_values    t_set_values
      EXCEPTIONS
        set_not_found 1
        OTHERS        2.

    LOOP AT t_set_values INTO wa_tsetvalues.
      ls_t134t-mtart  wa_tsetvalues-from.
      APPEND ls_t134t TO lt_t134t.
    ENDLOOP.
    READ TABLE lt_t134t INTO ls_t134t WITH KEY mtart i_mara-mtart.
    IF sy-subrc 0.
        endif.



  • First we need to use the FM G_SET_GET_ID_FROM_NAME to get the SETID based on the Setname in GS03.
  • SETID obtained from this function module need to be used in G_SET_GET_ALL_VALUES FM.

  data lv_setid    type sethier-setid.
  data lt_set_values type table of rgsb4.
  data ls_set_values type rgsb4.
      clear lv_setid.
      call function 'G_SET_GET_ID_FROM_NAME'
        exporting
          client                   sy-mandt
          shortname                s_setnam-low
        importing
          new_setid                lv_setid
        exceptions
          no_set_found             1
          no_set_picked_from_popup 2
          wrong_class              3
          wrong_subclass           4
          table_field_not_found    5
          fields_dont_match        6
          set_is_empty             7
          formula_in_set           8
          set_is_dynamic           9
          others                   10.
      if sy-subrc <> 0.
* Implement suitable error handling here
      else.
        call function 'G_SET_GET_ALL_VALUES'
          exporting
            client        sy-mandt
*           FORMULA_RETRIEVAL           = ' '
*           LEVEL         = 0
            setnr         lv_setid
*           VARIABLES_REPLACEMENT       = ' '
*           TABLE         = ' '
*           CLASS         = ' '
*           NO_DESCRIPTIONS             = 'X'
*           NO_RW_INFO    = 'X'
*           DATE_FROM     =
*           DATE_TO       =
*           FIELDNAME     = ' '
          tables
            set_values    lt_set_values
          exceptions
            set_not_found 1
            others        2.
        if sy-subrc <> 0.
* Implement suitable error handling here
        else.
          loop at lt_set_values into ls_set_values.
            s_pbukr-sign 'I'.
            s_pbukr-option 'EQ'.
            s_pbukr-low ls_set_values-from.
            append s_pbukr.
          endloop.
        endif.
      endif.


Comments

Popular posts from this blog

all user exit mv45afzz (implicit user exit )

How to Give Dropdown in alv report in sap abap programming Language

Long Text in input and output field in module pool