Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9129

Re: Dynamic checking internal table for empty columns

$
0
0

Hi.

 

You should try field-symbols or dynamic memory.

 

Declare a field symbol and a charfieldname type 30 char (length of your table's name and table's field)

Example

 

DATA: f_myfield(30),

          f_increm_col(3) TYPE  n,

FIELD-SYMBOLS:  <f_value> .

 

BEGIN OF my_new_table OCCURS 0,

         row_num(4) TYPE n,

         col_name (10),

         find TYPE c,

END OF my_new_table.

 

CONSTANTS: col_numbers TYPE i VALUE 5. "In your case.... if you need you can count number of                                                                     "columns dinamically

 

 

Inside your loop do the following

LOOP AT mytab.

CLEAR my_new_table.

ADD 1 TO my_new_table-row_num.

 

CLEAR f_increm_col.

 

DO 1 TO (col_numbers). "Loop through your columns searching for values...

 

     MOVE sy-index TO f_increm_col.

     CONCATENATE 'mytab-col001' f_increm_col INTO f_myfield.

     CONCATENATE 'col' f_increm_col INTO my_new_table-col_name.

     ASSIGN (f_myfield) TO <f_value>.

     IF sy-subrc EQ 0.

"Your COL001 has got a value and so you can create an entry in your new table

          my_new_table-find = abap_true.

     ELSE.

          my_new_table-find = abap_false.

     ENDIF.

     APPEND my_new_table.

ENDDO.

 

 

ENDLOOP.

 

Hope to help

Bye


Viewing all articles
Browse latest Browse all 9129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>