1
votes

I have a Search Help with many fields to be displayed to the user in order to apply values. I want to get 3 fields APOFASI, SKOPOS, KATDANL from the user.

In the CALLCONTROL-STEP = SELECT in the exit FM, I want to get these values in variables and then to make some selects and find another field APOFASISAP. I am trying to pass back to the selection fields of the search help the field APOFASSISAP, but the APOFASI field seems to be blank. The code is:

  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.

This code does not replace/add the values to the appropriate fields. Can someone help on this?

PS. Let me add another code that I wrote with the help of internet. It is in the STEP of 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.

It says NO VALUES FOR THIS SELECTION. The table lt_result contains 11 records.

Thanks again.

2
This is just an arbitrary snippet of code referring to some custom objects nobody but you knows anything about and without a clear description where it is called and what exactly is going wrong. Please try to provide a minimal reproducible examplestackoverflow.com/help/mcvevwegert
I have created a SH that displays 4 fields to the user and waiting to fill 3 of them. The fields that the user have to be fullfill are: APOFASI-SKOPOS-KATDAL. So when the user press enter the value of CALLCONTROL-STEP is becaming SELECT and in the EXIT FM I want to find the 4th field APOFASISAP and pass it to the appropriate field of the Search-Helps field. I also want to delete the value of the field APOFASI and proceed with the fields APOFASISAP-SKOPOS-KATDANL and display the appropriate records to the user in order to select one. This is the only code in FM (missing only the DATA VAR).ekekakos
Your F4UT_RESULTS_MAP call seems fine. Does IF sy-subrc = 0 check passes?Suncatcher
I did and the sy-subrc is 0. I noticed that the structure record_tab is full and the table is empty (record_tab[]). Is there any way to fill it?ekekakos
@ekekakos, it is empty because you clear it in DISP event.Suncatcher

2 Answers

0
votes

I agree with the forespeakers, that provided code is a mess, from which nothing can be figured out.

First of all, use DISP event in SHELP FM exit, not SELECT.

Secondly, you fill the wrong table (or do not show us right filling in the snippet above). In order to pass values back to user you should modify a RECORD_TAB table.

Your code should look something like this (joined selections from zsl_glk_apof and zsl_glk_apof_tr tables):

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.
-1
votes

Hello and thanks all for your valuable help. Finally I did it as follow:

  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.

Regards Elias