‎2008 Aug 14 8:47 AM
Hi ALL,
i am and BW consultant.Here i want to check 9 fields in an internal table of more than 75000 records.Then if our of 15 fields if mandatory fields is blank then i need to raise an error message.
I had written an ABAP code with If Statements and is there any other alternative way to improve the performance to check those fields.
‎2008 Aug 15 1:06 PM
It would help if you publish what you've tried already. I'll assume BW 3.5, and that you've got 15 fields, FIELD1 through to FIELD15 , and you want to raise an error if FIELD7 through to FIELD15 is blank. I'll also assume that you want to report all fields that are blank that shouldn't be. Also, that generally, you won't get that many errors.
FIELD-SYMBOLS: <ls_record> LIKE LINE OF DATA_PACKAGE.
SORT DATA_PACKAGE BY FIELD7 FIELD8 ... FIELD15.
LOOP AT DATA_PACKAGE ASSIGNING <ls_record>.
IF <ls_record>-field7 IS NOT INITIAL AND <ls_record>-field8 IS NOT INITIAL
AND <ls_record>-field9 IS NOT INITIAL... " and so on
EXIT.
ENDIF.
IF <ls_record>-field7 IS INITIAL.
" raise error field 7.
ELSEIF.
IF <ls_record>-field8 IS INITIAL.
" raise error field 8.
ENDIF.
... etc.
ENDLOOP.matt
‎2008 Aug 22 9:28 AM
Hi Sai Sandeep,
If you use the comparion with offset option,Your report will run much faster.
I think your mandatory fields are from FIELD7. to FIELD15 Consecutively..
Then Take the vaues from FIELD7 to FIELD15 values at a time in the FIELD-SYMBOL na dcomapre it at a time rather that with So many AND AND comparisions as below.
FIELD-SYMBOLS:
<one_time_comapre_string> TYPE ANY.
DATA:
From_offset TYPE I.
Note: Count the number of characters of each field from FILED1 to FIELD6.
From_offset = Sum of lengths of all the foelds from FIELD 1 TO FILED6.
TO_offset = Sum of lengths of all the foelds from FIELD 7 TO FILED15.
FIELD-SYMBOLS: <ls_record> LIKE LINE OF DATA_PACKAGE.
SORT DATA_PACKAGE BY FIELD7 FIELD8 ... FIELD15.
LOOP AT DATA_PACKAGE ASSIGNING <ls_record>.
<one_time_comapre_string> = <ls_record>+From_offset(TO_offset).
IF <one_time_comapre_string> IS NOT INITIAL.
EXIT.
ELSE.
MESAGE 'One of the mandatory field is empty' TYPE 'I'.
ENDIF.
clear <one_time_comapre_string>.
ENDLOOP.
Hope this solves your problem.
Regards,
Rama.
‎2008 Aug 24 4:15 AM
Hello Saisandeep,
I don't know your code and therefore an improvement can only be a guess.
I would design it in this way: using the assign component clause.
REPORT z_field_check.
TYPES: BEGIN OF ty_itab,
field1 TYPE c,
field2 TYPE c,
field3 TYPE c,
END OF ty_itab.
DATA: itab TYPE STANDARD TABLE OF ty_itab,
wa_itab TYPE ty_itab.
DATA: i_component LIKE sy-index,
i_record LIKE sy-index.
DATA:error_key TYPE c.
FIELD-SYMBOLS: <record> TYPE ty_itab,
<field> TYPE ANY.
DO 5 TIMES.
CLEAR: wa_itab.
wa_itab-field1 = ''.
wa_itab-field2 = 'b'.
wa_itab-field3 = ''.
APPEND wa_itab TO itab.
ENDDO.
CLEAR: error_key.
LOOP AT itab ASSIGNING <record>.
i_record = sy-tabix.
DO.
i_component = sy-index.
ASSIGN COMPONENT i_component OF STRUCTURE <record> TO <field>.
IF sy-subrc <> 0. CLEAR: sy-subrc. EXIT. ENDIF.
IF <field> IS INITIAL.
* raise error message for the i_component-th field in the record like:
WRITE: / 'The', i_component, 'th field in record', i_record, 'is INITIAL'.
error_key = 'X'.
ENDIF.
ENDDO.
ENDLOOP.
IF error_key IS INITIAL.
WRITE: 'Hurrah! No empty record found.'.
ENDIF.
Try it and have success.
Heinz