Application Development and Automation 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: 
Read only

Basic Doubts from Basic Abaper ;-)

Former Member
0 Likes
787

Hello All,

a) How do you normally decide on which list you are. SY-LSIND and SY-LISTI is confusing some times for a program, Is it possible to have some for list instead.

Problem: I am having a list as follows:

Basic List (L0)

..Detail List (L 0.1) [ called when pressed F7 from basic]

....Lower Detail List (L 0.1.1) [Called F7 from List 0.1)

..Detail List (L 0.2) [ called when pressed F8 from basic]

....Lower Detail List (L 0.2.1) [Called F7 from List 0.2)

My problem is list L0.2.1 and L0.1.1 are having different header and footer. Both are being called from SY-LISTI = 1 and SY-LSIND = 0. So, to format the header and footer just based on this two variable wont help. Is there any way in SAP that once the list is created, we can give it some name, so that we can refer to list based on name instead of indexes?

b) In the statement Read and Modify , is it possible to have field name as variable? like

MODIFY CURRENT LINE FIELD VALUE f_name from 'ABC'.

Here i want to give f_name as variable. Is it possible to do so?

Regards

Mitesh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
665

Hello Mitesh,

Your first question sounds interesting. But, unfortunately, we cannot denote a particular list by a <i>name</i>. Here's what I can think of -

1. With some care, you can actually maintain an internal table in your programwith two columns - one for the Sy-LSIND value and the other for the <i>name</i> (or some string such as 2.1.1 et al.,)that you choose to have. This internal table would have to be updated based on which level you are navigating to and from. Not really a very difficult thing to do, if you ask me.

2. I'm not sure if I got this right. But MODIFY CURRENT LINE has got a variable in the place you want. Do you want to specify the name of the field dynamically? I have never done that yet, but I suppose you could do it with Field Symbols. Give it a try.

Regards,

Anand Mandalika.

6 REPLIES 6
Read only

Former Member
0 Likes
666

Hello Mitesh,

Your first question sounds interesting. But, unfortunately, we cannot denote a particular list by a <i>name</i>. Here's what I can think of -

1. With some care, you can actually maintain an internal table in your programwith two columns - one for the Sy-LSIND value and the other for the <i>name</i> (or some string such as 2.1.1 et al.,)that you choose to have. This internal table would have to be updated based on which level you are navigating to and from. Not really a very difficult thing to do, if you ask me.

2. I'm not sure if I got this right. But MODIFY CURRENT LINE has got a variable in the place you want. Do you want to specify the name of the field dynamically? I have never done that yet, but I suppose you could do it with Field Symbols. Give it a try.

Regards,

Anand Mandalika.

Read only

0 Likes
665

Hi All,

Sorry for the late reply..

Second problem is solved with the help of field symbol. Yes, i wanted to pass the fields dynamically to the modify statement.

First problem, i think we are only having a way to hold the current screen name in a global variable.

Regards

Mitesh

Read only

christian_wohlfahrt
Active Contributor
0 Likes
665

Hi Mitesh,

since you are really asking for <i>any</i> way to handle three different list levels:

How about using module pools? You can use ALV-Grid to display your list -> lots of functions without much programming.

With each F7/F8 (or whatever function key you will define), you can jump into different dynpros - and immediately you know current status without additional effort.

Especially value changes are much better supported in dynpros than in lists - the main reason for switching the technic.

Otherwise: global variables might help, for modify you might use field-symbols to get general access.

Regards,

Christian

Read only

StevenDeSaeger
Contributor
0 Likes
665

Hi,

Assuming you use events to handle the user choosing the F7 or F8 you can simple use the 'At PF7' or 'At PF8' event handlers to choose the proper list. You can use a switch variable to set a flag within those 2 event handlers.

In your 'top-of-page' you can then check the value of your flag variable to choose proper list formatting.

Regards,

Steven

Read only

Former Member
0 Likes
665

Hi Anand, Christian, Steven,

Sorry, my PC is having problem, so i was not able to try your solution on Modify lines. I will try this on weekend.

Regarding List Name tracking I tried keeping a list name in a variable before, but this is failing under one few cases.

If we keep list name in a variable, every time we open another list, the variable need to be updated. The programmer should ensure that, else nothing will go fine.

When i tried to use global variable and was updating it at every point. But when user press Cancel(F12) or Back, it will take it to its parent list and our variable wont get changed.

Anand, Do you really mean the same logic by the user of internal table?

Regards

Mitesh

Read only

VijayasekarK
Active Participant
0 Likes
665

Hi,

Since u r using F7 & F8 for two different lists obviously the function code for F7 and F8 will be different . Make use of Function code (SY-UCOMM) along with SY-LSIND and SY-LISTI to determine the Report Header and Footer to get printed.

I think ...above soln will help u....

Regards,

Vijay