如何通过搜索帮助退出将值返回给用户



我有一个搜索帮助,其中许多字段要显示给用户以应用值。我想从用户获得3个字段APOFASISKOPOSKATDANL

在出口FM中的CALLCONTROL-STEP = SELECT中,我想在变量中获取这些值,然后进行一些选择并找到另一个字段APOFASISAP。我试图回到搜索的选择字段,帮助该字段ApoFassiSap,但Apofasi字段似乎是空白的。代码是:

  TYPES: BEGIN OF ty_apofasisap_tr,
          apofasisap_tr TYPE zglk_sap_afopasi,
         END OF ty_apofasisap_tr.
  DATA: it_apofasisap_tr TYPE TABLE OF ty_apofasisap_tr,
        wa_apofasisap_tr LIKE LINE OF it_apofasisap_tr.
  DATA: lv_apofasi TYPE zglk_kyanr_ap,
        lv_skopos  TYPE zskopos,
        lv_katdanl TYPE zsl_cat_dan,
        lv_apofasisap_arx TYPE zglk_sap_afopasi.        
    lv_apofasi = wa_shlp_selopt-low.
    ls_result-apofasi = ''.
    IF lv_apofasi <> ''.
      wa_shlp_selopt-low = ''.
      MODIFY shlp-selopt FROM wa_shlp_selopt INDEX sy-tabix.
    ENDIF.
    READ TABLE shlp-selopt INTO wa_shlp_selopt WITH KEY shlpfield = 'SKOPOS'.
    lv_skopos = wa_shlp_selopt-low.
    READ TABLE shlp-selopt INTO wa_shlp_selopt WITH KEY shlpfield = 'KATDANL'.
    lv_katdanl = wa_shlp_selopt-low.
    SELECT SINGLE apofasisap INTO lv_apofasisap_arx
      FROM zsl_glk_apof
      WHERE apofasi = lv_apofasi.
    SELECT * FROM zsl_glk_apof_tr
      WHERE apofasisap_trp = lv_apofasisap_arx.
      wa_apofasisap_tr-apofasisap_tr = zsl_glk_apof_tr-apofasisap_tr.
      APPEND wa_apofasisap_tr TO it_apofasisap_tr.
    ENDSELECT.
    wa_shlp_selopt-shlpname  = 'ZAPOF_TROP'.
    wa_shlp_selopt-shlpfield = 'APOFASISAP'.
    wa_shlp_selopt-sign      = 'I'.
    wa_shlp_selopt-option    = 'EQ'.
    wa_shlp_selopt-low       = wa_apofasisap_tr-apofasisap_tr.
    APPEND wa_shlp_selopt TO shlp-selopt.

此代码不会替换/将值添加到适当的字段中。有人可以为此提供帮助吗?

ps。让我添加我在Internet的帮助下编写的另一个代码。它在显示的步骤中。

IF callcontrol-step = 'DISP'.
TYPES: BEGIN OF ls_result,
      apofasi LIKE zsl_glk_apof-apofasi,
      apofasidate LIKE zsl_glk_apof-apofasidate,
      apofasisap LIKE zsl_glk_apof-apofasisap,
      apofasi_trp_x LIKE zsl_glk_apof-apofasi_trp_x,
      apofasi_tr_x LIKE zsl_glk_apof-apofasi_tr_x,
      fek LIKE zsl_glk_apof-fek,
      katdanl LIKE zsl_glk_apof-katdanl,
      reference LIKE zsl_glk_apof-reference,
      skopos LIKE zsl_glk_apof-skopos,
      thema LIKE zsl_glk_apof-thema,
      type_desc LIKE zsl_glk_apof-type_desc,
      ya_first LIKE zsl_glk_apof-ya_first,
END OF ls_result.
DATA: lt_result TYPE STANDARD TABLE OF ls_result.
CLEAR: lt_result, record_tab, record_tab[].
* Read the value that user gave
READ TABLE shlp-selopt INTO wa_shlp_selopt
                        WITH KEY shlpfield = 'APOFASI'.
lv_apofasi = wa_shlp_selopt-low.
IF lv_apofasi <> ''.
  * Clear this value
  wa_shlp_selopt-low = ''.
  MODIFY shlp-selopt FROM wa_shlp_selopt INDEX sy-tabix.
ENDIF.
* Find the number starting APOFASISAP from the APOFASI text
SELECT SINGLE apofasisap INTO lv_apofasisap_arx
  FROM zsl_glk_apof
  WHERE apofasi = lv_apofasi.
IF sy-subrc = 0.
 * Find the APOFASISAPs which changes the starting one and display the 
  *fields
  SELECT a~apofasi a~apofasidate a~apofasisap
         a~apofasi_tr_x a~apofasi_trp_x
         a~thema a~fek a~reference a~ya_first
      INTO CORRESPONDING FIELDS OF TABLE lt_result
    FROM zsl_glk_apof AS a INNER JOIN zsl_glk_apof_tr AS b
                            ON a~apofasisap = b~apofasisap_tr
    WHERE b~apofasisap_trp = lv_apofasisap_arx.
  IF sy-subrc = 0.
    *Pass them to display the result.
    CALL FUNCTION 'F4UT_RESULTS_MAP'
      EXPORTING
    *   SOURCE_STRUCTURE         =
        apply_restrictions       = 'X'
       TABLES
         shlp_tab                 = shlp_tab
         record_tab               = record_tab
         source_tab               = lt_result
       CHANGING
         shlp                     = shlp
         callcontrol              = callcontrol
      EXCEPTIONS
        illegal_structure        = 1
        OTHERS                   = 2
               .
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
  ENDIF.
  FREE lt_result.
ENDIF.

它没有说明此选择的值。表LT_Result包含11个记录。

再次感谢。

我同意前扬声器,提供的代码是一团糟,什么都无法弄清楚。

首先,使用 disp 在Shelp FM退出中的事件,而不是选择

其次,您填充错误的表(或不向我们显示上面的摘要中的正确填充)。为了将值传递给用户,您应该修改RECORD_TAB表。

您的代码应该看起来像这样(从zsl_glk_apofzsl_glk_apof_tr表连接了选择):

CHECK callcontrol-step = 'DISP'.
DATA: ls_selopt TYPE ddshselopt.  "loc str for shlp-selopt
DATA: BEGIN OF ls_record.
      INCLUDE STRUCTURE seahlpres.
DATA: END OF ls_record.
DATA: lv_glk_apof_tr TYPE zsl_glk_apof_tr-apofasisap_tr.
LOOP AT shlp-selopt INTO ls_selopt.
* finding SKOPOS and KATDANL values
  CASE ls_selopt-shlpfield.
   WHEN 'SKOPOS'.
    lv_skopos = ls_selopt-low.
   WHEN 'KATDANL'.
    lv_katdanl = ls_selopt-low.
   WHEN OTHERS.
  ENDCASE.
  * doing smth
  * finding some stuff from Z-tables
  SELECT SINGLE tr~apofasisap_tr
  FROM zsl_glk_apof AS ap
  JOIN zsl_glk_apof_tr AS tr
   ON ap~apofasisap = tr~apofasisap_trp
  INTO lv_glk_apof_tr
   WHERE ap~apofasi = lv_apofasi.
ENDLOOP.
* modify record_tab with the found value lv_glk_apof_tr
LOOP AT record_tab INTO ls_record.
  ls_record-string+25(5) = lv_glk_apof_tr.  "field shift should be based on your values
ENDLOOP.

您好,感谢所有人的宝贵帮助。最后,我做了以下操作:

  if callcontrol-step = 'SELECT'.
get parameter id 'ZAP' field p_apofasi.
get parameter id 'ZSK' field p_skopos.
get parameter id 'ZKATDANL' field p_katdanl.
select single apofasisap into lv_apofasisap_arx
  from zsl_glk_apof
  where apofasi = p_apofasi and
        katdanl = p_katdanl and
        skopos  = p_skopos.
select * into corresponding fields of table it_apofasisap_tr
  from zsl_glk_apof_tr
  where apofasisap_trp = lv_apofasisap_arx.
* Display the results to the user
types: begin of ls_result,
        apofasi like zsl_glk_apof-apofasi,
        apofasidate like zsl_glk_apof-apofasidate,
        apofasisap like zsl_glk_apof-apofasisap,
        apofasi_trp_x like zsl_glk_apof-apofasi_trp_x,
        apofasi_tr_x like zsl_glk_apof-apofasi_tr_x,
        katdanl like zsl_glk_apof-katdanl,
        skopos like zsl_glk_apof-skopos,
        type_desc like zsl_glk_apof-type_desc,
  end of ls_result.
data: lt_result type standard table of ls_result.
clear: lt_result, record_tab, record_tab[].
* Fill all the fields of the Search-Help with the data according to the
*selections of the user.
select apofasi apofasidate apofasisap
       apofasi_tr_x apofasi_trp_x
       katdanl skopos type_desc
    into corresponding fields of table lt_result
  from zsl_glk_apof
  for all entries in it_apofasisap_tr
  where apofasisap = it_apofasisap_tr-apofasisap_tr and
        apofasi_tr_x = 'X'. "lv_apofasi_tr_x.

call function 'F4UT_RESULTS_MAP'
  tables
    shlp_tab          = shlp_tab
    record_tab        = record_tab
    source_tab        = lt_result
  changing
    shlp              = shlp
    callcontrol       = callcontrol
  exceptions
    illegal_structure = 1
    others            = 2.
if sy-subrc = 0.
  callcontrol-step = 'DISP'.
else.
  callcontrol-step = 'EXIT'.
endif.
endif.

问候Elias

相关内容

  • 没有找到相关文章

最新更新