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

Modifying internal table

Former Member
0 Likes
360

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

2 REPLIES 2
Read only

uwe_schieferstein
Active Contributor
0 Likes
336

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

Read only

Former Member
0 Likes
336

Self