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: 

alv output issue

former_member574106
Participant
0 Kudos

Hi friends,

I have designed a classical ALV for displaying totals of amount. The logic is that the field  POPER from FAGLFLEXA is equal to a month of a financial year. For instance POPER = 1 corresponds to April , POPER = 2 corresponds to May, POPER = 3 corresponds to June and so on. The ALV displays the total of the amount for each month. Example, the month of April shows the total of amount for April given by the field HSL01. The month of May shows the total of amount for May represented by field HSL02, so on. The output is coming perfectly fine in my output. But if i am giving  any range of POPER in the selection screen , it is displaying totals for all the months. For example, if i give 5 to 12 as period in selection screen, it is displaying the totals of all the months from  1 to 12. I need to display only the totals from 5 to 12. How to solve this issue. Please go through the code and screenshots for complete understanding. Please help with code. Points will be duly rewarded.

Regards,

Saurav Lahiry

1 ACCEPTED SOLUTION

Rodrigo-Giner
Active Contributor
0 Kudos

Hi Saurav, if I understood correctly you wan't to show the columns (months) depending the ones selected in selection screen, right ?

If that is the case just check when you create the fieldcat if the POPER entered in the selection should be showed or not, if not set the field no_output = 'X' in the fieldcat.

for example if you give like u said 5 to 12.

In each column in the fieldcat do this conditional

* POPER 1 = c_poper1 = 1

wa_fieldcat-col_pos= '3'.
wa_fieldcat-fieldname  = 'HSL1'." Fieldname in the data table

  wa_fieldcat-seltext_m  = 'April'.

  wa_fieldcat-do_sum= 'X'.

IF c_poper1 IN so_per. "c_poper1 should have value 1

  wa_fieldcat-no_output = ' '.

ELSE.

  wa_fieldcat-no_output = 'X'.

ENDIF.

  APPEND wa_fieldcat  TO it_fieldcat.

CLEAR   wa_fieldcat.

In the following just use another constants

IF c_poper2 IN so_per.  "c_poper2 should have value 2

  wa_fieldcat-no_output = ' '.

ELSE.

  wa_fieldcat-no_output = 'X'.

ENDIF.

Regards

4 REPLIES 4

Rodrigo-Giner
Active Contributor
0 Kudos

Hi Saurav, if I understood correctly you wan't to show the columns (months) depending the ones selected in selection screen, right ?

If that is the case just check when you create the fieldcat if the POPER entered in the selection should be showed or not, if not set the field no_output = 'X' in the fieldcat.

for example if you give like u said 5 to 12.

In each column in the fieldcat do this conditional

* POPER 1 = c_poper1 = 1

wa_fieldcat-col_pos= '3'.
wa_fieldcat-fieldname  = 'HSL1'." Fieldname in the data table

  wa_fieldcat-seltext_m  = 'April'.

  wa_fieldcat-do_sum= 'X'.

IF c_poper1 IN so_per. "c_poper1 should have value 1

  wa_fieldcat-no_output = ' '.

ELSE.

  wa_fieldcat-no_output = 'X'.

ENDIF.

  APPEND wa_fieldcat  TO it_fieldcat.

CLEAR   wa_fieldcat.

In the following just use another constants

IF c_poper2 IN so_per.  "c_poper2 should have value 2

  wa_fieldcat-no_output = ' '.

ELSE.

  wa_fieldcat-no_output = 'X'.

ENDIF.

Regards

0 Kudos

Hi Rodrigo,

Thanks a lot for the reply. It worked perfectly. Awarding points.

Regards,

Saurav Lahiry

former_member182915
Active Contributor
0 Kudos

Hi Saurav,

You have to hide column as per selection in selection screen.

we need to achieve 2 thing.

1. hide in fieldcat log

2.correct amount should add in totaling column (i.e last column)

follow the Rodrigo Ariel Giner de la Vega way for first point.

second at the time of assign value to wa_final-(column name) check with so_per . if found value goes to column and added in to wa_final-ztotal & if not in period the wa_final-(column name) will blank and which not impact the totaling of amount .

demo code


if xyz in so_per.

wa_final-hslxyz = lv_totalxyz.

endif.


wa_final-ztotal = wa_final-hsl1 + wa_final-hsl2 + wa_final-hsl3 + wa_final-hsl4 + wa_final-hsl5 + wa_final-hsl6

                  + wa_final-hsl7 + wa_final-hsl8 + wa_final-hsl9 + wa_final-hsl10 + wa_final-hsl11 +

                  wa_final-hsl12 + wa_final-hsl13 + wa_final-hsl14 + wa_final-hsl15 + wa_final-hsl16.

Hope this will help You

Swadhin

0 Kudos

Hi Swadhin,

Issue already solved. Thanks a lot for the tips.

Regards,

Saurav Lahiry