‎2007 Dec 08 6:09 AM
Hi All,
I facing problem to display alv report as per the requirement given below.
I am having 54 columns( I mean fields) cocerning to quantity.
1. And whenever if any column does'nt contains at least one record( I mean record i.e., quantiy = 0) ,then we need to replace all 0 quantities with spaces .
2. But whenever the left side and right side columns of the middle one contains at least one record and middle one does not contains all zeros( I mean no single record exist), then we should not replace all zeros with replaces,these remains same.
Ex: Let us assume that F1, F2, F3, F4, F5, F6, F7, F8, F9, F10 are the columns for the quantity fields.
If F2 contains all zero's but F1 and F3 contains at least single record each, then we should not replace all zero's with spaces. So, we need to look up the adjustent columns values also.
All the Coulumns values depends on the each other.I got a bit confustion please let me if solution for this with piece of code.
thanks & Regards,
raju
‎2007 Dec 08 9:30 PM
Hello Prakash
The solution to your problem is a simple additional structural variable where you store the evaluation results of your data itab.
<b>(1) Evaluate your data itab.</b>
TYPES: BEGIN OF ty_s_flag.
TYPES: flag1 TYPE abap_bool.
TYPES: flag2 TYPE abap_bool.
...
TYPES: flag54 TYPE abap_bool.
TYPES: END OF ty_s_flag.
DATA:
ld_idx2 TYPE i,
ld_idx3 TYPE i,
ls_flag TYPE ty_s_flag.
FIELD-SYMBOLS:
<ld_fld> TYPE any,
<ld_flag> TYPE any,
<ld_flag1> TYPE any,
<ld_flag2> TYPE any,
<ld_flag3> TYPE any.
LOOP AT lt_data INTO ls_data.
DO.
ASSIGN COMPONENT syst-index OF STRUCTURE ls_data TO <ld_fld>.
IF ( syst-subrc NE 0 ).
EXIT.
ENDIF.
ASSIGN COMPONENT syst-index OF STRUCTURE ls_flag TO <ld_flag>.
IF ( <ld_fld> > 0 ). " quantity > 0
<ld_flag> = 'X'. " column sy-index contains quantity > 0
ENDIF.
ENDDO.
ENDLOOP.<b>(2) Evaluate the flags.</b>
DO 52 TIMES. " 52 = 54 - 2
ld_idx2 = syst-index + 1.
ld_idx3 = syst-index + 2.
ASSIGN COMPONENT syst-index OF STRUCTURE ls_flag TO <ld_flag1>.
ASSIGN COMPONENT ld_idx2 OF STRUCTURE ls_flag TO <ld_flag2>.
ASSIGN COMPONENT ld_idx3 OF STRUCTURE ls_flag TO <ld_flag3>.
IF ( <ld_flag1> = ' ' AND
<ld_flag2 = ' ' AND
<ld_flag3> = ' ' ).
" middle column & left and right column do not contain any value > 0, then
" replace 0 value in middle column with SPACE
LOOP AT lt_data INTO ls_data.
ASSIGN COMPONENT ld_idx2 OF STRUCTURE ls_data TO <ld_fld>.
<ld_fld> = space.
ENDLOOP.
ENDIF.Regards,
Uwe
‎2010 Dec 09 3:53 AM