2014 Jun 20 4:08 AM
Hi,
i wonder is it possible to pass value back to its internal table after using function lines?
All i know is that after using using lines, you have to pass value to integer variable.
The codes below is the example that my senior use to pass value back to its own:
g_kfgr_cnt = LINES( g_kfgr_cnt ).
g_kfgr_act_cnt = g_kfgr_cnt.
g_kfgr_cnt = g_kfgr_cnt + 1.
I do not know which exact table my senior used, but its purpose is to count the number of key figure.
2014 Jun 22 3:52 PM
The only possible way this would be syntactically valid is if g_kfgr_cnt is defined:
DATA; g_kfgr_cnt TYPE i OCCURS 0.
I.e. an internal table of integers (or some other numeric type), with a header line. In this day and age, to use such a construct would imply that your senior is in fact a dinosaur, using ABAP techniques of over 15 years ago. And with terrible variable naming habits...
The equivalent in modern coding would be something like:
DATA bunch_of_integers TYPE STANDARD TABLE OF i WITH NON-UNIQUE KEY table_line.
DATA an_integer TYPE i.
an_integer = LINES( bunch_of_integers ).
DATA another_integer TYPE i.
another_integer = an_integer.
ADD 1 TO an_integer.
At no point is the table in the above example (or in your original) modified in any way.
So your questions doesn't really make any sense. Why not ask your senior?
Hi,
i wonder is it possible to pass value back to its internal table after using function lines?
All i know is that after using using lines, you have to pass value to integer variable.
The codes below is the example that my senior use to pass value back to its own:
g_kfgr_cnt = LINES( g_kfgr_cnt ).
g_kfgr_act_cnt = g_kfgr_cnt.
g_kfgr_cnt = g_kfgr_cnt + 1.
I do not know which exact table my senior used, but its purpose is to count the number of key figure.
2014 Jun 20 7:11 AM
Hi,
g_kfgr_cnt = LINES( g_kfgr_cnt ).
g_kfgr_cnt must be an internal table, lines( arg ) returns the row count .
2014 Jun 22 2:34 PM
yes i know, but how can it return value to its own internal table. I understand if it returns to integer variable.
2014 Jun 20 7:25 AM
Hi Vong,
LINES is used for getting the ROW count of any internal table as per your code g_kfgr_cnt is an internal table.
can you please post the types declarations of g_kfgr_cnt and g_kfgr_act_cnt .
Regards,
Pavan
2014 Jun 22 2:32 PM
Hi,
The declaration is what is want to know because it's my senior code and i don have a complete code.
The statement is very strange for passing back to its own internal table. i ask because may be some of you experts understand and tell me how to declare it.
2014 Jun 22 2:49 PM
The only possible explanation that I can think of is that, g_kfgr_cnt is a Table of type integer with header line.
But it doesn't make much sense on how it is being used. We can deduce more is we could see more parts of the code.
2014 Jun 22 3:52 PM
The only possible way this would be syntactically valid is if g_kfgr_cnt is defined:
DATA; g_kfgr_cnt TYPE i OCCURS 0.
I.e. an internal table of integers (or some other numeric type), with a header line. In this day and age, to use such a construct would imply that your senior is in fact a dinosaur, using ABAP techniques of over 15 years ago. And with terrible variable naming habits...
The equivalent in modern coding would be something like:
DATA bunch_of_integers TYPE STANDARD TABLE OF i WITH NON-UNIQUE KEY table_line.
DATA an_integer TYPE i.
an_integer = LINES( bunch_of_integers ).
DATA another_integer TYPE i.
another_integer = an_integer.
ADD 1 TO an_integer.
At no point is the table in the above example (or in your original) modified in any way.
So your questions doesn't really make any sense. Why not ask your senior?
2014 Jun 23 2:35 AM
He just wants me to understand the codes. It's just like an exercise for me to solve.
This statement is really confusing that's y m asking.
Thanks for all the answers, everyone.
2014 Jun 23 4:31 AM
Hi,
It still gives error although i declare it DATA: g_kfgr_cnt TYPE I OCCURS 0.
2014 Jun 23 5:50 AM
I guess the exercise was meant to teach you how to read keyword documentation.
Using forum to reach the answer kind of defeats the purpose.
How about this snippet?
DATA lt TYPE TABLE OF i WITH HEADER LINE.
APPEND 11 TO lt.
APPEND 22 TO lt.
lt = lines( lt ).
WRITE: / 'Total ', lt.
LOOP AT lt.
WRITE: / 'Line' , sy-tabix, ': ', lt.
ENDLOOP.
2014 Jun 23 6:01 AM
To understand more i have to use the forum. Asking Qs and giving answer is one of the forum purposes.
The purpose of my senior is that i can find the answer and able to seek help for answers.
2014 Jun 23 7:23 AM
Yes, but this is quite basic stuff, so it's reasonable to expect you to be able to work it out. If he truly wants you to figure out how code works, why has he given you a sample of what is effectively very bad code?
2014 Jun 23 7:28 AM
I am a newbie in sap that's why i need to try every thing to get answer. Anyhow, still thanks for answers and advice. I am really confused right now. What exactly he, my senior, want me to do.
2014 Jun 23 7:40 AM
Actually, i have checked the document and i knew it would return integer, but The confusing part is that it returns value to it's own internal table.
2014 Jun 23 10:33 AM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |