In this requirement we need to get data from SAP Standard Program, for this sample we need to get data from SAP Program tcode KE25 ( Program RKEB0601 ).
We will submit parameter PERIOD as Period, ARTNR ( Product /Material ) and WERKS ( Plant ), parameter Werks or plant is Free selection so we need to use function module FREE_SELECTIONS_RANGE_2_EX to submit to free selection.
Declare all need of variable.
1 2 3 4 5 6 7 8 9 10 |
DATA: t_selopt TYPE rsds_selopt_t, t_selfield TYPE rsds_frange_t, t_seltab TYPE rsds_trange, t_exprs TYPE rsds_texpr, t_claus TYPE rsds_twhere. DATA: wa_selopt TYPE rsdsselopt, wa_selfield TYPE rsds_frange, wa_seltab TYPE rsds_range, wa_exprs TYPE rsds_expr. |
This is our selection screen
1 2 3 4 5 6 |
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001. SELECT-OPTIONS : lv_pmnux FOR s076-pmnux, lv_wenux FOR caufvd-werks OBLIGATORY. PARAMETERS : lv_spmon TYPE s076-spmon OBLIGATORY. SELECTION-SCREEN END OF BLOCK b1. |
We need to insert value of T_SELTAB internal table.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
LOOP AT lv_wenux. CLEAR : wa_selopt, wa_selfield, wa_seltab. REFRESH : t_selopt. wa_seltab-tablename = 'CE11000'. wa_selfield-fieldname = 'WERKS'. wa_selopt-sign = lv_wenux-sign. wa_selopt-option = lv_wenux-option. wa_selopt-low = lv_wenux-low. wa_selopt-high = lv_wenux-high. APPEND wa_selopt TO t_selopt. APPEND LINES OF t_selopt TO wa_selfield-selopt_t. APPEND wa_selfield TO wa_seltab-frange_t. APPEND wa_seltab TO t_seltab. ENDLOOP. <span class="L0S52">CALL </span><span class="L0S52">FUNCTION </span><span class="L0S33">'FREE_SELECTIONS_RANGE_2_EX'</span> <span class="L0S52">EXPORTING</span> field_ranges <span class="L0S55">= </span>t_seltab <span class="L0S52">IMPORTING</span> expressions <span class="L0S55">= </span>t_exprs<span class="L0S55">.</span> |
Then pass T_EXPRS to SUBMIT.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
SUBMIT rkeb0601 WITH perkrs = c_cost WITH ppatype = 1 WITH pplikz = 1 WITH paledger = '' WITH pvalutyp = 0 WITH SELECTION-TABLE isel WITH FREE SELECTIONS t_exprs AND RETURN. |