‎2008 Nov 19 6:00 AM
Hi Friends,
I have a requirement wherein I am required to append values from a select-options (s_werks)
to another structure. I am facing difficulties to write code for the same. I have done the following:
SELECT-OPTIONS: s_werks FOR mard-werks OBLIGATORY MEMORY ID wrk.
Data: gwa_swerks like line of s_werks.
loop at s_werks into gwa_swerks.
............
.............
endloop.
My problem is I need to consider values gwa_swerks-low, gwa_swerks-high and also values lying between these two values. All these values will have to be appended to another internal table.
Please suggest an efficient way of writing such a code.
Thanks in advance.
Regards,
Tejas
‎2008 Nov 19 6:06 AM
SELECT-OPTIONS: s_werks FOR mard-werks OBLIGATORY MEMORY ID wrk.
Data: gwa_swerks like line of s_werks.
loop at s_werks into gwa_swerks.
itab-werks = gwa_swerks-low.
append itab.
endloop.
loop at s_werks into gwa_swerks.
itab-werks = gwa_swerks-high.
append itab.
endloop.
Regards
Anbu B
‎2008 Nov 19 6:08 AM
hi,
do the following.
while s_werks-low LE s_werks-high.
< ur code >
add 1 to s_werks-low.
endwhile.
regards
Prasanth
‎2008 Nov 19 6:18 AM
hi,
jst write SELECT-OPTIONS: s_werks FOR mard-werks.
declare one more table like s_werks without using dispaly in selection screen. you can do this in 2 ways.
1. select-options : s2_werks for mard-werks no-display.
2. Ranges : s2_werks for mard-werks.
then s2_werks[ ] = s_werks[ ]
what ever data u have in s_werks will be copied in s2_werks.
you can do the same for any internal table.
Thanks & regards.
Edited by: Naseeruddin on Nov 19, 2008 7:19 AM
Edited by: Naseeruddin on Nov 19, 2008 7:20 AM
‎2008 Nov 19 6:25 AM
Hi,
To avoid non-existing plants, you can select all valid plants in that range from table T001W and then build the other structure.
SELECT werks
FROM t001w INTO TABLE it_werks
WHERE werks IN s_werks.
LOOP AT it_werks into wa_werks.
gwa_swerks-low = wa_werks-werks.
gwa_swerks-sign = 'I'.
gwa_swerks-option = 'EQ'.
APPEND gwa_swerks. "If it is a table. In your case not required
ENDLOOP.
Thanks,
Lakshmi.
‎2008 Nov 19 6:30 AM
Ignore the rest: Santhanalakshmi V has the entirely correct answer. Naseeruddin's will work if the structures are the same.
matt
‎2008 Nov 19 6:39 AM
Hi Bhakti Haria,
Try this code
It will fetch all the valid records of the SELECT-OPTION records into an internal table.
******************************************************************************************************
TABLES : mard.
SELECT-OPTIONS: s_werks FOR mard-werks OBLIGATORY MEMORY ID wrk.
TYPES : BEGIN OF ty_werks,
werks TYPE mard-werks,
END OF ty_werks.
DATA : it_werks TYPE TABLE OF ty_werks,
wa_werks TYPE ty_werks.
INITIALIZATION.
s_werks-sign = 'I'.
s_werks-option = 'BT'.
s_werks-low = '1'.
s_werks-high = '500'.
APPEND s_werks.
s_werks-sign = 'I'.
s_werks-option = 'EQ'.
s_werks-low = '1000'.
APPEND s_werks.
s_werks-sign = 'I'.
s_werks-option = 'BT'.
s_werks-low = '1200'.
s_werks-high = '5000'.
APPEND s_werks.
AT SELECTION-SCREEN ON s_werks.
IF s_werks IS NOT INITIAL.
SELECT
werks FROM t001w INTO TABLE it_werks
WHERE werks IN s_werks.
SORT it_werks.
DELETE ADJACENT DUPLICATES FROM it_werks COMPARING werks.
ENDIF.
START-OF-SELECTION.
BREAK-POINT.
*****************************************************************************************************
Regards
Bala Krishna
Edited by: Bala Krishna on Nov 19, 2008 12:10 PM
‎2008 Nov 19 7:01 AM
Hi,
Use this...
DATA: t_werks TYPE STANDARD TABLE OF werks_d WITH HEADER LINE.
RANGES: gwa_swerks FOR mard-werks.
SELECT-OPTIONS: s_werks FOR mard-werks OBLIGATORY MEMORY ID wrk.
AT SELECTION-SCREEN.
SELECT werks
FROM t001w
INTO TABLE t_werks
WHERE werks IN s_werks.
IF sy-subrc = 0.
LOOP AT t_werks.
gwa_swerks-sign = 'I'.
gwa_swerks-option = 'EQ'.
gwa_swerks-low = t_werks.
APPEND gwa_swerks.
CLEAR gwa_swerks.
ENDLOOP.
ENDIF.
‎2008 Nov 19 7:04 AM
Hi
Do like this.
REPORT abc.
TABLES: t001w.
DATA: gt_werks TYPE TABLE OF werks_d,
gwa_werks TYPE werks_d.
SELECT-OPTIONS: s_werks FOR t001w-werks OBLIGATORY MEMORY ID wrk.
SELECT werks FROM t001w INTO TABLE gt_werks WHERE werks IN s_werks.
LOOP AT gt_werks INTO gwa_werks.
WRITE:/ gwa_werks.
ENDLOOP.
‎2008 Nov 19 7:33 AM
REPORT ZSRK_068 .
TABLES : MARD.
SELECT-OPTIONS: S_WERKS FOR MARD-WERKS OBLIGATORY MEMORY ID WRK.
DATA: GWA_SWERKS LIKE LINE OF S_WERKS.
DATA : L_CNT TYPE I,
L_WERKS LIKE MARD-WERKS.
DATA : BEGIN OF ITAB OCCURS 0,
WERKS LIKE MARD-WERKS,
END OF ITAB.
LOOP AT S_WERKS INTO GWA_SWERKS.
L_CNT = GWA_SWERKS-HIGH - GWA_SWERKS-LOW.
ITAB-WERKS = GWA_SWERKS-LOW.
APPEND ITAB.
CLEAR ITAB.
L_WERKS = GWA_SWERKS-LOW.
DO L_CNT TIMES.
L_WERKS = L_WERKS + 1.
ITAB-WERKS = L_WERKS.
APPEND ITAB.
CLEAR ITAB.
ENDDO.
ENDLOOP.
LOOP AT ITAB.
WRITE : / ITAB-WERKS.
ENDLOOP.