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: 

Dynamic itab (field-symbols) and ALV event BEFORE_LINE_OUTPUT

josgabriel_martnez
Participant
0 Kudos

Hi all,

I was trying to solve this, but I can't find the solution yet.

How can I use a dynamic table (created by field-symbols) with the ALV event BEFORE_LINE_OUTPUT?

The dynamic table is used as the "outtab" parameter for function 'REUSE_ALV_LIST_DISPLAY'.

With a standard itab with header line, you can manipulate values at this event and assign the calculations to respective header line, but using the field-symbol as table, this one do not have header line... so how can you assign the desired values, if there is no "header line", in order to get a desired line/values for total line????

Thank you very much in advance.

José Gabriel.

12 REPLIES 12

Former Member
0 Kudos

Hi,

Check this forum

Thanks

Vikranth

0 Kudos

Hi Vikranth,

The itab described in the link you included above (ALVTAB) do not seem to be a dynamic table created with field-symbols, so, it is not the same case. Thanks anyway.

I need to use a FIELD-SYMBOL as outtab, not a standard itab with header line.

Regards,

José Gabriel

Former Member
0 Kudos

Hi,

Jose If you do usin internal table with header line is obselete.

so try to tod your code wihtout header line.

0 Kudos

Hi Sandipan,

That is not the problem (using table with header line or not), the problem is that IN FACT I am using a dynamic table (without header line) and I have problems trying to use it with event before_line_output.

Thanks,

Regards.

Former Member
0 Kudos

Hi,

Following is the procedure for creating dynamic internal table:

1)First you need to populate the internal table i_fc with the fields you want in dynamic internal table

2)using method cl_alv_create=>create_dynamic_table you can create a dynamic internal table

3)You can create work area as shown in the last line of code.

*******************************************************

Data: i_fc type lvc_t_fcat,

v_table type ref to data,

v_line type ref to data,

  • Create dynamic internal table and assign to FS

call method cl_alv_table_create=>create_dynamic_table

exporting

it_fieldcatalog = i_fc

importing

ep_table = v_table.

assign v_table->* to <fs_table>.

  • Create dynamic work area and assign to FS

create data v_line like line of <fs_table>.

***********************************************************

Regards

Madhu G S

Let me know in case you require more help.

<removed_by_moderator>

Edited by: Julius Bussche on Jun 23, 2008 8:01 PM

0 Kudos

Hi Madhu,

As I said before, the problem is not to create or populate the dynamic table.

I have already done that.

The problem is: I am having problems using my dynamic table with event BEFORE_LINE_OUTPUT:

I CAN NOT pass the desired values calculated in this event using a dynamic table (using a standard "static" table, there is no problems because I usually write the desired values on the desired columns of the "header line" of this table. So, the "totals" or "subtotals" lines appear modified with the desired values).

Thanks and regards.

0 Kudos

Hi

If you have created a dynamic table it means u shoudl have an internal table with the strcuture of the table u've created: i can suppose this table is like catalog table.

So u need to do a loop on catalog table in order to decide which fields has to be elaborated by field-symbols:

LOOP AT IT_FIELDCAT.
   ASSIGN IT_FIELDCAT-FIELDNAME OF STRUCTURE <STRUCTURE> TO <FS>.
   ......................

The routine have created for the event BEFORE_LINE_OUTPUT should be like:

FORM BEFORE_LINE_OUTPUT USING P_LINEINFO LIKE kkblo_lineinfo.

FIELD-SYMBOLS: <WA> TYPE ANY, <FIELD> TYPE ANY.

READ TABLE <FS_OUTPUT> ASSIGNING <WA> INDEX P_LINEINFO-TABINDEX.

LOOP AT IT_FIELDCAT.
   ASSIGN IT_FIELDCAT-FIELDNAME OF STRUCTURE <WA> TO <FIELD>.

   .............................

ENDFORM.

Max

josgabriel_martnez
Participant
0 Kudos

Hi Max,

But, if I am checking the following:

if p_lineinfo-endsum EQ 'X' OR p_lineinfo-subtot EQ 'X'.

.

.

endif

Should I use the "p_lineinfo-tabindex" that you say in order to access the fields of the "wa" or the line used by the ALV's routines, where the "totals" or "subtotals" are stored???, in order to put my own calculations? (I don't remember if that field is filled at that time: when 'endsum' or 'subtot' = 'X'... )

I don't see it quite clear yet... I can not test what you are propousing right now, but for sure I will try later today... I don't see how I can"reach" the fields (¿?), and then, modify the later line of totals displayed by ALV...

Thanks, I will answer if what you say works.

0 Kudos

Hi

tabindex is the index of the line is beeing shown, the event BEFORE_LINE_OUTPUT is triggered just before printing a record of output table.

If you want to change the subtotal u should use the event GROUPLEVEL_CHANGE

Max

josgabriel_martnez
Participant
0 Kudos

Hi Max,

(sorry if "in response to" is wrong, this browser doesn't show the appropiate button!!).

Thanks for your time to reply, I really appreciate it, but I feel that I have not explained well the problem.

About the lines coding in your first post:

I did not try it (I can not logon now to the SAP system where the program is), but I can se that the purpose of it is to "identify" the fields of the dynamic itab, so it could be possible to modify it content. If so, this is not the problem. I know the fields of the itab, but I do not want to modify their values.

About 'p_lineinfo-tabindex' and before_line_output:

At the time when:

"p_lineinfo-endsum EQ 'X' OR p_lineinfo-subtot EQ 'X'."

The tabindex = 0, so it's not useful.

Besides, the event GROUPLEVEL_CHANGE is not triggered, so I can not test what happens there. (I am using, and I need to use: 'REUSE_ALV_LIST_DISPLAY').

I do not know why is so hard to accoplish what I require: just modify the "totals" line with my own calculations, but using a dynamic table (with field-symbols) instead of a "normal" itab with header line.

When using a "normal" or standard table itab with header line, there is no problem, because I use the event before_line_output to change the totals line (I can modify it just changing desired values in the header line of my outtab, where the totals or subtotals results generated by ALV are stored: no problem with this!!!).

But with a dynamic outtab, lets say <outtab>, I can not do the same, in this case, because I do not have any header line to do what I explained before.

If there is another way or event or function (may be LVC_TOTALS_GET? I am checking it) or whatever to do this with a dynamic itab...well, its ok, so what is it??

Thanks anyway Max, your responses have more sense that the others before.

Regards.

josgabriel_martnez
Participant
0 Kudos

Hi all,

Please, if there is a community member or an ABAP expert that had faced the same situation, I will appreciate any help.

Thanks in advance.

José Gabriel.

josgabriel_martnez
Participant
0 Kudos

Well, finally I found a solution (!¡)

With FM reuse_alv_list_display and dynamic table, there isn't a solution, so I discarded it.

At the end, I did this (a sort of FM and OO ALV hybrid):

-Changed FM reuse...list_display to reuse...GRID_DISPLAY.

-Function module 'GET_GLOBALS_FROM_SLVC_FULLSCR'

to get global reference for grid created by reuse_alv_grid_display.

-Use of convenient ALV event to initialize ALV grid ref and calculations (---> 'END_OF_LIST' , but 'CALLER_EXIT' could be more elegant).

-Method GET_SUBTOTALS to get the totals line (main issue!! and reason of all the problem).

-Method REFRESH_TABLE_DISPLAY, to refresh changes.

-Some field-symbols... .

I really have to thank to the reply-posting of Jozsef Szanyi, whose ideas helped me to find a workaround to the problem.

Anybody can take a look at Thread: "Custom calculation in the Totals line of ALV Grid" .

Thanks to people who tried to help (specially those with "consistent" answers).

José Gabriel.