‎2010 Jul 12 4:15 AM
Hi,
I am extracting all data from table FMGLFLEXT. First, I will go in and extract data for the year that the user has entered on the selection screen.
However, the user will also enter the prior period & current period. These periods have to do with the fields between TSL01 and TSL16. For example, if the user enters 2 and 7, I should only work with data between fields TSL02 and TSL07.
How is this possible?
Please help.
‎2010 Jul 12 4:37 AM
Based on the selection screen, you will have to build dynamic where clause. Here is an some examples
http://www.abapcode.info/2007/12/how-to-use-dynamic-sql-in-abap-report.html
‎2010 Jul 12 4:28 AM
Hi,
This question is more generic. Please provide us with additional detials on your requirements.
Best regards,
Prabhu
‎2010 Jul 12 4:35 AM
Not sure how much more detail I can provide.
The user enters the prior period, current period & year on the selection screen. Maybe the account number as well, but that field has no impact on this issue.
I have to get the information from the table based on what the user has entered.
However, each period is its own field - TSL01 is period 1, TSL02 is period 2 and so on. So if the user enters prior period 2 and current period 7, I can only work with the fields between TSL02 and TSL07. How do I code and tell sap to only work with those fields that refer to the period the user has entered?
‎2010 Jul 12 4:37 AM
Based on the selection screen, you will have to build dynamic where clause. Here is an some examples
http://www.abapcode.info/2007/12/how-to-use-dynamic-sql-in-abap-report.html
‎2010 Jul 12 4:41 AM
Thank you but can you explain how to use the dynamic where clause to solve my issue. I don't understand.
‎2010 Jul 12 5:21 AM
I am sorry, I misunderstand your question. you can use field symbols to get the fields. You will have to use a similar logic like this.
DATA: lv_inc TYPE n LENGTH 2.
PARAMETERS: prior_period TYPE n LENGTH 2 value '02',
current_period TYPE n LENGTH 2 value '07'.
DATA: <fs_field> TYPE any.
data: lv_field type string.
SELECT * INTO TABLE lt_fmglflext FROM fmglflext.
lv_inc = prior_period.
loop at lt_fmglflext.
DO.
lv_inc = lv_inc + 1.
IF lv_inc > current_period.
EXIT.
ENDIF.
CONCATENATE 'LT_FMGLFLEXT-TSL' lv_inc INTO lv_field.
ASSIGN (lv_field) TO <fs_field>. "<< Contains the vaue LT_FMGLFLEXT-TSL02, LT_FMGLFLEXT-TSL03 and so on
ENDDO.
lv_inc = prior_period.
endloop.Edited by: Ramesh Kumar Pampapathi on Jul 12, 2010 6:24 AM