Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Work with specific fields, based on user input

Former Member
0 Kudos
108

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
49

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

http://www.howforge.com/dynamic-where-clause-in-abap-4

5 REPLIES 5

Former Member
0 Kudos
49

Hi,

This question is more generic. Please provide us with additional detials on your requirements.

Best regards,

Prabhu

0 Kudos
49

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?

Former Member
0 Kudos
50

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

http://www.howforge.com/dynamic-where-clause-in-abap-4

0 Kudos
49

Thank you but can you explain how to use the dynamic where clause to solve my issue. I don't understand.

0 Kudos
49

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