2010 Jul 02 12:38 PM
Hi Experts,
I am new to ABAP and I have a situation as follows.
I have a table say ztable where there are seven fields monday,tuesday,wednesday,thursday,friday and saturday.
Depending on the current calender day i have to fetch the content.
Suppose for monday, i have to fetch ztable-monday.
Is there any other way other than using if statements 7 times ? Like i wanna capture the day and substitute it in the place of z_table-"day".
Please help.
Thanks,
2010 Jul 02 1:04 PM
Hi,
In the below code you can pass any field of the table in W_FIELD.... It will fetch the particular field from the table....
w_block should be of same data element of your field in W_FIELD
PARAMETER : w_field TYPE NAME_FELD.
DATA w_block(1) TYPE c.
Select single (w_field) FROM RSEG INTO w_block
WHERE belnr EQ '5105701294'.
IF sy-subrc EQ 0.
WRITE / w_block.
ENDIF.Thanks and regards,
Senthil Kumar Anantham.
Edited by: Senthil Kumar on Jul 2, 2010 5:37 PM
Hi Experts,
I am new to ABAP and I have a situation as follows.
I have a table say ztable where there are seven fields monday,tuesday,wednesday,thursday,friday and saturday.
Depending on the current calender day i have to fetch the content.
Suppose for monday, i have to fetch ztable-monday.
Is there any other way other than using if statements 7 times ? Like i wanna capture the day and substitute it in the place of z_table-"day".
Please help.
Thanks,
2010 Jul 02 12:43 PM
Hey ,
yes there is.
You can write a Dynamic select query and it will solve your problem.
Search on SDN for 'Dynamic Select query'.
Hope this is helpful.
Regards,
Uma Dave
2010 Jul 02 1:04 PM
Hi,
In the below code you can pass any field of the table in W_FIELD.... It will fetch the particular field from the table....
w_block should be of same data element of your field in W_FIELD
PARAMETER : w_field TYPE NAME_FELD.
DATA w_block(1) TYPE c.
Select single (w_field) FROM RSEG INTO w_block
WHERE belnr EQ '5105701294'.
IF sy-subrc EQ 0.
WRITE / w_block.
ENDIF.Thanks and regards,
Senthil Kumar Anantham.
Edited by: Senthil Kumar on Jul 2, 2010 5:37 PM
2010 Jul 02 1:08 PM
There is a solution with FIELD-SYMBOLS:
FIELD-SYMBOLS <FS>.
DATA: WWFIELDN(100).
DATA: wwday(20).
wwday = 'monday'.
CONCATENATE 'z_table-' wwday INTO WWFIELDN.
ASSIGN (WWFIELDN) TO <FS>.
MOVE 100 TO <FS>.
There is another solution using DO ... VARYING.
2010 Jul 02 1:16 PM
Why not create seven select options and execute a single query ?
Is this what you want ?
data:r1 type range of z-monday.
data:r2 type range of z-tuesday.
data:r3 type range of z-wednesday.
data:r4 type range of z-thursday.
data:r5 type range of z-friday.
data:r6 type range of z-saturday.
data:r7 type range of z-sunday.
Populate the required ranges as required depending on your current calenadar day and leave others blank.
then select * from ztable where
monday in r1 and
tuesday in r2 and
wednesday in r3 and
thursday in r4 and
friday in r5 and
saturday in r6 and
friday in r7.
2010 Jul 06 1:14 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |