2014 Dec 12 12:53 PM
I want to get country LAND1 as an input from the user at selection screen. Based on this I want only the filed of customers KUNNR loaded into an internal table. These particular values needed to be fed HIDDEN into a select-option before the AT SELECTION SCREEN event. Based on which I need to extract VBELN from vbak table and put it into an internal table.
I do not know how to pass the value of an internal table into select-option. Thanks in advance.
REPORT ZGG_KR_083_VBELN_FORALLENTRIES.
TABLES: kna1, vbak, t005.
TYPES: BEGIN OF ty_kna1,
kunnr LIKE kna1-kunnr,
END OF ty_kna1,
BEGIN OF ty_vbak,
vbeln LIKE vbak-vbeln,
END OF ty_vbak,
BEGIN OF ty_main,
kunnr LIKE kna1-kunnr,
vbeln LIKE vbak-vbeln,
END OF ty_main.
DATA: it_kna1 TYPE STANDARD TABLE OF ty_kna1,
it_vbak TYPE STANDARD TABLE OF ty_vbak,
it_main TYPE STANDARD TABLE OF ty_main.
DATA: wa_kna1 TYPE ty_kna1,
wa_vbak TYPE ty_vbak,
wa_main TYPE ty_main.
SELECT-OPTIONS: s_land1 FOR kna1-land1 NO INTERVALS DEFAULT 'IN'." NO-DISPLAY.
SELECT-OPTIONS: s_kunnr FOR vbak-kunnr." NO-DISPLAY.
SELECT kunnr
FROM kna1
INTO TABLE it_kna1
WHERE land1 IN s_land1.
2014 Dec 12 1:00 PM
You need to use event AT SELECTION SCREEN OUTPUT in combination with USER-COMMAND on your s_land1 select-options.
But I am a bit puzzled why you want to do this since the select-options you are filling is NO-DISPLAY.
Therefore it doesn't make much of a difference when you do the select of the kunnr from KNA1 in the event START-OF-SELECTION in an inner join with VBAK.
Would be better for performance as well.
Can you elaborate why you want to do it like this ?
2014 Dec 12 1:48 PM
Thank you Peter.
I have commented the NO DISPLAY sections in my code. Sorry for the confusion.
1) I wan the user to enter country of this choice but by default am making it as IN (which of course can be changed by the user).
2) The KUNNR for the entered country, FR or IN or DE, is then passed onto to the internal table it_kna1.
Here is the actual problem.
I want to know how to pass the values of the internal table with KUNNR to the HIDDEN select-option s_kunnr.
I want to learn how the table formulation works.
2014 Dec 12 2:12 PM
OK but what is it now Hidden or not hidden ? You commented out the NO-DISPLAY but are still talking about hidden s_kunnr ?
Anyway if you want to fill the eslect-options it does not make a difference i you have NO-DISPLAY or not.. You can use the following code, but then the select options only get filled after an enter.
AT SELECTION-SCREEN OUTPUT.
CHECK NOT s_land1 IS INITIAL.
data: ls_kunnr like line of s_kunnr.
SELECT * FROM kna1 INTO TABLE lt_kna1 WHERE land1 IN s_land1.
IF sy-subrc = 0.
ls_kunnr-sign = 'I'.
ls_bupa-option = 'EQ'.
LOOP AT lt_kna1 INTO wa_kna1.
ls_kunnr-low = wa_kna1-kunnr.
APPEND ls_kunnrTO s_kun. nr
ENDLOOP.
ENDIF.
If the user does not push ENTER after filling s_land1, the s_kunnr will NOT be filled.
Therefore you would have to check this again (repeat the same code if s_kunnr is initial) as first thing in the start-of-selection event.
So this is not exactly as you wanted it. But play around with it to learn.
2014 Dec 12 5:40 PM
hi karthik,
Try this
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_KUNNR-LOW.
CHECK NOT s_land1 IS INITIAL.
data: ls_kunnr like line of s_kunnr.
SELECT kunnr FROM kna1 INTO TABLE it_kna1 WHERE land1 IN s_land1.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'kunnr'
DYNPPROG = SY-REPID
DYNPNR = '1000'
DYNPROFIELD = 'S_KUNNR'
VALUE_ORG = 'S'
TABLES
VALUE_TAB = it_kna1
* RETURN_TAB = IT_RETURN
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3.