如何从搜索帮助中返回值给用户退出

问题描述:

我有一个搜索帮助,其中包含许多要显示给用户以应用值的字段。我想从用户处获得3个字段APOFASI,SKOPOSKATDANL如何从搜索帮助中返回值给用户退出

在退出调频中的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。让我添加我在互联网帮助下编写的另一个代码。它在DISPLAY的步骤中。

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条记录。

再次感谢。

+0

这是代码指的是一些自定义的只是一个任意片段对象人,但你知道,并没有明确说明什么地方它被称为和究竟发生了什么问题。请尝试提供[MCVE] https://stackoverflow.com/help/mcve – vwegert

+0

我已经创建了一个SH,向用户显示4个字段,并等待填写其中的3个字段。用户必须填写的字段是:APOFASI-SKOPOS-KATDAL。因此,当用户按下输入CALLCONTROL-STEP的值是由于选择和在EXIT FM中我希望找到第四个字段APOFASISAP并将其传递到搜索帮助字段的相应字段。我也想要删除字段APOFASI的值并继续字段APOFASISAP-SKOPOS-KATDANL并向用户显示适当的记录以便选择一个。这是FM中唯一的代码(仅缺少数据VAR)。 – ekekakos

+0

你的'F4UT_RESULTS_MAP'调用看起来很好。 'IF sy-subrc = 0'检查通过了吗? – Suncatcher

我同意前面的提示,提供的代码是一团糟,从中无法想象出来。

首先,在SHELP FM出口处使用DISP事件,而不是SELECT。其次,你填写错误的表格(或者不要显示我们正确填写上面的代码片段)。为了将值传递给用户,您应该修改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. 
+0

我会试试你的解决方案。谢谢。 – ekekakos

您好,感谢所有的宝贵帮助。 最后我做到了如下:

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. 

问候 埃利亚斯