‎2017 Jul 19 7:58 AM
Good morning!
Does anybody know if a select-options match code can depend on another select-options match code? If yes ,please post an example.For example:
SELECT-OPTIONS: s_klart FOR klah-klart.
SELECT-OPTIONS: s_atinn FOR cabn-atinn NO INTERVALS NO-EXTENSION.
The match code of s_atinn need to depend on the match code of s_klart. Until now i`ve seen only dependency between select-option and a parameter.
Have a great day!
Please find below my code:
- code removed by moderator. Only post relevant code, and when you've posted it, make sure it is readable -
‎2017 Jul 26 3:52 PM
If the user has input some value in select-option or parameter and then press "Enter" button, this basically allow selection screen values to be passed to the relevent variables like S_KLART etc. In this case you can simply address this variable (select-option to be more precise) in "AT SELECTION-SCREEN ON VALUE-REQUEST FOR" for other select-options.
However if user just types the value or select the value from a list and then goes to next select-option/parameter, in this case the selection-screen values are not passed to relevent variables. In this case Sandra Rossi has given you a very good tip to use function module RS_SELECTIONSCREEN_READ to read such value.
I had a similar requirement in one report. Following code is derived from that report, although i have removed the code not relevant with your issue. This is owrking code. Just copy/paste in your system and it should work. It can give you some baseline to observe and apply similar changes in your report.
*&---------------------------------------------------------------------*
*& Report YYRJ_TEST0080
*&
*&---------------------------------------------------------------------*
*& Read selection screen elements
*& Working: Enter a valid PO number in s_ebeln. then press F4 for
*& s_ebelp-low. Basically it will retreive a list of all
*& all line items number for the PO given in s_ebeln.
*&---------------------------------------------------------------------*
REPORT yyrj_test0080.
TABLES: ekko, ekpo.
SELECT-OPTIONS :
s_ebeln FOR ekko-ebeln NO INTERVALS NO-EXTENSION,
s_ebelp FOR ekpo-ebelp.
TYPES: BEGIN OF tt_ebelp,
ebelp LIKE ekpo-ebelp,
END OF tt_ebelp.
DATA: lt_ebelp TYPE STANDARD TABLE OF tt_ebelp,
ls_ebelp TYPE tt_ebelp.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_ebelp-low.
PERFORM fetch_values_ebelp.
START-OF-SELECTION.
WRITE:/ 'What is this'..
*&---------------------------------------------------------------------*
*& Form FETCH_VALUES_EBELP
*&---------------------------------------------------------------------*
FORM fetch_values_ebelp.
DATA: lv_lin TYPE i,
lv_ebeln LIKE ekko-ebeln.
DATA: lt_fieldvals TYPE STANDARD TABLE OF rsselread,
ls_fieldvals TYPE rsselread.
IF s_ebeln IS INITIAL.
**may be value not passed to select option yet
** fill fieldvals table
CLEAR ls_fieldvals. REFRESH lt_fieldvals.
MOVE: 'S_EBELN' TO ls_fieldvals-name,
'S' TO ls_fieldvals-kind,
'LOW' TO ls_fieldvals-position.
APPEND ls_fieldvals TO lt_fieldvals.
** call the FM to read selection screen values
CALL FUNCTION 'RS_SELECTIONSCREEN_READ'
EXPORTING
program = sy-repid
TABLES
fieldvalues = lt_fieldvals.
** check fieldvals tab for values read
CLEAR lv_ebeln.
READ TABLE lt_fieldvals INTO ls_fieldvals WITH KEY name = 'S_EBELN'.
IF sy-subrc = 0.
CONDENSE ls_fieldvals-fieldvalue NO-GAPS.
lv_ebeln = ls_fieldvals-fieldvalue.
IF lv_ebeln IS NOT INITIAL.
SELECT ebelp INTO TABLE lt_ebelp
FROM ekpo
WHERE ebeln = lv_ebeln.
CHECK sy-subrc = 0.
PERFORM show_f4_ebelp.
ENDIF. "lv_ebeln not initial
ENDIF. "subrc read table
ELSE. "s_ebeln has some value
SELECT ebelp INTO TABLE lt_ebelp
FROM ekpo
WHERE ebeln IN s_ebeln.
IF sy-subrc = 0.
PERFORM show_f4_ebelp.
ENDIF. "subrc 0 check
ENDIF. "s_ebeln check
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SHOW_F4_EBELP
*&---------------------------------------------------------------------*
FORM show_f4_ebelp .
DATA: lt_return TYPE STANDARD TABLE OF ddshretval.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'EBELP'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_EBELP-LOW'
value_org = 'S'
* IMPORTING
* USER_RESET =
TABLES
value_tab = lt_ebelp
return_tab = lt_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
**** ??
ENDIF.
ENDFORM.
‎2017 Jul 19 8:16 AM
There are lots of examples all around the web how to display your own values, with function module F4IF_INT_TABLE_VALUE_REQUEST for instance. I guess you know how to build the list of S_ATINN possible values according to values in S_KLART, or are you stuck somewhere?
‎2017 Jul 19 8:25 AM
Dear Sandra,
Thank you for your reply. I only found that F4IF_INT_TABLE_VALUE_REQUEST can be used in conjunction of select-option and a parameter. I am stuck on getting a match code of s_atinn based on the value(from a match code) entered in s_klart. Thank you. I updated my question with my program code . Much appreciated.
‎2017 Jul 19 9:06 AM
Nonetheless, unless I completely misunderstand, Sandra's answer is correct. You cannot get a match-code of s_atinn based on the value(from a match code) entered in s_klart. You have to write your own code using the aforementioned function module.
‎2017 Jul 19 2:22 PM
Dear Matthew ,
I did as you advised me and i thank you for this . When i put a value in s_klart , after i can see in s_atinn the list accordingly to what i put in s_klart,which is good.The problem is that immediatly after my report gets blocked,enters in a sort of loop ,it countinuously loading without being able do anything else. Please find below my code:
DATA:
"Internal Tables of Value Table for F4 Help
* i_class1 TYPE STANDARD TABLE OF type_class1, pentru parametrul : s_klart
* i_ksml TYPE STANDARD TABLE OF type_ksml, pentru select-options s_atinn
* it_pspid1 TYPE STANDARD TABLE OF ty_pspid,
"Internal Tables of Return Table for F4 Help
wa_return1 TYPE ddshretval,
wa_return2 TYPE ddshretval,
wa_return3 TYPE ddshretval,
it_return1 TYPE STANDARD TABLE OF ddshretval,
it_return2 TYPE STANDARD TABLE OF ddshretval,
it_return3 TYPE STANDARD TABLE OF ddshretval.
CONSTANTS:
"Constants for F4IF_INT_TABLE_VALUE_REQUEST
c_klart TYPE dfies-fieldname VALUE 'S_KLART',
c_pspid_l TYPE dfies-fieldname VALUE 'P_PSPID-LOW',
c_pspid_h TYPE dfies-fieldname VALUE 'P_PSPID-HIGH',
c_vorg TYPE char1 VALUE 'S'.
* ALV data declarations
data: it_sortcat type slis_sortinfo_alv occurs 1,
wa_sort like line of it_sortcat.
DATA: it_filter TYPE slis_t_filter_alv.
Data: ls_filter TYPE slis_filter_alv.
*selection screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: s_klart LIKE klah-klart. "Tip clasa ,SELECT-OPTIONS: s_klart FOR klah-klart NO INTERVALS NO-EXTENSION.
SELECT-OPTIONS :s_class FOR klah-class OBLIGATORY MATCHCODE OBJECT clas DEFAULT 'Z_MEDIU'."Nume clasa NO INTERVALS NO-EXTENSION
SELECT-OPTIONS: s_matkl FOR mara-matkl. "Grup Material
SELECT-OPTIONS: s_mtart FOR t134t-mtart. "NO INTERVALS NO-EXTENSION DEFAULT '3010'. "Grup Material
SELECT-OPTIONS: s_matnr FOR mara-matnr." NO INTERVALS NO-EXTENSION. "Numar Material
SELECT-OPTIONS: s_atinn FOR cabn-atinn NO INTERVALS NO-EXTENSION. "Caracteristici
SELECTION-SCREEN END OF BLOCK b1.
*SELECTION-SCREEN SKIP 1.
*
*
*START-OF-SELECTION.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_klart.
SELECT DISTINCT class klart FROM klah INTO TABLE i_class1.
IF sy-subrc = 0.
SORT i_class1 BY klart.
ENDIF.
"Function Module to create F4 help
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = c_klart
value_org = c_vorg
TABLES
value_tab = i_class1
return_tab = it_return1
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF it_return1 IS NOT INITIAL.
LOOP AT it_return1 INTO wa_return1.
s_klart = wa_return1-fieldval.
ENDLOOP.
SELECT imerk clint klart FROM ksml INTO TABLE i_ksml
WHERE klart = s_klart.
IF sy-subrc = 0.
SORT i_ksml BY imerk.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_atinn-low.
"Function Module to create F4 help
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = c_pspid_l
value_org = c_vorg
TABLES
value_tab = i_ksml
return_tab = it_return2
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF it_return2 IS NOT INITIAL.
LOOP AT it_return2 INTO wa_return2.
s_atinn-low = wa_return2-fieldval.
ENDLOOP.
SELECT imerk clint klart FROM ksml INTO TABLE i_ksml
WHERE imerk GT s_atinn-low
AND klart = s_klart.
IF sy-subrc = 0.
SORT i_ksml BY imerk.
ENDIF.
ENDIF.
‎2017 Jul 19 9:06 AM
Hello,
If you know how to perform this selection with one parameter then all you have to do is to loop on every singe values from first select-options.
Something like :
AT SELECTION SCREEN ON VALUE REQUEST FOR S_ATINN.
DATA t_klart type table of khla-klart.
FIELD-SYMBOLS : <klart> type khla-klart.
select distinct klart from khla into table t_klart where klart in s_klart.
* Create values for s_atinn from t_klart and use F4IF_INT_TABLE_VALUE_REQUEST
Or :
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_klart.
SELECT DISTINCT class klart FROM klah INTO TABLE i_class1.
IF sy-subrc = 0.
SORT i_class1 BY klart.
ENDIF.
"Function Module to create F4 help
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'KLART' " Name of value_tab column to be returned
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_KLART' " Name of field to be filled
value_org = 'S' " I don't know why but it's mandatory
TABLES
value_tab = i_class1
* return_tab = it_return1
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_atinn-low.
CHECK s_klart IS NOT INITIAL.
SELECT imerk clint klart FROM ksml INTO TABLE i_ksml
WHERE klart = s_klart.
IF sy-subrc = 0.
SORT i_ksml BY imerk.
ENDIF.
DATA t_field_tab TYPE TABLE OF dfies.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'IMERK'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_ATINN-LOW'
value_org = 'S'
TABLES
value_tab = i_ksml
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
Best regards
Bertrand
‎2017 Jul 19 2:21 PM
Dear Bertrand ,
I did as you advised me and i thank you for this . When i put a value in s_klart , after i can see in s_atinn the list accordingly to what i put in s_klart,which is good.The problem is that immediatly after my report gets blocked,enters in a sort of loop ,it countinuously loading without being able do anything else. Please find below my code,do you think you can advise me of anything else that i made wrong?:
DATA:
"Internal Tables of Value Table for F4 Help
* i_class1 TYPE STANDARD TABLE OF type_class1, pentru parametrul : s_klart
* i_ksml TYPE STANDARD TABLE OF type_ksml, pentru select-options s_atinn
* it_pspid1 TYPE STANDARD TABLE OF ty_pspid,
"Internal Tables of Return Table for F4 Help
wa_return1 TYPE ddshretval,
wa_return2 TYPE ddshretval,
wa_return3 TYPE ddshretval,
it_return1 TYPE STANDARD TABLE OF ddshretval,
it_return2 TYPE STANDARD TABLE OF ddshretval,
it_return3 TYPE STANDARD TABLE OF ddshretval.
CONSTANTS:
"Constants for F4IF_INT_TABLE_VALUE_REQUEST
c_klart TYPE dfies-fieldname VALUE 'S_KLART',
c_pspid_l TYPE dfies-fieldname VALUE 'P_PSPID-LOW',
c_pspid_h TYPE dfies-fieldname VALUE 'P_PSPID-HIGH',
c_vorg TYPE char1 VALUE 'S'.
* ALV data declarations
data: it_sortcat type slis_sortinfo_alv occurs 1,
wa_sort like line of it_sortcat.
DATA: it_filter TYPE slis_t_filter_alv.
Data: ls_filter TYPE slis_filter_alv.
*selection screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: s_klart LIKE klah-klart. "Tip clasa ,SELECT-OPTIONS: s_klart FOR klah-klart NO INTERVALS NO-EXTENSION.
SELECT-OPTIONS :s_class FOR klah-class OBLIGATORY MATCHCODE OBJECT clas DEFAULT 'Z_MEDIU'."Nume clasa NO INTERVALS NO-EXTENSION
SELECT-OPTIONS: s_matkl FOR mara-matkl. "Grup Material
SELECT-OPTIONS: s_mtart FOR t134t-mtart. "NO INTERVALS NO-EXTENSION DEFAULT '3010'. "Grup Material
SELECT-OPTIONS: s_matnr FOR mara-matnr." NO INTERVALS NO-EXTENSION. "Numar Material
SELECT-OPTIONS: s_atinn FOR cabn-atinn NO INTERVALS NO-EXTENSION. "Caracteristici
SELECTION-SCREEN END OF BLOCK b1.
*SELECTION-SCREEN SKIP 1.
*
*
*START-OF-SELECTION.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_klart.
SELECT DISTINCT class klart FROM klah INTO TABLE i_class1.
IF sy-subrc = 0.
SORT i_class1 BY klart.
ENDIF.
"Function Module to create F4 help
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = c_klart
value_org = c_vorg
TABLES
value_tab = i_class1
return_tab = it_return1
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF it_return1 IS NOT INITIAL.
LOOP AT it_return1 INTO wa_return1.
s_klart = wa_return1-fieldval.
ENDLOOP.
SELECT imerk clint klart FROM ksml INTO TABLE i_ksml
WHERE klart = s_klart.
IF sy-subrc = 0.
SORT i_ksml BY imerk.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_atinn-low.
"Function Module to create F4 help
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = c_pspid_l
value_org = c_vorg
TABLES
value_tab = i_ksml
return_tab = it_return2
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF it_return2 IS NOT INITIAL.
LOOP AT it_return2 INTO wa_return2.
s_atinn-low = wa_return2-fieldval.
ENDLOOP.
SELECT imerk clint klart FROM ksml INTO TABLE i_ksml
WHERE imerk GT s_atinn-low
AND klart = s_klart.
IF sy-subrc = 0.
SORT i_ksml BY imerk.
ENDIF.
ENDIF.
‎2017 Jul 19 4:36 PM
Hello,
Ok, it seems you are lost and you complicated your code 🙂
- You should prepare data for a select-options just before you display list. Because your way imply user HAS to request data for s_klart before it can request for s_atinn -> that's not logical and unfair for people already knowing S_KART value
- F4IF_INT_TABLE_VALUE_REQUEST is able to fill your field directly : you don't have to do it manually. Check this :
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_klart.
SELECT DISTINCT class klart FROM klah INTO TABLE i_class1.
IF sy-subrc = 0.
SORT i_class1 BY klart.
ENDIF.
"Function Module to create F4 help
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'KLART' " Name of value_tab column to be returned
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_KLART' " Name of field to be filled
value_org = 'S' " I don't know why but it's mandatory
TABLES
value_tab = i_class1
* return_tab = it_return1
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_atinn-low.
CHECK s_klart IS NOT INITIAL.
SELECT imerk clint klart FROM ksml INTO TABLE i_ksml
WHERE klart = s_klart.
IF sy-subrc = 0.
SORT i_ksml BY imerk.
ENDIF.
DATA t_field_tab TYPE TABLE OF dfies.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'IMERK'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_ATINN-LOW'
value_org = 'S' " I don't know why but it's mandatory
TABLES
value_tab = i_ksml
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
In a "AT SELECTION-SCREEN ON VALUE-REQUEST" block you should do nothing more than filter data and fill corresponding field with selected value. Period.
After that you will check that all selected data are correct all together in START-OF-SELECTION for example but before to process your algorithm. If some parameter can't exist together you can then display a detailled error message to prevent execution.
Note that you can have some graphic buffer problem after you update your code. That's a known problem : if you see your breakpoints are not at the same place between your code and debug mode => save, close your window and log again.
‎2017 Jul 20 6:58 AM
Dear Bertrand,
Thank you for your support.I added the code you advised me and now when i click on select option of s_atinn it doesn`t show me any list. When i click on matchcode my program executes accordingly to the other select-options values. Also now when i press F8 to run my program it doesn`t execute. Please advise urgently. Thank you for your support.
‎2017 Jul 21 10:07 AM
Hello,
I edited my code, you have to use this parameter:
value_org = 'S' " I don't know why but it's mandatory
‎2017 Jul 21 2:13 PM
Hi Bertrand,
I have used that parameter,still not working,i`v got four days since i am working on this :(.
Thank you for your support...
‎2017 Jul 20 7:06 AM
PS: you may also need to call RS_SELECTIONSCREEN_READ when you process F4 on S_ATINN, to retrieve the last entered value of S_KLART, because all screen values are not automatically transferred when you press F4.
‎2017 Jul 26 7:37 AM
It's unfair to close the question by saying "Problem is not reproducible or outdated", because I think that the question was clear and the "right answer was given". From your side, maybe it's outdated, but for people looking for the same question, the answers are useful, so the closing text of the question is misleading (means something like "don't look at me").
‎2017 Jul 26 7:59 AM
Dear Sandra,the problem was not solved ,that`s why i closed the question and opened it in another thread in another way. At some point i thought that Bertrand`s reply is sufficient but it turned out that it isn`t. I will changed the answer of this question.
‎2017 Jul 26 8:36 AM
‎2017 Jul 26 3:52 PM
If the user has input some value in select-option or parameter and then press "Enter" button, this basically allow selection screen values to be passed to the relevent variables like S_KLART etc. In this case you can simply address this variable (select-option to be more precise) in "AT SELECTION-SCREEN ON VALUE-REQUEST FOR" for other select-options.
However if user just types the value or select the value from a list and then goes to next select-option/parameter, in this case the selection-screen values are not passed to relevent variables. In this case Sandra Rossi has given you a very good tip to use function module RS_SELECTIONSCREEN_READ to read such value.
I had a similar requirement in one report. Following code is derived from that report, although i have removed the code not relevant with your issue. This is owrking code. Just copy/paste in your system and it should work. It can give you some baseline to observe and apply similar changes in your report.
*&---------------------------------------------------------------------*
*& Report YYRJ_TEST0080
*&
*&---------------------------------------------------------------------*
*& Read selection screen elements
*& Working: Enter a valid PO number in s_ebeln. then press F4 for
*& s_ebelp-low. Basically it will retreive a list of all
*& all line items number for the PO given in s_ebeln.
*&---------------------------------------------------------------------*
REPORT yyrj_test0080.
TABLES: ekko, ekpo.
SELECT-OPTIONS :
s_ebeln FOR ekko-ebeln NO INTERVALS NO-EXTENSION,
s_ebelp FOR ekpo-ebelp.
TYPES: BEGIN OF tt_ebelp,
ebelp LIKE ekpo-ebelp,
END OF tt_ebelp.
DATA: lt_ebelp TYPE STANDARD TABLE OF tt_ebelp,
ls_ebelp TYPE tt_ebelp.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_ebelp-low.
PERFORM fetch_values_ebelp.
START-OF-SELECTION.
WRITE:/ 'What is this'..
*&---------------------------------------------------------------------*
*& Form FETCH_VALUES_EBELP
*&---------------------------------------------------------------------*
FORM fetch_values_ebelp.
DATA: lv_lin TYPE i,
lv_ebeln LIKE ekko-ebeln.
DATA: lt_fieldvals TYPE STANDARD TABLE OF rsselread,
ls_fieldvals TYPE rsselread.
IF s_ebeln IS INITIAL.
**may be value not passed to select option yet
** fill fieldvals table
CLEAR ls_fieldvals. REFRESH lt_fieldvals.
MOVE: 'S_EBELN' TO ls_fieldvals-name,
'S' TO ls_fieldvals-kind,
'LOW' TO ls_fieldvals-position.
APPEND ls_fieldvals TO lt_fieldvals.
** call the FM to read selection screen values
CALL FUNCTION 'RS_SELECTIONSCREEN_READ'
EXPORTING
program = sy-repid
TABLES
fieldvalues = lt_fieldvals.
** check fieldvals tab for values read
CLEAR lv_ebeln.
READ TABLE lt_fieldvals INTO ls_fieldvals WITH KEY name = 'S_EBELN'.
IF sy-subrc = 0.
CONDENSE ls_fieldvals-fieldvalue NO-GAPS.
lv_ebeln = ls_fieldvals-fieldvalue.
IF lv_ebeln IS NOT INITIAL.
SELECT ebelp INTO TABLE lt_ebelp
FROM ekpo
WHERE ebeln = lv_ebeln.
CHECK sy-subrc = 0.
PERFORM show_f4_ebelp.
ENDIF. "lv_ebeln not initial
ENDIF. "subrc read table
ELSE. "s_ebeln has some value
SELECT ebelp INTO TABLE lt_ebelp
FROM ekpo
WHERE ebeln IN s_ebeln.
IF sy-subrc = 0.
PERFORM show_f4_ebelp.
ENDIF. "subrc 0 check
ENDIF. "s_ebeln check
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SHOW_F4_EBELP
*&---------------------------------------------------------------------*
FORM show_f4_ebelp .
DATA: lt_return TYPE STANDARD TABLE OF ddshretval.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'EBELP'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_EBELP-LOW'
value_org = 'S'
* IMPORTING
* USER_RESET =
TABLES
value_tab = lt_ebelp
return_tab = lt_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
**** ??
ENDIF.
ENDFORM.
‎2017 Jul 27 9:56 AM
Dear Rashid ,thank you so much for your reply. To get in s_atinn the list for the value that i put in s_klart i follow this logic ,please correct me if i am wrong , for ex in se11 :from table Klah i select CLINT (for example 10 ) which is the counter for KLART (Z_MEDIU) ,then in table ksml i select CLINT (10 again) which gives me the IMERK values (0000000010,0000000011.......0000000021)for each characteristic. Then in table CABN in the field ATINN i put a value of IMERK(for ex 0000000013),and i can see in the field ATNAM or ATBEZ the value ADR
SELECT-OPTIONS: s_klart FOR klah-klart NO INTERVALS NO-EXTENSION DEFAULT '001'."PARAMETERS: s_klart LIKE klah-klart."
SELECT-OPTIONS: s_class FOR klah-class NO INTERVALS NO-EXTENSION OBLIGATORY MATCHCODE OBJECT clas DEFAULT 'Z_MEDIU'."Nume clasa NO INTERVALS NO-EXTENSION
SELECT-OPTIONS: s_matkl FOR mara-matkl NO INTERVALS NO-EXTENSION. "Grup Material
SELECT-OPTIONS: s_mtart FOR t134t-mtart NO INTERVALS NO-EXTENSION DEFAULT '3010'. "Cont Material
SELECT-OPTIONS: s_matnr FOR mara-matnr NO INTERVALS NO-EXTENSION. "Numar Material
SELECT-OPTIONS: s_atinn FOR cabn-atinn. "PARAMETERS:s_atinn LIKE cabn-atinn. " . "Caracteristici
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_atinn-low.
PERFORM fetch_values_atinn.
START-OF-SELECTION.
FORM fetch_values_atinn.
DATA: lv_lin TYPE i,
lv_klart LIKE klah-klart.
DATA: lt_fieldvals TYPE STANDARD TABLE OF rsselread,
ls_fieldvals TYPE rsselread.
IF s_klart IS INITIAL.
**may be value not passed to select option yet
** fill fieldvals table
CLEAR ls_fieldvals. REFRESH lt_fieldvals.
MOVE: 'S_KLART' TO ls_fieldvals-name,
'S' TO ls_fieldvals-kind,
'LOW' TO ls_fieldvals-position.
APPEND ls_fieldvals TO lt_fieldvals.
** call the FM to read selection screen values
CALL FUNCTION 'RS_SELECTIONSCREEN_READ'
EXPORTING
program = sy-repid
TABLES
fieldvalues = lt_fieldvals.
** check fieldvals tab for values read
CLEAR lv_klart.
READ TABLE lt_fieldvals INTO ls_fieldvals WITH KEY name = 'S_KLART'.
IF sy-subrc = 0.
CONDENSE ls_fieldvals-fieldvalue NO-GAPS.
lv_klart = ls_fieldvals-fieldvalue.
IF lv_klart IS NOT INITIAL.
SELECT imerk INTO TABLE i_ksml
FROM ksml
WHERE klart = lv_klart.
CHECK sy-subrc = 0.
PERFORM show_f4_atinn.
ENDIF. "lv_klart not initial
ENDIF. "subrc read table
ELSE. "s_klart has some value
SELECT imerk INTO TABLE i_ksml
FROM ksml
WHERE klart IN s_klart.
IF sy-subrc = 0.
PERFORM show_f4_atinn.
ENDIF. "subrc 0 check
ENDIF. "s_klart check
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SHOW_F4_EBELP
*&---------------------------------------------------------------------*
FORM show_f4_atinn.
DATA: lt_return TYPE STANDARD TABLE OF ddshretval.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'ATINN'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_ATINN-LOW'
value_org = 'S'
* IMPORTING
* USER_RESET =
TABLES
value_tab = i_ksml
return_tab = lt_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
**** ??
ENDIF.
ENDFORM.
***for what i modified above i get an erorr message saying that the below statement is not accesible
SELECT matnr werks
FROM marc
INTO TABLE i_marc WHERE matnr IN s_matnr.
‎2017 Jul 27 12:01 PM
Yes Manole, the logic seems good, hope you implement it without any issues!
Now the code that you pasted above, i noticed you have declared some code below the last ENDFORM statement. This doesn't work. Please delete or comment those lines (starting from ***for what i modified above..........). I think you should put that code under START-OF-Selection event as shown in the sample below.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_atinn-low.
PERFORM fetch_values_atinn.
START-OF-SELECTION.
****>>>> Report code
***for what i modified above i get an erorr message saying that the below statement is not accesible
SELECT matnr werks
FROM marc
INTO TABLE i_marc WHERE matnr IN s_matnr.
FORM fetch_values_atinn.
DATA: lv_lin TYPE i,
lv_klart LIKE klah-klart.
DATA: lt_fieldvals TYPE STANDARD TABLE OF rsselread,
ls_fieldvals TYPE rsselread.
...............................
.
‎2017 Jul 27 12:43 PM
Dear Rashid ,
Thank you so much for your replay. If i did as you advise me then my program won`t read nothing after the last ENDFORM. Before you replied to me i put START-OF-SELECTION just after ENDFORM and then select matnr werks..... In this way the s_atinn shows me the correct matchcode list for the value i put in s_klart(for example 001) and then press ENTER,if i don`t press ENTER s_atinn doesn`t show the correct list.When i select from matchcode of s_atinn one value then in the select-option field automatically the GUI puts the value 001 instead of a value from the list that I selected. After this i press F8 and GUI puts me in s_atinn the value DATAREC. There is still something wrong. Please see below my entire code ,if this helps. Normally it should work when i choose by mouse a value from s_klart and then select by mouse a value from s_atinn list. Thank you soo much again.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_atinn-low.
PERFORM fetch_values_atinn.
FORM fetch_values_atinn.
DATA: lv_klart LIKE klah-klart.
DATA: lt_fieldvals TYPE STANDARD TABLE OF rsselread,
ls_fieldvals TYPE rsselread.
IF s_klart IS INITIAL.
**may be value not passed to select option yet
** fill fieldvals table
CLEAR ls_fieldvals. REFRESH lt_fieldvals.
MOVE: 'S_KLART' TO ls_fieldvals-name,
'S' TO ls_fieldvals-kind,
'LOW' TO ls_fieldvals-position.
APPEND ls_fieldvals TO lt_fieldvals.
** call the FM to read selection screen values
CALL FUNCTION 'RS_SELECTIONSCREEN_READ'
EXPORTING
program = sy-repid
TABLES
fieldvalues = lt_fieldvals.
** check fieldvals tab for values read
CLEAR lv_klart.
READ TABLE lt_fieldvals INTO ls_fieldvals WITH KEY name = 'S_KLART'.
IF sy-subrc = 0.
CONDENSE ls_fieldvals-fieldvalue NO-GAPS.
lv_klart = ls_fieldvals-fieldvalue.
IF lv_klart IS NOT INITIAL.
SELECT imerk clint klart INTO TABLE i_ksml
FROM ksml
WHERE klart = lv_klart.
CHECK sy-subrc = 0.
PERFORM show_f4_atinn.
ENDIF. "lv_klart not initial
ENDIF. "subrc read table
ELSE. "s_klart has some value
SELECT imerk clint klart INTO TABLE i_ksml
FROM ksml
WHERE klart IN s_klart.
IF sy-subrc = 0.
PERFORM show_f4_atinn.
ENDIF. "subrc 0 check
ENDIF. "s_klart check
ENDFORM.
FORM show_f4_atinn.
DATA: lt_return TYPE STANDARD TABLE OF ddshretval.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'ATINN'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_ATINN-LOW'
value_org = 'S'
* IMPORTING
* USER_RESET =
TABLES
value_tab = i_ksml
return_tab = lt_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
**** ??
ENDIF.
ENDFORM.
START-OF-SELECTION.
SELECT matnr werks
FROM marc
INTO TABLE i_marc WHERE matnr IN s_matnr.
IF NOT i_marc[] IS INITIAL.
SELECT matnr
mtart
matkl
FROM mara INTO TABLE i_mara
FOR ALL ENTRIES IN i_marc
WHERE matnr = i_marc-matnr
AND mtart IN s_mtart
AND matkl IN s_matkl.
ENDIF.
IF NOT i_mara[] IS INITIAL.
SELECT matnr
maktx
FROM makt INTO TABLE i_makt1
FOR ALL ENTRIES IN i_mara
WHERE matnr = i_mara-matnr AND
spras = sy-langu.
ENDIF.
IF NOT i_mara[] IS INITIAL.
SELECT matkl
FROM t023t
INTO TABLE i_t023t
FOR ALL ENTRIES IN i_mara
WHERE matkl = i_mara-matkl AND
spras = sy-langu.
ENDIF.
SELECT class klart FROM klah INTO TABLE i_class1
WHERE class IN s_class
AND klart IN s_klart.
IF i_class1[] IS INITIAL.
MESSAGE 'Nu sunt date pentru selectia efectuata' TYPE 'E'.
EXIT.
ENDIF.
IF s_atinn[] IS NOT INITIAL. "s_atinn -caracteristica din select-options
IF i_class1[] IS NOT INITIAL.
SELECT imerk clint klart " imerk(are element de data atinn) -caracteristica interna , clint-numar intern clasa , klart-tip clasa
INTO TABLE i_ksml
FROM ksml FOR ALL ENTRIES IN i_class1
WHERE klart = i_class1-klart
AND imerk IN s_atinn
AND lkenz = space.
ENDIF.
.
.
.
.
.
.
‎2017 Jul 27 9:46 PM
I updated a little bit the code from Rashid. I think it works perfectly now (I added: conversion to upper case, completing of the "option" field, possibility to use a fully-functional select-options, not limited to one value), and I provide a reusable subroutine for using any select-options. Please note that I use the tables from the Flight Model used by all SAP demo programs (run program SAPBC_DATA_GENERATOR to fill the tables)
REPORT.
TABLES: scarr, spfli.
SELECT-OPTIONS :
s_carrid FOR scarr-carrid,
s_connid FOR spfli-connid.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_connid-low.
PERFORM fetch_values_connid.
START-OF-SELECTION.
WRITE:/ 'What is this'..
*&---------------------------------------------------------------------*
*& Macro MAC_READ_SELECT_OPTIONS
*&---------------------------------------------------------------------*
DEFINE mac_read_select_options.
perform f_read_select_options tables &1 using '&1-LOW' '&1-HIGH' &2 &3 changing &1-sign &1-option &1-low &1-high.
END-OF-DEFINITION.
*&---------------------------------------------------------------------*
*& Form F_READ_SELECT_OPTIONS
*&---------------------------------------------------------------------*
FORM f_read_select_options
TABLES select_options
USING low_fieldname high_fieldname tabname fieldname
CHANGING sign option low high.
DATA lt_dynpfield TYPE TABLE OF dynpread.
DATA ls_dynpfield TYPE dynpread.
DATA ls_table_field TYPE tabfield.
DATA l_table_field TYPE string.
DATA l_type.
ls_table_field-tabname = tabname.
ls_table_field-fieldname = fieldname.
READ TABLE select_options INDEX 1.
REFRESH lt_dynpfield.
ls_dynpfield-fieldname = low_fieldname.
APPEND ls_dynpfield TO lt_dynpfield.
ls_dynpfield-fieldname = high_fieldname.
APPEND ls_dynpfield TO lt_dynpfield.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
TABLES
dynpfields = lt_dynpfield
EXCEPTIONS
OTHERS = 9.
CHECK sy-subrc = 0.
LOOP AT lt_dynpfield INTO ls_dynpfield.
CASE ls_dynpfield-fieldname.
WHEN low_fieldname.
CALL FUNCTION 'RS_CONV_EX_2_IN'
EXPORTING
input_external = ls_dynpfield-fieldvalue
table_field = ls_table_field
IMPORTING
output_internal = low
EXCEPTIONS
OTHERS = 1.
WHEN high_fieldname.
CALL FUNCTION 'RS_CONV_EX_2_IN'
EXPORTING
input_external = ls_dynpfield-fieldvalue
table_field = ls_table_field
IMPORTING
output_internal = high
EXCEPTIONS
OTHERS = 1.
ENDCASE.
ENDLOOP.
DESCRIBE FIELD low TYPE l_type.
IF sign = space.
sign = 'I'.
ENDIF.
IF high IS INITIAL.
IF l_type = 'C' AND low CA '*+'.
option = 'CP'.
ELSE.
option = 'EQ'.
ENDIF.
ELSE.
option = 'BT'.
ENDIF.
IF lines( select_options ) = 0.
APPEND select_options.
ELSE.
MODIFY select_options INDEX 1.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FETCH_VALUES_connid
*&---------------------------------------------------------------------*
FORM fetch_values_connid.
DATA: lv_lin TYPE i.
mac_read_select_options s_carrid 'SCARR' 'CARRID'.
PERFORM show_f4_connid.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SHOW_F4_connid
*&---------------------------------------------------------------------*
FORM show_f4_connid .
TYPES: BEGIN OF tt_connid,
connid LIKE spfli-connid,
END OF tt_connid.
DATA: lt_connid TYPE STANDARD TABLE OF tt_connid.
SELECT connid INTO TABLE lt_connid
FROM spfli
WHERE carrid IN s_carrid.
CHECK sy-subrc = 0.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'CONNID'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_CONNID-LOW'
value_org = 'S'
TABLES
value_tab = lt_connid
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
**** ??
ENDIF.
ENDFORM.
‎2017 Aug 14 7:51 AM
‎2017 Jul 26 9:18 PM
Very much confused by this whole thread... Why can't you simply use a debugger? The follow up questions below are like "omg, this is not working! see my code [unreadable code follows]".
But what effort have you made to analyze and troubleshoot the issue? Hm, what was that saying about helping themselves...
‎2017 Jul 27 6:29 AM
"Smart" answer Jelena,
What makes you think i haven`t tried ? I am new to abap. I`ve tried with a debugger and couldn`t resolve anything. I have posted the code with what i tried but the moderator thought that is not relevant to post the whole code. How can the readers know what needs to be done if i don`t post the whole code?
‎2017 Jul 27 7:55 AM
Being a new to ABAP does not accord you any special treatment.
If you have a problem, it's important that you express it concisely and accurately. If you post source code, you must only post the relevant parts, must make sure that it is nicely formatted and easy to read. When people can't be bothered to even remove commented out code, it's a bit sad.
Remember, you cannot demand an answer. Anyone answering you here is doing so entirely voluntarily. The comments you've had so far are attempts to guide you.
‎2017 Jul 27 8:14 AM
Dear Matthew,
I thought i will be given some special treatment :). Thank you for your advices. I believed that all the source code is important because i think that an instruction may affect multiple parts of the source code.I will format the code better from now on. I never tried nor I am and never will force someone to answer to my questions.Is not in my character. I appreciate all people`s effort when they are trying to help me. But i also have the feeling that not everybody is too interested to help me and they are sarcastic. Struggling hard on a project and receiving sarcastic responses doesn`t help me at all,contrary It makes me worse. I expected from SAP comunity to be more friendly....
‎2017 Jul 27 8:14 AM
Please try the code given by Rashid. Something very important in his answer is that it's a small standalone code, with only the relevant code (everything useless has been removed to avoid confusion), so everyone who want to help can compile and test it immediately, instead of rewriting your code until it works on their system. So, the number one recommendation in your case, is to ask a question with the smallest standalone code so that people can answer you quickly.
Edit a few hours later: by the way, another extra thing which will make more people answer, is to make the code "basis" compatible, for instance by using the database tables from the Flight Model. Here, the EKKO, EKPO, MARC, KSML are ECC tables, they don't exist in SRM, CRM, etc. systems.
‎2017 Jul 27 9:26 AM
To be fair, I don't detect any sarcasm. Some frustration couple with dry humour, yes, but not sarcasm. We are a multicultural global site - what might be interpreted as a sarcasm may well not have been intended as such.
‎2017 Jul 27 9:54 AM
I adapted the code given by Rashid. To get in s_atinn the list for the value that i put in s_klart i follow this logic ,please correct me if i am wrong , for ex in se11 :from table Klah i select CLINT (for example 10 ) which is the counter for KLART (Z_MEDIU) ,then in table ksml i select CLINT (10 again) which gives me the IMERK values (0000000010,0000000011.......0000000021)for each characteristic. Then in table CABN in the field ATINN i put a value of IMERK(for ex 0000000013),and i can see in the field ATNAM or ATBEZ the value ADR
‎2017 Jul 27 10:02 AM
Don`t get me wrong. I am a fan of black humour ,english jokes.
‎2017 Jul 27 2:12 PM
Okay, you did a few SELECT changes to suit your exact requirement, but your question is about how to code F4 between 2 select-options. So, does the code of Rashid answer your question? Please answer directly to him.
‎2017 Jul 27 2:25 PM
The code given by Rashid works partially ,i also told him in a reply. if i put a value in s_klart from matchcode and press ENTER ,then when i choose from matchcode of s_atinn I see the correct list in s_atinn. problem is that when i click on a value from s_atinn list then in s_atinn select-options apears a wrong value. only if i write manually in s_atinn and press ENTER and then F8 my program works.
‎2017 Jul 27 8:09 PM
What makes me think is the information you've given us so far to in this post. Have you indicated that you ran the code through the debugger? Have you shared your findings with us? You think I'm being sarcastic while I'm merely expressing how your own text is perceived:
"The problem is that immediatly after my report gets blocked,enters in a sort of loop ,it countinuously loading without being able do anything else. Please find below my code:"
No word about debugging here or trying anything further.
Kindly refer to this blog if you're expecting to receive assistance from the volunteers on SCN in future.
‎2017 Jul 28 8:38 AM
Best thing is that all the other people that tried to help me figured out themselves that i did the best i could otherwise i wouldn`t be posting this thread.
‎2017 Aug 14 8:56 AM
Please do not keep editing the question (or any other posts). It makes it difficult for others who might want to use the discussion for their own purposes figure out what is going on. I have reverted the original post to the last reasonable version.
If you want to add information, use comments.
The text of your last revision is:
Good morning!
Thanks to Rashid my code now works.Please see below
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_klart FOR klah-klart NO INTERVALS NO-EXTENSION DEFAULT '001'."PARAMETERS: s_klart LIKE klah-klart."
SELECT-OPTIONS: s_class FOR klah-class NO INTERVALS NO-EXTENSION OBLIGATORY MATCHCODE OBJECT clas DEFAULT 'Z_MEDIU'."Nume clasa NO INTERVALS NO-EXTENSION
SELECT-OPTIONS: s_matkl FOR mara-matkl NO INTERVALS NO-EXTENSION. "Grup Material
SELECT-OPTIONS: s_mtart FOR t134t-mtart NO INTERVALS NO-EXTENSION. "Cont Material
SELECT-OPTIONS: s_matnr FOR mara-matnr NO INTERVALS NO-EXTENSION. "Numar Material
SELECT-OPTIONS: s_atinn FOR cabn-atinn. "PARAMETERS:s_atinn LIKE cabn-atinn. " . "Caracteristici
SELECTION-SCREEN END OF BLOCK b1. " DISPLAY_DATA
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_atinn-low.
PERFORM fetch_values_atinn.
FORM fetch_values_atinn.
DATA: lv_klart LIKE klah-klart.
DATA: lt_fieldvals TYPE STANDARD TABLE OF rsselread,
ls_fieldvals TYPE rsselread.
IF s_klart IS INITIAL.
**may be value not passed to select option yet
** fill fieldvals table
CLEAR ls_fieldvals. REFRESH lt_fieldvals.
MOVE: 'S_KLART' TO ls_fieldvals-name,
'S' TO ls_fieldvals-kind,
'LOW' TO ls_fieldvals-position.
APPEND ls_fieldvals TO lt_fieldvals.
** call the FM to read selection screen values
CALL FUNCTION 'RS_SELECTIONSCREEN_READ'
EXPORTING
program = sy-repid
TABLES
fieldvalues = lt_fieldvals.
** check fieldvals tab for values read
CLEAR lv_klart.
READ TABLE lt_fieldvals INTO ls_fieldvals WITH KEY name = 'S_KLART'.
IF sy-subrc = 0.
CONDENSE ls_fieldvals-fieldvalue NO-GAPS.
lv_klart = ls_fieldvals-fieldvalue.
IF lv_klart IS NOT INITIAL.
SELECT imerk clint klart INTO TABLE i_ksml
FROM ksml
WHERE klart = lv_klart.
CHECK sy-subrc = 0.
PERFORM show_f4_atinn.
ENDIF. "lv_klart not initial
ENDIF. "subrc read table
ELSE. "s_klart has some value
SELECT imerk clint klart INTO TABLE i_ksml
FROM ksml
WHERE klart IN s_klart.
IF sy-subrc = 0.
PERFORM show_f4_atinn.
ENDIF. "subrc 0 check
ENDIF. "s_klart check
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SHOW_F4_EBELP
*&---------------------------------------------------------------------*
FORM show_f4_atinn.
DATA: lt_return TYPE STANDARD TABLE OF ddshretval.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'IMERK'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_ATINN-LOW'
value_org = 'S'
TABLES
value_tab = i_ksml
return_tab = lt_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
**** ??
ENDIF.
ENDFORM.